From ef71add33f09f9328c795b0212a08ef5a76bfe5d Mon Sep 17 00:00:00 2001 From: dfighter Date: Wed, 8 Feb 2012 01:58:15 +0100 Subject: [PATCH 001/339] Moved xml_auto_ptr from game_share to nel misc. --- code/nel/include/nel/misc/xml_auto_ptr.h | 81 +++++++++++++++++++ code/nel/src/misc/stdmisc.h | 1 + code/ryzom/client/src/cdb_branch.cpp | 2 +- code/ryzom/client/src/cdb_leaf.cpp | 2 +- .../client/src/interface_v3/action_handler.h | 2 +- .../client/src/interface_v3/ctrl_base.cpp | 2 +- .../src/interface_v3/ctrl_base_button.cpp | 2 +- .../client/src/interface_v3/ctrl_button.cpp | 2 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../client/src/interface_v3/ctrl_tooltip.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 2 +- .../src/interface_v3/dbgroup_combo_box.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- ...roup_list_sheet_text_brick_composition.cpp | 2 +- .../dbgroup_list_sheet_text_share.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../client/src/interface_v3/dbview_bar.cpp | 2 +- .../client/src/interface_v3/dbview_bar3.cpp | 2 +- .../client/src/interface_v3/dbview_digit.cpp | 2 +- .../client/src/interface_v3/dbview_number.cpp | 2 +- .../src/interface_v3/dbview_quantity.cpp | 2 +- .../client/src/interface_v3/group_career.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../client/src/interface_v3/group_frame.cpp | 2 +- .../client/src/interface_v3/group_html_cs.cpp | 2 +- .../src/interface_v3/group_html_forum.cpp | 2 +- .../src/interface_v3/group_html_mail.cpp | 2 +- .../src/interface_v3/group_html_qcm.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 2 +- .../src/interface_v3/group_in_scene.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../client/src/interface_v3/group_modal.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../group_phrase_skill_filter.cpp | 2 +- .../src/interface_v3/group_quick_help.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_tab.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../interface_v3/input_handler_manager.cpp | 2 +- .../src/interface_v3/interface_3d_scene.cpp | 2 +- .../src/interface_v3/interface_anim.cpp | 2 +- .../client/src/interface_v3/interface_ddx.cpp | 2 +- .../src/interface_v3/interface_element.cpp | 2 +- .../src/interface_v3/interface_group.cpp | 2 +- .../src/interface_v3/interface_observer.h | 2 +- .../src/interface_v3/interface_options.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- .../client/src/interface_v3/view_bitmap.cpp | 2 +- .../src/interface_v3/view_bitmap_combo.cpp | 2 +- .../src/interface_v3/view_bitmap_faber_mp.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_radar.cpp | 2 +- .../client/src/interface_v3/view_text.cpp | 2 +- .../src/interface_v3/view_text_formated.cpp | 2 +- .../client/src/interface_v3/view_text_id.cpp | 2 +- .../interface_v3/view_text_id_formated.cpp | 2 +- .../src/game_share/generic_xml_msg_mngr.cpp | 2 +- .../common/src/game_share/ring_access.cpp | 2 +- .../player_manager/cdb_branch.cpp | 2 +- .../player_manager/cdb_leaf.cpp | 2 +- 68 files changed, 148 insertions(+), 66 deletions(-) create mode 100644 code/nel/include/nel/misc/xml_auto_ptr.h diff --git a/code/nel/include/nel/misc/xml_auto_ptr.h b/code/nel/include/nel/misc/xml_auto_ptr.h new file mode 100644 index 000000000..36e67331b --- /dev/null +++ b/code/nel/include/nel/misc/xml_auto_ptr.h @@ -0,0 +1,81 @@ +// Ryzom - MMORPG Framework +// 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 XML_AUTO_PTR_H +#define XML_AUTO_PTR_H + +#include + +/** Simple auto pointer for xml pointers + */ +class CXMLAutoPtr +{ +public: + CXMLAutoPtr(const char *value = NULL) : _Value(value) {} + CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {} + ~CXMLAutoPtr() { destroy(); } + operator const char *() const { return _Value; } + operator bool() const { return _Value != NULL; } + operator std::string() const { return std::string(_Value); } + bool operator ! () const { return _Value == NULL; } + operator const unsigned char *() const { return (const unsigned char *) _Value; } + char operator * () const { nlassert(_Value); return *_Value; } + /// NB : This remove previous owned pointer with xmlFree + CXMLAutoPtr &operator = (const char *other) + { + if (other == _Value) return *this; + destroy(); + _Value = other; + return *this; + } + + CXMLAutoPtr &operator = (const unsigned char *other) + { + *this = (const char *) other; + return *this; + } + char *getDatas() const { return const_cast(_Value); } +////////////////////////////////////////////////// +private: + const char *_Value; +private: + void destroy() + { + if (_Value) + { + xmlFree(const_cast(_Value)); + _Value = NULL; + } + } + + // We'd rather avoid problems + CXMLAutoPtr(const CXMLAutoPtr &/* other */) + { + nlassert(0); + } + CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */) + { + nlassert(0); + return *this; + } +}; + + +#endif + + diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 572a90f1a..860983518 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -52,6 +52,7 @@ #include "nel/misc/stream.h" #include "nel/misc/path.h" #include "nel/misc/string_common.h" +//#include "nel/misc/xml_auto_ptr.h" #ifdef NL_OS_WINDOWS #define NOMINMAX diff --git a/code/ryzom/client/src/cdb_branch.cpp b/code/ryzom/client/src/cdb_branch.cpp index 60c6b63f4..d7e3f185f 100644 --- a/code/ryzom/client/src/cdb_branch.cpp +++ b/code/ryzom/client/src/cdb_branch.cpp @@ -30,7 +30,7 @@ ////////////// #include "cdb_branch.h" #include "cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" //#include #include "interface_v3/interface_manager.h" diff --git a/code/ryzom/client/src/cdb_leaf.cpp b/code/ryzom/client/src/cdb_leaf.cpp index 9b3d26c89..b65f79c24 100644 --- a/code/ryzom/client/src/cdb_leaf.cpp +++ b/code/ryzom/client/src/cdb_leaf.cpp @@ -29,7 +29,7 @@ // Includes // ////////////// #include "cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" //#include #include "interface_v3/interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler.h b/code/ryzom/client/src/interface_v3/action_handler.h index c8800da63..e578c4959 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.h +++ b/code/ryzom/client/src/interface_v3/action_handler.h @@ -23,7 +23,7 @@ #include #include "nel/misc/types_nl.h" #include "nel/misc/debug.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include extern bool game_exit; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_base.cpp index 151d2be6f..f3c7dbbec 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "ctrl_base.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index b2f03b98b..12db635bf 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -20,7 +20,7 @@ #include "ctrl_base_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../time_client.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index fd1ba049b..b977c1c29 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -21,7 +21,7 @@ #include "ctrl_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index 31d64af31..ece811773 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "interface_manager.h" #include "ctrl_col_pick.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace NLMISC; using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 652bd5ed7..a95cda085 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "interface_manager.h" #include "ctrl_scroll.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_menu.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 1e8c7c07b..de302dbb1 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -22,7 +22,7 @@ #include "ctrl_text_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "view_text.h" #include "view_text_id.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp index 71bd4ab8c..5e276d886 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp @@ -21,7 +21,7 @@ #include "ctrl_tooltip.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index ce551a0b7..6f4eb1391 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -43,7 +43,7 @@ #include "sbrick_manager.h" #include "sphrase_manager.h" #include "../client_sheets/sphrase_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "../r2/editor.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 0834fd392..cbf6da945 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "dbgroup_combo_box.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "ctrl_button.h" #include "action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 40e62346f..8990abf42 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet_text.h" #include "group_container.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index 0ed457f43..bc205ba00 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_text_brick_composition.h" #include "../client_sheets/sbrick_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../string_manager_client.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index e31d052cc..e4efa0f52 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_text_share.h" #include "../client_sheets/sbrick_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "view_bitmap.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 7511ee8ef..24235085e 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet_trade.h" #include "interface_manager.h" #include "inventory_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index 512ca8256..49f477923 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -21,7 +21,7 @@ #include "dbview_bar.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp index da20ae57f..490952fb9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp @@ -21,7 +21,7 @@ #include "dbview_bar3.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.cpp b/code/ryzom/client/src/interface_v3/dbview_digit.cpp index 19c424ac8..86e79783d 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_digit.cpp @@ -20,7 +20,7 @@ #include "dbview_digit.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/dbview_number.cpp b/code/ryzom/client/src/interface_v3/dbview_number.cpp index 8ca6e7c94..1463fcc3f 100644 --- a/code/ryzom/client/src/interface_v3/dbview_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_number.cpp @@ -20,7 +20,7 @@ #include "dbview_number.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp b/code/ryzom/client/src/interface_v3/dbview_quantity.cpp index 915fcebce..6f95ddbc9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_quantity.cpp @@ -21,7 +21,7 @@ #include "dbview_quantity.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/group_career.cpp b/code/ryzom/client/src/interface_v3/group_career.cpp index f7dbe2cc9..04916f007 100644 --- a/code/ryzom/client/src/interface_v3/group_career.cpp +++ b/code/ryzom/client/src/interface_v3/group_career.cpp @@ -23,7 +23,7 @@ #include "interface_element.h" //#include "game_share/jobs.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index 0fa2b30e7..c2589310b 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "group_compas.h" #include "interface_3d_scene.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index eb98fb67a..e494af8f2 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -22,7 +22,7 @@ #include "group_container.h" #include "interface_manager.h" #include "interface_options.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" #include "group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 5bc516f47..fe423a9de 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -23,7 +23,7 @@ #include "input_handler_manager.h" #include "nel/misc/command.h" #include "view_text.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_options.h" #include "dbctrl_sheet.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/group_frame.cpp b/code/ryzom/client/src/interface_v3/group_frame.cpp index 4b7e5cdcc..54b95476e 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.cpp +++ b/code/ryzom/client/src/interface_v3/group_frame.cpp @@ -21,7 +21,7 @@ #include "group_frame.h" #include "interface_manager.h" #include "interface_element.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_html_cs.cpp b/code/ryzom/client/src/interface_v3/group_html_cs.cpp index 66d884437..a02231132 100644 --- a/code/ryzom/client/src/interface_v3/group_html_cs.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_cs.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_cs.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" // used for login cookie to be sent to the web server diff --git a/code/ryzom/client/src/interface_v3/group_html_forum.cpp b/code/ryzom/client/src/interface_v3/group_html_forum.cpp index b0fd96642..96e711500 100644 --- a/code/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_forum.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "guild_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_mail.cpp b/code/ryzom/client/src/interface_v3/group_html_mail.cpp index 2c0d9d225..ecc62367b 100644 --- a/code/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_mail.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp index 665a4ba9e..4414556b0 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_qcm.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "interface_manager.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 4a13d9806..5c9a423f3 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" #include "group_html_webig.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index b4e448458..9cc2a0871 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -24,7 +24,7 @@ #include "group_in_scene.h" #include "interface_manager.h" #include "view_renderer.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 7ccd5c51c..7a68be9d5 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -29,7 +29,7 @@ #include "lua_ihm.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 51d07bb88..e1d7b4ecd 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -38,7 +38,7 @@ #include "../global.h" #include "ctrl_quad.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "game_share/mission_desc.h" #include "game_share/inventories.h" #include "game_share/animal_type.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 22ff2b07c..8a1051e52 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "interface_expr.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "view_bitmap.h" #include "action_handler.h" // Just for getAllParams #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/ryzom/client/src/interface_v3/group_modal.cpp index 8055e66b2..bbd6a8015 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal.cpp @@ -21,7 +21,7 @@ #include "group_modal.h" #include "interface_manager.h" #include "interface_element.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index aad604d24..42def29d6 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -30,7 +30,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index beb88e2df..8494e7213 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -26,7 +26,7 @@ #include "game_share/skills.h" #include "game_share/brick_families.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "skill_manager.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 210c7110e..3f829c8ef 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -27,7 +27,7 @@ #include "../libwww.h" #include "interface_manager.h" #include "action_handler.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 611ecb738..645149b46 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -29,7 +29,7 @@ #include "dbview_bar.h" #include "game_share/skills.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "skill_manager.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 27e6aa3a4..d42855464 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "group_tab.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../time_client.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 48ec926a4..f31d5c6ac 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -29,7 +29,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 3a09241b6..9eb02ad10 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -30,7 +30,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 3ece9f125..c57346655 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -22,7 +22,7 @@ #include "nel/misc/file.h" #include "nel/misc/game_device_events.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "input_handler_manager.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 324edf91a..90e4aebc9 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -29,7 +29,7 @@ #include "nel/3d/u_particle_system_instance.h" #include "nel/3d/u_animation_set.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index 0594fe22b..18e3f9b08 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -22,7 +22,7 @@ #include "interface_anim.h" #include "interface_manager.h" #include "interface_expr.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index b987f9cf9..3e363225c 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -25,7 +25,7 @@ #include "group_modal.h" #include "../client_cfg.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 6db901b10..7edc093ae 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -24,7 +24,7 @@ #include "group_container.h" #include "../misc.h" #include "interface_link.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "nel/misc/mem_stream.h" // diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 91022dedb..a088b2c0c 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -20,7 +20,7 @@ #include "interface_group.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" #include "group_editbox.h" #include "group_scrolltext.h" diff --git a/code/ryzom/client/src/interface_v3/interface_observer.h b/code/ryzom/client/src/interface_v3/interface_observer.h index 645d8195c..b90c84f6b 100644 --- a/code/ryzom/client/src/interface_v3/interface_observer.h +++ b/code/ryzom/client/src/interface_v3/interface_observer.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" /** diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/ryzom/client/src/interface_v3/interface_options.cpp index 0a8135f71..3a06da8f5 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options.cpp @@ -22,7 +22,7 @@ #include "interface_options.h" #include "interface_manager.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../net_manager.h" #include "../sheet_manager.h" #include "../entity_animation_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 56b95be88..b01c0e8d1 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -27,7 +27,7 @@ #include "nel/misc/factory.h" #include "nel/misc/big_file.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_parser.h" #include "interface_observer.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index 9d59c5bcb..677084e5e 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -20,7 +20,7 @@ #include "skill_manager.h" #include "interface_manager.h" #include "game_share/skills.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "game_share/character_title.h" #include "game_share/fame.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index dba18c194..3ec51b270 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -22,7 +22,7 @@ #include "view_bitmap.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index 9085643a5..d9eb19957 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -20,7 +20,7 @@ #include "view_bitmap_combo.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp index dca41c35c..ff7b0fa70 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp @@ -19,7 +19,7 @@ #include "view_bitmap_faber_mp.h" #include "interface_manager.h" #include "../sheet_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" extern CSheetManager SheetMngr; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index e6e6dcaa2..092054ee2 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -28,7 +28,7 @@ #include "group_html.h" #include "group_map.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "group_container.h" #include "interface_3d_scene.h" diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index f0f613587..7f3d222b4 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -22,7 +22,7 @@ #include "view_radar.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" #include "../npc_icon.h" #include "nel/misc/fast_floor.h" diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 4714c8208..4bfd91a39 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -26,7 +26,7 @@ #include "group_container.h" // CCtrlResizer #include "ctrl_tooltip.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_formated.cpp index 5b2308f21..6d3513fce 100644 --- a/code/ryzom/client/src/interface_v3/view_text_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_formated.cpp @@ -23,7 +23,7 @@ #include "../string_manager_client.h" #include "action_handler_misc.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 2663e848d..326f67362 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "../string_manager_client.h" #include "view_text_id.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "nel/misc/algo.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp index 29d360a4e..70bacaa98 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp @@ -22,7 +22,7 @@ #include "../string_manager_client.h" #include "../user_entity.h" #include "../entities.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace STRING_MANAGER; diff --git a/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp b/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp index 8328186a9..0b17474d7 100644 --- a/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp +++ b/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp @@ -20,7 +20,7 @@ #include "generic_xml_msg_mngr.h" #include "nel/misc/file.h" -#include "xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/common/src/game_share/ring_access.cpp b/code/ryzom/common/src/game_share/ring_access.cpp index 9eda38010..3c04d0bb5 100644 --- a/code/ryzom/common/src/game_share/ring_access.cpp +++ b/code/ryzom/common/src/game_share/ring_access.cpp @@ -32,7 +32,7 @@ #include "nel/misc/o_xml.h" #include "nel/misc/i_xml.h" #include "nel/misc/algo.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp index f95777359..c622310e5 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp @@ -30,7 +30,7 @@ ////////////// #include "player_manager/cdb_branch.h" #include "player_manager/cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include //////////////// diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp b/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp index fc26bb83a..22b53b3b1 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp @@ -29,7 +29,7 @@ // Includes // ////////////// #include "player_manager/cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include From 86cf0b47f68adc24d01455cb042a4fefe5da7ded Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 8 Feb 2012 02:06:12 +0100 Subject: [PATCH 002/339] Oups didn't want to commit this. --- code/nel/src/misc/stdmisc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/code/nel/src/misc/stdmisc.h b/code/nel/src/misc/stdmisc.h index 860983518..572a90f1a 100644 --- a/code/nel/src/misc/stdmisc.h +++ b/code/nel/src/misc/stdmisc.h @@ -52,7 +52,6 @@ #include "nel/misc/stream.h" #include "nel/misc/path.h" #include "nel/misc/string_common.h" -//#include "nel/misc/xml_auto_ptr.h" #ifdef NL_OS_WINDOWS #define NOMINMAX From 6df7a47149b7ae804b930b0a31a438536642a64f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 8 Feb 2012 20:21:29 +0100 Subject: [PATCH 003/339] Changed the copyright header of a previously moved file for consistency --- code/nel/include/nel/misc/xml_auto_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/xml_auto_ptr.h b/code/nel/include/nel/misc/xml_auto_ptr.h index 36e67331b..250cd4a37 100644 --- a/code/nel/include/nel/misc/xml_auto_ptr.h +++ b/code/nel/include/nel/misc/xml_auto_ptr.h @@ -1,4 +1,4 @@ -// Ryzom - MMORPG Framework +// NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify From cec36b97e0b46f25e5e8c2e950fd111cf4d934d1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 8 Feb 2012 20:27:43 +0100 Subject: [PATCH 004/339] Seems I forgot to remove these.. --- .../common/src/game_share/xml_auto_ptr.cpp | 52 ------------ .../common/src/game_share/xml_auto_ptr.h | 81 ------------------- 2 files changed, 133 deletions(-) delete mode 100644 code/ryzom/common/src/game_share/xml_auto_ptr.cpp delete mode 100644 code/ryzom/common/src/game_share/xml_auto_ptr.h diff --git a/code/ryzom/common/src/game_share/xml_auto_ptr.cpp b/code/ryzom/common/src/game_share/xml_auto_ptr.cpp deleted file mode 100644 index 4fcdb9543..000000000 --- a/code/ryzom/common/src/game_share/xml_auto_ptr.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - -/* - * Completely implemented in xml_auto_ptr.h - */ - -#include "stdpch.h" - -/* -#include "xml_auto_ptr.h" -#include - -//======================================= -void CXMLAutoPtr::destroy() -{ - if (_Value) - { - xmlFree(const_cast(_Value)); - _Value = NULL; - } -} - -//======================================= -CXMLAutoPtr::~CXMLAutoPtr() -{ - destroy(); -} - -//======================================= -CXMLAutoPtr &CXMLAutoPtr::operator = (const char *other) -{ - if (other == _Value) return *this; - destroy(); - _Value = other; - return *this; -} - -*/ diff --git a/code/ryzom/common/src/game_share/xml_auto_ptr.h b/code/ryzom/common/src/game_share/xml_auto_ptr.h deleted file mode 100644 index 36e67331b..000000000 --- a/code/ryzom/common/src/game_share/xml_auto_ptr.h +++ /dev/null @@ -1,81 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 XML_AUTO_PTR_H -#define XML_AUTO_PTR_H - -#include - -/** Simple auto pointer for xml pointers - */ -class CXMLAutoPtr -{ -public: - CXMLAutoPtr(const char *value = NULL) : _Value(value) {} - CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {} - ~CXMLAutoPtr() { destroy(); } - operator const char *() const { return _Value; } - operator bool() const { return _Value != NULL; } - operator std::string() const { return std::string(_Value); } - bool operator ! () const { return _Value == NULL; } - operator const unsigned char *() const { return (const unsigned char *) _Value; } - char operator * () const { nlassert(_Value); return *_Value; } - /// NB : This remove previous owned pointer with xmlFree - CXMLAutoPtr &operator = (const char *other) - { - if (other == _Value) return *this; - destroy(); - _Value = other; - return *this; - } - - CXMLAutoPtr &operator = (const unsigned char *other) - { - *this = (const char *) other; - return *this; - } - char *getDatas() const { return const_cast(_Value); } -////////////////////////////////////////////////// -private: - const char *_Value; -private: - void destroy() - { - if (_Value) - { - xmlFree(const_cast(_Value)); - _Value = NULL; - } - } - - // We'd rather avoid problems - CXMLAutoPtr(const CXMLAutoPtr &/* other */) - { - nlassert(0); - } - CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */) - { - nlassert(0); - return *this; - } -}; - - -#endif - - From f0cc382971f8e36552311cdbcbc88ea05384cdea Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Feb 2012 01:41:46 +0100 Subject: [PATCH 005/339] CViewRenderer no longer depends on the Driver global variable. Also got rid of the same dependencies in files which included that global from the CViewRenderer header. --- code/ryzom/client/src/init.cpp | 3 + .../src/interface_v3/action_handler_help.cpp | 1 + .../src/interface_v3/action_handler_misc.cpp | 6 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 5 + .../client/src/interface_v3/group_editbox.cpp | 4 +- .../src/interface_v3/group_in_scene.cpp | 4 +- .../interface_v3/group_in_scene_bubble.cpp | 1 + .../interface_v3/input_handler_manager.cpp | 4 +- .../src/interface_v3/interface_3d_scene.cpp | 16 ++- .../src/interface_v3/interface_manager.cpp | 3 +- .../src/interface_v3/interface_options.cpp | 6 +- .../src/interface_v3/interface_parser.cpp | 15 +-- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_renderer.cpp | 110 +++++++++--------- .../client/src/interface_v3/view_renderer.h | 29 ++--- .../client/src/r2/object_factory_client.cpp | 1 - 16 files changed, 111 insertions(+), 99 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index a43dd97c0..4f019084c 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -62,6 +62,7 @@ #include "ingame_database_manager.h" #include "client_chat_manager.h" #include "interface_v3/input_handler_manager.h" +#include "interface_v3/interface_manager.h" //#include "crtdbg.h" #include "sound_manager.h" #include "net_manager.h" @@ -1074,6 +1075,8 @@ void prelogInit() // resetTextContext ("bremenb.ttf", false); resetTextContext ("ryzom.ttf", false); + CInterfaceManager::getInstance(); + ProgressBar.setFontFactor(0.85f); nmsg = "Loading background..."; diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 4c92fe6e0..b36e063d7 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -3920,6 +3920,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { #ifdef NL_OS_WINDOWS + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); if (Driver) { HWND wnd = Driver->getDisplay(); diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index b8af699dd..fad47b05f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -520,7 +520,8 @@ CCameraBackup setupCameraForScreenshot(UScene &scene, uint left, uint right, uin // Build a viewport CViewport viewport; - viewport.init (0, 0, (float)(right-left)/Driver->getWindowWidth(), (float)(bottom-top)/Driver->getWindowHeight()); + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + viewport.init (0, 0, (float)(right-left)/Driver->getWindowWidth(),(float)(bottom-top)/Driver->getWindowHeight()); // Activate all this scene.getCam().setFrustum (frustumPart); @@ -552,6 +553,7 @@ void renderSceneScreenShot (uint left, uint right, uint top, uint bottom, uint s void getBuffer (CBitmap &btm) { + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); // if (ClientCfg.ScreenShotWidth && ClientCfg.ScreenShotHeight) { @@ -611,6 +613,8 @@ bool screenshotZBuffer(const std::string &filename) std::string ext = filename.substr(pos+1); std::vector z; + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + Driver->getZBuffer(z); float min = std::numeric_limits::max(); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 6f4eb1391..f0aa58dd2 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -250,6 +250,7 @@ CCtrlSheetInfo::CCtrlSheetInfo() void CDBCtrlSheet::release () { + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); if (Driver) Driver->deleteMaterial(_GuildMat); @@ -489,6 +490,8 @@ CDBCtrlSheet::CDBCtrlSheet(const TCtorParam ¶m) // ---------------------------------------------------------------------------- CDBCtrlSheet::~CDBCtrlSheet() { + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + if (_GuildBack) { if (Driver) @@ -1304,6 +1307,8 @@ void CDBCtrlSheet::setupGuildFlag () sint8 nLastGuildBack = (sint8)(_MacroID&15); // 4 bits en pos 0 sint8 nLastGuildSymbol = (sint8)((_MacroID>>4)&63); // 6 bits en pos 4 + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + if (_GuildMat.empty()) { _GuildMat = Driver->createMaterial(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index fe423a9de..3f3e58a72 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -335,7 +335,7 @@ void CGroupEditBox::copy() stopParentBlink(); // get the selection and copy it - if (Driver->copyTextToClipboard(getSelection())) + if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->copyTextToClipboard(getSelection())) nlinfo ("Chat input was copied in the clipboard"); } @@ -353,7 +353,7 @@ void CGroupEditBox::paste() ucstring sString; - if (Driver->pasteTextFromClipboard(sString)) + if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->pasteTextFromClipboard(sString)) { // append string now appendStringFromClipboard(sString); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index 9cc2a0871..bad4e4236 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -86,8 +86,8 @@ void CGroupInScene::computeWindowPos(sint32 &newX, sint32 &newY, CVector &newPro tmp = pVR.getFrustum().projectZ (tmp); // Get the width and height - tmp.x *= (float)Driver->getWindowWidth(); - tmp.y *= (float)Driver->getWindowHeight(); + tmp.x *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowWidth(); + tmp.y *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowHeight(); // position without offset, in float newProjCenter.x= tmp.x; diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 85238ad7d..957fa5b0f 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -667,6 +667,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont if (target) { // Find a position + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); const uint width = Driver->getWindowWidth(); const uint height = Driver->getWindowHeight(); h = (target->getXReal() < ((sint)width-target->getXReal()-target->getWReal()))?"l":"r"; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index c57346655..5723952ee 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -174,13 +174,13 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) UserControls.stopFreeLook(); } // be nice with other app : let the mouse reappear (useful in direct 3D mode with no hardware cursor) - Driver->showCursor(true); + CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(true); // Driver->setSystemArrow(); } else { _RecoverFocusLost = true; // force to update mouse pos on next click or move - Driver->showCursor(IsMouseCursorHardware()); + CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(IsMouseCursorHardware()); _Focus = true; } diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 90e4aebc9..23e7dda44 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -78,6 +78,7 @@ CInterface3DScene::~CInterface3DScene() for (i = 0; i < _FXs.size(); ++i) delete _FXs[i]; + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); if (_Scene != NULL) Driver->deleteScene (_Scene); @@ -171,7 +172,8 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) return true; } - nlassert (Driver != NULL); + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + nlassert ( Driver != NULL); _Scene = Driver->createScene(true); @@ -297,7 +299,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (!animName.empty()) { if (_AutoAnimSet == NULL) - _AutoAnimSet = Driver->createAnimationSet(); + _AutoAnimSet = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet(); uint id = _AutoAnimSet->addAnimation (ptr, animName.c_str ()); if (id == UAnimationSet::NotFound) { @@ -376,7 +378,9 @@ void CInterface3DScene::draw () { H_AUTO( RZ_Interface_CInterface3DScene_draw ) - if (Driver == NULL) + NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + + if ( Driver == NULL) return; // No Op if screen minimized @@ -434,7 +438,7 @@ void CInterface3DScene::draw () float vpW = (float) clipw / iavoid0(wsw); float vpH = (float) cliph / iavoid0(wsh); newVP.init(vpX, vpY, vpW, vpH); - NL3D::CFrustum oldFrustum = Driver->getFrustum(); + NL3D::CFrustum oldFrustum = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getFrustum(); NL3D::CFrustum newFrustum; newFrustum.initPerspective (pI3DCam->getFOV() * (float) (NLMISC::Pi / 180), (float) _WReal / iavoid0(_HReal), 0.1f, 100.f); @@ -1093,7 +1097,7 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) setRotX (_Rot.x); setRotY (_Rot.y); setRotZ (_Rot.z); - _IG->addToScene (*parentGroup->getScene(), Driver); + _IG->addToScene (*parentGroup->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); parentGroup->getScene()->setToGlobalInstanceGroup (_IG); return true; @@ -1214,7 +1218,7 @@ void CInterface3DIG::setName (const std::string &ht) _IG = UInstanceGroup::createInstanceGroup(_Name); if (_IG == NULL) return; _IG->setPos (_Pos); - _IG->addToScene (*pI3DS->getScene(), Driver); + _IG->addToScene (*pI3DS->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); pI3DS->getScene()->setToGlobalInstanceGroup (_IG); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 180a25763..4ca1f9bac 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -253,7 +253,8 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS // ------------------------------------------------------------------------------------------------ -CInterfaceManager::CInterfaceManager() +CInterfaceManager::CInterfaceManager() : +_ViewRenderer( Driver ) { _Instance = this; _DbRootNode = new CCDBNodeBranch("ROOT"); diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/ryzom/client/src/interface_v3/interface_options.cpp index 3a06da8f5..f46111c79 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options.cpp @@ -414,7 +414,7 @@ COptionsAnimationSet::~COptionsAnimationSet() BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList (see deleteAnimationSet() doc) */ - Driver->deleteAnimationSet(AnimationSet); + CInterfaceManager::getInstance()->getViewRenderer().getDriver()->deleteAnimationSet(AnimationSet); AnimationSet= NULL; } } @@ -424,10 +424,10 @@ bool COptionsAnimationSet::parse (xmlNodePtr cur) { bool result = CInterfaceOptions::parse(cur); if (!result) return false; - nlassert(Driver); + nlassert( CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); // create the animation set - AnimationSet= Driver->createAnimationSet(); + AnimationSet= CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet(); nlassert(AnimationSet); AnimMale.clear(); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index b01c0e8d1..c7c873196 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -118,13 +118,14 @@ using namespace NLMISC; void badLuaParseMessageBox() { - NL3D::UDriver::TMessageBoxId ret = Driver->systemMessageBox( "LUA files reading failed!\n" - "Some LUA files are corrupted, moved or may have been removed.\n" - "Ryzom may need to be restarted to run properly.\n" - "Would you like to quit now?", - "LUA reading failed!", - NL3D::UDriver::yesNoType, - NL3D::UDriver::exclamationIcon); + NL3D::UDriver::TMessageBoxId ret = + CInterfaceManager::getInstance()->getViewRenderer().getDriver()->systemMessageBox( "LUA files reading failed!\n" + "Some LUA files are corrupted, moved or may have been removed.\n" + "Ryzom may need to be restarted to run properly.\n" + "Would you like to quit now?", + "LUA reading failed!", + NL3D::UDriver::yesNoType, + NL3D::UDriver::exclamationIcon); if (ret == NL3D::UDriver::yesId) { extern void quitCrashReport (); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 092054ee2..459ba3786 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -701,7 +701,7 @@ void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot) { // set new cursor for the hardware mouse std::string name = rVR.getTextureNameFromId(texId); - Driver->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0)); + rVR.getDriver()->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0)); } } diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp index 6a300275e..8f53d41f6 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ b/code/ryzom/client/src/interface_v3/view_renderer.cpp @@ -30,45 +30,15 @@ using namespace NLMISC; using namespace std; using namespace NL3D; - -/* - * constructor - */ -CViewRenderer::CViewRenderer() +CViewRenderer::CViewRenderer( NL3D::UDriver *driver ) { - _ClipX = _ClipY = 0; - _ClipW = 800; - _ClipH = 600; - _ScreenW = 800; - _ScreenH = 600; - _OneOverScreenW= 1.0f / (float)_ScreenW; - _OneOverScreenH= 1.0f / (float)_ScreenH; - _IsMinimized= false; - _WFigurTexture= 0; - _HFigurTexture= 0; - _WFigurSeparatorTexture = 0; - _FigurSeparatorTextureId = -1; - _FigurBlankId = -1; - _BlankId = -1; - _WorldSpaceTransformation = true; - _CurrentZ = 10; - for(uint i=0;idriver = driver; } - -/* - * destructor - */ CViewRenderer::~CViewRenderer() { - if (!_Material.empty() && Driver) - Driver->deleteMaterial(_Material); - for(uint i=0;igetWindowSize (w, h); + driver->getWindowSize (w, h); // not minimized? change coords if(w!=0 && h!=0) { @@ -145,14 +115,40 @@ void CViewRenderer::getScreenOOSize (float &oow, float &ooh) ooh= _OneOverScreenH; } +void CViewRenderer::setup() +{ + _ClipX = _ClipY = 0; + _ClipW = 800; + _ClipH = 600; + _ScreenW = 800; + _ScreenH = 600; + _OneOverScreenW= 1.0f / (float)_ScreenW; + _OneOverScreenH= 1.0f / (float)_ScreenH; + _IsMinimized= false; + _WFigurTexture= 0; + _HFigurTexture= 0; + _WFigurSeparatorTexture = 0; + _FigurSeparatorTextureId = -1; + _FigurBlankId = -1; + _BlankId = -1; + _WorldSpaceTransformation = true; + _CurrentZ = 10; + for(uint i=0;icreateMaterial(); + if (!driver) return; + _Material = driver->createMaterial(); setRenderStates(); @@ -188,7 +184,7 @@ void CViewRenderer::reset() UTextureFile *tf = dynamic_cast(ite->Texture); if (tf) { - Driver->deleteTextureFile (tf); + driver->deleteTextureFile (tf); } ite++; } @@ -200,6 +196,10 @@ void CViewRenderer::reset() _IndexesToTextureIds.clear(); } +NL3D::UDriver* CViewRenderer::getDriver(){ + return driver; +} + // *************************************************************************** void CViewRenderer::SImage::setupQuadUV(bool flipv, uint8 rot, CQuadColorUV &dest) { @@ -711,7 +711,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std: CIFile ifTmp; if (ifTmp.open(filename)) CBitmap::loadSize (ifTmp, gt.Width, gt.Height); - gt.Texture = Driver->createTextureFile (filename); + gt.Texture = driver->createTextureFile (filename); // Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again. // Its why we don't release it at the end, because it is likely to be uploaded soon) CBitmap *texDatas = gt.Texture->generateDatas(); @@ -729,7 +729,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std: _GlobalTextures.push_back (gt); - Driver->setCursorScale(ClientCfg.HardwareCursorScale); + driver->setCursorScale(ClientCfg.HardwareCursorScale); char bufTmp[256], tgaName[256]; string sTGAname; @@ -781,7 +781,7 @@ void CViewRenderer::loadTextures (const std::string &textureFileName, const std: CBitmap curs; curs.resize(x1 - x0, y1 - y0); curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0); - Driver->addCursor(image.Name, curs); + driver->addCursor(image.Name, curs); } } } @@ -877,7 +877,7 @@ sint32 CViewRenderer::createTexture (const std::string &sGlobalTextureName, nlwarning("Failed to load the texture '%s', please check image format", filename.c_str()); } } - gtTmp.Texture = Driver->createTextureFile (sLwrGTName); + gtTmp.Texture = driver->createTextureFile (sLwrGTName); gtTmp.Name = sLwrGTName; gtTmp.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); if(uploadDXTC) @@ -1007,7 +1007,7 @@ void CViewRenderer::deleteTexture (sint32 textureId) UTextureFile *tf = dynamic_cast(iteGT->Texture); if (tf) { - Driver->deleteTextureFile (tf); + driver->deleteTextureFile (tf); } _GlobalTextures.erase (iteGT); return; @@ -1151,13 +1151,13 @@ void CViewRenderer::flush () // draw quads and empty list if (layer.NbQuads != 0) { - Driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material); + driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material); layer.NbQuads = 0; } if (!layer.Tris.empty()) { - Driver->drawTriangles(layer.Tris, _Material); + driver->drawTriangles(layer.Tris, _Material); layer.Tris.clear(); } @@ -1178,12 +1178,12 @@ void CViewRenderer::flush () // alpha blended if (!layer.FilteredAlphaBlendedQuads.empty()) { - Driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material); + driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material); layer.FilteredAlphaBlendedQuads.clear(); } if (!layer.FilteredAlphaBlendedTris.empty()) { - Driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material); + driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material); layer.FilteredAlphaBlendedTris.clear(); } // additif @@ -1193,12 +1193,12 @@ void CViewRenderer::flush () _Material.setBlendFunc (NL3D::UMaterial::one, NL3D::UMaterial::one); if (!layer.FilteredAdditifQuads.empty()) { - Driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material); + driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material); layer.FilteredAdditifQuads.clear(); } if (!layer.FilteredAdditifTris.empty()) { - Driver->drawTriangles(layer.FilteredAdditifTris, _Material); + driver->drawTriangles(layer.FilteredAdditifTris, _Material); layer.FilteredAdditifTris.clear(); } // restore alpha blend @@ -1546,13 +1546,13 @@ URenderStringBuffer *CViewRenderer::getStringRenderBuffer(sint layerId) // *************************************************************************** void CViewRenderer::drawWiredQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/) { - Driver->drawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); + driver->drawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); } // *************************************************************************** void CViewRenderer::drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/) { - Driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); + driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); } @@ -1610,7 +1610,7 @@ void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, worldSpaceTransformation (qcoluv2_clipped); // Draw clipped quad - Driver->drawQuads (&qcoluv2_clipped, 1, Mat); + driver->drawQuads (&qcoluv2_clipped, 1, Mat); } // *************************************************************************** @@ -1658,7 +1658,7 @@ void CViewRenderer::drawCustom(sint32 x, sint32 y, sint32 width, sint32 height, } // Draw clipped quad - Driver->drawQuads (&qcoluv_clipped, 1, Mat); + driver->drawQuads (&qcoluv_clipped, 1, Mat); } // *************************************************************************** @@ -1716,7 +1716,7 @@ void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, worldSpaceTransformation (qcoluv2_clipped); // Draw clipped quad - Driver->drawQuads (&qcoluv2_clipped, 1, Mat); + driver->drawQuads (&qcoluv2_clipped, 1, Mat); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_renderer.h b/code/ryzom/client/src/interface_v3/view_renderer.h index ea7583dfa..ff53a4c67 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.h +++ b/code/ryzom/client/src/interface_v3/view_renderer.h @@ -29,16 +29,6 @@ #include "../ingame_database_manager.h" -//the NEL 3d driver -extern NL3D::UDriver* Driver; - -//the NEL 3d textcontext -extern NL3D::UTextContext *TextContext; - -//the network database node -extern CCDBSynchronised IngameDbMngr; - - // *************************************************************************** #define VR_NUM_LAYER 32 #define VR_BIAS_LAYER (VR_NUM_LAYER/2) @@ -113,15 +103,13 @@ public: sint32 _TextureId; }; - /** - * destructor - */ - CViewRenderer (); - /** - * destructor - */ + CViewRenderer( NL3D::UDriver *driver ); + ~CViewRenderer (); + /// setup the default values for everything + void setup(); + /// init when TextContext and Driver are created void init(); @@ -131,6 +119,9 @@ public: /// Delete all textures and the like and reset the view renderer void reset(); + /// Retrieves the 3d driver we are using + NL3D::UDriver* getDriver(); + /* * setClipWindow : set the current clipping window * (this window do not inherit properties from parent or whatever) @@ -567,7 +558,9 @@ private: NL3D::CFrustum _CameraFrustum; // Transform from screen space to world space NLMISC::CMatrix _WorldSpaceMatrix; // Matrix to be applied for world space transformation bool _WorldSpaceScale; - + + + NL3D::UDriver *driver; }; diff --git a/code/ryzom/client/src/r2/object_factory_client.cpp b/code/ryzom/client/src/r2/object_factory_client.cpp index 975d2d6a1..a8ad45e3d 100644 --- a/code/ryzom/client/src/r2/object_factory_client.cpp +++ b/code/ryzom/client/src/r2/object_factory_client.cpp @@ -300,7 +300,6 @@ void CObjectRefIdClient::getNameInParent(std::string &name, sint32 &indexInArray nlwarning("ObservedObject parent instance ptr = %p", parent); parent->getLuaProjection().dump(); } - Driver->systemMessageBox("Bug catched, please send log.log to vizerie@nevrax.com", "nevrax internal", NL3D::UDriver::okType, NL3D::UDriver::exclamationIcon); nlassert(0); // not found in parent } From 7149af988601d6768d769a36f4ec281703a5f2ed Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Feb 2012 02:28:14 +0100 Subject: [PATCH 006/339] VCiewRenderer no longer depends on the global TextContext variable. Instead it's updated when it changes. --- code/ryzom/client/src/global.cpp | 1 + .../client/src/interface_v3/interface_manager.cpp | 7 ++++++- .../client/src/interface_v3/interface_manager.h | 3 +++ .../client/src/interface_v3/view_renderer.cpp | 14 ++++++++++---- code/ryzom/client/src/interface_v3/view_renderer.h | 6 +++++- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/global.cpp b/code/ryzom/client/src/global.cpp index 01756dd01..ee6e1f483 100644 --- a/code/ryzom/client/src/global.cpp +++ b/code/ryzom/client/src/global.cpp @@ -83,6 +83,7 @@ void resetTextContext (const char *font, bool resetInterfaceManager) if (resetInterfaceManager) { CInterfaceManager *im = CInterfaceManager::getInstance(); + im->setTextContext( TextContext ); im->resetTextIndex(); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 4ca1f9bac..64839446c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -254,7 +254,7 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager() : -_ViewRenderer( Driver ) +_ViewRenderer( Driver, TextContext ) { _Instance = this; _DbRootNode = new CCDBNodeBranch("ROOT"); @@ -6599,4 +6599,9 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) ucstr = str; return true;; +} + +void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext ) +{ + _ViewRenderer.setTextContext( textcontext ); } \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index ced23130f..f6192f95b 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -720,6 +720,9 @@ public: */ static bool parseTokens(ucstring& ucstr); + /// Sets the current TextContext. + void setTextContext( NL3D::UTextContext *textcontext ); + // ------------------------------------------------------------------------------------------------ private: diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp index 8f53d41f6..833e9b47b 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ b/code/ryzom/client/src/interface_v3/view_renderer.cpp @@ -30,11 +30,12 @@ using namespace NLMISC; using namespace std; using namespace NL3D; -CViewRenderer::CViewRenderer( NL3D::UDriver *driver ) +CViewRenderer::CViewRenderer( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { setup(); this->driver = driver; + this->textcontext = textcontext; } CViewRenderer::~CViewRenderer() @@ -155,7 +156,7 @@ void CViewRenderer::init() // Init all renderBuffer for(uint i=0;icreateRenderBuffer(); + _StringRBLayers[i]= textcontext->createRenderBuffer(); } } @@ -200,6 +201,11 @@ NL3D::UDriver* CViewRenderer::getDriver(){ return driver; } +void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext) +{ + this->textcontext = textcontext; +} + // *************************************************************************** void CViewRenderer::SImage::setupQuadUV(bool flipv, uint8 rot, CQuadColorUV &dest) { @@ -1211,9 +1217,9 @@ void CViewRenderer::flush () // **** Display Computed Strings of this layer if (_WorldSpaceTransformation) - TextContext->flushRenderBufferUnProjected(_StringRBLayers[layerId], false); + textcontext->flushRenderBufferUnProjected(_StringRBLayers[layerId], false); else - TextContext->flushRenderBuffer(_StringRBLayers[layerId]); + textcontext->flushRenderBuffer(_StringRBLayers[layerId]); // flushed _EmptyLayer[layerId]= true; diff --git a/code/ryzom/client/src/interface_v3/view_renderer.h b/code/ryzom/client/src/interface_v3/view_renderer.h index ff53a4c67..eed178795 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.h +++ b/code/ryzom/client/src/interface_v3/view_renderer.h @@ -103,7 +103,7 @@ public: sint32 _TextureId; }; - CViewRenderer( NL3D::UDriver *driver ); + CViewRenderer( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); ~CViewRenderer (); @@ -122,6 +122,9 @@ public: /// Retrieves the 3d driver we are using NL3D::UDriver* getDriver(); + /// Sets the current TextContext. + void setTextContext( NL3D::UTextContext *textcontext ); + /* * setClipWindow : set the current clipping window * (this window do not inherit properties from parent or whatever) @@ -561,6 +564,7 @@ private: NL3D::UDriver *driver; + NL3D::UTextContext *textcontext; }; From 94b7c2a8e783bd65e529cb4d56aba784dcad16a8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Feb 2012 04:19:31 +0100 Subject: [PATCH 007/339] CInterfaceManager and CViewText will no longer depend on the TextContext global variable. --- code/ryzom/client/src/init.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 4 ++- .../src/interface_v3/interface_manager.h | 7 +++-- .../client/src/interface_v3/view_text.cpp | 29 ++++++++++++++----- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 4f019084c..a5d4bc51b 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1075,7 +1075,7 @@ void prelogInit() // resetTextContext ("bremenb.ttf", false); resetTextContext ("ryzom.ttf", false); - CInterfaceManager::getInstance(); + CInterfaceManager::getInstance()->setTextContext( TextContext ); ProgressBar.setFontFactor(0.85f); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 64839446c..b225f19a0 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -342,6 +342,7 @@ _ViewRenderer( Driver, TextContext ) _DebugTrackGroupCreateCount = 0; _DebugTrackGroupDestroyCount = 0; #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS + textcontext = NULL; } // ------------------------------------------------------------------------------------------------ @@ -1354,7 +1355,7 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) drawViews(camera); // The interface manager may change usual Global setup. reset them. - TextContext->setShadeColor(CRGBA::Black); + textcontext->setShadeColor(CRGBA::Black); } @@ -6603,5 +6604,6 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext ) { + this->textcontext = textcontext; _ViewRenderer.setTextContext( textcontext ); } \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index f6192f95b..f5aa69b7c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -48,9 +48,6 @@ static const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; static const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; -//the NEL 3d textcontext -extern NL3D::UTextContext *TextContext; - //the network database node extern CCDBSynchronised IngameDbMngr; @@ -723,8 +720,12 @@ public: /// Sets the current TextContext. void setTextContext( NL3D::UTextContext *textcontext ); + /// Retrueves the current TextContext + inline NL3D::UTextContext* getTextContext() const{ return textcontext; }; + // ------------------------------------------------------------------------------------------------ private: + NL3D::UTextContext *textcontext; // Observer for copying db branch changes class CServerToLocalAutoCopy diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 4bfd91a39..6a4dc36d6 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -125,7 +125,7 @@ CViewText:: CViewText (const std::string& id, const std::string Text, sint FontS CViewText::~CViewText() { if (_Index != 0xFFFFFFFF) - TextContext->erase (_Index); + CInterfaceManager::getInstance()->getTextContext()->erase (_Index); clearLines(); if (!_Setuped) @@ -139,7 +139,7 @@ CViewText::~CViewText() CViewText &CViewText::operator=(const CViewText &vt) { if (_Index != 0xFFFFFFFF) - TextContext->erase (_Index); + CInterfaceManager::getInstance()->getTextContext()->erase (_Index); // Create database entries _Active = vt._Active; @@ -436,6 +436,8 @@ void CViewText::draw () return; rVR.getScreenOOSize (oow, ooh); + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + // *** get current color CRGBA col, shcol; @@ -459,6 +461,7 @@ void CViewText::draw () { if (_Lines.size() == 0) return; + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -865,6 +868,8 @@ void CViewText::updateTextContextMultiLine(uint nMaxWidth) rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); } + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + // Parse the letter { ucLetter = _Text[i]; @@ -1041,7 +1046,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS // Get the word value. wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd); // compute width of word - si = TextContext->getStringInfo(wordValue); + si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(wordValue); // compute size of spaces/Tab + word newLineWidth = lineWidth + numSpaces * _SpaceWidth; @@ -1120,7 +1125,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS for(currChar = 0; currChar < wordValue.length(); ++currChar) { oneChar = wordValue[currChar]; - si = TextContext->getStringInfo(oneChar); + si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(oneChar); if ((uint) (px + si.StringWidth) > nMaxWidth) break; px += si.StringWidth; } @@ -1239,6 +1244,8 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS // *************************************************************************** void CViewText::updateTextContext () { + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -1549,6 +1556,7 @@ void CViewText::setColorRGBA(NLMISC::CRGBA col) void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const { NLMISC::clamp(index, 0, (sint) _Text.length()); + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -1660,7 +1668,7 @@ static uint getCharacterIndex(const ucstring &textValue, float x) { // get character width singleChar[0] = textValue[i]; - si = TextContext->getStringInfo(singleChar); + si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(singleChar); px += si.StringWidth; // the character is at the i - 1 position if (px > x) @@ -1677,6 +1685,8 @@ static uint getCharacterIndex(const ucstring &textValue, float x) // *************************************************************************** void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const { + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + // setup the text context TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -1815,7 +1825,7 @@ void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &te quadSize--; } // select what quad to skip - TextContext->setStringSelection(stringId, quadStart, quadSize); + CInterfaceManager::getInstance()->getTextContext()->setStringSelection(stringId, quadStart, quadSize); } // *************************************************************************** @@ -1907,7 +1917,7 @@ void CViewText::CLine::clear() for(uint k = 0; k < _Words.size(); ++k) { if (_Words[k].Index != 0xffffffff) - TextContext->erase(_Words[k].Index); + CInterfaceManager::getInstance()->getTextContext()->erase(_Words[k].Index); } _Words.clear(); _NumChars = 0; @@ -1928,6 +1938,7 @@ void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/) { Text = text; NumSpaces = numSpaces; + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); Index = TextContext->textPush(text); Info = TextContext->getStringInfo(Index); } @@ -1950,6 +1961,7 @@ sint32 CViewText::getMaxUsedW() const static const ucstring lineFeedStr("\n"); float maxWidth = 0; + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2033,6 +2045,7 @@ sint32 CViewText::getMinUsedW() const // If we can't clip the words, return the size of the largest word else if ((_TextMode == DontClipWord) || (_TextMode == Justified)) { + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2083,6 +2096,7 @@ void CViewText::onInvalidateContent() // *************************************************************************** void CViewText::computeFontSize () { + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2436,6 +2450,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text) } // convert in ULetterColors + NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); ULetterColors * letterColors = TextContext->createLetterColors(); for(uint i=0; i Date: Sat, 11 Feb 2012 23:44:55 +0100 Subject: [PATCH 008/339] CInterfaceManager no longer depends on Driver global variable. --- code/ryzom/client/src/init.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 41 ++++++++++++------- .../src/interface_v3/interface_manager.h | 11 +++-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index a5d4bc51b..1721164e7 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1075,7 +1075,7 @@ void prelogInit() // resetTextContext ("bremenb.ttf", false); resetTextContext ("ryzom.ttf", false); - CInterfaceManager::getInstance()->setTextContext( TextContext ); + CInterfaceManager::create( Driver, TextContext ); ProgressBar.setFontFactor(0.85f); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b225f19a0..f3b8d27d4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -97,7 +97,7 @@ #include "../login.h" #include "../sheet_manager.h" // for emotes -#include "../global.h" // for emotes +//#include "../global.h" // for emotes #include "../entity_animation_manager.h" // for emotes #include "../net_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes @@ -127,6 +127,7 @@ extern CContinentManager ContinentMngr; extern CStringMapper *_UIStringMapper; extern bool IsInRingSession; extern CEventsListener EventsListener; +extern CEntityAnimationManager *EAM; namespace R2 { @@ -163,7 +164,7 @@ using namespace NLNET; // ------------------------------------------------------------------------------------------------ -extern NL3D::UDriver *Driver; +//extern NL3D::UDriver *Driver; extern bool loginFinished; // Edit actions CActionsManager EditActions; @@ -253,9 +254,11 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS // ------------------------------------------------------------------------------------------------ -CInterfaceManager::CInterfaceManager() : -_ViewRenderer( Driver, TextContext ) +CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) : +_ViewRenderer( driver, textcontext ) { + this->driver = driver; + this->textcontext = textcontext; _Instance = this; _DbRootNode = new CCDBNodeBranch("ROOT"); _ScreenW = _ScreenH = 0; @@ -430,6 +433,14 @@ void CInterfaceManager::resetShardSpecificData() pGC->setActive(false); } +// ------------------------------------------------------------------------------------------------ + +void CInterfaceManager::create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) +{ + nlassert( _Instance == NULL ); + new CInterfaceManager( driver, textcontext ); +} + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::destroy () { @@ -646,7 +657,8 @@ void CInterfaceManager::uninitOutGame() void badXMLParseMessageBox() { - NL3D::UDriver::TMessageBoxId ret = Driver->systemMessageBox( "Interface XML reading failed!\n" + NL3D::UDriver *driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver::TMessageBoxId ret = driver->systemMessageBox( "Interface XML reading failed!\n" "Some XML files are corrupted and may have been removed.\n" "Ryzom may need to be restarted to run properly.\n" "Would you like to quit now?", @@ -1468,7 +1480,8 @@ void CInterfaceManager::setupOptions() // Try to change font if any string sFont = _SystemOptions[OptionFont].getValStr(); - if ((!sFont.empty()) && (Driver != NULL)) + extern void resetTextContext( const char*, bool ); + if ((!sFont.empty()) && (driver != NULL)) resetTextContext(sFont.c_str(), true); // Continue to parse the rest of the interface @@ -2056,9 +2069,9 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) { if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty()) { - Driver->setViewMatrix(CMatrix::Identity); - Driver->setModelMatrix(CMatrix::Identity); - Driver->setFrustum(camera.getFrustum()); + driver->setViewMatrix(CMatrix::Identity); + driver->setModelMatrix(CMatrix::Identity); + driver->setFrustum(camera.getFrustum()); _ViewRenderer.activateWorldSpaceMatrix (true); } @@ -2082,7 +2095,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty()) { - Driver->setMatrixMode2D11(); + driver->setMatrixMode2D11(); _ViewRenderer.activateWorldSpaceMatrix (false); } } @@ -2138,7 +2151,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) _ViewRenderer.flush(); // todo hulud remove Return in 2d world - Driver->setMatrixMode2D11(); + driver->setMatrixMode2D11(); // flush obs CCDBNodeBranch::flushObserversCalls(); @@ -5615,9 +5628,9 @@ REGISTER_ACTION_HANDLER( CHandlerEmote, "emote"); bool CInterfaceManager::testDragCopyKey() { // hardcoded for now - return Driver->AsyncListener.isKeyDown(KeyCONTROL) || - Driver->AsyncListener.isKeyDown(KeyLCONTROL) || - Driver->AsyncListener.isKeyDown(KeyRCONTROL); + return driver->AsyncListener.isKeyDown(KeyCONTROL) || + driver->AsyncListener.isKeyDown(KeyLCONTROL) || + driver->AsyncListener.isKeyDown(KeyRCONTROL); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index f5aa69b7c..1400750b1 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -113,11 +113,13 @@ public: /// Singleton method : Get the unique interface loader instance static CInterfaceManager* getInstance() { - if (_Instance == NULL) - _Instance = new CInterfaceManager(); + nlassert( _Instance != NULL ); return _Instance; } + /// Create singleton + static void create( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); + /// Destroy singleton static void destroy (); @@ -725,7 +727,6 @@ public: // ------------------------------------------------------------------------------------------------ private: - NL3D::UTextContext *textcontext; // Observer for copying db branch changes class CServerToLocalAutoCopy @@ -906,7 +907,7 @@ private: uint8 _GlobalRolloverFactorContainer; /// Constructor - CInterfaceManager(); + CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); ///the singleton's instance static CInterfaceManager* _Instance; @@ -1067,6 +1068,8 @@ private: // Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0) void updateTooltipCoords(CCtrlBase *newCtrl); + NL3D::UDriver *driver; + NL3D::UTextContext *textcontext; }; #endif // NL_INTERFACE_MANAGER_H From c756db1201d84c7dacf4abbe0b4cb451b18e415d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 11 Feb 2012 23:47:54 +0100 Subject: [PATCH 009/339] FIXED: CInterfaceManager will no longer be prematurely released while quitting. --- code/ryzom/client/src/release.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 26edece3c..3695ec1ac 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -431,9 +431,6 @@ void releaseMainLoop(bool closeConnection) // Unlink the net manager NetMngr.setDataBase (NULL); - // Destroy interface manager - CInterfaceManager::destroy (); - // Send a msg to server if(!ClientCfg.Local) { From a26458be479249fcbe5557c478e77e75bd48dd26 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 12 Feb 2012 02:18:00 +0100 Subject: [PATCH 010/339] We might as well load the input config when we initialize the input handler. --- code/ryzom/client/src/init.cpp | 4 ++++ code/ryzom/client/src/interface_v3/interface_manager.cpp | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 1721164e7..e9d60774e 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1071,6 +1071,10 @@ void prelogInit() CInputHandlerManager *InputHandlerManager = CInputHandlerManager::getInstance(); InputHandlerManager->addToServer (&Driver->EventServer); + std::string filename = CPath::lookup( ClientCfg.XMLInputFile, false ); + if( !filename.empty() ) + InputHandlerManager->readInputConfigFile( filename ); + // Create a text context. We need to put the full path because we not already add search path // resetTextContext ("bremenb.ttf", false); resetTextContext ("ryzom.ttf", false); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index f3b8d27d4..3e665e7ba 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -297,13 +297,6 @@ _ViewRenderer( driver, textcontext ) // Global initialization // ********************* - - //init the input handler through the parsing of a config file - CInputHandlerManager *InputHandlerManager = CInputHandlerManager::getInstance(); - string filename = CPath::lookup(ClientCfg.XMLInputFile, false); - if (!filename.empty()) - InputHandlerManager->readInputConfigFile(filename); - // Interface Manager init _ViewRenderer.checkNewScreenSize(); _ViewRenderer.init(); From 8b278c8c61da5b575398d6068c9b0ec0fb0be733 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Feb 2012 02:30:26 +0100 Subject: [PATCH 011/339] Moved an action handler, from the view manager's source to the game action handlers' source. --- .../src/interface_v3/action_handler_game.cpp | 121 +++++++++++++++++ .../src/interface_v3/interface_manager.cpp | 124 ------------------ 2 files changed, 121 insertions(+), 124 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 22d65d138..ec0931b73 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4106,3 +4106,124 @@ public: } }; REGISTER_ACTION_HANDLER(CHandlerConfigureQuitDialogBox, "configure_quit_dialog_box"); + +// ---------------------------------------------------------------------------- +static bool isSwimming() +{ + if (UserEntity != NULL) + return (UserEntity->mode() == MBEHAV::SWIM || UserEntity->mode() == MBEHAV::MOUNT_SWIM); + else + return false; +} + +static bool isStunned() +{ + if (UserEntity != NULL) + return (UserEntity->behaviour() == MBEHAV::STUNNED); + else + return false; +} + +static bool isDead() +{ + if (UserEntity != NULL) + return (UserEntity->mode() == MBEHAV::DEATH); + else + return false; +} + +// *************************************************************************** + +class CHandlerEmote : public IActionHandler +{ +public: + void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + { + // An emote is 2 things : a phrase and an animation + // Phrase is the phrase that server returns in chat system + // Behav is the animation played + // CustomPhrase is an user phrase which can replace default phrase + string sPhraseNb = getParam(sParams, "nb"); + string sBehav = getParam(sParams, "behav"); + string sCustomPhrase = getParam(sParams, "custom_phrase"); + + uint32 phraseNb; + fromString(sPhraseNb, phraseNb); + uint8 behaviour; + fromString(sBehav, behaviour); + + MBEHAV::EBehaviour behavToSend = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + behaviour); + uint16 phraseNbToSend = (uint16)phraseNb; + + if (EAM) + { + const uint nbBehav = EAM->getNbEmots(); // Miscalled: this is the number of behaviour for all emotes + if ((behaviour >= nbBehav) || (behaviour == 255)) + behavToSend = MBEHAV::IDLE; + } + else + { + if (behaviour == 255) + behavToSend = MBEHAV::IDLE; + } + + /* Emotes forbidden when dead, emotes with behav forbidden when + * stunned or swimming */ + if ( ( behavToSend != MBEHAV::IDLE && (isSwimming() || isStunned() || isDead() ) ) ) + { + return; + } + + if( sCustomPhrase.empty() ) + { + // Create the message and send. + const string msgName = "COMMAND:EMOTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + out.serialEnum(behavToSend); + out.serial(phraseNbToSend); + NetMngr.push(out); + //nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend); + } + else + nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + } + else + { + // Create the message and send. + const string msgName = "COMMAND:CUSTOM_EMOTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + ucstring ucstr; + ucstr.fromUtf8(sCustomPhrase); + + if( sCustomPhrase == "none" ) + { + if( behavToSend == MBEHAV::IDLE ) + { + // display "no animation for emote" + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); + string cat = getStringCategory(msg, msg); + pIM->displaySystemInfo(msg, cat); + return; + } + } + else + { + ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; + } + + out.serialEnum(behavToSend); + out.serial(ucstr); + NetMngr.push(out); + //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); + } + else + nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + } + } +}; +REGISTER_ACTION_HANDLER( CHandlerEmote, "emote"); \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 3e665e7ba..b002e019f 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -29,7 +29,6 @@ // Globals #include "interface_manager.h" -#include "input_handler_manager.h" #include "interface_config.h" #include "task_bar_manager.h" #include "guild_manager.h" @@ -97,7 +96,6 @@ #include "../login.h" #include "../sheet_manager.h" // for emotes -//#include "../global.h" // for emotes #include "../entity_animation_manager.h" // for emotes #include "../net_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes @@ -127,7 +125,6 @@ extern CContinentManager ContinentMngr; extern CStringMapper *_UIStringMapper; extern bool IsInRingSession; extern CEventsListener EventsListener; -extern CEntityAnimationManager *EAM; namespace R2 { @@ -164,7 +161,6 @@ using namespace NLNET; // ------------------------------------------------------------------------------------------------ -//extern NL3D::UDriver *Driver; extern bool loginFinished; // Edit actions CActionsManager EditActions; @@ -5497,126 +5493,6 @@ bool CInterfaceManager::CEmoteCmd::execute(const std::string &/* rawCommandStrin return true; } -// ---------------------------------------------------------------------------- -static bool isSwimming() -{ - if (UserEntity != NULL) - return (UserEntity->mode() == MBEHAV::SWIM || UserEntity->mode() == MBEHAV::MOUNT_SWIM); - else - return false; -} - -static bool isStunned() -{ - if (UserEntity != NULL) - return (UserEntity->behaviour() == MBEHAV::STUNNED); - else - return false; -} - -static bool isDead() -{ - if (UserEntity != NULL) - return (UserEntity->mode() == MBEHAV::DEATH); - else - return false; -} - -// *************************************************************************** -class CHandlerEmote : public IActionHandler -{ -public: - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) - { - // An emote is 2 things : a phrase and an animation - // Phrase is the phrase that server returns in chat system - // Behav is the animation played - // CustomPhrase is an user phrase which can replace default phrase - string sPhraseNb = getParam(sParams, "nb"); - string sBehav = getParam(sParams, "behav"); - string sCustomPhrase = getParam(sParams, "custom_phrase"); - - uint32 phraseNb; - fromString(sPhraseNb, phraseNb); - uint8 behaviour; - fromString(sBehav, behaviour); - - MBEHAV::EBehaviour behavToSend = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + behaviour); - uint16 phraseNbToSend = (uint16)phraseNb; - - if (EAM) - { - const uint nbBehav = EAM->getNbEmots(); // Miscalled: this is the number of behaviour for all emotes - if ((behaviour >= nbBehav) || (behaviour == 255)) - behavToSend = MBEHAV::IDLE; - } - else - { - if (behaviour == 255) - behavToSend = MBEHAV::IDLE; - } - - /* Emotes forbidden when dead, emotes with behav forbidden when - * stunned or swimming */ - if ( ( behavToSend != MBEHAV::IDLE && (isSwimming() || isStunned() || isDead() ) ) ) - { - return; - } - - if( sCustomPhrase.empty() ) - { - // Create the message and send. - const string msgName = "COMMAND:EMOTE"; - CBitMemStream out; - if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) - { - out.serialEnum(behavToSend); - out.serial(phraseNbToSend); - NetMngr.push(out); - //nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend); - } - else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); - } - else - { - // Create the message and send. - const string msgName = "COMMAND:CUSTOM_EMOTE"; - CBitMemStream out; - if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) - { - ucstring ucstr; - ucstr.fromUtf8(sCustomPhrase); - - if( sCustomPhrase == "none" ) - { - if( behavToSend == MBEHAV::IDLE ) - { - // display "no animation for emote" - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); - string cat = getStringCategory(msg, msg); - pIM->displaySystemInfo(msg, cat); - return; - } - } - else - { - ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; - } - - out.serialEnum(behavToSend); - out.serial(ucstr); - NetMngr.push(out); - //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); - } - else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); - } - } -}; -REGISTER_ACTION_HANDLER( CHandlerEmote, "emote"); - // *************************************************************************** bool CInterfaceManager::testDragCopyKey() { From 4313f62647381364714bf651601219771607a901 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Apr 2012 01:31:21 +0200 Subject: [PATCH 012/339] CDB no longer depends on CInterfaceLink. --- code/ryzom/client/src/cdb_branch.cpp | 42 ++++++++++++++++--- code/ryzom/client/src/cdb_branch.h | 18 ++++++++ .../src/interface_v3/interface_link.cpp | 13 ++++++ .../client/src/interface_v3/interface_link.h | 16 +++++-- .../src/interface_v3/interface_manager.cpp | 3 ++ .../src/interface_v3/interface_manager.h | 3 +- 6 files changed, 84 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/cdb_branch.cpp b/code/ryzom/client/src/cdb_branch.cpp index 351203493..52c6fe455 100644 --- a/code/ryzom/client/src/cdb_branch.cpp +++ b/code/ryzom/client/src/cdb_branch.cpp @@ -16,8 +16,6 @@ -#include "stdpch.h" - //#define TRACE_READ_DELTA //#define TRACE_WRITE_DELTA //#define TRACE_SET_VALUE @@ -32,7 +30,6 @@ #include "cdb_leaf.h" #include "game_share/xml_auto_ptr.h" //#include -#include "interface_v3/interface_manager.h" //////////////// // Namespaces // @@ -84,6 +81,8 @@ uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS]; extern const char *CDBBankNames[INVALID_CDB_BANK+1]; +std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers; + // reset all static data void CCDBNodeBranch::reset() { @@ -703,15 +702,46 @@ void CCDBNodeBranch::flushObserversCalls() } nlassert(_FirstNotifiedObs[1 - _CurrNotifiedObsList] == NULL); nlassert(_LastNotifiedObs[1 - _CurrNotifiedObsList] == NULL); - // update triggered link - CInterfaceLink::updateTrigeredLinks(); + triggerFlushObservers(); // examine other list to see if nodes have been registered _CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList]; } - CInterfaceLink::updateTrigeredLinks(); // should call it at least once + triggerFlushObservers(); // nlassert(_CrtCheckMemory()); } +void CCDBNodeBranch::triggerFlushObservers() +{ + for( std::vector< IBranchObserverCallFlushObserver* >::iterator itr = flushObservers.begin(); itr != flushObservers.end(); itr++ ) + { + (*itr)->onObserverCallFlush(); + } +} + +void CCDBNodeBranch::addFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer ) +{ + std::vector< IBranchObserverCallFlushObserver* >::iterator itr + = std::find( flushObservers.begin(), flushObservers.end(), observer ); + + // Already exists + if( itr != flushObservers.end() ) + return; + + flushObservers.push_back( observer ); +} + +void CCDBNodeBranch::removeFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer ) +{ + std::vector< IBranchObserverCallFlushObserver* >::iterator itr + = std::find( flushObservers.begin(), flushObservers.end(), observer ); + + // Isn't in our list + if( itr == flushObservers.end() ) + return; + + flushObservers.erase( itr ); +} + //----------------------------------------------- void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, NLMISC::TStringId modifiedLeafName) { diff --git a/code/ryzom/client/src/cdb_branch.h b/code/ryzom/client/src/cdb_branch.h index 74e085ca4..3c4cb736c 100644 --- a/code/ryzom/client/src/cdb_branch.h +++ b/code/ryzom/client/src/cdb_branch.h @@ -31,6 +31,12 @@ class CCDBNodeBranch : public ICDBNode { public: + /// Triggered when the branch observers are updated + class IBranchObserverCallFlushObserver : public NLMISC::CRefCount{ + public: + virtual ~IBranchObserverCallFlushObserver(){} + virtual void onObserverCallFlush() = 0; + }; // default constructor CCDBNodeBranch(const std::string &name) : ICDBNode(name) @@ -212,6 +218,13 @@ public: */ static void flushObserversCalls(); +private: + static void triggerFlushObservers(); + +public: + static void addFlushObserver( IBranchObserverCallFlushObserver *observer ); + static void removeFlushObserver( IBranchObserverCallFlushObserver *observer ); + // mark this branch and parent branch as 'modified'. This is usually called by sub-leaves void linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName); @@ -324,6 +337,11 @@ protected: /// called by clear void removeAllBranchObserver(); void removeBranchInfoIt(TObsList::iterator it); + + +private: + static std::vector< IBranchObserverCallFlushObserver* > flushObservers; + }; diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index e8f583bea..69274dbd7 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -130,7 +130,20 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem return true; } +CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() +{ + CCDBNodeBranch::addFlushObserver( this ); +} +CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() +{ + CCDBNodeBranch::removeFlushObserver( this ); +} + +void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush() +{ + CInterfaceLink::updateTrigeredLinks(); +} ///////////// // MEMBERS // diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/ryzom/client/src/interface_v3/interface_link.h index 5b7e6d9fb..49abe429c 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.h +++ b/code/ryzom/client/src/interface_v3/interface_link.h @@ -19,12 +19,9 @@ #ifndef CL_INTERFACE_LINK_H #define CL_INTERFACE_LINK_H -#include "../cdb.h" -#include "nel/misc/smart_ptr.h" +#include "../cdb_branch.h" class CInterfaceElement; -class ICDBNode; -class CCDBNodeLeaf; class CReflectedProperty; class CInterfaceExprValue; class CInterfaceGroup; @@ -66,6 +63,17 @@ public: */ bool affect(const CInterfaceExprValue &value); }; + + + /// Updates triggered interface links when triggered by the observed branch + class CInterfaceLinkUpdater : public CCDBNodeBranch::IBranchObserverCallFlushObserver + { + public: + CInterfaceLinkUpdater(); + ~CInterfaceLinkUpdater(); + void onObserverCallFlush(); + }; + public: CInterfaceLink(); ~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index cfae646d2..2c0ab250c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -257,6 +257,7 @@ CInterfaceManager::CInterfaceManager() { _Instance = this; _DbRootNode = new CCDBNodeBranch("ROOT"); + interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; _Pointer = NULL; @@ -372,6 +373,8 @@ CInterfaceManager::~CInterfaceManager() // release the database observers releaseServerToLocalAutoCopyObservers(); + delete interfaceLinkUpdater; + interfaceLinkUpdater = NULL; } // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 7ee6d1951..615378d92 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -1063,7 +1063,8 @@ private: // Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0) void updateTooltipCoords(CCtrlBase *newCtrl); - + + CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; }; #endif // NL_INTERFACE_MANAGER_H From 631a3710fc502cdd86449da75d692dbce7d52315 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Apr 2012 02:18:07 +0200 Subject: [PATCH 013/339] CDB no longer depends on Ryzom database banks. --- code/ryzom/client/src/cdb_branch.cpp | 18 +++++++++--------- code/ryzom/client/src/cdb_branch.h | 16 ++++++++++------ code/ryzom/client/src/cdb_leaf.cpp | 4 ---- code/ryzom/client/src/cdb_synchronised.cpp | 4 +--- code/ryzom/client/src/cdb_synchronised.h | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/code/ryzom/client/src/cdb_branch.cpp b/code/ryzom/client/src/cdb_branch.cpp index 52c6fe455..07cd08307 100644 --- a/code/ryzom/client/src/cdb_branch.cpp +++ b/code/ryzom/client/src/cdb_branch.cpp @@ -68,25 +68,25 @@ CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL; uint CCDBNodeBranch::_CurrNotifiedObsList = 0; // Mapping from server database index to client database index (first-level nodes) -vector CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [NB_CDB_BANKS]; +vector CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX]; // Mapping from client database index to TCDBBank (first-level nodes) -vector CCDBNodeBranch::_UnifiedIndexToBank; +vector CCDBNodeBranch::_UnifiedIndexToBank; // Last index mapped uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0; // Number of bits for first-level branches, by bank -uint CCDBNodeBranch::_FirstLevelIdBitsByBank [NB_CDB_BANKS]; +uint CCDBNodeBranch::_FirstLevelIdBitsByBank [CDB_BANKS_MAX]; -extern const char *CDBBankNames[INVALID_CDB_BANK+1]; +extern const char *CDBBankNames[CDB_BANK_INVALID+1]; std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers; // reset all static data void CCDBNodeBranch::reset() { - for ( uint b=0; b _CDBBankToUnifiedIndexMapping [NB_CDB_BANKS]; + static std::vector _CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX]; // Mapping from client database index to TCDBBank (first-level nodes) - static std::vector _UnifiedIndexToBank; + static std::vector _UnifiedIndexToBank; /// Last index mapped static uint _CDBLastUnifiedIndex; /// Number of bits for first-level branches, by bank - static uint _FirstLevelIdBitsByBank [NB_CDB_BANKS]; + static uint _FirstLevelIdBitsByBank [CDB_BANKS_MAX]; /// called by clear void removeAllBranchObserver(); diff --git a/code/ryzom/client/src/cdb_leaf.cpp b/code/ryzom/client/src/cdb_leaf.cpp index 9b3d26c89..7111e81bc 100644 --- a/code/ryzom/client/src/cdb_leaf.cpp +++ b/code/ryzom/client/src/cdb_leaf.cpp @@ -16,9 +16,6 @@ -#include "stdpch.h" - - //#define TRACE_READ_DELTA //#define TRACE_WRITE_DELTA //#define TRACE_SET_VALUE @@ -31,7 +28,6 @@ #include "cdb_leaf.h" #include "game_share/xml_auto_ptr.h" //#include -#include "interface_v3/interface_manager.h" //////////////// // Namespaces // diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 21b1f1748..d25564e70 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -16,8 +16,6 @@ -#include "stdpch.h" - //#define TRACE_READ_DELTA //#define TRACE_WRITE_DELTA //#define TRACE_SET_VALUE @@ -175,7 +173,7 @@ void CCDBSynchronised::write( const string &fileName ) // readDelta // //----------------------------------------------- -void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, TCDBBank bank ) +void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, uint bank ) { nldebug("Update DB"); diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index a405b39a0..c4a70dd2b 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -84,7 +84,7 @@ public: * Update the database from a stream coming from the FE * \param f the stream */ - void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank ); + void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank ); /** * Return the value of a property (the update flag is set to false) From 7e3c4aa15eb5ecc159932ad2010958c6a9eb2090 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Apr 2012 02:50:18 +0200 Subject: [PATCH 014/339] Moved xml auto pointer to nlmisc. --- .../include/nel/misc}/xml_auto_ptr.h | 0 code/ryzom/client/src/cdb_branch.cpp | 2 +- code/ryzom/client/src/cdb_leaf.cpp | 2 +- .../client/src/interface_v3/action_handler.h | 2 +- .../client/src/interface_v3/ctrl_base.cpp | 2 +- .../src/interface_v3/ctrl_base_button.cpp | 2 +- .../client/src/interface_v3/ctrl_button.cpp | 2 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../client/src/interface_v3/ctrl_tooltip.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 2 +- .../src/interface_v3/dbgroup_combo_box.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- ...roup_list_sheet_text_brick_composition.cpp | 2 +- .../dbgroup_list_sheet_text_share.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../client/src/interface_v3/dbview_bar.cpp | 2 +- .../client/src/interface_v3/dbview_bar3.cpp | 2 +- .../client/src/interface_v3/dbview_digit.cpp | 2 +- .../client/src/interface_v3/dbview_number.cpp | 2 +- .../src/interface_v3/dbview_quantity.cpp | 2 +- .../client/src/interface_v3/group_career.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../client/src/interface_v3/group_frame.cpp | 2 +- .../client/src/interface_v3/group_html_cs.cpp | 2 +- .../src/interface_v3/group_html_forum.cpp | 2 +- .../src/interface_v3/group_html_mail.cpp | 2 +- .../src/interface_v3/group_html_qcm.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 2 +- .../src/interface_v3/group_in_scene.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../client/src/interface_v3/group_modal.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../group_phrase_skill_filter.cpp | 2 +- .../src/interface_v3/group_quick_help.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_tab.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../interface_v3/input_handler_manager.cpp | 2 +- .../src/interface_v3/interface_3d_scene.cpp | 2 +- .../src/interface_v3/interface_anim.cpp | 2 +- .../client/src/interface_v3/interface_ddx.cpp | 2 +- .../src/interface_v3/interface_element.cpp | 2 +- .../src/interface_v3/interface_group.cpp | 2 +- .../src/interface_v3/interface_observer.h | 2 +- .../src/interface_v3/interface_options.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- .../client/src/interface_v3/view_bitmap.cpp | 2 +- .../src/interface_v3/view_bitmap_combo.cpp | 2 +- .../src/interface_v3/view_bitmap_faber_mp.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_radar.cpp | 2 +- .../client/src/interface_v3/view_text.cpp | 2 +- .../src/interface_v3/view_text_formated.cpp | 2 +- .../client/src/interface_v3/view_text_id.cpp | 2 +- .../interface_v3/view_text_id_formated.cpp | 2 +- .../src/game_share/generic_xml_msg_mngr.cpp | 2 +- .../common/src/game_share/ring_access.cpp | 2 +- .../common/src/game_share/xml_auto_ptr.cpp | 52 ------------------- .../player_manager/cdb_branch.cpp | 2 +- .../player_manager/cdb_leaf.cpp | 2 +- 68 files changed, 66 insertions(+), 118 deletions(-) rename code/{ryzom/common/src/game_share => nel/include/nel/misc}/xml_auto_ptr.h (100%) delete mode 100644 code/ryzom/common/src/game_share/xml_auto_ptr.cpp diff --git a/code/ryzom/common/src/game_share/xml_auto_ptr.h b/code/nel/include/nel/misc/xml_auto_ptr.h similarity index 100% rename from code/ryzom/common/src/game_share/xml_auto_ptr.h rename to code/nel/include/nel/misc/xml_auto_ptr.h diff --git a/code/ryzom/client/src/cdb_branch.cpp b/code/ryzom/client/src/cdb_branch.cpp index 07cd08307..5a6b49b8c 100644 --- a/code/ryzom/client/src/cdb_branch.cpp +++ b/code/ryzom/client/src/cdb_branch.cpp @@ -28,7 +28,7 @@ ////////////// #include "cdb_branch.h" #include "cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" //#include //////////////// diff --git a/code/ryzom/client/src/cdb_leaf.cpp b/code/ryzom/client/src/cdb_leaf.cpp index 7111e81bc..e680ef96a 100644 --- a/code/ryzom/client/src/cdb_leaf.cpp +++ b/code/ryzom/client/src/cdb_leaf.cpp @@ -26,7 +26,7 @@ // Includes // ////////////// #include "cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" //#include //////////////// diff --git a/code/ryzom/client/src/interface_v3/action_handler.h b/code/ryzom/client/src/interface_v3/action_handler.h index c8800da63..e578c4959 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.h +++ b/code/ryzom/client/src/interface_v3/action_handler.h @@ -23,7 +23,7 @@ #include #include "nel/misc/types_nl.h" #include "nel/misc/debug.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include extern bool game_exit; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_base.cpp index 151d2be6f..f3c7dbbec 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "ctrl_base.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index b2f03b98b..12db635bf 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -20,7 +20,7 @@ #include "ctrl_base_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../time_client.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index 0f77fc6fe..112759519 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -21,7 +21,7 @@ #include "ctrl_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index 31d64af31..ece811773 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "interface_manager.h" #include "ctrl_col_pick.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace NLMISC; using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 652bd5ed7..a95cda085 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "interface_manager.h" #include "ctrl_scroll.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_menu.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 1e8c7c07b..de302dbb1 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -22,7 +22,7 @@ #include "ctrl_text_button.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "view_text.h" #include "view_text_id.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp index 71bd4ab8c..5e276d886 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp @@ -21,7 +21,7 @@ #include "ctrl_tooltip.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index c7afcaf92..4f69ec00f 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -43,7 +43,7 @@ #include "sbrick_manager.h" #include "sphrase_manager.h" #include "../client_sheets/sphrase_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "game_share/bot_chat_types.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 0834fd392..cbf6da945 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "dbgroup_combo_box.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "ctrl_button.h" #include "action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 40e62346f..8990abf42 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet_text.h" #include "group_container.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp index 0ed457f43..bc205ba00 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_text_brick_composition.h" #include "../client_sheets/sbrick_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../string_manager_client.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index e31d052cc..e4efa0f52 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_text_share.h" #include "../client_sheets/sbrick_sheet.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "view_bitmap.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index bd30d61f6..bc8476c23 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet_trade.h" #include "interface_manager.h" #include "inventory_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index 512ca8256..49f477923 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -21,7 +21,7 @@ #include "dbview_bar.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp index da20ae57f..490952fb9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp @@ -21,7 +21,7 @@ #include "dbview_bar3.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.cpp b/code/ryzom/client/src/interface_v3/dbview_digit.cpp index 19c424ac8..86e79783d 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_digit.cpp @@ -20,7 +20,7 @@ #include "dbview_digit.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/dbview_number.cpp b/code/ryzom/client/src/interface_v3/dbview_number.cpp index 5ac955659..4b1ebc5ef 100644 --- a/code/ryzom/client/src/interface_v3/dbview_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_number.cpp @@ -20,7 +20,7 @@ #include "dbview_number.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/common.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp b/code/ryzom/client/src/interface_v3/dbview_quantity.cpp index 915fcebce..6f95ddbc9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_quantity.cpp @@ -21,7 +21,7 @@ #include "dbview_quantity.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/group_career.cpp b/code/ryzom/client/src/interface_v3/group_career.cpp index f7dbe2cc9..04916f007 100644 --- a/code/ryzom/client/src/interface_v3/group_career.cpp +++ b/code/ryzom/client/src/interface_v3/group_career.cpp @@ -23,7 +23,7 @@ #include "interface_element.h" //#include "game_share/jobs.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index fa7655591..fa9d62d5a 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "group_compas.h" #include "interface_3d_scene.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index eb98fb67a..e494af8f2 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -22,7 +22,7 @@ #include "group_container.h" #include "interface_manager.h" #include "interface_options.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" #include "group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 5bc516f47..fe423a9de 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -23,7 +23,7 @@ #include "input_handler_manager.h" #include "nel/misc/command.h" #include "view_text.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_options.h" #include "dbctrl_sheet.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/group_frame.cpp b/code/ryzom/client/src/interface_v3/group_frame.cpp index 4b7e5cdcc..54b95476e 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.cpp +++ b/code/ryzom/client/src/interface_v3/group_frame.cpp @@ -21,7 +21,7 @@ #include "group_frame.h" #include "interface_manager.h" #include "interface_element.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_html_cs.cpp b/code/ryzom/client/src/interface_v3/group_html_cs.cpp index 13d7dda24..063a9bbe9 100644 --- a/code/ryzom/client/src/interface_v3/group_html_cs.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_cs.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_cs.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_forum.cpp b/code/ryzom/client/src/interface_v3/group_html_forum.cpp index 53d1058d9..405b91645 100644 --- a/code/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_forum.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "guild_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_mail.cpp b/code/ryzom/client/src/interface_v3/group_html_mail.cpp index 9c723d45b..d527f0879 100644 --- a/code/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_mail.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp index 665a4ba9e..4414556b0 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_html_qcm.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "interface_manager.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 0e17c47d3..38b92a8e2 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" #include "group_html_webig.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "../user_entity.h" #include "../entities.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index b4e448458..9cc2a0871 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -24,7 +24,7 @@ #include "group_in_scene.h" #include "interface_manager.h" #include "view_renderer.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 7ccd5c51c..7a68be9d5 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -29,7 +29,7 @@ #include "lua_ihm.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 51d07bb88..e1d7b4ecd 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -38,7 +38,7 @@ #include "../global.h" #include "ctrl_quad.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "game_share/mission_desc.h" #include "game_share/inventories.h" #include "game_share/animal_type.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 22ff2b07c..8a1051e52 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "interface_expr.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "view_bitmap.h" #include "action_handler.h" // Just for getAllParams #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/ryzom/client/src/interface_v3/group_modal.cpp index 8055e66b2..bbd6a8015 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal.cpp @@ -21,7 +21,7 @@ #include "group_modal.h" #include "interface_manager.h" #include "interface_element.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index aad604d24..42def29d6 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -30,7 +30,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index beb88e2df..8494e7213 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -26,7 +26,7 @@ #include "game_share/skills.h" #include "game_share/brick_families.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "skill_manager.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 210c7110e..3f829c8ef 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -27,7 +27,7 @@ #include "../libwww.h" #include "interface_manager.h" #include "action_handler.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 611ecb738..645149b46 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -29,7 +29,7 @@ #include "dbview_bar.h" #include "game_share/skills.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "skill_manager.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 27e6aa3a4..d42855464 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "group_tab.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../time_client.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 890a8b0fe..378c33be5 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -29,7 +29,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 3a09241b6..9eb02ad10 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -30,7 +30,7 @@ #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 3ece9f125..c57346655 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -22,7 +22,7 @@ #include "nel/misc/file.h" #include "nel/misc/game_device_events.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "input_handler_manager.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 324edf91a..90e4aebc9 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -29,7 +29,7 @@ #include "nel/3d/u_particle_system_instance.h" #include "nel/3d/u_animation_set.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index 0594fe22b..18e3f9b08 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -22,7 +22,7 @@ #include "interface_anim.h" #include "interface_manager.h" #include "interface_expr.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index b987f9cf9..3e363225c 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -25,7 +25,7 @@ #include "group_modal.h" #include "../client_cfg.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 6db901b10..7edc093ae 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -24,7 +24,7 @@ #include "group_container.h" #include "../misc.h" #include "interface_link.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "nel/misc/mem_stream.h" // diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 91022dedb..a088b2c0c 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -20,7 +20,7 @@ #include "interface_group.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" #include "group_editbox.h" #include "group_scrolltext.h" diff --git a/code/ryzom/client/src/interface_v3/interface_observer.h b/code/ryzom/client/src/interface_v3/interface_observer.h index 645d8195c..b90c84f6b 100644 --- a/code/ryzom/client/src/interface_v3/interface_observer.h +++ b/code/ryzom/client/src/interface_v3/interface_observer.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" /** diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/ryzom/client/src/interface_v3/interface_options.cpp index 0a8135f71..3a06da8f5 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options.cpp @@ -22,7 +22,7 @@ #include "interface_options.h" #include "interface_manager.h" #include "group_menu.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../net_manager.h" #include "../sheet_manager.h" #include "../entity_animation_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 109b3d5cd..c21b6ec81 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -27,7 +27,7 @@ #include "nel/misc/factory.h" #include "nel/misc/big_file.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "interface_parser.h" #include "interface_observer.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index c5fec7eb8..f22758350 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -20,7 +20,7 @@ #include "skill_manager.h" #include "interface_manager.h" #include "game_share/skills.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "game_share/character_title.h" #include "game_share/fame.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index dba18c194..3ec51b270 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -22,7 +22,7 @@ #include "view_bitmap.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index 9085643a5..d9eb19957 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -20,7 +20,7 @@ #include "view_bitmap_combo.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp index dca41c35c..ff7b0fa70 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp @@ -19,7 +19,7 @@ #include "view_bitmap_faber_mp.h" #include "interface_manager.h" #include "../sheet_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" extern CSheetManager SheetMngr; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 27d3dae86..79342cfb2 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -28,7 +28,7 @@ #include "group_html.h" #include "group_map.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "group_container.h" #include "interface_3d_scene.h" diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index f0f613587..7f3d222b4 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -22,7 +22,7 @@ #include "view_radar.h" #include "interface_manager.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "group_container.h" #include "../npc_icon.h" #include "nel/misc/fast_floor.h" diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 4714c8208..4bfd91a39 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -26,7 +26,7 @@ #include "group_container.h" // CCtrlResizer #include "ctrl_tooltip.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" #include "lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_formated.cpp index 5b2308f21..6d3513fce 100644 --- a/code/ryzom/client/src/interface_v3/view_text_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_formated.cpp @@ -23,7 +23,7 @@ #include "../string_manager_client.h" #include "action_handler_misc.h" // -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" // #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 2663e848d..326f67362 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "../string_manager_client.h" #include "view_text_id.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" #include "nel/misc/algo.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp index 29d360a4e..70bacaa98 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp @@ -22,7 +22,7 @@ #include "../string_manager_client.h" #include "../user_entity.h" #include "../entities.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace STRING_MANAGER; diff --git a/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp b/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp index 8328186a9..0b17474d7 100644 --- a/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp +++ b/code/ryzom/common/src/game_share/generic_xml_msg_mngr.cpp @@ -20,7 +20,7 @@ #include "generic_xml_msg_mngr.h" #include "nel/misc/file.h" -#include "xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/common/src/game_share/ring_access.cpp b/code/ryzom/common/src/game_share/ring_access.cpp index 9eda38010..3c04d0bb5 100644 --- a/code/ryzom/common/src/game_share/ring_access.cpp +++ b/code/ryzom/common/src/game_share/ring_access.cpp @@ -32,7 +32,7 @@ #include "nel/misc/o_xml.h" #include "nel/misc/i_xml.h" #include "nel/misc/algo.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/common/src/game_share/xml_auto_ptr.cpp b/code/ryzom/common/src/game_share/xml_auto_ptr.cpp deleted file mode 100644 index 4fcdb9543..000000000 --- a/code/ryzom/common/src/game_share/xml_auto_ptr.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - -/* - * Completely implemented in xml_auto_ptr.h - */ - -#include "stdpch.h" - -/* -#include "xml_auto_ptr.h" -#include - -//======================================= -void CXMLAutoPtr::destroy() -{ - if (_Value) - { - xmlFree(const_cast(_Value)); - _Value = NULL; - } -} - -//======================================= -CXMLAutoPtr::~CXMLAutoPtr() -{ - destroy(); -} - -//======================================= -CXMLAutoPtr &CXMLAutoPtr::operator = (const char *other) -{ - if (other == _Value) return *this; - destroy(); - _Value = other; - return *this; -} - -*/ diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp index 156f17f14..3748fe29a 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp @@ -30,7 +30,7 @@ ////////////// #include "player_manager/cdb_branch.h" #include "player_manager/cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include //////////////// diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp b/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp index fc26bb83a..22b53b3b1 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_leaf.cpp @@ -29,7 +29,7 @@ // Includes // ////////////// #include "player_manager/cdb_leaf.h" -#include "game_share/xml_auto_ptr.h" +#include "nel/misc/xml_auto_ptr.h" #include From cf2305b1ced7b1507863a5da156816b642757a71 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Apr 2012 06:08:12 +0200 Subject: [PATCH 015/339] CDB is now part of NLMISC. However it still requires some work! --- .../client/src => nel/include/nel/misc}/cdb.h | 45 +++++----- .../src => nel/include/nel/misc}/cdb_branch.h | 23 ++--- .../include/nel/misc}/cdb_check_sum.h | 4 +- .../src => nel/include/nel/misc}/cdb_leaf.h | 25 +++--- .../client/src => nel/src/misc}/cdb.cpp | 13 +-- .../src => nel/src/misc}/cdb_branch.cpp | 46 +++++++--- .../src => nel/src/misc}/cdb_check_sum.cpp | 8 +- .../client/src => nel/src/misc}/cdb_leaf.cpp | 18 ++-- code/ryzom/client/src/cdb_synchronised.cpp | 2 +- code/ryzom/client/src/cdb_synchronised.h | 8 +- code/ryzom/client/src/character_cl.cpp | 2 +- code/ryzom/client/src/client_chat_manager.h | 8 +- code/ryzom/client/src/commands.cpp | 2 +- code/ryzom/client/src/entity_cl.h | 9 +- code/ryzom/client/src/game_context_menu.h | 24 ++--- .../client/src/ingame_database_manager.h | 6 +- .../src/interface_v3/action_handler_help.h | 4 +- .../src/interface_v3/action_phrase_faber.h | 8 +- .../interface_v3/animal_position_state.cpp | 2 + .../src/interface_v3/animal_position_state.h | 26 +++--- .../client/src/interface_v3/bar_manager.h | 18 ++-- .../bot_chat_page_player_gift.cpp | 2 + .../src/interface_v3/bot_chat_page_trade.h | 2 +- .../src/interface_v3/chat_text_manager.h | 9 +- .../client/src/interface_v3/ctrl_scroll.h | 4 +- .../client/src/interface_v3/dbctrl_sheet.h | 32 +++---- .../src/interface_v3/dbgroup_list_sheet.h | 8 +- .../dbgroup_list_sheet_bonus_malus.h | 2 +- .../dbgroup_list_sheet_icon_phrase.h | 2 +- .../dbgroup_list_sheet_mission.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.h | 8 +- .../dbgroup_list_sheet_text_phrase.h | 2 +- .../interface_v3/dbgroup_list_sheet_trade.h | 2 +- .../client/src/interface_v3/group_compas.h | 2 +- .../interface_v3/group_in_scene_user_info.h | 6 +- .../ryzom/client/src/interface_v3/group_map.h | 6 +- .../interface_v3/group_phrase_skill_filter.h | 4 +- .../client/src/interface_v3/group_skills.h | 4 +- .../client/src/interface_v3/guild_manager.h | 10 +-- .../src/interface_v3/interface_config.h | 6 +- .../client/src/interface_v3/interface_ddx.h | 10 +-- .../client/src/interface_v3/interface_expr.h | 15 ++-- .../src/interface_v3/interface_expr_node.cpp | 8 +- .../src/interface_v3/interface_expr_node.h | 28 +++--- .../src/interface_v3/interface_link.cpp | 2 +- .../client/src/interface_v3/interface_link.h | 10 +-- .../src/interface_v3/interface_manager.h | 90 +++++++++---------- .../src/interface_v3/interface_observer.h | 6 +- .../src/interface_v3/interface_property.h | 16 ++-- .../src/interface_v3/inventory_manager.cpp | 8 +- .../src/interface_v3/inventory_manager.h | 78 ++++++++-------- .../client/src/interface_v3/obs_huge_list.h | 68 +++++++------- .../client/src/interface_v3/sbrick_manager.h | 10 +-- .../client/src/interface_v3/skill_manager.cpp | 2 +- .../client/src/interface_v3/skill_manager.h | 12 +-- .../client/src/interface_v3/sphrase_manager.h | 24 ++--- .../src/interface_v3/view_bitmap_combo.h | 8 +- .../client/src/interface_v3/view_text_id.cpp | 1 + .../client/src/interface_v3/view_text_id.h | 5 +- code/ryzom/client/src/net_manager.cpp | 12 +-- code/ryzom/client/src/net_manager.h | 2 +- code/ryzom/client/src/network_connection.cpp | 6 +- code/ryzom/client/src/network_connection.h | 6 +- code/ryzom/client/src/npc_icon.h | 3 +- .../client/src/r2/displayer_visual_entity.cpp | 2 +- code/ryzom/client/src/r2/editor.h | 4 +- .../client/src/r2/tool_create_entity.cpp | 2 +- code/ryzom/client/src/user_entity.h | 24 ++--- code/ryzom/client/src/village.h | 2 +- .../src/game_share/ryzom_database_banks.cpp | 2 + 70 files changed, 481 insertions(+), 399 deletions(-) rename code/{ryzom/client/src => nel/include/nel/misc}/cdb.h (85%) rename code/{ryzom/client/src => nel/include/nel/misc}/cdb_branch.h (91%) rename code/{ryzom/client/src => nel/include/nel/misc}/cdb_check_sum.h (93%) rename code/{ryzom/client/src => nel/include/nel/misc}/cdb_leaf.h (88%) rename code/{ryzom/client/src => nel/src/misc}/cdb.cpp (90%) rename code/{ryzom/client/src => nel/src/misc}/cdb_branch.cpp (93%) rename code/{ryzom/client/src => nel/src/misc}/cdb_check_sum.cpp (91%) rename code/{ryzom/client/src => nel/src/misc}/cdb_leaf.cpp (91%) diff --git a/code/ryzom/client/src/cdb.h b/code/nel/include/nel/misc/cdb.h similarity index 85% rename from code/ryzom/client/src/cdb.h rename to code/nel/include/nel/misc/cdb.h index f8ad3148a..dc95e51e9 100644 --- a/code/ryzom/client/src/cdb.h +++ b/code/nel/include/nel/misc/cdb.h @@ -20,18 +20,17 @@ #define CDB_H // misc -#include "nel/misc/types_nl.h" -#include "nel/misc/smart_ptr.h" -#include "nel/misc/string_mapper.h" +#include "types_nl.h" +#include "smart_ptr.h" +#include "string_mapper.h" +#include "sstring.h" #include namespace NLMISC { - class IProgressCallback; - class CBitMemStream; -} - +class IProgressCallback; +class CBitMemStream; class CCDBNodeLeaf; class CCDBNodeBranch; @@ -48,7 +47,7 @@ extern bool VerboseDatabase; * \date 2002 */ -class ICDBNode : public NLMISC::CRefCount +class ICDBNode : public CRefCount { //----------------------------------------------------------------------- // end of IDBNode interface @@ -78,7 +77,7 @@ public: * \author Nevrax France * \date 2002 */ - class IPropertyObserver : public NLMISC::CRefCount + class IPropertyObserver : public CRefCount { public : virtual ~IPropertyObserver() {} @@ -198,7 +197,7 @@ public : * Build the structure of the database from a file * \param f is the stream */ - virtual void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ) = 0; + virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false ) = 0; /** * Save a backup of the database @@ -212,7 +211,7 @@ public : * \param gc the server gameCycle of this update. Any outdated update are aborted * \param f : the stream. */ - virtual void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ) = 0; + virtual void readDelta( TGameCycle gc, CBitMemStream & f ) = 0; /** * Get a node . Create it if it does not exist yet @@ -252,7 +251,7 @@ public : virtual bool setProp( CTextId& id, sint64 value ) = 0; /// Reset all leaf data from this point - virtual void resetData(NLMISC::TGameCycle gc, bool forceReset=false) = 0; + virtual void resetData(TGameCycle gc, bool forceReset=false) = 0; /** * Clear the node and his children @@ -314,16 +313,16 @@ public : virtual void display (const std::string &/* prefix */){} /// Return the string id corresponding to the argument - static NLMISC::TStringId getStringId(const std::string& nodeName) + static TStringId getStringId(const std::string& nodeName) { - if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); + if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper(); return _DBSM->localMap(nodeName); } /// Return a pointer to the string corresponding to the argument - static const std::string *getStringFromId(NLMISC::TStringId nodeStringId) + static const std::string *getStringFromId(TStringId nodeStringId) { - if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); + if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper(); return &_DBSM->localUnmap(nodeStringId); } @@ -335,32 +334,34 @@ protected: /// Constructor ICDBNode() : _AtomicFlag(false) { - if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); - _Name = NLMISC::CStringMapper::emptyId(); + if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper(); + _Name = CStringMapper::emptyId(); } /// Constructor ICDBNode (const std::string &name) : _AtomicFlag(false) { - if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); + if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper(); _Name = _DBSM->localMap(name); //_NameDbg = name; } // utility to build full name efficiently (without reallocating the string at each parent level) - void _buildFullName(NLMISC::CSString &fullName); + void _buildFullName(CSString &fullName); /// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group bool _AtomicFlag : 1; /// Name of the node - NLMISC::TStringId _Name; + TStringId _Name; //std::string _NameDbg; - static NLMISC::CStringMapper *_DBSM; + static CStringMapper *_DBSM; }; +} + #endif // CDB_H diff --git a/code/ryzom/client/src/cdb_branch.h b/code/nel/include/nel/misc/cdb_branch.h similarity index 91% rename from code/ryzom/client/src/cdb_branch.h rename to code/nel/include/nel/misc/cdb_branch.h index 9020ef0ec..7d7187aa1 100644 --- a/code/ryzom/client/src/cdb_branch.h +++ b/code/nel/include/nel/misc/cdb_branch.h @@ -21,6 +21,8 @@ #include "cdb.h" +namespace NLMISC{ + enum{ CDB_BANKS_MAX = 3, CDB_BANK_INVALID @@ -36,7 +38,7 @@ class CCDBNodeBranch : public ICDBNode { public: /// Triggered when the branch observers are updated - class IBranchObserverCallFlushObserver : public NLMISC::CRefCount{ + class IBranchObserverCallFlushObserver : public CRefCount{ public: virtual ~IBranchObserverCallFlushObserver(){} virtual void onObserverCallFlush() = 0; @@ -54,7 +56,7 @@ public: * Build the structure of the database from a file * \param f is the stream */ - void init( xmlNodePtr node, class NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ); + void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false ); /** * Add a new sub node @@ -103,10 +105,10 @@ public: void write( CTextId& id, FILE * f); /// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping) - void readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank ); + void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank ); /// Update the database from a stream coming from the FE - void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ); + void readDelta( TGameCycle gc, CBitMemStream & f ); /** * Return the value of a property (the update flag is set to false) @@ -129,7 +131,7 @@ public: void clear(); /// Reset the data corresponding to the bank (works only on top level node) - void resetBank( NLMISC::TGameCycle gc, uint bank) + void resetBank( TGameCycle gc, uint bank) { //nlassert( getParent() == NULL ); for ( uint i=0; i!=_Nodes.size(); ++i ) @@ -140,7 +142,7 @@ public: } /// Reset all leaf data from this point - void resetData(NLMISC::TGameCycle gc, bool forceReset=false) + void resetData(TGameCycle gc, bool forceReset=false) { for ( uint i=0; i!=_Nodes.size(); ++i ) { @@ -230,7 +232,7 @@ public: static void removeFlushObserver( IBranchObserverCallFlushObserver *observer ); // mark this branch and parent branch as 'modified'. This is usually called by sub-leaves - void linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName); + void linkInModifiedNodeList(TStringId modifiedLeafName); /// Find a subnode at this level ICDBNode * find (const std::string &nodeName); @@ -254,7 +256,7 @@ protected: class CDBBranchObsInfo { public: - NLMISC::CRefPtr Observer; + CRefPtr Observer; // 2 linked list are required : while the observer is notified, it can triger one other observer, so we must link it in another list bool Touched[2]; CDBBranchObsInfo *PrevNotifiedObserver[2]; // NULL means this is the head @@ -265,7 +267,7 @@ protected: // This is equivalent to creating a sub-branch containing only the specified leaves // and setting a branch observer on it, except you don't need to change your database paths // and update large amounts of code and script! - std::vector PositiveLeafNameFilter; + std::vector PositiveLeafNameFilter; public: @@ -294,7 +296,7 @@ protected: } // Unlink from the given list. This also clear the '_Touched' flag void unlink(uint list); - void link(uint list, NLMISC::TStringId modifiedLeafName); + void link(uint list, TStringId modifiedLeafName); }; typedef std::list TObsList; // must use a list because pointers on CDBObserverInfo instances must remains valids @@ -348,6 +350,7 @@ private: }; +} #endif // CDB_BRANCH_H diff --git a/code/ryzom/client/src/cdb_check_sum.h b/code/nel/include/nel/misc/cdb_check_sum.h similarity index 93% rename from code/ryzom/client/src/cdb_check_sum.h rename to code/nel/include/nel/misc/cdb_check_sum.h index df0cf3959..02ce8f18b 100644 --- a/code/ryzom/client/src/cdb_check_sum.h +++ b/code/nel/include/nel/misc/cdb_check_sum.h @@ -19,8 +19,9 @@ #ifndef NL_CDB_CHECK_SUM_H #define NL_CDB_CHECK_SUM_H -#include "nel/misc/types_nl.h" +#include "types_nl.h" +namespace NLMISC{ /** * class implementing check sum for the client database @@ -81,6 +82,7 @@ private: }; +} #endif // NL_CDB_CHECK_SUM_H diff --git a/code/ryzom/client/src/cdb_leaf.h b/code/nel/include/nel/misc/cdb_leaf.h similarity index 88% rename from code/ryzom/client/src/cdb_leaf.h rename to code/nel/include/nel/misc/cdb_leaf.h index d28cff2c2..fed2b908d 100644 --- a/code/ryzom/client/src/cdb_leaf.h +++ b/code/nel/include/nel/misc/cdb_leaf.h @@ -21,7 +21,10 @@ #include "cdb.h" #include "cdb_branch.h" -#include "nel/misc/time_nl.h" +#include "time_nl.h" +#include "rgba.h" + +namespace NLMISC{ /** * Database node which contains a unique property @@ -50,16 +53,16 @@ public: void setValue8 (sint8 prop); inline bool getValueBool() { return (_Property!=(sint64)0 ); } void setValueBool (bool prop); - inline NLMISC::CRGBA getValueRGBA() + inline CRGBA getValueRGBA() { - NLMISC::CRGBA col; + CRGBA col; col.R = (uint8)(_Property&0xff); col.G = (uint8)((_Property>>8)&0xff); col.B = (uint8)((_Property>>16)&0xff); col.A = (uint8)((_Property>>24)&0xff); return col; } - void setValueRGBA (const NLMISC::CRGBA &color); + void setValueRGBA (const CRGBA &color); /// Return the value of the property before the database change inline sint64 getOldValue64() { return _oldProperty; } @@ -98,7 +101,7 @@ public: * Build the structure of the database from a file * \param f is the stream */ - void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ); + void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false ); /** * Get a node @@ -132,7 +135,7 @@ public: * Update the database from a stream coming from the FE * \param f : the stream. */ - void readDelta(NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ); + void readDelta(TGameCycle gc, CBitMemStream & f ); /** * Return the value of a property (the update flag is set to false) @@ -154,10 +157,10 @@ public: /** * Set the value of a property, only if gc>=_LastChangeGC */ - bool setPropCheckGC(NLMISC::TGameCycle gc, sint64 value); + bool setPropCheckGC(TGameCycle gc, sint64 value); /// Reset all leaf data from this point - void resetData(NLMISC::TGameCycle gc, bool forceReset=false); + void resetData(TGameCycle gc, bool forceReset=false); /** * Clear the node and his children @@ -215,7 +218,7 @@ public: /// get the last change GameCycle (server tick) for this value - NLMISC::TGameCycle getLastChangeGC() const {return _LastChangeGC;} + TGameCycle getLastChangeGC() const {return _LastChangeGC;} private: @@ -234,7 +237,7 @@ private: /// gamecycle (servertick) of the last change for this value. /// change are made in readDelta only for change >= _LastChangeGC - NLMISC::TGameCycle _LastChangeGC; + TGameCycle _LastChangeGC; /// observers to call when the value really change std::vector _Observers; @@ -249,7 +252,7 @@ private: //////////////////// - +} #endif // CDB_LEAF_H diff --git a/code/ryzom/client/src/cdb.cpp b/code/nel/src/misc/cdb.cpp similarity index 90% rename from code/ryzom/client/src/cdb.cpp rename to code/nel/src/misc/cdb.cpp index f670932ec..8d4c6527f 100644 --- a/code/ryzom/client/src/cdb.cpp +++ b/code/nel/src/misc/cdb.cpp @@ -16,21 +16,19 @@ -#include "stdpch.h" - ////////////// // Includes // ////////////// -#include "cdb.h" -#include "cdb_branch.h" -#include +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_branch.h" +#include "nel/misc/bit_mem_stream.h" //////////////// // Namespaces // //////////////// -using namespace NLMISC; using namespace std; +namespace NLMISC{ CStringMapper *ICDBNode::_DBSM = NULL; @@ -82,3 +80,6 @@ void ICDBNode::releaseStringMapper() delete _DBSM; _DBSM = NULL; } + +} + diff --git a/code/ryzom/client/src/cdb_branch.cpp b/code/nel/src/misc/cdb_branch.cpp similarity index 93% rename from code/ryzom/client/src/cdb_branch.cpp rename to code/nel/src/misc/cdb_branch.cpp index 5a6b49b8c..45bef670a 100644 --- a/code/ryzom/client/src/cdb_branch.cpp +++ b/code/nel/src/misc/cdb_branch.cpp @@ -26,15 +26,14 @@ ////////////// // Includes // ////////////// -#include "cdb_branch.h" -#include "cdb_leaf.h" +#include "nel/misc/cdb_branch.h" +#include "nel/misc/cdb_leaf.h" #include "nel/misc/xml_auto_ptr.h" //#include //////////////// // Namespaces // //////////////// -using namespace NLMISC; using namespace std; @@ -43,6 +42,8 @@ using namespace std; #include "nel/misc/file.h" #include "nel/misc/i_xml.h" #include "nel/misc/progress_callback.h" +#include "nel/misc/bit_mem_stream.h" +#include "nel/misc/bit_set.h" #include //#include @@ -53,7 +54,9 @@ using namespace std; using namespace std; -using namespace NLMISC; + + +namespace NLMISC{ ///////////// // GLOBALS // @@ -134,7 +137,7 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode std::vector &nodes, std::vector &nodesSorted, xmlNodePtr &child, const string& bankName, bool atomBranch, bool clientOnly, - NLMISC::IProgressCallback &progressCallBack, + IProgressCallback &progressCallBack, bool mapBanks ) { nodesSorted.push_back(newNode); @@ -158,7 +161,7 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode } } -void CCDBNodeBranch::init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks ) +void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks ) { xmlNodePtr child; @@ -459,7 +462,7 @@ bool CCDBNodeBranch::setProp( CTextId& id, sint64 value ) /* * Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping) */ -void CCDBNodeBranch::readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, uint bank ) +void CCDBNodeBranch::readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank ) { nlassert( ! isAtomic() ); // root node mustn't be atomic @@ -491,7 +494,7 @@ void CCDBNodeBranch::readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStre // readDelta // //----------------------------------------------- -void CCDBNodeBranch::readDelta( NLMISC::TGameCycle gc, CBitMemStream & f ) +void CCDBNodeBranch::readDelta( TGameCycle gc, CBitMemStream & f ) { if ( isAtomic() ) { @@ -679,8 +682,6 @@ void CCDBNodeBranch::removeNode (const CTextId& id) //----------------------------------------------- void CCDBNodeBranch::flushObserversCalls() { - H_AUTO ( RZ_Interface_flushObserversCalls ) - // nlassert(_CrtCheckMemory()); _CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList]; while (_CurrNotifiedObs) @@ -743,7 +744,7 @@ void CCDBNodeBranch::removeFlushObserver( CCDBNodeBranch::IBranchObserverCallFlu } //----------------------------------------------- -void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, NLMISC::TStringId modifiedLeafName) +void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, TStringId modifiedLeafName) { // If there a filter set? if (!PositiveLeafNameFilter.empty()) @@ -810,7 +811,7 @@ void CCDBNodeBranch::CDBBranchObsInfo::unlink(uint list) } //----------------------------------------------- -void CCDBNodeBranch::linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName) +void CCDBNodeBranch::linkInModifiedNodeList(TStringId modifiedLeafName) { // nlassert(_CrtCheckMemory()); CCDBNodeBranch *curr = this; @@ -913,7 +914,15 @@ void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode: else { branchNode = safe_cast(getNode(ICDBNode::CTextId(dbPathFromThisNode), false)); - BOMB_IF (!branchNode, (*getName()) << ":" << dbPathFromThisNode << " branch missing in DB", return); + if( branchNode == NULL ){ + std::string msg = *getName(); + msg += ":"; + msg += dbPathFromThisNode; + msg += " branch missing in DB"; + + nlerror( msg.c_str() ); + return; + } } std::vector leavesToMonitor(positiveLeafNameFilterSize); for (uint i=0; i!=positiveLeafNameFilterSize; ++i) @@ -927,7 +936,14 @@ void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode: void CCDBNodeBranch::removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer) { CCDBNodeBranch *branchNode = safe_cast(getNode(ICDBNode::CTextId(dbPathFromThisNode), false)); - BOMB_IF (!branchNode, (*getName()) << ":" << dbPathFromThisNode << " branch missing in DB", return); + if( branchNode == NULL ){ + std::string msg = *getName(); + msg += ":"; + msg += dbPathFromThisNode; + msg += " branch missing in DB"; + nlerror( msg.c_str() ); + return; + } branchNode->removeBranchObserver(&observer); } @@ -1043,3 +1059,5 @@ ICDBNode *CCDBNodeBranch::find(const std::string &nodeName) #undef TRACE_SET_VALUE #endif +} + diff --git a/code/ryzom/client/src/cdb_check_sum.cpp b/code/nel/src/misc/cdb_check_sum.cpp similarity index 91% rename from code/ryzom/client/src/cdb_check_sum.cpp rename to code/nel/src/misc/cdb_check_sum.cpp index 44782fea3..4f5f32030 100644 --- a/code/ryzom/client/src/cdb_check_sum.cpp +++ b/code/nel/src/misc/cdb_check_sum.cpp @@ -16,10 +16,11 @@ -#include "stdpch.h" -#include "cdb_check_sum.h" +#include "nel/misc/cdb_check_sum.h" +namespace NLMISC{ + /* * Constructor */ @@ -40,3 +41,6 @@ void CCDBCheckSum::add(uint8 el) _Factor = (cipher + _Factor) * _Const1 + _Const2; _Sum += cipher; } + +} + diff --git a/code/ryzom/client/src/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp similarity index 91% rename from code/ryzom/client/src/cdb_leaf.cpp rename to code/nel/src/misc/cdb_leaf.cpp index e680ef96a..96a4b4428 100644 --- a/code/ryzom/client/src/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -25,21 +25,23 @@ ////////////// // Includes // ////////////// -#include "cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/bit_mem_stream.h" //#include //////////////// // Namespaces // //////////////// -using namespace NLMISC; using namespace std; +namespace NLMISC{ + //----------------------------------------------- // init //----------------------------------------------- -void CCDBNodeLeaf::init( xmlNodePtr node, NLMISC::IProgressCallback &/* progressCallBack */, bool /* mapBanks */ ) +void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBack */, bool /* mapBanks */ ) { CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type")); nlassert((const char *) type != NULL); @@ -124,7 +126,7 @@ void CCDBNodeLeaf::write( CTextId& id, FILE * f) //----------------------------------------------- // readDelta //----------------------------------------------- -void CCDBNodeLeaf::readDelta(NLMISC::TGameCycle gc, CBitMemStream & f ) +void CCDBNodeLeaf::readDelta(TGameCycle gc, CBitMemStream & f ) { // If the property Type is valid. if(_Type > UNKNOWN && _Type < Nb_Prop_Type) @@ -180,7 +182,7 @@ void CCDBNodeLeaf::readDelta(NLMISC::TGameCycle gc, CBitMemStream & f ) //----------------------------------------------- // resetData //----------------------------------------------- -void CCDBNodeLeaf::resetData(NLMISC::TGameCycle gc, bool forceReset) +void CCDBNodeLeaf::resetData(TGameCycle gc, bool forceReset) { if(forceReset) { @@ -247,7 +249,7 @@ bool CCDBNodeLeaf::setProp( CTextId& id, sint64 value ) //----------------------------------------------- // setPropCheckGC //----------------------------------------------- -bool CCDBNodeLeaf::setPropCheckGC(NLMISC::TGameCycle gc, sint64 value) +bool CCDBNodeLeaf::setPropCheckGC(TGameCycle gc, sint64 value) { // Apply only if happens after the DB change if(gc>=_LastChangeGC) @@ -318,7 +320,7 @@ void CCDBNodeLeaf::setValueBool(bool prop) setValue64(newVal); } -void CCDBNodeLeaf::setValueRGBA (const NLMISC::CRGBA &color) +void CCDBNodeLeaf::setValueRGBA (const CRGBA &color) { sint64 newVal = (uint32)(color.R+(color.G<<8)+(color.B<<16)+(color.A<<24)); setValue64(newVal); @@ -386,3 +388,5 @@ void CCDBNodeLeaf::notifyObservers() #endif //############################################################################################# +} + diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index d25564e70..caf487b81 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -48,7 +48,7 @@ using namespace NLMISC; using namespace std; -bool VerboseDatabase = false; +bool NLMISC::VerboseDatabase = false; uint32 NbDatabaseChanges = 0; diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index c4a70dd2b..d65dc1523 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -20,8 +20,8 @@ #define CDB_SYNCHRONISED_H -#include "cdb.h" -#include "cdb_branch.h" +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_branch.h" /** * Class to manage a database of properties @@ -32,7 +32,7 @@ class CCDBSynchronised { /// database - NLMISC::CRefPtr _Database; + NLMISC::CRefPtr _Database; /// string associations std::map _Strings; @@ -60,7 +60,7 @@ public: * Return a ptr on the node * \return ptr on the node */ - CCDBNodeBranch * getNodePtr() { return _Database; } + NLMISC::CCDBNodeBranch * getNodePtr() { return _Database; } /** * Build the structure of the database from a file diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 2d5076b90..259461b6e 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -76,7 +76,7 @@ #include "user_entity.h" #include "projectile_manager.h" #include "init_main_loop.h" -#include "cdb_branch.h" +#include "nel/misc/cdb_branch.h" #include "animation_fx_misc.h" #include "attack_list.h" #include "animation_fx_id_array.h" diff --git a/code/ryzom/client/src/client_chat_manager.h b/code/ryzom/client/src/client_chat_manager.h index 8a591a27d..d48ad9be1 100644 --- a/code/ryzom/client/src/client_chat_manager.h +++ b/code/ryzom/client/src/client_chat_manager.h @@ -32,6 +32,10 @@ #include #include +namespace NLMISC{ +class CCDBNodeLeaf; +} + //#define OLD_STRING_SYSTEM @@ -338,8 +342,8 @@ private : /// \name Dynamic Chat channel mgt // @{ TChanID _ChatDynamicChannelId; - class CCDBNodeLeaf *_DynamicChannelNameLeaf[CChatGroup::MaxDynChanPerPlayer]; - class CCDBNodeLeaf *_DynamicChannelIdLeaf[CChatGroup::MaxDynChanPerPlayer]; + NLMISC::CCDBNodeLeaf *_DynamicChannelNameLeaf[CChatGroup::MaxDynChanPerPlayer]; + NLMISC::CCDBNodeLeaf *_DynamicChannelIdLeaf[CChatGroup::MaxDynChanPerPlayer]; // Id cached. If different from precedent, then the channel must be flushed enum {DynamicChannelEmptyId=-1}; uint32 _DynamicChannelIdCache[CChatGroup::MaxDynChanPerPlayer]; diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index f62d8f245..efdee9bc9 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -74,7 +74,7 @@ #include "commands.h" #include "entities.h" #include "teleport.h" -#include "cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "view.h" #include "misc.h" #include "demo.h" diff --git a/code/ryzom/client/src/entity_cl.h b/code/ryzom/client/src/entity_cl.h index bb508dd42..e2d6cf6e6 100644 --- a/code/ryzom/client/src/entity_cl.h +++ b/code/ryzom/client/src/entity_cl.h @@ -91,7 +91,10 @@ class CItemSheet; class CPhysicalDamage; +namespace NLMISC{ class CCDBNodeLeaf; +class CCDBNodeBranch; +} extern CLFECOMMON::TCLEntityId SlotUnderCursor; @@ -809,7 +812,7 @@ public: virtual void setDiffuse(bool onOff, NLMISC::CRGBA diffuse); - static CCDBNodeLeaf *getOpacityDBNode(); + static NLMISC::CCDBNodeLeaf *getOpacityDBNode(); static uint32 getOpacityMin(); static void setOpacityMin(uint32 value); @@ -884,7 +887,7 @@ protected: // Persistent NPC Alias of the entity uint32 _NPCAlias; // Local DB Branch for this entity - class CCDBNodeBranch *_DBEntry; + class NLMISC::CCDBNodeBranch *_DBEntry; // Playlist NL3D::UPlayList *_PlayList; NL3D::UPlayList *_FacePlayList; @@ -1108,7 +1111,7 @@ protected: // for localSelectBox() computing sint64 _LastLocalSelectBoxComputeTime; - static NLMISC::CRefPtr _OpacityMinNodeLeaf; + static NLMISC::CRefPtr _OpacityMinNodeLeaf; protected: /** diff --git a/code/ryzom/client/src/game_context_menu.h b/code/ryzom/client/src/game_context_menu.h index de628c2c6..e1a854507 100644 --- a/code/ryzom/client/src/game_context_menu.h +++ b/code/ryzom/client/src/game_context_menu.h @@ -30,7 +30,9 @@ // *************************************************************************** class CGroupMenu; class CViewTextMenu; +namespace NLMISC{ class CCDBNodeLeaf; +} // *************************************************************************** /** @@ -77,21 +79,21 @@ private: // MilkoPad CInterfaceGroupPtr _GroupMilkoPad; - CCDBNodeLeaf *_MilkoAttackDisengage; + NLMISC::CCDBNodeLeaf *_MilkoAttackDisengage; CCtrlTextButtonPtr _MilkoAttDisBut1; CCtrlTextButtonPtr _MilkoAttDisBut2; CGroupMenu *_GroupMenu; - CCDBNodeLeaf *_ContextVal; - CCDBNodeLeaf *_AvailablePrograms; - CCDBNodeLeaf *_ServerTeamPresent; - CCDBNodeLeaf *_MissionOption[NUM_MISSION_OPTIONS]; - CCDBNodeLeaf *_ServerInDuel; - CCDBNodeLeaf *_ServerInPvpChallenge; - CCDBNodeLeaf *_WebPageTitle; - CCDBNodeLeaf *_OutpostSheet; - CCDBNodeLeaf *_OutpostRightToBannish; - CCDBNodeLeaf *_MissionRing[BOTCHATTYPE::MaxR2MissionEntryDatabase]; + NLMISC::CCDBNodeLeaf *_ContextVal; + NLMISC::CCDBNodeLeaf *_AvailablePrograms; + NLMISC::CCDBNodeLeaf *_ServerTeamPresent; + NLMISC::CCDBNodeLeaf *_MissionOption[NUM_MISSION_OPTIONS]; + NLMISC::CCDBNodeLeaf *_ServerInDuel; + NLMISC::CCDBNodeLeaf *_ServerInPvpChallenge; + NLMISC::CCDBNodeLeaf *_WebPageTitle; + NLMISC::CCDBNodeLeaf *_OutpostSheet; + NLMISC::CCDBNodeLeaf *_OutpostRightToBannish; + NLMISC::CCDBNodeLeaf *_MissionRing[BOTCHATTYPE::MaxR2MissionEntryDatabase]; CViewTextMenuPtr _TextLootAction; diff --git a/code/ryzom/client/src/ingame_database_manager.h b/code/ryzom/client/src/ingame_database_manager.h index 634544f61..043e2ee98 100644 --- a/code/ryzom/client/src/ingame_database_manager.h +++ b/code/ryzom/client/src/ingame_database_manager.h @@ -27,9 +27,9 @@ // Misc. #include "nel/misc/types_nl.h" // Game share. -#include "cdb.h" -#include "cdb_leaf.h" -#include "cdb_branch.h" +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" #include "cdb_synchronised.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.h b/code/ryzom/client/src/interface_v3/action_handler_help.h index 48253ea96..59a218a27 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.h +++ b/code/ryzom/client/src/interface_v3/action_handler_help.h @@ -141,10 +141,10 @@ private: }; // update the brick help window when weight of hands has changed - class CFittedWeaponWeightObserver : public ICDBNode::IPropertyObserver + class CFittedWeaponWeightObserver : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.h b/code/ryzom/client/src/interface_v3/action_phrase_faber.h index 517b25210..18b772baa 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.h +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.h @@ -143,18 +143,18 @@ private: // The Inventory manipulated. std::vector _InventoryMirror; bool _InventoryObsSetup; - class CDBInventoryObs : public ICDBNode::IPropertyObserver + class CDBInventoryObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CDBInventoryObs _DBInventoryObs; friend class CDBInventoryObs; // The animals Status - class CDBAnimalObs : public ICDBNode::IPropertyObserver + class CDBAnimalObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CDBAnimalObs _DBAnimalObs; friend class CDBAnimalObs; diff --git a/code/ryzom/client/src/interface_v3/animal_position_state.cpp b/code/ryzom/client/src/interface_v3/animal_position_state.cpp index a3dc479f0..910230ce0 100644 --- a/code/ryzom/client/src/interface_v3/animal_position_state.cpp +++ b/code/ryzom/client/src/interface_v3/animal_position_state.cpp @@ -24,6 +24,8 @@ #include "group_compas.h" #include "game_share/animal_status.h" +using NLMISC::CCDBNodeLeaf; + // *************************************************************************** // CPositionState // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/animal_position_state.h b/code/ryzom/client/src/interface_v3/animal_position_state.h index 17bb2021d..f53f476e5 100644 --- a/code/ryzom/client/src/interface_v3/animal_position_state.h +++ b/code/ryzom/client/src/interface_v3/animal_position_state.h @@ -26,7 +26,9 @@ // *************************************************************************** +namespace NLMISC{ class CCDBNodeLeaf; +} // *************************************************************************** /** @@ -58,7 +60,7 @@ protected: virtual bool getDbPos(sint32 &px, sint32 &py) = 0; // helper to serial a CDBNodeLeaf, based on itsname - void serialNodeLeaf(NLMISC::IStream &f, CCDBNodeLeaf *&dbNode); + void serialNodeLeaf(NLMISC::IStream &f, NLMISC::CCDBNodeLeaf *&dbNode); }; @@ -82,8 +84,8 @@ public: virtual void serial(NLMISC::IStream &f); protected: // Database infos - CCDBNodeLeaf *_DBPos; - CCDBNodeLeaf *_Uid; + NLMISC::CCDBNodeLeaf *_DBPos; + NLMISC::CCDBNodeLeaf *_Uid; // The slot of the entity that may be used to get more precise position CLFECOMMON::TCLEntityId _EntitySlot; virtual CEntityCL *getEntity(); @@ -103,18 +105,18 @@ class CNamedEntityPositionState : public CPositionState public: NLMISC_DECLARE_CLASS(CNamedEntityPositionState) virtual bool dbOk() {return _Name && _X && _Y;} - void build(CCDBNodeLeaf *name, CCDBNodeLeaf *x, CCDBNodeLeaf *y); - CCDBNodeLeaf *getNameNode() const { return _Name; } - CCDBNodeLeaf *getXNode() const { return _X; } - CCDBNodeLeaf *getYNode() const { return _X; } + void build(NLMISC::CCDBNodeLeaf *name, NLMISC::CCDBNodeLeaf *x, NLMISC::CCDBNodeLeaf *y); + NLMISC::CCDBNodeLeaf *getNameNode() const { return _Name; } + NLMISC::CCDBNodeLeaf *getXNode() const { return _X; } + NLMISC::CCDBNodeLeaf *getYNode() const { return _X; } // virtual bool canSave() const { return true; } virtual void serial(NLMISC::IStream &f); protected: // Database infos - CCDBNodeLeaf *_Name; - CCDBNodeLeaf *_X; - CCDBNodeLeaf *_Y; + NLMISC::CCDBNodeLeaf *_Name; + NLMISC::CCDBNodeLeaf *_X; + NLMISC::CCDBNodeLeaf *_Y; virtual CEntityCL *getEntity(); virtual bool getDbPos(sint32 &px, sint32 &py); }; @@ -148,7 +150,7 @@ public: virtual void serial(NLMISC::IStream &/* f */) { nlassert(0); /* notsavable */ } protected: // Database infos - CCDBNodeLeaf *_Present; + NLMISC::CCDBNodeLeaf *_Present; // DB ok. bool dbOk() {return _DBPos && _Present && _Uid;} @@ -182,7 +184,7 @@ public: private: // Animal Database infos - CCDBNodeLeaf *_Status; + NLMISC::CCDBNodeLeaf *_Status; // DB ok. bool dbOk() {return _DBPos && _Status && _Uid;} diff --git a/code/ryzom/client/src/interface_v3/bar_manager.h b/code/ryzom/client/src/interface_v3/bar_manager.h index 54e8770d3..901a6ebb0 100644 --- a/code/ryzom/client/src/interface_v3/bar_manager.h +++ b/code/ryzom/client/src/interface_v3/bar_manager.h @@ -23,6 +23,10 @@ #include "game_share/inventories.h" #include "game_share/scores.h" +namespace NLMISC{ + class CCDBNodeLeaf; +} + // *************************************************************************** /** @@ -214,12 +218,12 @@ private: CBarInfo BarInfo; // Connection input (used only for TargetType, TeamMemberType and AnimalType) - class CCDBNodeLeaf *UIDIn; - class CCDBNodeLeaf *PresentIn; // if not NULL, this is an additional test: if(PresentIn->getValue()==0) => not present - class CCDBNodeLeaf *ScoreIn[SCORES::NUM_SCORES]; + NLMISC::CCDBNodeLeaf *UIDIn; + NLMISC::CCDBNodeLeaf *PresentIn; // if not NULL, this is an additional test: if(PresentIn->getValue()==0) => not present + NLMISC::CCDBNodeLeaf *ScoreIn[SCORES::NUM_SCORES]; // Connection output - class CCDBNodeLeaf *ScoreOut[SCORES::NUM_SCORES]; + NLMISC::CCDBNodeLeaf *ScoreOut[SCORES::NUM_SCORES]; public: CBarDataEntry(); @@ -258,11 +262,11 @@ private: // last score get from impulse USER:BARS sint32 Score; // input DB value, to get the current MAX - class CCDBNodeLeaf *DBInMax; + NLMISC::CCDBNodeLeaf *DBInMax; // output DB to store the real value, but clamped to 0 - class CCDBNodeLeaf *DBOutVal; + NLMISC::CCDBNodeLeaf *DBOutVal; // output DB to store the ratio -1024,1024 value - class CCDBNodeLeaf *DBOutRatio; + NLMISC::CCDBNodeLeaf *DBOutRatio; CUserScore() { Score= 0; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp index 1c16a68cc..2e54f41f9 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp @@ -29,6 +29,8 @@ static const char *WIN_BOT_CHAT_PAGE_PLAYER_GIFT = "ui:interface:bot_chat_player_gift"; +using NLMISC::CCDBNodeLeaf; + // ************************************************************************************* void CBotChatPagePlayerGift::begin() { diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.h b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.h index 1d3880c02..8c5038fb7 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.h @@ -142,7 +142,7 @@ private: uint32 _FilterBuyDlgMaxValue; // keep pointer on leaf for fame price factor - CCDBNodeLeaf * _FamePriceFactorLeaf; + NLMISC::CCDBNodeLeaf * _FamePriceFactorLeaf; bool _DownloadComplete; private: diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.h b/code/ryzom/client/src/interface_v3/chat_text_manager.h index db4cce447..1c9d6d0cf 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.h +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.h @@ -23,6 +23,9 @@ class CViewBase; class ucstring; +namespace NLMISC{ + class CCDBNodeLeaf; +} /** Class to get chat text parameters, and to build new text lines * \author Nicolas Vizerie @@ -56,9 +59,9 @@ public: private: static CChatTextManager *_Instance; - mutable class CCDBNodeLeaf *_TextFontSize; - mutable CCDBNodeLeaf *_TextMultilineSpace; - mutable CCDBNodeLeaf *_TextShadowed; + mutable NLMISC::CCDBNodeLeaf *_TextFontSize; + mutable NLMISC::CCDBNodeLeaf *_TextMultilineSpace; + mutable NLMISC::CCDBNodeLeaf *_TextShadowed; // ctor, private because of singleton CChatTextManager(); diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h index 5f80598a8..f86d0047d 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.h @@ -28,7 +28,7 @@ * \author Nevrax France * \date 2002 */ -class CCtrlScroll : public CCtrlBase, public ICDBNode::IPropertyObserver +class CCtrlScroll : public CCtrlBase, public NLMISC::ICDBNode::IPropertyObserver { public: @@ -183,7 +183,7 @@ protected: void computeTargetOfsFromPos(); // from IPropertyObserver - virtual void update(ICDBNode *node); + virtual void update(NLMISC::ICDBNode *node); // step the value, and clamp it void normalizeValue(sint32 &value); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 6bd7706fb..95bd7278c 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -318,7 +318,7 @@ public: static void setCurrSelection(CDBCtrlSheet *selected); // get the root branch containing the properties for that sheet - CCDBNodeBranch *getRootBranch() const; + NLMISC::CCDBNodeBranch *getRootBranch() const; /** If the branch in setSheet(branch) is of the form ...:# (where # is a number), return this number. * The value is hence modified by setSheet(). return 0 if not of this form. @@ -443,7 +443,7 @@ public: sint getIndexInParent() const; // get the 'LOCKED' field in the db - CCDBNodeLeaf *getLockValuePtr() { return _GrayedLink; } + NLMISC::CCDBNodeLeaf *getLockValuePtr() { return _GrayedLink; } /// \name Macro // @{ @@ -483,35 +483,35 @@ public: void initSheetSize(); // @} - CCDBNodeLeaf *getSlotType() const { return _TradeSlotType.getNodePtr(); } + NLMISC::CCDBNodeLeaf *getSlotType() const { return _TradeSlotType.getNodePtr(); } // get item weight uint16 getItemWeight() const; - CCDBNodeLeaf *getItemWeightPtr() const; + NLMISC::CCDBNodeLeaf *getItemWeightPtr() const; // set item weight void setItemWeight(uint16 weight); // get item info version uint8 getItemInfoVersion() const; - CCDBNodeLeaf *getItemInfoVersionPtr() const; + NLMISC::CCDBNodeLeaf *getItemInfoVersionPtr() const; // set item info version void setItemInfoVersion(uint8 infoVersion); // get item Locked state uint16 getItemLocked() const; - CCDBNodeLeaf *getItemLockedPtr() const; + NLMISC::CCDBNodeLeaf *getItemLockedPtr() const; // set item locked state void setItemLocked(uint16 lock); // get item PRICE. 0 if no DB sint32 getItemPrice() const; - CCDBNodeLeaf *getItemPricePtr() const; + NLMISC::CCDBNodeLeaf *getItemPricePtr() const; // set item PRICE void setItemPrice(sint32 price); // get item RESALE_FLAG. 0 if no DB sint32 getItemResaleFlag() const; - CCDBNodeLeaf *getItemResaleFlagPtr() const; + NLMISC::CCDBNodeLeaf *getItemResaleFlagPtr() const; // set item RESALE_FLAG void setItemResaleFlag(sint32 rf); @@ -523,25 +523,25 @@ public: // get item SELLER_TYPE. 0 if no DB sint32 getItemSellerType() const; - CCDBNodeLeaf *getItemSellerTypePtr() const; + NLMISC::CCDBNodeLeaf *getItemSellerTypePtr() const; // set item SELLER_TYPE void setItemSellerType(sint32 rf); // get item FABER_QUALITY. 0 if no DB RM_CLASS_TYPE::TRMClassType getItemRMClassType() const; - CCDBNodeLeaf *getItemRMClassTypePtr() const {return _ItemRMClassType;} + NLMISC::CCDBNodeLeaf *getItemRMClassTypePtr() const {return _ItemRMClassType;} // set item FABER_QUALITY void setItemRMClassType(sint32 fq); // get item FABER_STAT_TYPE. 0 if no DB RM_FABER_STAT_TYPE::TRMStatType getItemRMFaberStatType() const; - CCDBNodeLeaf *getItemRMFaberStatTypePtr() const {return _ItemRMFaberStatType;} + NLMISC::CCDBNodeLeaf *getItemRMFaberStatTypePtr() const {return _ItemRMFaberStatType;} // set item FABER_STAT_TYPE void setItemRMFaberStatType(sint32 fss); // get item PREREQUISIT_VALID. true of no DB bool getItemPrerequisitValid() const; - CCDBNodeLeaf *getItemPrerequisitValidPtr() const; + NLMISC::CCDBNodeLeaf *getItemPrerequisitValidPtr() const; // set item PREREQUISIT_VALID void setItemPrerequisitValid(bool prv); @@ -610,8 +610,8 @@ protected: CInterfaceProperty _Worned; // if true means that item is worned (red cross, no longer usable unless it's a tool) // As node leaf for backward compatibilities - CCDBNodeLeaf *_ItemRMClassType; - CCDBNodeLeaf *_ItemRMFaberStatType; + NLMISC::CCDBNodeLeaf *_ItemRMClassType; + NLMISC::CCDBNodeLeaf *_ItemRMFaberStatType; mutable sint32 _LastSheetId; @@ -703,7 +703,7 @@ protected: // This String is optional and usage dependent for Item, Macro, or Sentence std::string _OptString; - CCDBNodeLeaf *_GrayedLink; + NLMISC::CCDBNodeLeaf *_GrayedLink; // Macro or sentence String compiled as texture Ids and positions, from the _OptString. struct CCharBitmap @@ -734,7 +734,7 @@ protected: sint32 _ItemCaracReqValue; // Special for Armour - CCDBNodeLeaf *_UserColor; + NLMISC::CCDBNodeLeaf *_UserColor; // keep pointer on item sheet const CItemSheet *_ItemSheet; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index d0edc49d9..a1005f3b6 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -141,14 +141,14 @@ protected: // branch of the DB - CCDBNodeBranch *_DbBranch; + NLMISC::CCDBNodeBranch *_DbBranch; std::string _DbBranchName; // Branch observer - class CDBObs : public ICDBNode::IPropertyObserver + class CDBObs : public NLMISC::ICDBNode::IPropertyObserver { public: CDBGroupListSheet *Owner; - virtual void update(ICDBNode* /* node */) {Owner->_BranchModified= true;} + virtual void update(NLMISC::ICDBNode* /* node */) {Owner->_BranchModified= true;} }; friend class CDBObs; CDBObs _DbBranchObs; @@ -192,7 +192,7 @@ protected: } // For animals only - CCDBNodeLeaf *_AnimalStatus; + NLMISC::CCDBNodeLeaf *_AnimalStatus; sint32 _CacheAnimalStatus; // For sectionnable purpose diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h index 5daa683da..f1764181d 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.h @@ -44,7 +44,7 @@ public: private: sint32 _TextId; - std::vector _DisableStates; + std::vector _DisableStates; }; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.h index 5e3af2734..2748ad097 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.h @@ -45,7 +45,7 @@ public: virtual bool isInvalidated(CDBGroupListSheet *pFather); virtual void update(CDBGroupListSheet *pFather); virtual sint getSectionId() const; - CCDBNodeLeaf *LevelDB; + NLMISC::CCDBNodeLeaf *LevelDB; uint LevelCache; }; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index fb8db2b74..80bfe50c7 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet_mission.h" #include "view_text_id_formated.h" -#include "../cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "interface_manager.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 7f4f274a1..38d538df3 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -203,14 +203,14 @@ protected: // branch of the DB - CCDBNodeBranch *_DbBranch; + NLMISC::CCDBNodeBranch *_DbBranch; std::string _DbBranchName; // Branch observer - class CDBObs : public ICDBNode::IPropertyObserver + class CDBObs : public NLMISC::ICDBNode::IPropertyObserver { public: CDBGroupListSheetText *Owner; - virtual void update(ICDBNode* /* node */) {Owner->_BranchModified= true;} + virtual void update(NLMISC::ICDBNode* /* node */) {Owner->_BranchModified= true;} }; friend class CDBObs; CDBObs _DbBranchObs; @@ -269,7 +269,7 @@ protected: sint getIndexOf(const CCtrlButton *button) const; // For animals only - CCDBNodeLeaf *_AnimalStatus; + NLMISC::CCDBNodeLeaf *_AnimalStatus; sint32 _CacheAnimalStatus; // For items only (requirement color) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.h index 4b857501e..e36b7c3d5 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.h @@ -46,7 +46,7 @@ public: virtual void update(CDBGroupListSheetText *pFather); virtual void updateViewText(CDBGroupListSheetText *pFather); virtual sint getSectionId() const; - CCDBNodeLeaf *LevelDB; + NLMISC::CCDBNodeLeaf *LevelDB; uint LevelCache; }; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h index 7d5fd4922..54b7dba75 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h @@ -140,7 +140,7 @@ protected: bool _ApplyFamePriceFactor; // keep pointer on leaf for fame price factor - CCDBNodeLeaf * _FamePriceFactorLeaf; + NLMISC::CCDBNodeLeaf * _FamePriceFactorLeaf; sint16 _LastFamePriceFactor; TSellerTypeFilter _SellerTypeFilter; diff --git a/code/ryzom/client/src/interface_v3/group_compas.h b/code/ryzom/client/src/interface_v3/group_compas.h index ecef51114..112b6ae68 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.h +++ b/code/ryzom/client/src/interface_v3/group_compas.h @@ -110,7 +110,7 @@ private: CCompassTarget _SavedTarget; bool _SavedTargetValid; - CCDBNodeLeaf *_DynamicTargetPos; + NLMISC::CCDBNodeLeaf *_DynamicTargetPos; uint32 _LastDynamicTargetPos; // Color for each type of target diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h index 8622e38d2..69cd13847 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.h @@ -93,9 +93,9 @@ protected: static NLMISC::CRGBA BarColorHPNegative; // Node user leaf - static CCDBNodeLeaf *_Value; - static CCDBNodeLeaf *_ValueBegin; - static CCDBNodeLeaf *_ValueEnd; + static NLMISC::CCDBNodeLeaf *_Value; + static NLMISC::CCDBNodeLeaf *_ValueBegin; + static NLMISC::CCDBNodeLeaf *_ValueEnd; // Special guild bool _NeedGuildNameId; diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index 09974152d..b192b0c2f 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -35,7 +35,9 @@ class CContinent; +namespace NLMISC{ class CCDBNodeLeaf; +} class CWorldSheet; class CCtrlQuad; struct SMap; @@ -425,8 +427,8 @@ private: // have the texts been received for mission targets ? std::vector _MissionTargetTextReceived; // ptr on db leaf for coordinates of special landmarks - CCDBNodeLeaf *_TargetPos; - CCDBNodeLeaf *_HomePos; + NLMISC::CCDBNodeLeaf *_TargetPos; + NLMISC::CCDBNodeLeaf *_HomePos; // Animals State for landMarks std::vector > _AnimalPosStates; // Teammate State for landMarks diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h index 0e5735088..26099f8e3 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h @@ -53,12 +53,12 @@ private: private: // observer to know that brick family are modified - struct CBrickFamilyObs : public ICDBNode::IPropertyObserver + struct CBrickFamilyObs : public NLMISC::ICDBNode::IPropertyObserver { CGroupPhraseSkillFilter *Owner; BRICK_FAMILIES::TBrickFamily BrickFamily; - virtual void update (ICDBNode *node); + virtual void update (NLMISC::ICDBNode *node); }; friend struct CBrickFamilyObs; CBrickFamilyObs _BrickFamilyObs[BRICK_FAMILIES::NbFamilies]; diff --git a/code/ryzom/client/src/interface_v3/group_skills.h b/code/ryzom/client/src/interface_v3/group_skills.h index 3fa9cb25f..e486ae098 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.h +++ b/code/ryzom/client/src/interface_v3/group_skills.h @@ -51,10 +51,10 @@ private: private: // observer to know that skills are modified - struct CSkillsObs : public ICDBNode::IPropertyObserver + struct CSkillsObs : public NLMISC::ICDBNode::IPropertyObserver { CGroupSkills *Owner; - virtual void update (ICDBNode *node); + virtual void update (NLMISC::ICDBNode *node); } _SkillsObs; friend struct CSkillsObs; diff --git a/code/ryzom/client/src/interface_v3/guild_manager.h b/code/ryzom/client/src/interface_v3/guild_manager.h index 17b21c74c..20f51ca70 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.h +++ b/code/ryzom/client/src/interface_v3/guild_manager.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "obs_huge_list.h" #include "dbgroup_list_sheet_text.h" -#include "../cdb.h" +#include "nel/misc/cdb.h" #include "game_share/guild_grade.h" #include "game_share/misc_const.h" @@ -209,15 +209,15 @@ private: // Database management stuff - class CDBObs : public ICDBNode::IPropertyObserver + class CDBObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; - class CDBObsMembers : public ICDBNode::IPropertyObserver + class CDBObsMembers : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CDBObs _DBObs; diff --git a/code/ryzom/client/src/interface_v3/interface_config.h b/code/ryzom/client/src/interface_v3/interface_config.h index 6dfeb603f..9e3becba6 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.h +++ b/code/ryzom/client/src/interface_v3/interface_config.h @@ -22,7 +22,9 @@ #include "nel/misc/stream.h" class CGroupContainer; +namespace NLMISC{ class CCDBNodeLeaf; +} /** * interface config @@ -111,8 +113,8 @@ public: // ------------------------------ void serial (NLMISC::IStream &f); // ------------------------------ - void setFrom (CCDBNodeLeaf *pNL); - void setTo (CCDBNodeLeaf *pNL); + void setFrom (NLMISC::CCDBNodeLeaf *pNL); + void setTo (NLMISC::CCDBNodeLeaf *pNL); }; void dataBaseToStream (NLMISC::IStream &f); diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.h b/code/ryzom/client/src/interface_v3/interface_ddx.h index 72d3f20c0..fbf05920e 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.h +++ b/code/ryzom/client/src/interface_v3/interface_ddx.h @@ -52,7 +52,7 @@ public: void updateRealtime(CCtrlBase *pSB, bool updateOnScrollEnd); // Update all parameters to obey their preset (no op if no preset or if preset is Custom) - void updateParamPreset(CCDBNodeLeaf *presetChanged); + void updateParamPreset(NLMISC::CCDBNodeLeaf *presetChanged); // set apply button can be pushed void validateApplyButton(); @@ -90,7 +90,7 @@ private: sint32 RTBackupValue; // When canceling // For ConfigFile widget only - CCDBNodeLeaf *PresetDB; + NLMISC::CCDBNodeLeaf *PresetDB; // ----------------------- CParam() @@ -128,16 +128,16 @@ private: std::vector _Parameters; // For preset change - class CPresetObs : public ICDBNode::IPropertyObserver + class CPresetObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); CInterfaceDDX *Owner; CPresetObs() : Owner(NULL) {} }; CPresetObs _PresetObs; - std::set _PresetNodes; + std::set _PresetNodes; // reset the preset values according to parameters values void resetPreSet(); diff --git a/code/ryzom/client/src/interface_v3/interface_expr.h b/code/ryzom/client/src/interface_v3/interface_expr.h index 2ba26415e..33c6b70af 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr.h +++ b/code/ryzom/client/src/interface_v3/interface_expr.h @@ -26,8 +26,11 @@ #include "nel/misc/ucstring.h" #include "nel/misc/rgba.h" - +namespace NLMISC{ class ICDBNode; +class CCDBNodeLeaf; +class CCDBNodeBranch; +} struct CInterfaceExprUserType; @@ -166,7 +169,7 @@ public: * Node will only be inserted once, so we end up with a set of node (not ordered) * \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on. */ - static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes = NULL, bool noFctCalls = false); + static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes = NULL, bool noFctCalls = false); /** Build a tree from the given expression so that it can be evaluated quickly. * This is useful for a fixed expression that must be evaluated often @@ -193,11 +196,11 @@ private: /** eval the value of a single expression * \return position to the next valid character */ - static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls); - static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector *nodes, bool noFctCalls); - static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector *nodes); + static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls); + static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector *nodes, bool noFctCalls); + static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector *nodes); public: - static const char *unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections = NULL); + static const char *unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections = NULL); /** Build tree of a single expression * \return position to the next valid character diff --git a/code/ryzom/client/src/interface_v3/interface_expr_node.cpp b/code/ryzom/client/src/interface_v3/interface_expr_node.cpp index 319c3fc9f..0d999f407 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_node.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_node.cpp @@ -18,8 +18,12 @@ #include "stdpch.h" #include "interface_expr_node.h" -#include "../cdb_leaf.h" -#include "../cdb_branch.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" + +using NLMISC::ICDBNode; +using NLMISC::CCDBNodeBranch; +using NLMISC::CCDBNodeLeaf; // ******************************************************************************************************* void CInterfaceExprNodeValue::eval(CInterfaceExprValue &result) diff --git a/code/ryzom/client/src/interface_v3/interface_expr_node.h b/code/ryzom/client/src/interface_v3/interface_expr_node.h index 7327c4ada..6dc30f8b8 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_node.h +++ b/code/ryzom/client/src/interface_v3/interface_expr_node.h @@ -33,9 +33,9 @@ public: // eval result of expression, and eventually get the nodes the epression depends on virtual void eval(CInterfaceExprValue &result) = 0; // The same, but get db nodes the expression depends on (appended to vector) - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) = 0; + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) = 0; // Get dependencies of the node (appended to vector) - virtual void getDepends(std::vector &nodes) = 0; + virtual void getDepends(std::vector &nodes) = 0; }; @@ -48,8 +48,8 @@ public: CInterfaceExprValue Value; public: virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); }; // ******************************************************************************************************* @@ -63,8 +63,8 @@ public: std::vector Params; public: virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); virtual ~CInterfaceExprNodeValueFnCall(); }; @@ -74,11 +74,11 @@ public: class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode { public: - class CCDBNodeLeaf *Leaf; + class NLMISC::CCDBNodeLeaf *Leaf; public: virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); }; // ******************************************************************************************************* @@ -87,11 +87,11 @@ public: class CInterfaceExprNodeDBBranch : public CInterfaceExprNode { public: - class CCDBNodeBranch *Branch; + class NLMISC::CCDBNodeBranch *Branch; public: virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); }; // ******************************************************************************************************* @@ -104,8 +104,8 @@ public: std::string Expr; public: virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); }; diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 69274dbd7..32a88553b 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -24,7 +24,7 @@ #include "interface_manager.h" #include "interface_expr_node.h" #include "reflect.h" -#include "../cdb_branch.h" +#include "nel/misc/cdb_branch.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/ryzom/client/src/interface_v3/interface_link.h index 49abe429c..88b8d416d 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.h +++ b/code/ryzom/client/src/interface_v3/interface_link.h @@ -19,7 +19,7 @@ #ifndef CL_INTERFACE_LINK_H #define CL_INTERFACE_LINK_H -#include "../cdb_branch.h" +#include "nel/misc/cdb_branch.h" class CInterfaceElement; class CReflectedProperty; @@ -45,7 +45,7 @@ class CInterfaceExprNode; * \author Nevrax France * \date 2002 */ -class CInterfaceLink : public ICDBNode::IPropertyObserver +class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver { public: #ifdef NL_DEBUG @@ -66,7 +66,7 @@ public: /// Updates triggered interface links when triggered by the observed branch - class CInterfaceLinkUpdater : public CCDBNodeBranch::IBranchObserverCallFlushObserver + class CInterfaceLinkUpdater : public NLMISC::CCDBNodeBranch::IBranchObserverCallFlushObserver { public: CInterfaceLinkUpdater(); @@ -119,7 +119,7 @@ private: typedef std::list TLinkList; typedef NLMISC::CSmartPtr TLinkSmartPtr; typedef std::vector TLinkVect; - typedef std::vector TNodeVect; + typedef std::vector TNodeVect; private: std::vector _Targets; TNodeVect _ObservedNodes; @@ -161,7 +161,7 @@ private: * This doesn't update the node directly, but mark it as 'triggered' * The node is really updated during the call to 'updateTrigeredLinks()' */ - virtual void update(ICDBNode *node); + virtual void update(NLMISC::ICDBNode *node); void createObservers(const TNodeVect &nodes); void removeObservers(const TNodeVect &nodes); // debug : check that there are as many targets as reference to a link diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 615378d92..6ee4a6f50 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -229,12 +229,12 @@ public: /// Get the root of the database - CCDBNodeBranch *getDB() const { return _DbRootNode; } + NLMISC::CCDBNodeBranch *getDB() const { return _DbRootNode; } // yoyo: should avoid to try creating DbPropr with this system... very dangerous - CCDBNodeLeaf* getDbProp (const std::string & name, bool bCreate=true); + NLMISC::CCDBNodeLeaf* getDbProp (const std::string & name, bool bCreate=true); void delDbProp(const std::string & name); // get a Db Branch by its name. NULL if don't exist or not a branch (never try to create it) - CCDBNodeBranch *getDbBranch(const std::string &name); + NLMISC::CCDBNodeBranch *getDbBranch(const std::string &name); // return the DB as an int32. return 0 if the DB does not exist (never create) sint32 getDbValue32 (const std::string & name); @@ -448,7 +448,7 @@ public: * \param id : the text id of the element to observe * \return true if success */ - bool addDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id); + bool addDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, NLMISC::ICDBNode::CTextId id); /** * add an observer to a database entry @@ -456,17 +456,17 @@ public: * \param id : the text id of the element to observe * \return true if success */ - bool addDBObserver (ICDBNode::IPropertyObserver* observer, const std::string& id) + bool addDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, const std::string& id) { - return addDBObserver(observer, ICDBNode::CTextId(id)); + return addDBObserver(observer, NLMISC::ICDBNode::CTextId(id)); } /** remove the observer from the dataBase */ - bool removeDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id); - bool removeDBObserver (ICDBNode::IPropertyObserver* observer, const std::string& id) + bool removeDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, NLMISC::ICDBNode::CTextId id); + bool removeDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, const std::string& id) { - return removeDBObserver(observer, ICDBNode::CTextId(id)); + return removeDBObserver(observer, NLMISC::ICDBNode::CTextId(id)); } /// \name Global Interface Options @@ -658,7 +658,7 @@ public: uint8 getLocalSyncActionCounter() const {return _LocalSyncActionCounter;} uint8 getLocalSyncActionCounterMask() const {return _LocalSyncActionCounterMask;} - bool localActionCounterSynchronizedWith(CCDBNodeLeaf *leaf) + bool localActionCounterSynchronizedWith(NLMISC::CCDBNodeLeaf *leaf) { if (!leaf) return false; uint srvVal= leaf->getValue32(); @@ -737,31 +737,31 @@ private: void release(); // When something in the SERVER DB changes - void onServerChange(ICDBNode *serverNode); + void onServerChange(NLMISC::ICDBNode *serverNode); // When something in the LOCAL DB changes - void onLocalChange(ICDBNode *localNode); + void onLocalChange(NLMISC::ICDBNode *localNode); private: - class CLocalDBObserver : public ICDBNode::IPropertyObserver + class CLocalDBObserver : public NLMISC::ICDBNode::IPropertyObserver { public: CServerToLocalAutoCopy &_Owner; CLocalDBObserver(CServerToLocalAutoCopy &owner) : _Owner(owner) {} - virtual void update(ICDBNode *node) {_Owner.onLocalChange(node);} + virtual void update(NLMISC::ICDBNode *node) {_Owner.onLocalChange(node);} }; - class CServerDBObserver : public ICDBNode::IPropertyObserver + class CServerDBObserver : public NLMISC::ICDBNode::IPropertyObserver { public: CServerToLocalAutoCopy &_Owner; CServerDBObserver(CServerToLocalAutoCopy &owner) : _Owner(owner) {} - virtual void update(ICDBNode *node) {_Owner.onServerChange(node);} + virtual void update(NLMISC::ICDBNode *node) {_Owner.onServerChange(node);} }; // A node here is a pair Server<->Local struct CNode { - CCDBNodeLeaf *ServerNode; - CCDBNodeLeaf *LocalNode; + NLMISC::CCDBNodeLeaf *ServerNode; + NLMISC::CCDBNodeLeaf *LocalNode; bool InsertedInUpdateList; CNode() { @@ -786,7 +786,7 @@ private: private: // Counter Node - CCDBNodeLeaf *_ServerCounter; + NLMISC::CCDBNodeLeaf *_ServerCounter; // updaters CLocalDBObserver _LocalObserver; CServerDBObserver _ServerObserver; @@ -802,7 +802,7 @@ private: // List of nodes to update until next synchonized client-server counter std::vector _UpdateList; - void buildRecursLocalLeaves(CCDBNodeBranch *branch, std::vector &leaves); + void buildRecursLocalLeaves(NLMISC::CCDBNodeBranch *branch, std::vector &leaves); }; // Infos about a modal window. @@ -833,10 +833,10 @@ private: // Database management stuff - class CDBLandmarkObs : public ICDBNode::IPropertyObserver + class CDBLandmarkObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode *node); + virtual void update(NLMISC::ICDBNode *node); }; // EMOTES @@ -858,22 +858,22 @@ private: // ------------------------------------------------------------------------------------------------ public: // cache and expose some commonly used db nodes - CCDBNodeBranch *_DBB_UI_DUMMY; - CCDBNodeLeaf *_DB_UI_DUMMY_QUANTITY; - CCDBNodeLeaf *_DB_UI_DUMMY_QUALITY; - CCDBNodeLeaf *_DB_UI_DUMMY_SHEET; - CCDBNodeLeaf *_DB_UI_DUMMY_NAMEID; - CCDBNodeLeaf *_DB_UI_DUMMY_ENCHANT; - CCDBNodeLeaf *_DB_UI_DUMMY_SLOT_TYPE; - CCDBNodeLeaf *_DB_UI_DUMMY_PHRASE; - CCDBNodeLeaf *_DB_UI_DUMMY_WORNED; - CCDBNodeLeaf *_DB_UI_DUMMY_PREREQUISIT_VALID; - CCDBNodeLeaf *_DB_UI_DUMMY_FACTION_TYPE; + NLMISC::CCDBNodeBranch *_DBB_UI_DUMMY; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_QUANTITY; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_QUALITY; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_SHEET; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_NAMEID; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_ENCHANT; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_SLOT_TYPE; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_PHRASE; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_WORNED; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_PREREQUISIT_VALID; + NLMISC::CCDBNodeLeaf *_DB_UI_DUMMY_FACTION_TYPE; private: - CCDBNodeLeaf *_CheckMailNode; - CCDBNodeLeaf *_CheckForumNode; + NLMISC::CCDBNodeLeaf *_CheckMailNode; + NLMISC::CCDBNodeLeaf *_CheckForumNode; sint64 _UpdateWeatherTime; // @} @@ -908,7 +908,7 @@ private: ///the singleton's instance static CInterfaceManager* _Instance; - CCDBNodeLeaf *_DescTextTarget; + NLMISC::CCDBNodeLeaf *_DescTextTarget; // Capture NLMISC::CRefPtr _CaptureKeyboard; @@ -960,7 +960,7 @@ private: sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface // root node for interfaces properties in the databases - CCDBNodeBranch *_DbRootNode; + NLMISC::CCDBNodeBranch *_DbRootNode; // List of active Anims std::vector _ActiveAnims; @@ -998,14 +998,14 @@ private: void restoreAllContainersBackupPosition(); // Some Node leaf - CCDBNodeLeaf *_NeutralColor; - CCDBNodeLeaf *_WarningColor; - CCDBNodeLeaf *_ErrorColor; - CCDBNodeLeaf *_RProp; - CCDBNodeLeaf *_GProp; - CCDBNodeLeaf *_BProp; - CCDBNodeLeaf *_AProp; - CCDBNodeLeaf *_AlphaRolloverSpeedDB; + NLMISC::CCDBNodeLeaf *_NeutralColor; + NLMISC::CCDBNodeLeaf *_WarningColor; + NLMISC::CCDBNodeLeaf *_ErrorColor; + NLMISC::CCDBNodeLeaf *_RProp; + NLMISC::CCDBNodeLeaf *_GProp; + NLMISC::CCDBNodeLeaf *_BProp; + NLMISC::CCDBNodeLeaf *_AProp; + NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; // The next ViewText to draw for Over NLMISC::CRefPtr _OverExtendViewText; diff --git a/code/ryzom/client/src/interface_v3/interface_observer.h b/code/ryzom/client/src/interface_v3/interface_observer.h index b90c84f6b..da508aeb7 100644 --- a/code/ryzom/client/src/interface_v3/interface_observer.h +++ b/code/ryzom/client/src/interface_v3/interface_observer.h @@ -30,7 +30,7 @@ * \author Nevrax France * \date 2002 */ -class IInterfaceObserver : public ICDBNode::IPropertyObserver +class IInterfaceObserver : public NLMISC::ICDBNode::IPropertyObserver { public: @@ -45,7 +45,7 @@ public: /** * observer update */ - virtual void update (CCDBNodeLeaf* leaf)=0; + virtual void update (NLMISC::CCDBNodeLeaf* leaf)=0; }; @@ -160,7 +160,7 @@ public: return NULL; } } - if ( ! iMngr->addDBObserver(obs,ICDBNode::CTextId (data) ) ) + if ( ! iMngr->addDBObserver(obs,NLMISC::ICDBNode::CTextId (data) ) ) { return NULL; } diff --git a/code/ryzom/client/src/interface_v3/interface_property.h b/code/ryzom/client/src/interface_v3/interface_property.h index cec2c2815..06355f17a 100644 --- a/code/ryzom/client/src/interface_v3/interface_property.h +++ b/code/ryzom/client/src/interface_v3/interface_property.h @@ -22,9 +22,9 @@ #include "nel/misc/types_nl.h" #include "nel/misc/rgba.h" -#include "../cdb.h" -#include "../cdb_leaf.h" -#include "../cdb_branch.h" +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" #include "../cdb_synchronised.h" @@ -50,20 +50,20 @@ public: _VolatileValue = NULL; } - CCDBNodeLeaf* getNodePtr() const + NLMISC::CCDBNodeLeaf* getNodePtr() const { return _VolatileValue; } - void setNodePtr(CCDBNodeLeaf *ptr) + void setNodePtr(NLMISC::CCDBNodeLeaf *ptr) { _VolatileValue = ptr; } bool link (const char *DBProp); - bool link( CCDBNodeLeaf *dbNode ); - bool link( CCDBNodeBranch *dbNode, const std::string &leafId, CCDBNodeLeaf *defaultLeaf = NULL ); + bool link( NLMISC::CCDBNodeLeaf *dbNode ); + bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); /// float operations void setDouble (double value) {setSInt64((sint64&) value);} @@ -99,7 +99,7 @@ public: private: /// volatile value of the property (pointer to a leaf of the database) - CCDBNodeLeaf* _VolatileValue; + NLMISC::CCDBNodeLeaf* _VolatileValue; }; #endif // NL_INTERFACE_PROPERTY_H diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 421076364..1c2892b0d 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -17,16 +17,16 @@ #include "stdpch.h" -#include "../cdb_leaf.h" -#include "../cdb_branch.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" #include "inventory_manager.h" #include "interface_manager.h" #include "bot_chat_page_trade.h" #include "bot_chat_page_all.h" #include "group_container.h" #include "group_menu.h" -#include "../cdb_leaf.h" -#include "../cdb_branch.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" #include "list_sheet_base.h" #include "../net_manager.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.h b/code/ryzom/client/src/interface_v3/inventory_manager.h index 12de9ad98..faacb8708 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.h +++ b/code/ryzom/client/src/interface_v3/inventory_manager.h @@ -19,7 +19,7 @@ #ifndef RY_INVENTORY_MANAGER_H #define RY_INVENTORY_MANAGER_H -#include "../cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "dbgroup_list_sheet_text.h" #include "dbgroup_list_sheet.h" #include "game_share/item_infos.h" @@ -27,7 +27,9 @@ #include "game_share/inventories.h" #include "game_share/bot_chat_types.h" +namespace NLMISC{ class CCDBNodeBranch; +} class CDBCtrlSheet; @@ -55,21 +57,21 @@ const uint MAX_PLAYER_INV_ENTRIES = std::max(MAX_BAGINV_ENTRIES, MAX_ANIMALINV_E class CItemImage { public: - CCDBNodeLeaf *Sheet; - CCDBNodeLeaf *Quality; - CCDBNodeLeaf *Quantity; - CCDBNodeLeaf *UserColor; - CCDBNodeLeaf *Price; - CCDBNodeLeaf *Weight; - CCDBNodeLeaf *NameId; - CCDBNodeLeaf *InfoVersion; - CCDBNodeLeaf *ResaleFlag; + NLMISC::CCDBNodeLeaf *Sheet; + NLMISC::CCDBNodeLeaf *Quality; + NLMISC::CCDBNodeLeaf *Quantity; + NLMISC::CCDBNodeLeaf *UserColor; + NLMISC::CCDBNodeLeaf *Price; + NLMISC::CCDBNodeLeaf *Weight; + NLMISC::CCDBNodeLeaf *NameId; + NLMISC::CCDBNodeLeaf *InfoVersion; + NLMISC::CCDBNodeLeaf *ResaleFlag; public: // ctor CItemImage(); // build from a branch - void build(CCDBNodeBranch *branch); + void build(NLMISC::CCDBNodeBranch *branch); // shortcuts to avoid NULL pointer tests uint32 getSheetID() const { return (uint32) (Sheet ? Sheet->getValue32() : 0); } uint16 getQuality() const { return (uint16) (Quality ? Quality->getValue16() : 0); } @@ -302,14 +304,14 @@ private: sint32 Equip[MAX_EQUIPINV_ENTRIES]; CDBCtrlSheet *UIEquip[MAX_EQUIPINV_ENTRIES]; CDBCtrlSheet *UIEquip2[MAX_EQUIPINV_ENTRIES]; - CCDBNodeLeaf *Money; + NLMISC::CCDBNodeLeaf *Money; CItemImage PAInv[MAX_INVENTORY_ANIMAL][MAX_ANIMALINV_ENTRIES]; // SERVER INVENTORY CItemImage ServerBag[MAX_BAGINV_ENTRIES]; CItemImage ServerTempInv[MAX_TEMPINV_ENTRIES]; sint32 ServerHands[MAX_HANDINV_ENTRIES]; sint32 ServerEquip[MAX_EQUIPINV_ENTRIES]; - CCDBNodeLeaf *ServerMoney; + NLMISC::CCDBNodeLeaf *ServerMoney; CItemImage ServerPAInv[MAX_INVENTORY_ANIMAL][MAX_ANIMALINV_ENTRIES]; // Drag'n'Drop TFrom DNDFrom; @@ -343,24 +345,24 @@ private: // ItemExtraInfo management. void onTradeChangeSession(); - void onReceiveItemSheet(ICDBNode* node); - void onReceiveItemInfoSlotVersion(ICDBNode* node); + void onReceiveItemSheet(NLMISC::ICDBNode* node); + void onReceiveItemInfoSlotVersion(NLMISC::ICDBNode* node); void updateItemInfoQueue(); void updateItemInfoWaiters(uint slotId); - class CItemInfoSlotVersionObs : public ICDBNode::IPropertyObserver + class CItemInfoSlotVersionObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; - class CItemSheetObs : public ICDBNode::IPropertyObserver + class CItemSheetObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; - class CItemInfoTradeObs : public ICDBNode::IPropertyObserver + class CItemInfoTradeObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CItemInfoTradeObs _DBTradeInfoObs; CItemInfoSlotVersionObs _DBInfoSlotVersionObs; @@ -370,19 +372,19 @@ private: friend class CItemSheetObs; // Equipment observer - class CDBEquipObs : public ICDBNode::IPropertyObserver + class CDBEquipObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CDBEquipObs _DBEquipObs; friend class CDBEquipObs; // Bag observer for auto equipment (put only on the sheet leaf) - class CDBBagObs : public ICDBNode::IPropertyObserver + class CDBBagObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CDBBagObs _DBBagObs; }; @@ -441,24 +443,24 @@ private: CTempInvManager(); // Database management stuff - class CDBObs : public ICDBNode::IPropertyObserver + class CDBObs : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; - class CDBObsType : public ICDBNode::IPropertyObserver + class CDBObsType : public NLMISC::ICDBNode::IPropertyObserver { public: - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; // Database management stuff, specialized for forage progress - class CDBForageQQObs : public ICDBNode::IPropertyObserver + class CDBForageQQObs : public NLMISC::ICDBNode::IPropertyObserver { public: - CDBForageQQObs() : ICDBNode::IPropertyObserver(), WhichOne(~0), FullValue(0.0f) {} - virtual void update(ICDBNode *node); + CDBForageQQObs() : NLMISC::ICDBNode::IPropertyObserver(), WhichOne(~0), FullValue(0.0f) {} + virtual void update(NLMISC::ICDBNode *node); uint WhichOne; float FullValue; }; @@ -504,12 +506,12 @@ struct SBagOptions { CInventoryManager::TInvType InvType; - CCDBNodeLeaf *DbFilterArmor; - CCDBNodeLeaf *DbFilterWeapon; - CCDBNodeLeaf *DbFilterTool; - CCDBNodeLeaf *DbFilterMP; - CCDBNodeLeaf *DbFilterMissMP; - CCDBNodeLeaf *DbFilterTP; + NLMISC::CCDBNodeLeaf *DbFilterArmor; + NLMISC::CCDBNodeLeaf *DbFilterWeapon; + NLMISC::CCDBNodeLeaf *DbFilterTool; + NLMISC::CCDBNodeLeaf *DbFilterMP; + NLMISC::CCDBNodeLeaf *DbFilterMissMP; + NLMISC::CCDBNodeLeaf *DbFilterTP; bool LastDbFilterArmor; bool LastDbFilterWeapon; diff --git a/code/ryzom/client/src/interface_v3/obs_huge_list.h b/code/ryzom/client/src/interface_v3/obs_huge_list.h index 04ab62ad7..477eaf998 100644 --- a/code/ryzom/client/src/interface_v3/obs_huge_list.h +++ b/code/ryzom/client/src/interface_v3/obs_huge_list.h @@ -76,7 +76,7 @@ * \author Nevrax France * \date August 2003 */ -class CHugeListObs : public ICDBNode::IPropertyObserver +class CHugeListObs : public NLMISC::ICDBNode::IPropertyObserver { public: @@ -119,39 +119,39 @@ private: class CItemDBLeaves { public: - CCDBNodeLeaf *GuildIcon; // valid only for ascensor - CCDBNodeLeaf *GuildName; // valid only for ascensor + NLMISC::CCDBNodeLeaf *GuildIcon; // valid only for ascensor + NLMISC::CCDBNodeLeaf *GuildName; // valid only for ascensor // - CCDBNodeLeaf *SlotType; - CCDBNodeLeaf *Quality; - CCDBNodeLeaf *SheetIDOrSkill; + NLMISC::CCDBNodeLeaf *SlotType; + NLMISC::CCDBNodeLeaf *Quality; + NLMISC::CCDBNodeLeaf *SheetIDOrSkill; // - CCDBNodeLeaf *LogicTextID; // valid if the item is to be obtained for a mission - CCDBNodeLeaf *DescTextID; // valid if the item is to be obtained for a mission + NLMISC::CCDBNodeLeaf *LogicTextID; // valid if the item is to be obtained for a mission + NLMISC::CCDBNodeLeaf *DescTextID; // valid if the item is to be obtained for a mission // - CCDBNodeLeaf *Price; // valid if the item is to be obtained with money + NLMISC::CCDBNodeLeaf *Price; // valid if the item is to be obtained with money // - CCDBNodeLeaf *MissionText; - CCDBNodeLeaf *MissionDetailText; - CCDBNodeLeaf *MissionIcon; - CCDBNodeLeaf *MissionPreReqState; + NLMISC::CCDBNodeLeaf *MissionText; + NLMISC::CCDBNodeLeaf *MissionDetailText; + NLMISC::CCDBNodeLeaf *MissionIcon; + NLMISC::CCDBNodeLeaf *MissionPreReqState; // items only - CCDBNodeLeaf *Weight; - CCDBNodeLeaf *NameId; - CCDBNodeLeaf *InfoVersion; - CCDBNodeLeaf *UserColor; - CCDBNodeLeaf *Enchant; - CCDBNodeLeaf *RMClassType; - CCDBNodeLeaf *RMFaberStatType; - CCDBNodeLeaf *PrerequisitValid; + NLMISC::CCDBNodeLeaf *Weight; + NLMISC::CCDBNodeLeaf *NameId; + NLMISC::CCDBNodeLeaf *InfoVersion; + NLMISC::CCDBNodeLeaf *UserColor; + NLMISC::CCDBNodeLeaf *Enchant; + NLMISC::CCDBNodeLeaf *RMClassType; + NLMISC::CCDBNodeLeaf *RMFaberStatType; + NLMISC::CCDBNodeLeaf *PrerequisitValid; // items Resale only - CCDBNodeLeaf *Quantity; - CCDBNodeLeaf *PriceRetire; - CCDBNodeLeaf *ResaleTimeLeft; - CCDBNodeLeaf *VendorNameId; - CCDBNodeLeaf *FactionType; - CCDBNodeLeaf *FactionPointPrice; - CCDBNodeLeaf *SellerType; + NLMISC::CCDBNodeLeaf *Quantity; + NLMISC::CCDBNodeLeaf *PriceRetire; + NLMISC::CCDBNodeLeaf *ResaleTimeLeft; + NLMISC::CCDBNodeLeaf *VendorNameId; + NLMISC::CCDBNodeLeaf *FactionType; + NLMISC::CCDBNodeLeaf *FactionPointPrice; + NLMISC::CCDBNodeLeaf *SellerType; public: CItemDBLeaves() : GuildIcon(NULL), GuildName(NULL), @@ -182,7 +182,7 @@ private: {} }; // - virtual void update(ICDBNode *node); + virtual void update(NLMISC::ICDBNode *node); void updateUIItemPage(uint index); @@ -199,9 +199,9 @@ private: bool _Init; CItemDBLeaves _Items[TRADE_PAGE_NUM_ITEMS]; sint16 _CurrentSessionNb; - CCDBNodeLeaf *_Session; - CCDBNodeLeaf *_PageID; - CCDBNodeLeaf *_HasNext; + NLMISC::CCDBNodeLeaf *_Session; + NLMISC::CCDBNodeLeaf *_PageID; + NLMISC::CCDBNodeLeaf *_HasNext; bool _DownloadComplete; @@ -272,8 +272,8 @@ private: uint32 _PhraseClientFillFlags; uint32 _PhraseClientFillRace; uint32 _PhraseClientFillNumPhrase; - CCDBNodeLeaf *_RoleMasterFlagDB; - CCDBNodeLeaf *_RoleMasterRaceDB; + NLMISC::CCDBNodeLeaf *_RoleMasterFlagDB; + NLMISC::CCDBNodeLeaf *_RoleMasterRaceDB; }; #endif diff --git a/code/ryzom/client/src/interface_v3/sbrick_manager.h b/code/ryzom/client/src/interface_v3/sbrick_manager.h index 7d9d5943c..3ef3c3293 100644 --- a/code/ryzom/client/src/interface_v3/sbrick_manager.h +++ b/code/ryzom/client/src/interface_v3/sbrick_manager.h @@ -23,7 +23,7 @@ #include "../client_sheets/sbrick_sheet.h" #include "game_share/sabrina_com.h" #include "game_share/skills.h" -#include "../cdb.h" +#include "nel/misc/cdb.h" #include "brick_learned_callback.h" @@ -83,7 +83,7 @@ public: /** * \return the DB pointing on the BitField for this family. */ - class CCDBNodeLeaf* getKnownBrickBitFieldDB(uint family) const; + class NLMISC::CCDBNodeLeaf* getKnownBrickBitFieldDB(uint family) const; /** * \return true if the brick is learn by the player. @@ -159,7 +159,7 @@ protected: std::vector > _SheetsByFamilies; ///vector of bit fields describing the known bricks of each family - std::vector _FamiliesBits; + std::vector _FamiliesBits; /// list of roots only std::vector _Roots; @@ -195,11 +195,11 @@ protected: NLMISC::CSheetId _InterfaceRemoveBrick; // Observer when a brick is learned - struct CBrickFamilyObs : public ICDBNode::IPropertyObserver + struct CBrickFamilyObs : public NLMISC::ICDBNode::IPropertyObserver { CSBrickManager *Owner; - virtual void update (ICDBNode *node); + virtual void update (NLMISC::ICDBNode *node); }; friend struct CBrickFamilyObs; CBrickFamilyObs _BrickFamilyObs; diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index f22758350..6adf2fa32 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -24,7 +24,7 @@ #include "game_share/character_title.h" #include "game_share/fame.h" #include "../sheet_manager.h" -#include "../cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "action_handler.h" #include "sbrick_manager.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.h b/code/ryzom/client/src/interface_v3/skill_manager.h index 7c710a391..60a144603 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.h +++ b/code/ryzom/client/src/interface_v3/skill_manager.h @@ -23,7 +23,7 @@ #include "game_share/skills.h" //#include "game_share/jobs.h" #include "game_share/roles.h" -#include "../cdb.h" +#include "nel/misc/cdb.h" #include "brick_learned_callback.h" #include "skill_change_callback.h" @@ -189,16 +189,16 @@ private: uint32 _MinSkillValue[SKILLS::NUM_SKILLS]; /// Nodes on skill values and base values - CCDBNodeLeaf *_SkillValues[SKILLS::NUM_SKILLS]; - CCDBNodeLeaf *_SkillBaseValues[SKILLS::NUM_SKILLS]; + NLMISC::CCDBNodeLeaf *_SkillValues[SKILLS::NUM_SKILLS]; + NLMISC::CCDBNodeLeaf *_SkillBaseValues[SKILLS::NUM_SKILLS]; // Max child baseskill value (used when checking requirements) uint32 _MaxChildBaseSkillValue[SKILLS::NUM_SKILLS]; // CallBack set for skill changes - struct CSkillChangeObs : public ICDBNode::IPropertyObserver + struct CSkillChangeObs : public NLMISC::ICDBNode::IPropertyObserver { - virtual void update (ICDBNode * /* node */) + virtual void update (NLMISC::ICDBNode * /* node */) { CSkillManager *pSM= CSkillManager::getInstance(); pSM->onSkillChange(); @@ -214,7 +214,7 @@ private: sint32 _CacheSkillBaseValues[SKILLS::NUM_SKILLS]; // A node incremented at each change of skill (the number is not relevant) - CCDBNodeLeaf *_TrackSkillChange; + NLMISC::CCDBNodeLeaf *_TrackSkillChange; // "Title of the player" Management // ----------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.h b/code/ryzom/client/src/interface_v3/sphrase_manager.h index bf40dcc35..f14dfcf0d 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.h @@ -54,7 +54,9 @@ const std::string PHRASE_DB_COUNTER_CYCLE="SERVER:EXECUTE_PHRASE:CYCLE_COUNTER" // TODO_OPTIM: too big test for the list_sheet* each frame with 512 entries!!! class CSuccessTableSheet; +namespace NLMISC{ class CCDBNodeLeaf; +} /** Special helper class for lua export : enclose a phrase into an object accessible to lua @@ -457,11 +459,11 @@ private: CTickRange _BrickRegenRange[64]; // Shortcut To Phrases Leaves - std::vector _BookDbLeaves; - std::vector _MemoryDbLeaves; - std::vector _MemoryAltDbLeaves; - CCDBNodeLeaf *_NextExecuteLeaf; - CCDBNodeLeaf *_NextExecuteIsCyclicLeaf; + std::vector _BookDbLeaves; + std::vector _MemoryDbLeaves; + std::vector _MemoryAltDbLeaves; + NLMISC::CCDBNodeLeaf *_NextExecuteLeaf; + NLMISC::CCDBNodeLeaf *_NextExecuteIsCyclicLeaf; // extra client data struct CPhraseClient @@ -582,8 +584,8 @@ private: void updateMemoryCtrlState(uint memorySlot); // Shortcut To PhraseSheets Leaves in BotChat - std::vector _BotChatPhraseSheetLeaves; - std::vector _BotChatPhrasePriceLeaves; + std::vector _BotChatPhraseSheetLeaves; + std::vector _BotChatPhrasePriceLeaves; // For phrase compatibility with enchant weapon special power NLMISC::CSheetId _EnchantWeaponMainBrick; @@ -597,9 +599,9 @@ private: NumProgressType }; - std::vector _ProgressionDbSheets[NumProgressType]; - std::vector _ProgressionDbLevels[NumProgressType]; - std::vector _ProgressionDbLocks[NumProgressType]; + std::vector _ProgressionDbSheets[NumProgressType]; + std::vector _ProgressionDbLevels[NumProgressType]; + std::vector _ProgressionDbLocks[NumProgressType]; // For each skill, which phrase are learned when the skill is gained class CPhraseProgressInfo @@ -704,7 +706,7 @@ private: CTickRange getRegenTickRange(const CSPhraseCom &phrase) const; - CCDBNodeLeaf *getRegenTickRangeDbLeaf(uint powerIndex) const; + NLMISC::CCDBNodeLeaf *getRegenTickRangeDbLeaf(uint powerIndex) const; // get regen tick range for a specific power, from the database CTickRange getRegenTickRange(uint powerIndex) const; public: diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h b/code/ryzom/client/src/interface_v3/view_bitmap_combo.h index 5a478ef1d..767499c95 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.h @@ -20,7 +20,7 @@ #ifndef NL_VIEW_BITMAP_COMBO_H #define NL_VIEW_BITMAP_COMBO_H -#include "../cdb.h" +#include "nel/misc/cdb.h" #include "view_base.h" #include "nel/3d/u_texture.h" #include @@ -67,7 +67,7 @@ struct CComboBoxDesc { bool parse(xmlNodePtr cur, CInterfaceElement *owner); - void addObserver(ICDBNode::IPropertyObserver *obs); + void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs); void getGridSize(uint &numRow,uint &numCol) const; void getDimensions(uint &width, uint &height) const; CInterfaceProperty NumRow; @@ -94,7 +94,7 @@ struct CComboBoxDesc * \author Nevrax France * \date 2002 */ -class CViewBitmapCombo : public CViewBase, public ICDBNode::IPropertyObserver +class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver { public: typedef std::vector TIdArray; @@ -160,7 +160,7 @@ private: void setupSize(); void getDimensions(uint &numRow, uint &numCol); // From ICDBNode::IPropertyObserver - void update(ICDBNode *leaf); + void update(NLMISC::ICDBNode *leaf); // Return a color from the array, or white if it is empty static NLMISC::CRGBA getCol(const TColorArray &array, uint index); static const std::string *getTex(const TStringArray &array, uint index); diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 326f67362..533ccf194 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -28,6 +28,7 @@ using namespace std; using namespace STRING_MANAGER; +using NLMISC::CCDBNodeLeaf; NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h index 836e55d58..91d6b5f6e 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ b/code/ryzom/client/src/interface_v3/view_text_id.h @@ -22,8 +22,9 @@ #include "nel/misc/types_nl.h" #include "view_text.h" - +namespace NLMISC{ class CCDBNodeLeaf; +} // *************************************************************************** class IOnReceiveTextId @@ -91,7 +92,7 @@ public: */ bool setDBTextID(const std::string &dbPath); // set a text from a db leaf - void setDBLeaf(CCDBNodeLeaf *leaf); + void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf); std::string getTextIdDbLink() const; void setTextIdDbLink(const std::string &link); diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index d66188e09..ec8705202 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -141,7 +141,9 @@ extern bool CharNameValid; bool IsInRingSession = false; TSessionId HighestMainlandSessionId; // highest in the position stack +namespace NLMISC{ extern const char *CDBBankNames[INVALID_CDB_BANK+1]; +} void cbImpulsionGatewayOpen(NLMISC::CBitMemStream &bms); void cbImpulsionGatewayMessage(NLMISC::CBitMemStream &bms); @@ -220,7 +222,7 @@ void impulseDatabaseUpdateBank(NLMISC::CBitMemStream &impulse) } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:UPDATE_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:UPDATE_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); } } @@ -240,7 +242,7 @@ void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse) // read delta IngameDbMngr.readDelta( serverTick, impulse, (TCDBBank)bank ); - nldebug( "CDB: DB_GROUP:INIT_BANK %s", CDBBankNames[bank] ); + nldebug( "CDB: DB_GROUP:INIT_BANK %s", NLMISC::CDBBankNames[bank] ); // read guild inventory update if ( bank == CDBGuild ) @@ -250,7 +252,7 @@ void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse) } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:INIT_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:INIT_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); } } @@ -270,11 +272,11 @@ void impulseDatabaseResetBank(NLMISC::CBitMemStream &impulse) // reset the bank IngameDbMngr.getNodePtr()->resetBank( serverTick, (TCDBBank)bank ); - nldebug( "CDB: DB_GROUP:RESET_BANK %s", CDBBankNames[bank] ); + nldebug( "CDB: DB_GROUP:RESET_BANK %s", NLMISC::CDBBankNames[bank] ); } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:RESET_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:RESET_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); } } diff --git a/code/ryzom/client/src/net_manager.h b/code/ryzom/client/src/net_manager.h index e51bdc22a..1d7852a76 100644 --- a/code/ryzom/client/src/net_manager.h +++ b/code/ryzom/client/src/net_manager.h @@ -244,7 +244,7 @@ public: //void clearChanges() { ALL_MANAGERS->clearChanges(); } void setImpulseCallback(CNetworkConnection::TImpulseCallback callback, void *argument = NULL) { FIRST_MANAGER->setImpulseCallback( callback, argument ); } - void setDataBase(CCDBNodeBranch *database) { ALL_MANAGERS->setDataBase( database ); } + void setDataBase(NLMISC::CCDBNodeBranch *database) { ALL_MANAGERS->setDataBase( database ); } bool connect(std::string &result) { bool res = false; std::vector::iterator inm; for( inm=_NetManagers.begin(); inm!=_NetManagers.end(); ++inm ) if ( (*inm)->connect( result ) ) res = true; return res; } CNetworkConnection::TConnectionState getConnectionState() const { return FIRST_MANAGER->getConnectionState(); } diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index f633126e5..9f20a7a3d 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -41,9 +41,9 @@ #include "game_share/simlag.h" -#include "cdb.h" -#include "cdb_leaf.h" -#include "cdb_branch.h" +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" #include "cdb_synchronised.h" #include "nel/misc/variable.h" diff --git a/code/ryzom/client/src/network_connection.h b/code/ryzom/client/src/network_connection.h index 755994275..1c1581664 100644 --- a/code/ryzom/client/src/network_connection.h +++ b/code/ryzom/client/src/network_connection.h @@ -60,7 +60,9 @@ const uint PropertiesPerEntity = 16; const uint EntitiesPerClient = 256; */ +namespace NLMISC{ class CCDBNodeBranch; +} namespace CLFECOMMON { @@ -364,7 +366,7 @@ public: /** * Set database entry point */ - void setDataBase(CCDBNodeBranch *database); + void setDataBase(NLMISC::CCDBNodeBranch *database); //@} @@ -669,7 +671,7 @@ protected: CPropertyDecoder _PropertyDecoder; /// The database entry - CCDBNodeBranch *_DataBase; + NLMISC::CCDBNodeBranch *_DataBase; /// @name Header message decoding diff --git a/code/ryzom/client/src/npc_icon.h b/code/ryzom/client/src/npc_icon.h index 07a5ec4eb..dbd0a35bf 100644 --- a/code/ryzom/client/src/npc_icon.h +++ b/code/ryzom/client/src/npc_icon.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "game_share/entity_types.h" #include "game_share/msg_client_server.h" -#include "cdb.h" +#include "nel/misc/cdb.h" #include "entity_cl.h" #include "interface_v3/view_radar.h" #include @@ -51,6 +51,7 @@ namespace NPC_ICON }; }; +using NLMISC::ICDBNode; /** * Description of a mission giver NPC. diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.cpp b/code/ryzom/client/src/r2/displayer_visual_entity.cpp index 20f84c90f..7a27f1c11 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -27,7 +27,7 @@ #include "../misc.h" #include "../entities.h" #include "../pacs_client.h" -#include "../cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "../interface_v3/interface_manager.h" #include "entity_sorter.h" // diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h index d909a9980..89b470db0 100644 --- a/code/ryzom/client/src/r2/editor.h +++ b/code/ryzom/client/src/r2/editor.h @@ -887,7 +887,7 @@ private: public: static uint getMaxNumPlotItems(); - static CCDBNodeLeaf *getPlotItemSheetDBLeaf(uint index); + static NLMISC::CCDBNodeLeaf *getPlotItemSheetDBLeaf(uint index); static bool getIsStartingScenario() { return _IsStartingScenario; } bool isClearingContent() const { return _ClearingContent; } @@ -897,7 +897,7 @@ private: static void initDummyPlotItems(); void resetPlotItems(); static void setReferencePlotItemSheet(uint index, uint32 sheetId); - static CCDBNodeLeaf *getRefPlotItemSheetDBLeaf(uint index); + static NLMISC::CCDBNodeLeaf *getRefPlotItemSheetDBLeaf(uint index); ////////// // MISC // diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index 9633d242e..73b55a0d7 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -28,7 +28,7 @@ #include "../player_r2_cl.h" #include "../sheet_manager.h" #include "../interface_v3/lua_ihm.h" -#include "../cdb_leaf.h" +#include "nel/misc/cdb_leaf.h" #include "../interface_v3/interface_manager.h" #include "dmc/palette.h" #include "displayer_visual.h" diff --git a/code/ryzom/client/src/user_entity.h b/code/ryzom/client/src/user_entity.h index 30c9fed41..6dd039c23 100644 --- a/code/ryzom/client/src/user_entity.h +++ b/code/ryzom/client/src/user_entity.h @@ -29,7 +29,7 @@ // 3D Interface. #include "nel/3d/u_visual_collision_entity.h" // Client DB -#include "cdb.h" +#include "nel/misc/cdb.h" // Client #include "player_cl.h" #include "client_cfg.h" @@ -163,7 +163,7 @@ public: CEntityCL* getMountEntity(); /// Return the DB entry for the specified user's animal (NULL if not found) - CCDBNodeBranch *getBeastDBEntry( CLFECOMMON::TClientDataSetIndex uid ); + NLMISC::CCDBNodeBranch *getBeastDBEntry( CLFECOMMON::TClientDataSetIndex uid ); /** To Inform about an entity removed (to remove from selection for example). * This will remove the entity from the target. @@ -486,7 +486,7 @@ public: } protected: - class CSpeedFactor : public ICDBNode::IPropertyObserver + class CSpeedFactor : public NLMISC::ICDBNode::IPropertyObserver { public: /// Initialize @@ -498,7 +498,7 @@ protected: virtual void serial(class NLMISC::IStream &f) throw(NLMISC::EStream) {f.serial(_Value);} protected: /// Method called when the ping message is back. - virtual void update(ICDBNode* leaf); + virtual void update(NLMISC::ICDBNode* leaf); private: float _Value; }; @@ -515,7 +515,7 @@ protected: virtual void serial(class NLMISC::IStream &/* f */) throw(NLMISC::EStream) {} }; - class CMountSpeeds : public ICDBNode::IPropertyObserver + class CMountSpeeds : public NLMISC::ICDBNode::IPropertyObserver { public: /// Initialize @@ -528,7 +528,7 @@ protected: float getRunSpeed() const { return _RunSpeed; } protected: /// Method called when the value is changed - virtual void update(ICDBNode* leaf); + virtual void update(NLMISC::ICDBNode* leaf); private: float _WalkSpeed; float _RunSpeed; @@ -587,31 +587,31 @@ protected: /// CSkill points observer - class CSkillPointsObserver : public ICDBNode::IPropertyObserver + class CSkillPointsObserver : public NLMISC::ICDBNode::IPropertyObserver { public : uint SpType; /// From ICDBNode::IPropertyObserver - virtual void update(ICDBNode* node ); + virtual void update(NLMISC::ICDBNode* node ); }; CSkillPointsObserver _SkillPointObs[EGSPD::CSPType::EndSPType]; - class CInvisibleObserver : public ICDBNode::IPropertyObserver + class CInvisibleObserver : public NLMISC::ICDBNode::IPropertyObserver { public : - virtual void update(ICDBNode* node); + virtual void update(NLMISC::ICDBNode* node); }; CInvisibleObserver _InvisibleObs; /// Fame observer - class CFameObserver : public ICDBNode::IPropertyObserver + class CFameObserver : public NLMISC::ICDBNode::IPropertyObserver { public : uint32 FactionIndex; /// From ICDBNode::IPropertyObserver - virtual void update(ICDBNode* node ); + virtual void update(NLMISC::ICDBNode* node ); }; std::vector _FamesObs; diff --git a/code/ryzom/client/src/village.h b/code/ryzom/client/src/village.h index 20251ccfc..216551f8e 100644 --- a/code/ryzom/client/src/village.h +++ b/code/ryzom/client/src/village.h @@ -25,7 +25,7 @@ #include "nel/misc/types_nl.h" #include "streamable_ig.h" -#include "cdb.h" +#include "nel/misc/cdb.h" #include "client_sheets/continent_sheet.h" #include "game_share/misc_const.h" #include diff --git a/code/ryzom/common/src/game_share/ryzom_database_banks.cpp b/code/ryzom/common/src/game_share/ryzom_database_banks.cpp index 46fddd789..cffa4e138 100644 --- a/code/ryzom/common/src/game_share/ryzom_database_banks.cpp +++ b/code/ryzom/common/src/game_share/ryzom_database_banks.cpp @@ -17,7 +17,9 @@ #include "stdpch.h" #include "ryzom_database_banks.h" +namespace NLMISC{ const char *CDBBankNames[INVALID_CDB_BANK+1] = { "PLR", "GUILD", /* "CONTINENT", */ "OUTPOST", /* "GLOBAL", */ "", "INVALID" }; +} // leave not static else this workaround don't work From 4e6e7d9a6ee21473b96fb2c873743efa17fe448d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 17 Apr 2012 08:23:02 +0200 Subject: [PATCH 016/339] Extracted the CDB bank handling code into a new class CCDBBankHandler, the CDB system should be now totally independent of Ryzom. --- code/nel/include/nel/misc/cdb.h | 3 +- code/nel/include/nel/misc/cdb_bank_handler.h | 79 +++++++++++++++ code/nel/include/nel/misc/cdb_branch.h | 40 ++------ code/nel/include/nel/misc/cdb_leaf.h | 2 +- code/nel/src/misc/cdb_bank_handler.cpp | 96 +++++++++++++++++++ code/nel/src/misc/cdb_branch.cpp | 80 +++------------- code/nel/src/misc/cdb_leaf.cpp | 2 +- code/ryzom/client/src/cdb_synchronised.cpp | 17 +++- code/ryzom/client/src/cdb_synchronised.h | 5 + code/ryzom/client/src/net_manager.cpp | 14 ++- .../src/game_share/ryzom_database_banks.cpp | 2 - 11 files changed, 224 insertions(+), 116 deletions(-) create mode 100644 code/nel/include/nel/misc/cdb_bank_handler.h create mode 100644 code/nel/src/misc/cdb_bank_handler.cpp diff --git a/code/nel/include/nel/misc/cdb.h b/code/nel/include/nel/misc/cdb.h index dc95e51e9..d23986b0c 100644 --- a/code/nel/include/nel/misc/cdb.h +++ b/code/nel/include/nel/misc/cdb.h @@ -33,6 +33,7 @@ class IProgressCallback; class CBitMemStream; class CCDBNodeLeaf; class CCDBNodeBranch; +class CCDBBankHandler; ///global bool, must be set to true if we want to display database modification. See displayDBModifs in commands.cpp extern bool VerboseDatabase; @@ -197,7 +198,7 @@ public : * Build the structure of the database from a file * \param f is the stream */ - virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false ) = 0; + virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ) = 0; /** * Save a backup of the database diff --git a/code/nel/include/nel/misc/cdb_bank_handler.h b/code/nel/include/nel/misc/cdb_bank_handler.h new file mode 100644 index 000000000..560a81b46 --- /dev/null +++ b/code/nel/include/nel/misc/cdb_bank_handler.h @@ -0,0 +1,79 @@ +// Ryzom - MMORPG Framework +// 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 CDB_BANK_HANDLER +#define CDB_BANK_HANDLER + +#include +#include "nel/misc/types_nl.h" + +namespace NLMISC{ + +class CCDBBankHandler{ +public: + CCDBBankHandler( uint maxbanks ); + + ~CCDBBankHandler(){} + + uint getUIDForBank( uint bank ) const; + + uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; } + + uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; } + + uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; } + + std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; } + + uint getBankByName( const std::string &name ) const; + + void mapNodeByBank( const std::string &bankName ); + + void fillBankNames( const char **strings, uint size ); + + void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); } + + void reset(); + + uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); } + + void calcIdBitsByBank(); + + uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; } + +private: + /// Mapping from server database index to client database index (first-level nodes) + std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping; + + /// Mapping from client database index to bank IDs (first-level nodes) + std::vector< uint > _UnifiedIndexToBank; + + /// Last index mapped + uint _CDBLastUnifiedIndex; + + /// Number of bits for first-level branches, by bank + std::vector< uint > _FirstLevelIdBitsByBank; + + /// Names of the CDB banks + std::vector< std::string > _CDBBankNames; + + uint maxBanks; +}; + +} + +#endif + diff --git a/code/nel/include/nel/misc/cdb_branch.h b/code/nel/include/nel/misc/cdb_branch.h index 7d7187aa1..632d6e9a3 100644 --- a/code/nel/include/nel/misc/cdb_branch.h +++ b/code/nel/include/nel/misc/cdb_branch.h @@ -23,11 +23,6 @@ namespace NLMISC{ -enum{ - CDB_BANKS_MAX = 3, - CDB_BANK_INVALID -}; - /** * Database Node which contains a set of properties * \author Stephane Coutelas @@ -56,7 +51,7 @@ public: * Build the structure of the database from a file * \param f is the stream */ - void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false ); + void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ); /** * Add a new sub node @@ -105,7 +100,7 @@ public: void write( CTextId& id, FILE * f); /// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping) - void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank ); + void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler ); /// Update the database from a stream coming from the FE void readDelta( TGameCycle gc, CBitMemStream & f ); @@ -130,15 +125,12 @@ public: /// Clear the node and his children void clear(); - /// Reset the data corresponding to the bank (works only on top level node) - void resetBank( TGameCycle gc, uint bank) + void resetNode( TGameCycle gc, uint node ) { - //nlassert( getParent() == NULL ); - for ( uint i=0; i!=_Nodes.size(); ++i ) - { - if ( _UnifiedIndexToBank[i] == bank ) - _Nodes[i]->resetData(gc); - } + if( node > _Nodes.size() ) + return; + + _Nodes[ node ]->resetData( gc ); } /// Reset all leaf data from this point @@ -237,15 +229,9 @@ public: /// Find a subnode at this level ICDBNode * find (const std::string &nodeName); - /// Main init - static void resetNodeBankMapping() { _UnifiedIndexToBank.clear(); } - // reset all static mappings static void reset(); - /// Internal use only - static void mapNodeByBank( ICDBNode *node, const std::string& bankStr, bool clientOnly, uint nodeIndex ); - protected: @@ -328,18 +314,6 @@ protected: static CDBBranchObsInfo *_CurrNotifiedObs; static CDBBranchObsInfo *_NextNotifiedObs; - /// Mapping from server database index to client database index (first-level nodes) - static std::vector _CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX]; - - // Mapping from client database index to TCDBBank (first-level nodes) - static std::vector _UnifiedIndexToBank; - - /// Last index mapped - static uint _CDBLastUnifiedIndex; - - /// Number of bits for first-level branches, by bank - static uint _FirstLevelIdBitsByBank [CDB_BANKS_MAX]; - /// called by clear void removeAllBranchObserver(); void removeBranchInfoIt(TObsList::iterator it); diff --git a/code/nel/include/nel/misc/cdb_leaf.h b/code/nel/include/nel/misc/cdb_leaf.h index fed2b908d..566394d97 100644 --- a/code/nel/include/nel/misc/cdb_leaf.h +++ b/code/nel/include/nel/misc/cdb_leaf.h @@ -101,7 +101,7 @@ public: * Build the structure of the database from a file * \param f is the stream */ - void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false ); + void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ); /** * Get a node diff --git a/code/nel/src/misc/cdb_bank_handler.cpp b/code/nel/src/misc/cdb_bank_handler.cpp new file mode 100644 index 000000000..f090ece4c --- /dev/null +++ b/code/nel/src/misc/cdb_bank_handler.cpp @@ -0,0 +1,96 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/cdb_bank_handler.h" + +namespace NLMISC{ + CCDBBankHandler::CCDBBankHandler(uint maxbanks) : +_CDBBankToUnifiedIndexMapping( maxbanks, std::vector< uint >() ), +_FirstLevelIdBitsByBank( maxbanks ) + { + std::fill( _FirstLevelIdBitsByBank.begin(), _FirstLevelIdBitsByBank.end(), 0 ); + maxBanks = maxbanks; + } + + uint CCDBBankHandler::getUIDForBank( uint bank ) const + { + uint uid = static_cast< uint >( -1 ); + + for( uint i = 0; i < _UnifiedIndexToBank.size(); i++ ) + if( _UnifiedIndexToBank[ i ] == bank ) + return i; + + return uid; + } + + uint CCDBBankHandler::getBankByName( const std::string &name ) const + { + uint b = static_cast< uint >( -1 ); + + for( uint i = 0; i < _CDBBankNames.size(); i++ ) + if( _CDBBankNames[ i ].compare( name ) == 0 ) + return i; + + return b; + } + + void CCDBBankHandler::mapNodeByBank( const std::string &bankName ) + { + uint b = getBankByName( bankName ); + // no such bank + if( b == static_cast< uint >( -1 ) ) + return; + + _CDBBankToUnifiedIndexMapping[ b ].push_back( _CDBLastUnifiedIndex ); + ++_CDBLastUnifiedIndex; + _UnifiedIndexToBank.push_back( b ); + } + + void CCDBBankHandler::fillBankNames( const char **strings, uint size ) + { + _CDBBankNames.clear(); + + for( uint i = 0; i < size; i++ ) + _CDBBankNames.push_back( std::string( strings[ i ] ) ); + } + + void CCDBBankHandler::reset() + { + for( std::vector< std::vector< uint > >::iterator itr =_CDBBankToUnifiedIndexMapping.begin(); + itr != _CDBBankToUnifiedIndexMapping.end(); ++itr ) + itr->clear(); + + _UnifiedIndexToBank.clear(); + _CDBLastUnifiedIndex = 0; + } + + void CCDBBankHandler::calcIdBitsByBank() + { + for( uint bank = 0; bank != maxBanks; bank++ ) + { + uint nbNodesOfBank = static_cast< uint >( _CDBBankToUnifiedIndexMapping[ bank ].size() ); + uint idb = 0; + + if ( nbNodesOfBank > 0 ) + for ( idb = 1; nbNodesOfBank > unsigned( 1 << idb ) ; idb++ ) + ; + + _FirstLevelIdBitsByBank[ bank ] = idb; + } + } +} + + diff --git a/code/nel/src/misc/cdb_branch.cpp b/code/nel/src/misc/cdb_branch.cpp index 45bef670a..738c66b2f 100644 --- a/code/nel/src/misc/cdb_branch.cpp +++ b/code/nel/src/misc/cdb_branch.cpp @@ -44,6 +44,7 @@ using namespace std; #include "nel/misc/progress_callback.h" #include "nel/misc/bit_mem_stream.h" #include "nel/misc/bit_set.h" +#include "nel/misc/cdb_bank_handler.h" #include //#include @@ -70,30 +71,11 @@ CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL; // uint CCDBNodeBranch::_CurrNotifiedObsList = 0; -// Mapping from server database index to client database index (first-level nodes) -vector CCDBNodeBranch::_CDBBankToUnifiedIndexMapping [CDB_BANKS_MAX]; - -// Mapping from client database index to TCDBBank (first-level nodes) -vector CCDBNodeBranch::_UnifiedIndexToBank; - -// Last index mapped -uint CCDBNodeBranch::_CDBLastUnifiedIndex = 0; - -// Number of bits for first-level branches, by bank -uint CCDBNodeBranch::_FirstLevelIdBitsByBank [CDB_BANKS_MAX]; - -extern const char *CDBBankNames[CDB_BANK_INVALID+1]; - std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers; // reset all static data void CCDBNodeBranch::reset() { - for ( uint b=0; bmapNodeByBank( bankName ); //nldebug( "CDB: Mapping %s for %s (node %u)", newName.c_str(), bankName.c_str(), nodes.size()-1 ); } else @@ -161,7 +118,7 @@ static /*inline*/ void addNode( ICDBNode *newNode, std::string newName, CCDBNode } } -void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks ) +void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks, CCDBBankHandler *bankHandler ) { xmlNodePtr child; @@ -200,7 +157,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, // nlinfo("+ %s%d",name,i); string newName = string(name.getDatas())+toString(i); - addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks ); + addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks, bankHandler ); // nlinfo("-"); // Progress bar @@ -212,7 +169,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, // dealing with a single entry // nlinfo("+ %s",name); string newName = string(name.getDatas()); - addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks ); + addNode( new CCDBNodeBranch(newName), newName, this, _Nodes, _NodesByName, child, sBank, sAtom=="1", sClientonly=="1", progressCallBack, mapBanks, bankHandler ); // nlinfo("-"); } @@ -249,7 +206,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, // nlinfo(" %s%d",name,i); string newName = string(name.getDatas())+toString(i); - addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks ); + addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks, bankHandler ); // Progress bar progressCallBack.popCropedValues (); @@ -259,7 +216,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, { // nlinfo(" %s",name); string newName = string(name.getDatas()); - addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks ); + addNode( new CCDBNodeLeaf(newName), newName, this, _Nodes, _NodesByName, child, sBank, false, false, progressCallBack, mapBanks, bankHandler ); } // Progress bar @@ -269,18 +226,11 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack, // count number of bits required to store the id if ( (mapBanks) && (getParent() == NULL) ) - { - nlassertex( _UnifiedIndexToBank.size() == countNode, ("Mapped: %u Nodes: %u", _UnifiedIndexToBank.size(), countNode) ); - + { + nlassert( bankHandler != NULL ); + nlassertex( bankHandler->getUnifiedIndexToBankSize() == countNode, ("Mapped: %u Nodes: %u", bankHandler->getUnifiedIndexToBankSize(), countNode) ); + bankHandler->calcIdBitsByBank(); _IdBits = 0; - for ( uint b=0; b!=CDB_BANKS_MAX; ++b ) - { - uint nbNodesOfBank = (uint)_CDBBankToUnifiedIndexMapping[b].size(); - uint idb = 0; - if ( nbNodesOfBank > 0 ) - for ( idb=1; nbNodesOfBank > unsigned(1<getFirstLevelIdBits( bank ) ); // Translate bank index -> unified index - idx = _CDBBankToUnifiedIndexMapping[bank][idx]; + idx = bankHandler->getServerToClientUIDMapping( bank, idx ); if (idx >= _Nodes.size()) { throw Exception ("idx %d > _Nodes.size() %d ", idx, _Nodes.size()); diff --git a/code/nel/src/misc/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp index 96a4b4428..992699627 100644 --- a/code/nel/src/misc/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -41,7 +41,7 @@ namespace NLMISC{ //----------------------------------------------- // init //----------------------------------------------- -void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBack */, bool /* mapBanks */ ) +void CCDBNodeLeaf::init( xmlNodePtr node, IProgressCallback &/* progressCallBack */, bool /* mapBanks */, CCDBBankHandler * /* bankHandler */ ) { CXMLAutoPtr type((const char*)xmlGetProp (node, (xmlChar*)"type")); nlassert((const char *) type != NULL); diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index caf487b81..2379d34a4 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -40,6 +40,8 @@ #include +#include "../../common/src/game_share/ryzom_database_banks.h" + //////////////// // Namespaces // @@ -56,11 +58,11 @@ uint32 NbDatabaseChanges = 0; // CCDBSynchronised // //----------------------------------------------- -CCDBSynchronised::CCDBSynchronised() : _Database(0), _InitInProgress(true), _InitDeltaReceived(0) +CCDBSynchronised::CCDBSynchronised() : _Database(0), _InitInProgress(true), _InitDeltaReceived(0), bankHandler( NB_CDB_BANKS ) { } - +extern const char *CDBBankNames[INVALID_CDB_BANK+1]; //----------------------------------------------- // init @@ -78,9 +80,10 @@ void CCDBSynchronised::init( const string &fileName, NLMISC::IProgressCallback & read.init (file); //Parse the parser output!!! - CCDBNodeBranch::resetNodeBankMapping(); // in case the game is restarted from start + bankHandler.resetNodeBankMapping(); // in case the game is restarted from start + bankHandler.fillBankNames( CDBBankNames, INVALID_CDB_BANK + 1 ); _Database = new CCDBNodeBranch("SERVER"); - _Database->init( read.getRootNode (), progressCallBack, true ); + _Database->init( read.getRootNode (), progressCallBack, true, &bankHandler ); } } catch (const Exception &e) @@ -193,7 +196,7 @@ void CCDBSynchronised::readDelta( NLMISC::TGameCycle gc, CBitMemStream& s, uint for( uint i=0; i!=propertyCount; ++i ) { - _Database->readAndMapDelta( gc, s, bank ); + _Database->readAndMapDelta( gc, s, bank, &bankHandler ); } /*// Read "client only" property changes @@ -307,6 +310,7 @@ void CCDBSynchronised::clear() // clear CCDBNodeBranch static data CCDBNodeBranch::reset(); + bankHandler.reset(); } @@ -320,6 +324,9 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB() } +void CCDBSynchronised::resetBank( uint gc, uint bank ){ + _Database->resetNode( gc, bankHandler.getUIDForBank( bank ) ); +} #ifdef TRACE_READ_DELTA #undef TRACE_READ_DELTA diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index d65dc1523..b9d11e5b6 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -22,6 +22,7 @@ #include "nel/misc/cdb.h" #include "nel/misc/cdb_branch.h" +#include "nel/misc/cdb_bank_handler.h" /** * Class to manage a database of properties @@ -144,6 +145,8 @@ public: } } + void resetBank( uint gc, uint bank ); + private: friend void impulseDatabaseInitPlayer( NLMISC::CBitMemStream &impulse ); @@ -153,6 +156,8 @@ private: bool allInitPacketReceived() const { return _InitDeltaReceived == 2; } // Classic database + inventory void writeInitInProgressIntoUIDB(); + + NLMISC::CCDBBankHandler bankHandler; }; diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index ec8705202..8116ccaea 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -141,9 +141,7 @@ extern bool CharNameValid; bool IsInRingSession = false; TSessionId HighestMainlandSessionId; // highest in the position stack -namespace NLMISC{ extern const char *CDBBankNames[INVALID_CDB_BANK+1]; -} void cbImpulsionGatewayOpen(NLMISC::CBitMemStream &bms); void cbImpulsionGatewayMessage(NLMISC::CBitMemStream &bms); @@ -222,7 +220,7 @@ void impulseDatabaseUpdateBank(NLMISC::CBitMemStream &impulse) } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:UPDATE_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:UPDATE_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); } } @@ -242,7 +240,7 @@ void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse) // read delta IngameDbMngr.readDelta( serverTick, impulse, (TCDBBank)bank ); - nldebug( "CDB: DB_GROUP:INIT_BANK %s", NLMISC::CDBBankNames[bank] ); + nldebug( "CDB: DB_GROUP:INIT_BANK %s", CDBBankNames[bank] ); // read guild inventory update if ( bank == CDBGuild ) @@ -252,7 +250,7 @@ void impulseDatabaseInitBank(NLMISC::CBitMemStream &impulse) } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:INIT_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:INIT_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); } } @@ -271,12 +269,12 @@ void impulseDatabaseResetBank(NLMISC::CBitMemStream &impulse) impulse.serial( bank, nbits ); // reset the bank - IngameDbMngr.getNodePtr()->resetBank( serverTick, (TCDBBank)bank ); - nldebug( "CDB: DB_GROUP:RESET_BANK %s", NLMISC::CDBBankNames[bank] ); + IngameDbMngr.resetBank( serverTick, bank ); + nldebug( "CDB: DB_GROUP:RESET_BANK %s", CDBBankNames[bank] ); } catch (const Exception &e) { - BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:RESET_BANK %s msg, skipped: %s", NLMISC::CDBBankNames[bank], e.what() ), return ); + BOMB( NLMISC::toString( "Problem while decoding a DB_GROUP:RESET_BANK %s msg, skipped: %s", CDBBankNames[bank], e.what() ), return ); } } diff --git a/code/ryzom/common/src/game_share/ryzom_database_banks.cpp b/code/ryzom/common/src/game_share/ryzom_database_banks.cpp index cffa4e138..46fddd789 100644 --- a/code/ryzom/common/src/game_share/ryzom_database_banks.cpp +++ b/code/ryzom/common/src/game_share/ryzom_database_banks.cpp @@ -17,9 +17,7 @@ #include "stdpch.h" #include "ryzom_database_banks.h" -namespace NLMISC{ const char *CDBBankNames[INVALID_CDB_BANK+1] = { "PLR", "GUILD", /* "CONTINENT", */ "OUTPOST", /* "GLOBAL", */ "", "INVALID" }; -} // leave not static else this workaround don't work From e056c07e2f7b62e863eb0715c2a644daa5b59368 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 18 Apr 2012 04:15:34 +0200 Subject: [PATCH 017/339] Documented CCDBBankHandler class. --- code/nel/include/nel/misc/cdb_bank_handler.h | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/code/nel/include/nel/misc/cdb_bank_handler.h b/code/nel/include/nel/misc/cdb_bank_handler.h index 560a81b46..102026f4d 100644 --- a/code/nel/include/nel/misc/cdb_bank_handler.h +++ b/code/nel/include/nel/misc/cdb_bank_handler.h @@ -22,36 +22,95 @@ namespace NLMISC{ +/** + @brief Manages the bank names and mappings of the CDB it's associated with + + Banks are numeric identifiers for the top-level branches of the CDB. + They are used for saving bandwidth, because the local CDBs are updated with deltas, + that identify the updatable top-level branch with this id. + The CCDBBankHandler manages the mapping of banks to their names, unified (node) index, + and the other way around. + + */ class CCDBBankHandler{ public: + /** + @brief The class' constructor + @param maxbanks the maximum number of banks we need to handle + */ CCDBBankHandler( uint maxbanks ); + /// Very surprisingly this is the destructor ~CCDBBankHandler(){} + /** + @brief Returns the unified (node) index for the specified bank Id. + @param bank The bank whose uid we need. + @return Returns an uid or static_cast< uint >( -1 ) on failure. + */ uint getUIDForBank( uint bank ) const; + /** + @brief Returns the bank Id for the specified unified (node) index. + @param uid The unified (node) index we need to translate to bank Id. + @return Returns a bank Id. + */ uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; } + /// Returns the last unified (node) index we mapped. uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; } + /** + @brief Returns the number of bits used to store the number of nodes that belong to this bank. + @param bank The banks whose id bits we need. + @return Returns the number of bits used to store the number of nodes that belong to this bank. + */ uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; } + /** + @brief Returns the name of the specified bank. + @param bank The id of the bank we need the name of. + @return Returns the name of the specified bank. + */ std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; } + /** + @brief Looks up the bank Id of the bank name specified. + @param name The name of the bank whose Id we need. + @return Returns the id of the bank, or static_cast< uint >( -1 ) on fail. + */ uint getBankByName( const std::string &name ) const; + /** + @brief Maps the specified bank name to a unified (node) index and vica versa. + @param bankName Name of the bank to map. + */ void mapNodeByBank( const std::string &bankName ); + /** + @brief Loads the known bank names from an array ( the order decides the bank Id ). + @param strings The array of the banks names. + @param size The size of the array. + */ void fillBankNames( const char **strings, uint size ); + /// Resets the node to bank mapping vector void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); } + /// Resets all maps, and sets _CDBLastUnifiedIndex to 0. void reset(); uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); } + /// Calculates the number of bits used to store the number of nodes that belong to the banks. void calcIdBitsByBank(); + /** + @brief Looks up the unified (node) index of a bank node. + @param bank The bank id of the node we are looking up. + @param index The index of the node within the bank. + @return Returns the unified (node) index of the specified bank node. + */ uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; } private: @@ -70,6 +129,7 @@ private: /// Names of the CDB banks std::vector< std::string > _CDBBankNames; + /// The number of banks used uint maxBanks; }; From d2d4838252ad70ab05b226d006cd1c69a859259f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Apr 2012 06:45:35 +0200 Subject: [PATCH 018/339] Refactored the static branch observing code into a new class CCDBBranchObservingHandler. The CDB system *should* be fully reusable now! --- code/nel/include/nel/misc/cdb_branch.h | 111 ++------ .../nel/misc/cdb_branch_observing_handler.h | 128 +++++++++ code/nel/src/misc/cdb_branch.cpp | 243 +++--------------- .../src/misc/cdb_branch_observing_handler.cpp | 201 +++++++++++++++ code/nel/src/misc/cdb_leaf.cpp | 4 +- code/ryzom/client/src/cdb_synchronised.cpp | 85 +++++- code/ryzom/client/src/cdb_synchronised.h | 15 ++ code/ryzom/client/src/connection.cpp | 27 +- code/ryzom/client/src/far_tp.cpp | 6 +- .../client/src/ingame_database_manager.h | 1 + code/ryzom/client/src/init_main_loop.cpp | 6 +- .../src/interface_v3/action_phrase_faber.cpp | 8 +- .../interface_v3/bot_chat_page_mission.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 5 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../client/src/interface_v3/guild_manager.cpp | 12 +- .../client/src/interface_v3/interface_ddx.cpp | 3 +- .../src/interface_v3/interface_link.cpp | 8 +- .../client/src/interface_v3/interface_link.h | 3 +- .../src/interface_v3/interface_manager.cpp | 119 ++++++++- .../src/interface_v3/interface_manager.h | 14 + .../src/interface_v3/inventory_manager.cpp | 3 +- .../client/src/interface_v3/macrocmd_key.cpp | 6 +- .../src/interface_v3/macrocmd_manager.cpp | 3 +- .../src/interface_v3/sbrick_manager.cpp | 2 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- code/ryzom/client/src/login.cpp | 13 +- code/ryzom/client/src/main_loop.cpp | 12 +- code/ryzom/client/src/npc_icon.cpp | 14 +- code/ryzom/client/src/progress.cpp | 4 +- code/ryzom/client/src/r2/editor.cpp | 6 +- 32 files changed, 688 insertions(+), 382 deletions(-) create mode 100644 code/nel/include/nel/misc/cdb_branch_observing_handler.h create mode 100644 code/nel/src/misc/cdb_branch_observing_handler.cpp diff --git a/code/nel/include/nel/misc/cdb_branch.h b/code/nel/include/nel/misc/cdb_branch.h index 632d6e9a3..a2255ca09 100644 --- a/code/nel/include/nel/misc/cdb_branch.h +++ b/code/nel/include/nel/misc/cdb_branch.h @@ -32,11 +32,20 @@ namespace NLMISC{ class CCDBNodeBranch : public ICDBNode { public: - /// Triggered when the branch observers are updated - class IBranchObserverCallFlushObserver : public CRefCount{ + + class ICDBDBBranchObserverHandle + { public: - virtual ~IBranchObserverCallFlushObserver(){} - virtual void onObserverCallFlush() = 0; + virtual ~ICDBDBBranchObserverHandle(){} + + virtual ICDBNode* owner() = 0; + virtual IPropertyObserver* observer() = 0; + virtual bool observesLeaf( const std::string &leafName ) = 0; + virtual bool inList( uint list ) = 0; + virtual void addToFlushableList() = 0; + virtual void removeFromFlushableList( uint list ) = 0; + virtual void removeFromFlushableList() = 0; + }; // default constructor @@ -194,7 +203,7 @@ public: * and setting a branch observer on it, except you don't need to change your database paths * and update large amounts of code!). */ - void addBranchObserver(IPropertyObserver* observer, const std::vector& positiveLeafNameFilter=std::vector()); + void addBranchObserver( ICDBDBBranchObserverHandle* handle, const std::vector& positiveLeafNameFilter=std::vector()); /** * Easy version of addBranchObserver() (see above). @@ -202,7 +211,7 @@ public: * "" -> this node * "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node */ - void addBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0); + void addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0); // Remove observer from all sub-leaves bool removeBranchObserver(IPropertyObserver* observer); @@ -212,83 +221,14 @@ public: virtual bool isLeaf() const { return false; } - /** Update all observers of branchs that have been modified - */ - static void flushObserversCalls(); - -private: - static void triggerFlushObservers(); - -public: - static void addFlushObserver( IBranchObserverCallFlushObserver *observer ); - static void removeFlushObserver( IBranchObserverCallFlushObserver *observer ); - // mark this branch and parent branch as 'modified'. This is usually called by sub-leaves - void linkInModifiedNodeList(TStringId modifiedLeafName); + void onLeafChanged( TStringId leafName ); /// Find a subnode at this level ICDBNode * find (const std::string &nodeName); - // reset all static mappings - static void reset(); - protected: - - - /** Struct identifying an observer of a db branch - * This struct can be linked in a list so that we can update observers only once per pass. - * An observer that watch a whole branch can be updated once and only once after each element of the branch has been modified - */ - class CDBBranchObsInfo - { - public: - CRefPtr Observer; - // 2 linked list are required : while the observer is notified, it can triger one other observer, so we must link it in another list - bool Touched[2]; - CDBBranchObsInfo *PrevNotifiedObserver[2]; // NULL means this is the head - CDBBranchObsInfo *NextNotifiedObserver[2]; - ICDBNode *Owner; - - // If non-empty, only a leaf whose name is found here will notify something - // This is equivalent to creating a sub-branch containing only the specified leaves - // and setting a branch observer on it, except you don't need to change your database paths - // and update large amounts of code and script! - std::vector PositiveLeafNameFilter; - - public: - - /// Constructor. See above for usage of positiveLeafNameFilter. - CDBBranchObsInfo(IPropertyObserver *obs = NULL, ICDBNode *owner = NULL, const std::vector& positiveLeafNameFilter=std::vector()) - { - Owner = owner; - Observer = obs; - Touched[0] = Touched[1] = false; - PrevNotifiedObserver[0] = PrevNotifiedObserver[1] = NULL; - NextNotifiedObserver[0] = NextNotifiedObserver[1] = NULL; - for (std::vector::const_iterator ipf=positiveLeafNameFilter.begin(); ipf!=positiveLeafNameFilter.end(); ++ipf) - { - PositiveLeafNameFilter.push_back(ICDBNode::getStringId(*ipf)); // the ids are also mapped at database init, we don't need to unmap them in destructor - } - } - ~CDBBranchObsInfo() - { - // should have been unlinked - nlassert(Touched[0] == false); - nlassert(Touched[1] == false); - nlassert(PrevNotifiedObserver[0] == NULL); - nlassert(PrevNotifiedObserver[1] == NULL); - nlassert(NextNotifiedObserver[0] == NULL); - nlassert(NextNotifiedObserver[1] == NULL); - } - // Unlink from the given list. This also clear the '_Touched' flag - void unlink(uint list); - void link(uint list, TStringId modifiedLeafName); - }; - - typedef std::list TObsList; // must use a list because pointers on CDBObserverInfo instances must remains valids - -protected: - + typedef std::list< ICDBDBBranchObserverHandle* > TObserverHandleList; CCDBNodeBranch *_Parent; @@ -303,25 +243,10 @@ protected: bool _Sorted : 1; // observers for this node or branch - TObsList _Observers; - - friend class CDBBranchObsInfo; - // Global list of modified nodes - static CDBBranchObsInfo *_FirstNotifiedObs[2]; - static CDBBranchObsInfo *_LastNotifiedObs[2]; - static uint _CurrNotifiedObsList; // 0 or 1 => tell in which list observers of modified values must be added - // current & next observers being notified : if such observer if removed during notification, pointer will be valids - static CDBBranchObsInfo *_CurrNotifiedObs; - static CDBBranchObsInfo *_NextNotifiedObs; + TObserverHandleList observerHandles; /// called by clear void removeAllBranchObserver(); - void removeBranchInfoIt(TObsList::iterator it); - - -private: - static std::vector< IBranchObserverCallFlushObserver* > flushObservers; - }; } diff --git a/code/nel/include/nel/misc/cdb_branch_observing_handler.h b/code/nel/include/nel/misc/cdb_branch_observing_handler.h new file mode 100644 index 000000000..d7ec508af --- /dev/null +++ b/code/nel/include/nel/misc/cdb_branch_observing_handler.h @@ -0,0 +1,128 @@ +// Ryzom - MMORPG Framework +// 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 CDB_BRANCH_OBS_HNDLR +#define CDB_BRANCH_OBS_HNDLR + +#include "nel/misc/cdb_branch.h" + +namespace NLMISC{ + + /** + @brief Manages the CDB branch observers. + + When a leaf's data changes, it notifies the branch, which then marks the observers as notifiable. + The marked observers can then be notified and flushed on request. + + */ + class CCDBBranchObservingHandler{ + + enum{ + MAX_OBS_LST = 2 + }; + + public: + CCDBBranchObservingHandler(); + + ~CCDBBranchObservingHandler(); + + /// Notifies the observers, and flushes the list + void flushObserverCalls(); + + void reset(); + + void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ); + + void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); + + void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer ); + + void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ); + + + ///Observer for branch observer flush events. + class IBranchObserverCallFlushObserver : public CRefCount{ + public: + virtual ~IBranchObserverCallFlushObserver(){} + virtual void onObserverCallFlush() = 0; + }; + + private: + void triggerFlushObservers(); + + public: + void addFlushObserver( IBranchObserverCallFlushObserver *observer ); + void removeFlushObserver( IBranchObserverCallFlushObserver *observer ); + + private: + + /** + @brief Handle to a branch observer. + + The handle stores the owner branch, the observer and remembers if it's marked for notifying the observer. + Also it manages adding/removing itself to/from the marked observer handles list, which is handled by CCDBBranchObservingHandler. + + */ + class CCDBDBBranchObserverHandle : public CCDBNodeBranch::ICDBDBBranchObserverHandle{ + + public: + + CCDBDBBranchObserverHandle( ICDBNode::IPropertyObserver *observer, CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler ); + + ~CCDBDBBranchObserverHandle(); + + ICDBNode* owner(){ return _owner; } + + ICDBNode::IPropertyObserver* observer(){ return _observer; } + + bool observesLeaf( const std::string &leafName ); + + bool inList( uint list ); + + void addToFlushableList(); + + void removeFromFlushableList( uint list ); + + void removeFromFlushableList(); + + private: + + bool _inList[ MAX_OBS_LST ]; + + std::vector< std::string > _observedLeaves; + + CCDBNodeBranch *_owner; + + NLMISC::CRefPtr< ICDBNode::IPropertyObserver > _observer; + + CCDBBranchObservingHandler *_handler; + + }; + + std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* > flushableObservers[ MAX_OBS_LST ]; + + CCDBNodeBranch::ICDBDBBranchObserverHandle *currentHandle; + + uint currentList; + + std::vector< IBranchObserverCallFlushObserver* > flushObservers; + + }; +} + +#endif + + diff --git a/code/nel/src/misc/cdb_branch.cpp b/code/nel/src/misc/cdb_branch.cpp index 738c66b2f..6d8301049 100644 --- a/code/nel/src/misc/cdb_branch.cpp +++ b/code/nel/src/misc/cdb_branch.cpp @@ -59,33 +59,6 @@ using namespace std; namespace NLMISC{ -///////////// -// GLOBALS // -///////////// - -CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_FirstNotifiedObs[2] = { NULL, NULL }; -CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_LastNotifiedObs[2] = { NULL, NULL }; -CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_CurrNotifiedObs = NULL; -CCDBNodeBranch::CDBBranchObsInfo *CCDBNodeBranch::_NextNotifiedObs = NULL; - -// -uint CCDBNodeBranch::_CurrNotifiedObsList = 0; - -std::vector< CCDBNodeBranch::IBranchObserverCallFlushObserver* > CCDBNodeBranch::flushObservers; - -// reset all static data -void CCDBNodeBranch::reset() -{ - _FirstNotifiedObs[0] = NULL; - _FirstNotifiedObs[1] = NULL; - _LastNotifiedObs[0] = NULL; - _LastNotifiedObs[1] = NULL; - _CurrNotifiedObsList = 0; - _CurrNotifiedObs = NULL; - _NextNotifiedObs = NULL; -} - - //----------------------------------------------- // init // @@ -626,155 +599,14 @@ void CCDBNodeBranch::removeNode (const CTextId& id) delete pNode; } - - - -//----------------------------------------------- -void CCDBNodeBranch::flushObserversCalls() +void CCDBNodeBranch::onLeafChanged( NLMISC::TStringId leafName ) { -// nlassert(_CrtCheckMemory()); - _CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList]; - while (_CurrNotifiedObs) - { - // modified node should now store them in other list when they're modified - _CurrNotifiedObsList = 1 - _CurrNotifiedObsList; - // switch list so that modified node are stored in the other list - while (_CurrNotifiedObs) - { - _NextNotifiedObs = _CurrNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList]; - nlassert(_CurrNotifiedObs->Owner); - if (_CurrNotifiedObs->Observer) - _CurrNotifiedObs->Observer->update(_CurrNotifiedObs->Owner); - if (_CurrNotifiedObs) // this may be modified by the call (if current observer is removed) - { - _CurrNotifiedObs->unlink(1 - _CurrNotifiedObsList); - } - _CurrNotifiedObs = _NextNotifiedObs; - } - nlassert(_FirstNotifiedObs[1 - _CurrNotifiedObsList] == NULL); - nlassert(_LastNotifiedObs[1 - _CurrNotifiedObsList] == NULL); - triggerFlushObservers(); - // examine other list to see if nodes have been registered - _CurrNotifiedObs = _FirstNotifiedObs[_CurrNotifiedObsList]; - } - triggerFlushObservers(); -// nlassert(_CrtCheckMemory()); -} + for( TObserverHandleList::iterator itr = observerHandles.begin(); itr != observerHandles.end(); ++itr ) + if( (*itr)->observesLeaf( *leafName ) ) + (*itr)->addToFlushableList(); -void CCDBNodeBranch::triggerFlushObservers() -{ - for( std::vector< IBranchObserverCallFlushObserver* >::iterator itr = flushObservers.begin(); itr != flushObservers.end(); itr++ ) - { - (*itr)->onObserverCallFlush(); - } -} - -void CCDBNodeBranch::addFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer ) -{ - std::vector< IBranchObserverCallFlushObserver* >::iterator itr - = std::find( flushObservers.begin(), flushObservers.end(), observer ); - - // Already exists - if( itr != flushObservers.end() ) - return; - - flushObservers.push_back( observer ); -} - -void CCDBNodeBranch::removeFlushObserver( CCDBNodeBranch::IBranchObserverCallFlushObserver *observer ) -{ - std::vector< IBranchObserverCallFlushObserver* >::iterator itr - = std::find( flushObservers.begin(), flushObservers.end(), observer ); - - // Isn't in our list - if( itr == flushObservers.end() ) - return; - - flushObservers.erase( itr ); -} - -//----------------------------------------------- -void CCDBNodeBranch::CDBBranchObsInfo::link(uint list, TStringId modifiedLeafName) -{ - // If there a filter set? - if (!PositiveLeafNameFilter.empty()) - { - // Don't link if modifiedLeafName is not in the filter - if (std::find(PositiveLeafNameFilter.begin(), PositiveLeafNameFilter.end(), modifiedLeafName) == PositiveLeafNameFilter.end()) - return; - } - -// nlassert(_CrtCheckMemory()); - nlassert(list < 2); - if (Touched[list]) return; // already inserted in list - Touched[list] = true; - nlassert(!PrevNotifiedObserver[list]); - nlassert(!NextNotifiedObserver[list]); - if (!_FirstNotifiedObs[list]) - { - _FirstNotifiedObs[list] = _LastNotifiedObs[list] = this; - } - else - { - nlassert(!_LastNotifiedObs[list]->NextNotifiedObserver[list]); - _LastNotifiedObs[list]->NextNotifiedObserver[list] = this; - PrevNotifiedObserver[list] = _LastNotifiedObs[list]; - _LastNotifiedObs[list] = this; - } -// nlassert(_CrtCheckMemory()); -} - -//----------------------------------------------- -void CCDBNodeBranch::CDBBranchObsInfo::unlink(uint list) -{ -// nlassert(_CrtCheckMemory()); - nlassert(list < 2); - if (!Touched[list]) - { - // not linked in this list - nlassert(PrevNotifiedObserver[list] == NULL); - nlassert(NextNotifiedObserver[list] == NULL); - return; - } - if (PrevNotifiedObserver[list]) - { - PrevNotifiedObserver[list]->NextNotifiedObserver[list] = NextNotifiedObserver[list]; - } - else - { - // this was the first node - _FirstNotifiedObs[list] = NextNotifiedObserver[list]; - } - if (NextNotifiedObserver[list]) - { - NextNotifiedObserver[list]->PrevNotifiedObserver[list] = PrevNotifiedObserver[list]; - } - else - { - // this was the last node - _LastNotifiedObs[list] = PrevNotifiedObserver[list]; - } - PrevNotifiedObserver[list] = NULL; - NextNotifiedObserver[list] = NULL; - Touched[list] = false; -// nlassert(_CrtCheckMemory()); -} - -//----------------------------------------------- -void CCDBNodeBranch::linkInModifiedNodeList(TStringId modifiedLeafName) -{ -// nlassert(_CrtCheckMemory()); - CCDBNodeBranch *curr = this; - do - { - for(TObsList::iterator it = curr->_Observers.begin(); it != curr->_Observers.end(); ++it) - { - it->link(_CurrNotifiedObsList, modifiedLeafName); - } - curr = curr->getParent(); - } - while(curr); -// nlassert(_CrtCheckMemory()); + if( _Parent != NULL ) + _Parent->onLeafChanged( leafName ); } @@ -847,14 +679,21 @@ bool CCDBNodeBranch::removeObserver(IPropertyObserver* observer, CTextId& id) //----------------------------------------------- -void CCDBNodeBranch::addBranchObserver(IPropertyObserver* observer, const std::vector& positiveLeafNameFilter) +void CCDBNodeBranch::addBranchObserver( ICDBDBBranchObserverHandle *handle, const std::vector& positiveLeafNameFilter) { - CDBBranchObsInfo oi(observer, this, positiveLeafNameFilter); - _Observers.push_front(oi); + CCDBNodeBranch::TObserverHandleList::iterator itr + = std::find( observerHandles.begin(), observerHandles.end(), handle ); + + if( itr != observerHandles.end() ){ + delete handle; + return; + } + + observerHandles.push_back( handle ); } //----------------------------------------------- -void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize) +void CCDBNodeBranch::addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize) { CCDBNodeBranch *branchNode; if (dbPathFromThisNode[0] == '\0') // empty string @@ -871,6 +710,7 @@ void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode: msg += " branch missing in DB"; nlerror( msg.c_str() ); + delete handle; return; } } @@ -879,7 +719,7 @@ void CCDBNodeBranch::addBranchObserver(const char *dbPathFromThisNode, ICDBNode: { leavesToMonitor[i] = string(positiveLeafNameFilter[i]); } - branchNode->addBranchObserver(&observer, leavesToMonitor); + branchNode->addBranchObserver(handle, leavesToMonitor); } //----------------------------------------------- @@ -902,55 +742,38 @@ void CCDBNodeBranch::removeBranchObserver(const char *dbPathFromThisNode, ICDBNo bool CCDBNodeBranch::removeBranchObserver(IPropertyObserver* observer) { bool found = false; - TObsList::iterator it = _Observers.begin(); - while (it != _Observers.end()) + + TObserverHandleList::iterator itr = observerHandles.begin(); + while( itr != observerHandles.end() ) { - if (it->Observer == observer) + if( (*itr)->observer() == observer ) { - removeBranchInfoIt(it); - it = _Observers.erase(it); + (*itr)->removeFromFlushableList(); + delete *itr; + itr = observerHandles.erase( itr ); found = true; } else { - ++it; + ++itr; } } + return found; } //----------------------------------------------- void CCDBNodeBranch::removeAllBranchObserver() { - TObsList::iterator it = _Observers.begin(); - while (it != _Observers.end()) - { - removeBranchInfoIt(it); - ++it; + for( TObserverHandleList::iterator itr = observerHandles.begin(); + itr != observerHandles.end(); ++itr ){ + (*itr)->removeFromFlushableList(); + delete *itr; } - _Observers.clear(); -} -//----------------------------------------------- -void CCDBNodeBranch::removeBranchInfoIt(TObsList::iterator it) -{ - CDBBranchObsInfo *oi = &(*it); - // if this node is currenlty being notified, update iterators - if (oi == _CurrNotifiedObs) - { - _CurrNotifiedObs = NULL; - } - if (oi == _NextNotifiedObs) - { - nlassert(_CurrNotifiedObsList < 2); - _NextNotifiedObs = _NextNotifiedObs->NextNotifiedObserver[1 - _CurrNotifiedObsList]; - } - // unlink observer from both update lists - oi->unlink(0); - oi->unlink(1); + observerHandles.clear(); } - //----------------------------------------------- // Useful for find //----------------------------------------------- diff --git a/code/nel/src/misc/cdb_branch_observing_handler.cpp b/code/nel/src/misc/cdb_branch_observing_handler.cpp new file mode 100644 index 000000000..8f531b9a3 --- /dev/null +++ b/code/nel/src/misc/cdb_branch_observing_handler.cpp @@ -0,0 +1,201 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/cdb_branch_observing_handler.h" + +namespace NLMISC{ + CCDBBranchObservingHandler::CCDBBranchObservingHandler() + { + reset(); + } + + CCDBBranchObservingHandler::~CCDBBranchObservingHandler() + { + reset(); + } + + void CCDBBranchObservingHandler::flushObserverCalls() + { + bool flushed = false; + + do + { + flushed = false; + uint oldList = currentList; + currentList = 1 - currentList; + + std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* >::iterator itr + = flushableObservers[ oldList ].begin(); + + while( itr != flushableObservers[ oldList ].end() ) + { + currentHandle = *itr; + ++itr; + + if( currentHandle->observer() != NULL ) + currentHandle->observer()->update( currentHandle->owner() ); + + // Update might have removed it + if( currentHandle != NULL ) + currentHandle->removeFromFlushableList( oldList ); + + currentHandle = NULL; + flushed = true; + } + triggerFlushObservers(); + + }while( flushed ); + + triggerFlushObservers(); + } + + void CCDBBranchObservingHandler::reset() + { + currentList = 0; + currentHandle = NULL; + + for( uint i = 0; i < MAX_OBS_LST; i++ ) + flushableObservers[ i ].clear(); + } + + void CCDBBranchObservingHandler::addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) + { + if( branch == NULL ) + return; + + CCDBDBBranchObserverHandle *handle = new CCDBDBBranchObserverHandle( observer, branch, this ); + branch->addBranchObserver( handle, positiveLeafNameFilter ); + } + + void CCDBBranchObservingHandler::addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) + { + if( branch == NULL ) + return; + + CCDBDBBranchObserverHandle *handle = new CCDBDBBranchObserverHandle( &observer, branch, this ); + branch->addBranchObserver( handle, dbPathFromThisNode, positiveLeafNameFilter, positiveLeafNameFilterSize ); + } + + void CCDBBranchObservingHandler::removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer ) + { + branch->removeBranchObserver( observer ); + } + + void CCDBBranchObservingHandler::removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ) + { + branch->removeBranchObserver( dbPathFromThisNode, observer ); + } + + void CCDBBranchObservingHandler::triggerFlushObservers() + { + for( std::vector< IBranchObserverCallFlushObserver* >::iterator itr = flushObservers.begin(); + itr != flushObservers.end(); itr++ ) + (*itr)->onObserverCallFlush(); + } + + void CCDBBranchObservingHandler::addFlushObserver( IBranchObserverCallFlushObserver *observer ) + { + std::vector< IBranchObserverCallFlushObserver* >::iterator itr + = std::find( flushObservers.begin(), flushObservers.end(), observer ); + + if( itr != flushObservers.end() ) + return; + + flushObservers.push_back( observer ); + } + + void CCDBBranchObservingHandler::removeFlushObserver( IBranchObserverCallFlushObserver *observer ) + { + std::vector< IBranchObserverCallFlushObserver* >::iterator itr + = std::find( flushObservers.begin(), flushObservers.end(), observer ); + + if( itr == flushObservers.end() ) + return; + + flushObservers.erase( itr ); + } + + CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::CCDBDBBranchObserverHandle( NLMISC::ICDBNode::IPropertyObserver *observer, NLMISC::CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler ) + { + std::fill( _inList, _inList + MAX_OBS_LST, false ); + _observer = observer; + _owner = owner; + _handler = handler; + } + + CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::~CCDBDBBranchObserverHandle() + { + _observer = NULL; + } + + bool CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::observesLeaf( const std::string &leafName ) + { + if( !_observedLeaves.empty() ){ + std::vector< std::string >::iterator itr + = std::find( _observedLeaves.begin(), _observedLeaves.end(), leafName ); + + if( itr == _observedLeaves.end() ) + return false; + else + return true; + } + + return true; + } + + bool CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::inList( uint list ) + { + return _inList[ list ]; + } + + void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::addToFlushableList() + { + uint list = _handler->currentList; + + if( _inList[ list ] ) + return; + + _handler->flushableObservers[ list ].push_back( this ); + _inList[ list ] = true; + } + + void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::removeFromFlushableList( uint list ) + { + if( !_inList[ list ] ) + return; + + std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* >::iterator itr + = std::find( _handler->flushableObservers[ list ].begin(), + _handler->flushableObservers[ list ].end(), this ); + + if( itr == _handler->flushableObservers[ list ].end() ) + return; + + if( _handler->currentHandle == this ) + _handler->currentHandle = NULL; + + _handler->flushableObservers[ list ].erase( itr ); + _inList[ list ] = false; + + } + + void CCDBBranchObservingHandler::CCDBDBBranchObserverHandle::removeFromFlushableList() + { + for( uint i = 0; i < MAX_OBS_LST; i++ ) + removeFromFlushableList( i ); + } +} + diff --git a/code/nel/src/misc/cdb_leaf.cpp b/code/nel/src/misc/cdb_leaf.cpp index 992699627..fce66bd4a 100644 --- a/code/nel/src/misc/cdb_leaf.cpp +++ b/code/nel/src/misc/cdb_leaf.cpp @@ -365,9 +365,7 @@ void CCDBNodeLeaf::notifyObservers() } // mark parent branchs if (_Parent) - { - _Parent->linkInModifiedNodeList(_Name); - } + _Parent->onLeafChanged( _Name ); } diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 2379d34a4..9aee26da8 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -309,7 +309,7 @@ void CCDBSynchronised::clear() } // clear CCDBNodeBranch static data - CCDBNodeBranch::reset(); + branchObservingHandler.reset(); bankHandler.reset(); } @@ -328,6 +328,89 @@ void CCDBSynchronised::resetBank( uint gc, uint bank ){ _Database->resetNode( gc, bankHandler.getUIDForBank( bank ) ); } +void CCDBSynchronised::addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + + branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter ); +} + +void CCDBSynchronised::addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) +{ + if( branch == NULL ) + return; + + branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter ); +} + +void CCDBSynchronised::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + + branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); +} + +void CCDBSynchronised::addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) +{ + if( branch == NULL ) + return; + branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); +} + +void CCDBSynchronised::removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, observer ); +} + +void CCDBSynchronised::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ) +{ + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, observer ); +} + +void CCDBSynchronised::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer ); +} + +void CCDBSynchronised::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) +{ + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer ); +} + +void CCDBSynchronised::addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) +{ + if( observer == NULL ) + return; + branchObservingHandler.addFlushObserver( observer ); +} + +void CCDBSynchronised::removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) +{ + if( observer == NULL ) + return; + branchObservingHandler.removeFlushObserver( observer ); +} + +void CCDBSynchronised::flushObserverCalls() +{ + branchObservingHandler.flushObserverCalls(); +} + + #ifdef TRACE_READ_DELTA #undef TRACE_READ_DELTA #endif diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index b9d11e5b6..f7c21f01b 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -23,6 +23,7 @@ #include "nel/misc/cdb.h" #include "nel/misc/cdb_branch.h" #include "nel/misc/cdb_bank_handler.h" +#include "nel/misc/cdb_branch_observing_handler.h" /** * Class to manage a database of properties @@ -158,6 +159,20 @@ private: void writeInitInProgressIntoUIDB(); NLMISC::CCDBBankHandler bankHandler; + NLMISC::CCDBBranchObservingHandler branchObservingHandler; + +public: + void addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + void addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 ); + void addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); + void removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ); + void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ); + void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); + void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); + void addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + void removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + void flushObserverCalls(); }; diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 32962cd93..b7f3c1c97 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -390,7 +390,8 @@ bool connection (const string &cookie, const string &fsaddr) pIM->activateMasterGroup ("ui:outgame", true); pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Active inputs Actions.enable(true); @@ -553,7 +554,8 @@ bool reconnection() pIM->activateMasterGroup ("ui:outgame", true); pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Active inputs Actions.enable(true); @@ -992,7 +994,8 @@ TInterfaceState globalMenu() pIM->initOutGame(); pIM->activateMasterGroup ("ui:outgame", true); pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); pIM->getElementFromId("ui:outgame:charsel")->setActive(false); pIM->getElementFromId("ui:outgame:charsel")->setActive(true); // Active inputs @@ -1030,7 +1033,8 @@ TInterfaceState globalMenu() } } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // check if we can send another dated block if (NetMngr.getCurrentServerTick() != serverTick) @@ -1056,7 +1060,8 @@ TInterfaceState globalMenu() // Interface handling & displaying (processes clicks...) pIM->updateFrameEvents(); pIM->updateFrameViews(NULL); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Movie shooter globalMenuMovieShooter(); @@ -1121,9 +1126,11 @@ TInterfaceState globalMenu() if (pNL != NULL) { pNL->setValue64 (1); // Send impulse to interface observers - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); pNL->setValue64 (0); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } } else @@ -1184,9 +1191,11 @@ TInterfaceState globalMenu() if (pNL != NULL) { pNL->setValue64 (1); // Send impulse to interface observers - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); pNL->setValue64 (0); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } } } diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index fb23b5810..caa31a305 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -1267,7 +1267,8 @@ void CFarTP::sendReady() CInputHandlerManager::getInstance()->pumpEventsNoIM(); // Update Network. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Be nice to the system nlSleep(100); } @@ -1405,7 +1406,8 @@ void CFarTP::farTPmainLoop() // Update Network. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // TODO: resend in case the last datagram sent was lost? // // check if we can send another dated block diff --git a/code/ryzom/client/src/ingame_database_manager.h b/code/ryzom/client/src/ingame_database_manager.h index 043e2ee98..5186cf0b7 100644 --- a/code/ryzom/client/src/ingame_database_manager.h +++ b/code/ryzom/client/src/ingame_database_manager.h @@ -30,6 +30,7 @@ #include "nel/misc/cdb.h" #include "nel/misc/cdb_leaf.h" #include "nel/misc/cdb_branch.h" +#include "nel/misc/cdb_branch_observing_handler.h" #include "cdb_synchronised.h" diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 2610b5882..45fa7b59e 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -315,7 +315,8 @@ inline void waitForNetworkMessage(bool &var) CInputHandlerManager::getInstance()->pumpEventsNoIM(); // Update network. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Send dummy info NetMngr.send(); // Do not take all the CPU. @@ -1216,7 +1217,8 @@ void initMainLoop() CInputHandlerManager::getInstance()->pumpEventsNoIM(); // Update Network. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } // Set the LastGameCycle diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 097247f6f..4cb128f89 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -186,16 +186,16 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn // ensure remove (if setuped before), then add CCDBNodeBranch *branch; branch= pIM->getDbBranch("LOCAL:INVENTORY:BAG"); - if(branch) branch->removeBranchObserver(&_DBInventoryObs); - if(branch) branch->addBranchObserver(&_DBInventoryObs); + if(branch) pIM->removeBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); + if(branch) pIM->addBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); // and for all pack animals uint i; for(i=0;igetDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i)); - if(branch) branch->removeBranchObserver(&_DBInventoryObs); - if(branch) branch->addBranchObserver(&_DBInventoryObs); + if(branch) pIM->removeBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); + if(branch) pIM->addBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); } // Add observers on animal status, cause inventory may become unavailabe during the process diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index fff35b70a..aa8e1cab4 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -50,7 +50,7 @@ void CBotChatPageMission::init() { CInterfaceManager *im = CInterfaceManager::getInstance(); if (im->getDbBranch("SERVER:CHOOSE_MISSIONS")) - im->getDbBranch("SERVER:CHOOSE_MISSIONS")->addBranchObserver(&_MissionPagesObs); + im->addBranchObserver("SERVER:CHOOSE_MISSIONS", &_MissionPagesObs); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index bde03fa4b..509dfcd62 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -161,7 +161,7 @@ void CBotChatPageTrade::init() CInterfaceManager *im = CInterfaceManager::getInstance(); if (im->getDbBranch("SERVER:TRADING")) { - im->getDbBranch("SERVER:TRADING")->addBranchObserver(&_TradePagesObs); + im->addBranchObserver( "SERVER:TRADING", &_TradePagesObs); } _FamePriceFactorLeaf = im->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR"); @@ -2990,7 +2990,8 @@ NLMISC_COMMAND( testResaleItems, "Temp : test resale", "" ) // // Force for next page - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); return true; } diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 58cb0bae7..93d525558 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -123,7 +123,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) _DbBranch= branch; _DbBranchName= (const char*)prop; // add observer - _DbBranch->addBranchObserver(&_DbBranchObs); + pIM->addBranchObserver(branch, &_DbBranchObs); } // parse the common ctrl info diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 8990abf42..557ede4e3 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -107,7 +107,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) _DbBranch= branch; _DbBranchName= (const char*)prop; // add observer - _DbBranch->addBranchObserver(&_DbBranchObs); + pIM->addBranchObserver( branch, &_DbBranchObs ); } // parse the common ctrl info diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 209e85ab2..44e3cd6fc 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -672,20 +672,14 @@ void CGuildManager::initDBObservers() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // add an observer on the whole guild - CCDBNodeBranch *pGuild = pIM->getDbBranch("SERVER:GUILD"); - if (pGuild != NULL) - pGuild->addBranchObserver(&_DBObs); + pIM->addBranchObserver( "SERVER:GUILD", &_DBObs ); // add an observer on members only => need to update all - CCDBNodeBranch *pGuildMembers = pIM->getDbBranch("SERVER:GUILD:MEMBERS"); - if (pGuildMembers != NULL) - pGuildMembers->addBranchObserver(&_DBObsMembers); + pIM->addBranchObserver("SERVER:GUILD:MEMBERS", &_DBObsMembers); // observer on ascencors Ascensors.setListType(CHugeListObs::Ascensor); - CCDBNodeBranch *pAscensor = pIM->getDbBranch("SERVER:ASCENSOR"); - if (pAscensor != NULL) - pAscensor->addBranchObserver(&Ascensors); + pIM->addBranchObserver("SERVER:ASCENSOR", &Ascensors); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index 3e363225c..ff70ab120 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -790,7 +790,8 @@ void CInterfaceDDX::updateRealtime(CCtrlBase *pSB, bool updateOnScrollEnd) ClientCfg.IsInvalidated = true; } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); for (i = 0; i < _Parameters.size(); ++i) { diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 32a88553b..7ab34ac8c 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -132,12 +132,12 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() { - CCDBNodeBranch::addFlushObserver( this ); + CInterfaceManager::getInstance()->addFlushObserver( this ); } CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() { - CCDBNodeBranch::removeFlushObserver( this ); + CInterfaceManager::getInstance()->removeFlushObserver( this ); } void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush() @@ -276,7 +276,7 @@ void CInterfaceLink::createObservers(const TNodeVect &nodes) else { CCDBNodeBranch *br = static_cast(*it); - br->addBranchObserver(this); + CInterfaceManager::getInstance()->addBranchObserver( br, this ); } } } @@ -294,7 +294,7 @@ void CInterfaceLink::removeObservers(const TNodeVect &nodes) else { CCDBNodeBranch *br = static_cast(*it); - br->removeBranchObserver(this); + CInterfaceManager::getInstance()->removeBranchObserver( br, this ); } } } diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/ryzom/client/src/interface_v3/interface_link.h index 88b8d416d..c83ef5034 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.h +++ b/code/ryzom/client/src/interface_v3/interface_link.h @@ -20,6 +20,7 @@ #define CL_INTERFACE_LINK_H #include "nel/misc/cdb_branch.h" +#include "nel/misc/cdb_branch_observing_handler.h" class CInterfaceElement; class CReflectedProperty; @@ -66,7 +67,7 @@ public: /// Updates triggered interface links when triggered by the observed branch - class CInterfaceLinkUpdater : public NLMISC::CCDBNodeBranch::IBranchObserverCallFlushObserver + class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver { public: CInterfaceLinkUpdater(); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 2c0ab250c..5cb70e401 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1236,7 +1236,8 @@ void CInterfaceManager::updateFrameEvents() CInterfaceAnim *pIA = vTmp[i]; pIA->update(); } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::flushObserverCalls(); // // Next : Test if we have to remove anims for (i = 0; i < (sint)_ActiveAnims.size(); ++i) @@ -1249,7 +1250,8 @@ void CInterfaceManager::updateFrameEvents() } } // - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Handle waiting texts from server processServerIDString(); @@ -1341,7 +1343,8 @@ void CInterfaceManager::updateFrameEvents() { (*it)->handleEvent(clockTick); } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Update SPhrase manager CSPhraseManager *pPM= CSPhraseManager::getInstance(); @@ -1985,8 +1988,9 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) H_AUTO ( RZ_Interface_DrawViews_Setup ) _ViewRenderer.activateWorldSpaceMatrix (false); - - CCDBNodeBranch::flushObserversCalls(); + + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // If an element has captured the keyboard, make sure it is alway visible (all parent windows active) if (_CaptureKeyboard != NULL) @@ -2058,7 +2062,8 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) To minimize texture swapping, we first sort per Window, then we sort per layer, then we render per Global Texture. Computed String are rendered in on big drawQuads at last part of each layer */ - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { @@ -2108,8 +2113,9 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) { H_AUTO ( RZ_Interface_DrawViews_After ) - - CCDBNodeBranch::flushObserversCalls(); + + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // draw the special over extend text drawOverExtendViewText(); @@ -2157,7 +2163,8 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) Driver->setMatrixMode2D11(); // flush obs - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } } @@ -2725,7 +2732,8 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) if(_CaptureKeyboard && _CaptureKeyboard->getRootWindow()==tw) { bool result = _CaptureKeyboard->handleEvent(event); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); return result; } else @@ -2782,7 +2790,8 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) if (_CaptureKeyboard != NULL && !handled) { bool result = _CaptureKeyboard->handleEvent(event); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); return result; } } @@ -3042,7 +3051,8 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) handled|= _MouseOverWindow; } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // event handled? return handled; } @@ -6640,4 +6650,87 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) ucstr = str; return true;; -} \ No newline at end of file +} + +void CInterfaceManager::addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + + branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter ); +} + +void CInterfaceManager::addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) +{ + if( branch == NULL ) + return; + + branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter ); +} + +void CInterfaceManager::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + + branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); +} + +void CInterfaceManager::addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) +{ + if( branch == NULL ) + return; + branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); +} + +void CInterfaceManager::removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, observer ); +} + +void CInterfaceManager::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ) +{ + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, observer ); +} + +void CInterfaceManager::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) +{ + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer ); +} + +void CInterfaceManager::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) +{ + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer ); +} + +void CInterfaceManager::addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) +{ + if( observer == NULL ) + return; + branchObservingHandler.addFlushObserver( observer ); +} + +void CInterfaceManager::removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) +{ + if( observer == NULL ) + return; + branchObservingHandler.removeFlushObserver( observer ); +} + +void CInterfaceManager::flushObserverCalls() +{ + branchObservingHandler.flushObserverCalls(); +} + diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 6ee4a6f50..a98d4a8fc 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -1065,6 +1065,20 @@ private: void updateTooltipCoords(CCtrlBase *newCtrl); CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; + NLMISC::CCDBBranchObservingHandler branchObservingHandler; + +public: + void addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + void addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 ); + void addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); + void removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ); + void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ); + void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); + void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); + void addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + void removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + void flushObserverCalls(); }; #endif // NL_INTERFACE_MANAGER_H diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 1c2892b0d..bb050520e 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -1864,7 +1864,8 @@ void CTempInvManager::open(TEMP_INV_MODE::TInventoryMode m) } pIM->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->setValue8((uint8)_Mode); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); if (pGC != NULL) { diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 6ebc3ccd6..2c4fbc24c 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -582,12 +582,14 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std pCB = dynamic_cast(pIM->getElementFromId(WinName+WIN_EDITCMD_COMBO_CATEGORY)); pCB->setSelection(catCBIndex); onChangeCategory(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); //pIM->runActionHandler("editcmd_change_category",NULL); pCB = dynamic_cast(pIM->getElementFromId(WinName+WIN_EDITCMD_COMBO_ACTION)); pCB->setSelection(actCBIndex); onChangeAction(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); //pIM->runActionHandler("editcmd_change_action",NULL); // Count number of displayed param diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 352d0ca0d..e4555d092 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -488,7 +488,8 @@ void CMacroCmdManager::updateMacroExecution () pIM->runActionHandler(rC.Name, NULL, rC.Params); // Flush interface links (else bug with Macro "Select ShortCutBar/Run Shortcut" - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); if (bWaitForServer) { diff --git a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp index 64c651b46..ec29be009 100644 --- a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -132,7 +132,7 @@ void CSBrickManager::initInGame() } // Add a branch observer on brick family - pIM->getDbBranch("SERVER:BRICK_FAMILY")->addBranchObserver(&_BrickFamilyObs); + pIM->addBranchObserver( "SERVER:BRICK_FAMILY", &_BrickFamilyObs); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index 6adf2fa32..d335f0c33 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -158,7 +158,7 @@ void CSkillManager::initInGame() // Get a node used to inform interface that a skill has changed _TrackSkillChange= pIM->getDbProp("UI:VARIABLES:TRACK_SKILL_CHANGE", true); // Add a branch observer on skill value change - pIM->getDbBranch("SERVER:CHARACTER_INFO:SKILLS")->addBranchObserver(&_SkillChangeObs); + pIM->addBranchObserver( "SERVER:CHARACTER_INFO:SKILLS", &_SkillChangeObs ); } diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 157a97f8a..d8cfa7878 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -360,7 +360,8 @@ void loginMainLoop() && LoginSM.getCurrentState() != CLoginStateMachine::st_ingame) // while (loginFinished == false) { - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Update the DT T0 and T1 global variables updateClientTime(); @@ -378,7 +379,8 @@ void loginMainLoop() // Interface handling & displaying pIM->updateFrameEvents(); pIM->updateFrameViews(NULL); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); @@ -810,7 +812,8 @@ bool login() loginIntro(); pIM->initLogin(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); bool tmpDI = ClientCfg.DisableDirectInput; ClientCfg.DisableDirectInput = true; @@ -3031,8 +3034,8 @@ void loginIntro() const ucstring nmsg(""); ProgressBar.newMessage (nmsg); - - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } } beginLoading(StartBackground); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 15a525f58..635e2476a 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1638,7 +1638,8 @@ bool mainLoop() // flush observers - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); } @@ -1655,7 +1656,8 @@ bool mainLoop() // NetWork Update. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // lets some CPU. NetMngr.send(); nlSleep(100); @@ -1764,7 +1766,8 @@ bool mainLoop() { NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); bool prevDatabaseInitStatus = IngameDbMngr.initInProgress(); IngameDbMngr.setChangesProcessed(); bool newDatabaseInitStatus = IngameDbMngr.initInProgress(); @@ -1834,7 +1837,8 @@ bool mainLoop() // update bot chat CBotChatManager::getInstance()->update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // updateItemEdition CInterfaceItemEdition::getInstance()->update(); diff --git a/code/ryzom/client/src/npc_icon.cpp b/code/ryzom/client/src/npc_icon.cpp index 7d03ede01..a1935b6ad 100644 --- a/code/ryzom/client/src/npc_icon.cpp +++ b/code/ryzom/client/src/npc_icon.cpp @@ -150,24 +150,24 @@ void CNPCIconCache::addObservers() // Mission Journal static const char *missionStartStopLeavesToMonitor [2] = {"TITLE", "FINISHED"}; - IngameDbMngr.getNodePtr()->addBranchObserver("MISSIONS", MissionStartStopObserver, missionStartStopLeavesToMonitor, getArraySize(missionStartStopLeavesToMonitor)); + IngameDbMngr.addBranchObserver( IngameDbMngr.getNodePtr(), "MISSIONS", MissionStartStopObserver, missionStartStopLeavesToMonitor, getArraySize(missionStartStopLeavesToMonitor)); static const char *missionNpcAliasLeavesToMonitor [1] = {"NPC_ALIAS"}; - IngameDbMngr.getNodePtr()->addBranchObserver("MISSIONS", MissionNpcAliasObserver, missionNpcAliasLeavesToMonitor, getArraySize(missionNpcAliasLeavesToMonitor)); + IngameDbMngr.addBranchObserver( IngameDbMngr.getNodePtr(), "MISSIONS", MissionNpcAliasObserver, missionNpcAliasLeavesToMonitor, getArraySize(missionNpcAliasLeavesToMonitor)); // Skills static const char *skillLeavesToMonitor [2] = {"SKILL", "BaseSKILL"}; - IngameDbMngr.getNodePtr()->addBranchObserver("CHARACTER_INFO:SKILLS", MissionPrerequisitEventObserver, skillLeavesToMonitor, getArraySize(skillLeavesToMonitor)); + IngameDbMngr.addBranchObserver( IngameDbMngr.getNodePtr(), "CHARACTER_INFO:SKILLS", MissionPrerequisitEventObserver, skillLeavesToMonitor, getArraySize(skillLeavesToMonitor)); // Owned Items static const char *bagLeavesToMonitor [1] = {"SHEET"}; // just saves 2000 bytes or so (500 * observer pointer entry in vector) compared to one observer per bag slot - IngameDbMngr.getNodePtr()->addBranchObserver("INVENTORY:BAG", MissionPrerequisitEventObserver, bagLeavesToMonitor, getArraySize(bagLeavesToMonitor)); + IngameDbMngr.addBranchObserver( IngameDbMngr.getNodePtr(), "INVENTORY:BAG", MissionPrerequisitEventObserver, bagLeavesToMonitor, getArraySize(bagLeavesToMonitor)); // Worn Items - IngameDbMngr.getNodePtr()->addBranchObserver("INVENTORY:HAND", MissionPrerequisitEventObserver); - IngameDbMngr.getNodePtr()->addBranchObserver("INVENTORY:EQUIP", MissionPrerequisitEventObserver); + IngameDbMngr.addBranchObserver( "INVENTORY:HAND", &MissionPrerequisitEventObserver); + IngameDbMngr.addBranchObserver( "INVENTORY:EQUIP", &MissionPrerequisitEventObserver); // Known Bricks - IngameDbMngr.getNodePtr()->addBranchObserver("BRICK_FAMILY", MissionPrerequisitEventObserver); + IngameDbMngr.addBranchObserver( "BRICK_FAMILY", &MissionPrerequisitEventObserver); // For other events, search for calls of onEventForMissionAvailabilityForThisChar() } diff --git a/code/ryzom/client/src/progress.cpp b/code/ryzom/client/src/progress.cpp index be3363072..6bce2a735 100644 --- a/code/ryzom/client/src/progress.cpp +++ b/code/ryzom/client/src/progress.cpp @@ -27,6 +27,7 @@ #include "weather.h" #include "weather_manager_client.h" #include "interface_v3/input_handler_manager.h" +#include "interface_v3/interface_manager.h" #include "release.h" #include "net_manager.h" #include "client_cfg.h" @@ -393,7 +394,8 @@ void CProgress::internalProgress (float value) // \todo GUIGUI : Remove this when possible. NetMngr.update(); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // update system dependent progress bar static uint previousValue = 0; diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index d7a17c20f..1c355ca8a 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -1724,7 +1724,8 @@ void CEditor::waitScenarioScreen() } } - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // check if we can send another dated block if (NetMngr.getCurrentServerTick() != serverTick) @@ -1769,7 +1770,8 @@ void CEditor::waitScenarioScreen() if (sysInfo) sysInfo->setActive(false); getUI().updateFrameViews(NULL); - CCDBNodeBranch::flushObserversCalls(); + IngameDbMngr.flushObserverCalls(); + CInterfaceManager::getInstance()->flushObserverCalls(); // Movie shooter globalMenuMovieShooter(); From 5f041538c852f1d8db77f32b165da0d6cf5ef31d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 27 Apr 2012 22:49:38 +0200 Subject: [PATCH 019/339] Added new class CCDBManager, which encapsulates the separate CDB components into a easily (re)usable database solution. Also made CCDBSynchronized and CInterfaceManager use it. --- code/nel/include/nel/misc/cdb_manager.h | 184 ++++++++++++++++++ code/nel/src/misc/cdb_manager.cpp | 149 ++++++++++++++ code/ryzom/client/src/cdb_synchronised.cpp | 94 +-------- code/ryzom/client/src/cdb_synchronised.h | 26 +-- .../src/interface_v3/interface_manager.cpp | 125 ++---------- .../src/interface_v3/interface_manager.h | 24 +-- 6 files changed, 358 insertions(+), 244 deletions(-) create mode 100644 code/nel/include/nel/misc/cdb_manager.h create mode 100644 code/nel/src/misc/cdb_manager.cpp diff --git a/code/nel/include/nel/misc/cdb_manager.h b/code/nel/include/nel/misc/cdb_manager.h new file mode 100644 index 000000000..de6ccd20f --- /dev/null +++ b/code/nel/include/nel/misc/cdb_manager.h @@ -0,0 +1,184 @@ +// Ryzom - MMORPG Framework +// 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 CDB_MANAGER_H +#define CDB_MANAGER_H + +#include "nel/misc/cdb_branch.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_bank_handler.h" +#include "nel/misc/cdb_branch_observing_handler.h" + +namespace NLMISC{ + + /// Class that encapsulates the separate CDB components + class CCDBManager{ + + public: + /** + The constructor + @param maxBanks - The maximum number of banks to be used + + */ + CCDBManager( const char *rootNodeName, uint maxBanks ); + + ~CCDBManager(); + + + /** + Returns the specified leaf node from the database. + @param name The name of the leaf node. + @param create Specifies if the node should be created if it doesn't exist yet. + + */ + CCDBNodeLeaf* getDbLeaf( const std::string &name, bool create = true ); + + + + /** + Returns the specified branch node from the database. + @param name The name of the branch. + + */ + CCDBNodeBranch* getDbBranch( const std::string &name ); + + + /** + Deletes the specified database node. + @param name The name of the database node. + + */ + void delDbNode( const std::string &name ); + + /** + Adds an observer to a branch of the database. + @param branchName The name of the branch we want to observe + @param observer The observer we want to add + @param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe + + */ + void addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + + /** + Adds an observer to a branch of the database. + @param branch The branch we want to observe + @param observer The observer we want to add + @param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe + + */ + void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); + + + /** + Adds an observer to a branch of the database. + @param branchName The name of the branch we start from + @param dbPathFromThisNode The path to the branch we want to observe + @param observer The observer we want to add + @param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe + @param positiveLeafNameFilterSize The size of the array + + */ + void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 ); + + + /** + Adds an observer to a branch of the database. + @param branch The branch we start from + @param dbPathFromThisNode The path to the branch we want to observe + @param observer The observer we want to add + @param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe + @param positiveLeafNameFilterSize The size of the array + + */ + void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); + + + /** + Removes an observer from a branch in the database. + @param branchName The name of the branch + @param observer The observer we want to remove + + */ + void removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer ); + + + /** + Removes an observer from a branch in the database. + @param branch The branch + @param observer The observer we want to remove + + */ + void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer ); + + + /** + Removes an observer from a branch in the database. + @param branchName The name of the branch we start from + @param dbPathFromThisNode The path to the branch we want to observe from the starting branch + @param observer The observer we want to remove + + */ + void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ); + + + /** + Removes an observer from a branch in the database. + @param branchName The name of the branch we start from + @param dbPathFromThisNode The path to the branch we want to observe from the starting branch + @param observer The observer we want to remove + + */ + void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ); + + + /** + Adds a branch observer call flush observer. ( These are notified after the branch observers are notified ) + @param observer The observer + + */ + void addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + + + /** + Removes a branch observer call flush observer. + @param observer The observer + */ + void removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); + + /** + Notifies the observers whose observed branches were updated. + */ + void flushObserverCalls(); + + /** + Resets the specified bank. + @param gc GameCycle ( no idea what it is exactly, probably some time value ) + @param bank The banks we want to reset + + */ + void resetBank( uint gc, uint bank ); + + protected: + CCDBBankHandler bankHandler; + CCDBBranchObservingHandler branchObservingHandler; + CRefPtr< CCDBNodeBranch > _Database; + }; + +} + +#endif + diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp new file mode 100644 index 000000000..a13527217 --- /dev/null +++ b/code/nel/src/misc/cdb_manager.cpp @@ -0,0 +1,149 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/cdb_manager.h" + +namespace NLMISC{ + + CCDBManager::CCDBManager( const char *rootNodeName, uint maxBanks ) : bankHandler( maxBanks ) + { + _Database = new CCDBNodeBranch( std::string( rootNodeName ) ); + } + + CCDBManager::~CCDBManager() + { + if( _Database != NULL ) + { + _Database->clear(); + delete _Database; + _Database = NULL; + } + } + + CCDBNodeLeaf* CCDBManager::getDbLeaf( const std::string &name, bool create ) + { + if( name.empty() ) + return NULL; + + CCDBNodeLeaf *leaf = NULL; + leaf = dynamic_cast< CCDBNodeLeaf* >( _Database->getNode( ICDBNode::CTextId( name ), create ) ); + return leaf; + } + + CCDBNodeBranch* CCDBManager::getDbBranch( const std::string &name ) + { + if( name.empty() ) + return NULL; + + CCDBNodeBranch *branch = NULL; + branch = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( name ), false ) ); + return branch; + } + + + void CCDBManager::delDbNode( const stlpx_std::string &name ) + { + if( name.empty() ) + return; + + _Database->removeNode( ICDBNode::CTextId( name ) ); + } + + void CCDBManager::addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) + { + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter ); + } + + void CCDBManager::addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) + { + if( branch == NULL ) + return; + branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter ); + } + + void CCDBManager::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) + { + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); + } + + void CCDBManager::addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) + { + if( branch == NULL ) + return; + branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); + } + + void CCDBManager::removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer ) + { + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, observer ); + } + + void CCDBManager::removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer ) + { + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, observer ); + } + + void CCDBManager::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ) + { + CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); + if( b == NULL ) + return; + branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer ); + } + + void CCDBManager::removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer ) + { + if( branch == NULL ) + return; + branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer ); + } + + void CCDBManager::addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) + { + if( observer == NULL ) + return; + branchObservingHandler.addFlushObserver( observer ); + } + + void CCDBManager::removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) + { + if( observer == NULL ) + return; + branchObservingHandler.removeFlushObserver( observer ); + } + + void CCDBManager::flushObserverCalls() + { + branchObservingHandler.flushObserverCalls(); + } + + void CCDBManager::resetBank( uint gc, uint bank ) + { + _Database->resetNode( gc, bankHandler.getUIDForBank( bank ) ); + } + +} diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 9aee26da8..2a161d295 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -58,7 +58,7 @@ uint32 NbDatabaseChanges = 0; // CCDBSynchronised // //----------------------------------------------- -CCDBSynchronised::CCDBSynchronised() : _Database(0), _InitInProgress(true), _InitDeltaReceived(0), bankHandler( NB_CDB_BANKS ) +CCDBSynchronised::CCDBSynchronised() : _InitInProgress(true), _InitDeltaReceived(0), CCDBManager( "SERVER", NB_CDB_BANKS ) { } @@ -82,7 +82,8 @@ void CCDBSynchronised::init( const string &fileName, NLMISC::IProgressCallback & //Parse the parser output!!! bankHandler.resetNodeBankMapping(); // in case the game is restarted from start bankHandler.fillBankNames( CDBBankNames, INVALID_CDB_BANK + 1 ); - _Database = new CCDBNodeBranch("SERVER"); + if( _Database == NULL ) + _Database = new CCDBNodeBranch( "SERVER" ); _Database->init( read.getRootNode (), progressCallBack, true, &bankHandler ); } } @@ -305,7 +306,7 @@ void CCDBSynchronised::clear() { _Database->clear(); delete _Database; - _Database = 0; + _Database = NULL; } // clear CCDBNodeBranch static data @@ -324,93 +325,6 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB() } -void CCDBSynchronised::resetBank( uint gc, uint bank ){ - _Database->resetNode( gc, bankHandler.getUIDForBank( bank ) ); -} - -void CCDBSynchronised::addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - - branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter ); -} - -void CCDBSynchronised::addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) -{ - if( branch == NULL ) - return; - - branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter ); -} - -void CCDBSynchronised::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - - branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); -} - -void CCDBSynchronised::addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) -{ - if( branch == NULL ) - return; - branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); -} - -void CCDBSynchronised::removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - branchObservingHandler.removeBranchObserver( b, observer ); -} - -void CCDBSynchronised::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ) -{ - if( branch == NULL ) - return; - branchObservingHandler.removeBranchObserver( branch, observer ); -} - -void CCDBSynchronised::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _Database->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer ); -} - -void CCDBSynchronised::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) -{ - if( branch == NULL ) - return; - branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer ); -} - -void CCDBSynchronised::addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) -{ - if( observer == NULL ) - return; - branchObservingHandler.addFlushObserver( observer ); -} - -void CCDBSynchronised::removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) -{ - if( observer == NULL ) - return; - branchObservingHandler.removeFlushObserver( observer ); -} - -void CCDBSynchronised::flushObserverCalls() -{ - branchObservingHandler.flushObserverCalls(); -} - - #ifdef TRACE_READ_DELTA #undef TRACE_READ_DELTA #endif diff --git a/code/ryzom/client/src/cdb_synchronised.h b/code/ryzom/client/src/cdb_synchronised.h index f7c21f01b..cc151cbcb 100644 --- a/code/ryzom/client/src/cdb_synchronised.h +++ b/code/ryzom/client/src/cdb_synchronised.h @@ -22,8 +22,7 @@ #include "nel/misc/cdb.h" #include "nel/misc/cdb_branch.h" -#include "nel/misc/cdb_bank_handler.h" -#include "nel/misc/cdb_branch_observing_handler.h" +#include "nel/misc/cdb_manager.h" /** * Class to manage a database of properties @@ -31,11 +30,8 @@ * \author Nevrax France * \date 2002 */ -class CCDBSynchronised +class CCDBSynchronised : public NLMISC::CCDBManager { - /// database - NLMISC::CRefPtr _Database; - /// string associations std::map _Strings; @@ -146,8 +142,6 @@ public: } } - void resetBank( uint gc, uint bank ); - private: friend void impulseDatabaseInitPlayer( NLMISC::CBitMemStream &impulse ); @@ -157,22 +151,6 @@ private: bool allInitPacketReceived() const { return _InitDeltaReceived == 2; } // Classic database + inventory void writeInitInProgressIntoUIDB(); - - NLMISC::CCDBBankHandler bankHandler; - NLMISC::CCDBBranchObservingHandler branchObservingHandler; - -public: - void addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); - void addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); - void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 ); - void addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); - void removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ); - void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ); - void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); - void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); - void addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); - void removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); - void flushObserverCalls(); }; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 5cb70e401..fa1fdd335 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -103,6 +103,8 @@ #include "../client_chat_manager.h" // for emotes #include "../entities.h" +#include "../../common/src/game_share/ryzom_database_banks.h" + #include "chat_text_manager.h" #include "../npc_icon.h" @@ -253,10 +255,9 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS // ------------------------------------------------------------------------------------------------ -CInterfaceManager::CInterfaceManager() +CInterfaceManager::CInterfaceManager() : NLMISC::CCDBManager( "ROOT", NB_CDB_BANKS ) { _Instance = this; - _DbRootNode = new CCDBNodeBranch("ROOT"); interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; @@ -361,10 +362,11 @@ CInterfaceManager::~CInterfaceManager() _Templates.clear(); _Instance = NULL; - if (_DbRootNode) + if (_Database) { - delete _DbRootNode; - _DbRootNode = NULL; + _Database->clear(); + delete _Database; + _Database = NULL; } // release the local string mapper @@ -502,7 +504,7 @@ void CInterfaceManager::uninitLogin() CInterfaceLink::removeAllLinks(); ICDBNode::CTextId textId("UI"); - _DbRootNode->removeNode(textId); + _Database->removeNode(textId); { uninitActions(); @@ -597,7 +599,7 @@ void CInterfaceManager::uninitOutGame() disableModalWindow(); - //_DbRootNode->display(""); + //_Database->display(""); CBotChatManager::getInstance()->setCurrPage(NULL); CInterfaceItemEdition::getInstance()->setCurrWindow(NULL); @@ -627,7 +629,7 @@ void CInterfaceManager::uninitOutGame() //nlinfo ("%d seconds for removeAllLinks", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); ICDBNode::CTextId textId("UI"); - _DbRootNode->removeNode(textId); + _Database->removeNode(textId); //nlinfo ("%d seconds for removeNode", (uint32)(ryzomGetLocalTime ()-initStart)/1000); // Init the action manager @@ -1160,7 +1162,7 @@ void CInterfaceManager::uninitInGame1 () // remove DB entry ICDBNode::CTextId textId("UI"); - _DbRootNode->removeNode(textId); + _Database->removeNode(textId); // Uninit the action manager { @@ -3327,13 +3329,13 @@ void CInterfaceManager::updateAllLocalisedElements() // ------------------------------------------------------------------------------------------------ bool CInterfaceManager::addDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id) { - return _DbRootNode->addObserver(observer, id); + return _Database->addObserver(observer, id); } // ------------------------------------------------------------------------------------------------ bool CInterfaceManager::removeDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id) { - return _DbRootNode->removeObserver(observer, id); + return _Database->removeObserver(observer, id); } // ------------------------------------------------------------------------------------------------ @@ -3431,26 +3433,13 @@ sint32 CInterfaceManager::getDbValue32 (const std::string & name) // ------------------------------------------------------------------------------------------------ CCDBNodeLeaf* CInterfaceManager::getDbProp(const std::string & name, bool bCreate) { - if (name.empty()) return NULL; - CCDBNodeLeaf *pDBNL = NULL; - pDBNL = dynamic_cast(_DbRootNode->getNode( ICDBNode::CTextId(name), bCreate )); - return pDBNL; + return getDbLeaf( name, bCreate ); } // ------------------------------------------------------------------------------------------------ void CInterfaceManager::delDbProp(const std::string & name) { - if (name.empty()) return; - _DbRootNode->removeNode( ICDBNode::CTextId(name) ); -} - -// ------------------------------------------------------------------------------------------------ -CCDBNodeBranch *CInterfaceManager::getDbBranch(const std::string &name) -{ - if (name.empty()) return NULL; - CCDBNodeBranch *nodeBranch; - nodeBranch = dynamic_cast(_DbRootNode->getNode( ICDBNode::CTextId(name), false )); - return nodeBranch; + delDbNode( name ); } // ------------------------------------------------------------------------------------------------ @@ -6113,7 +6102,7 @@ void CInterfaceManager::createLocalBranch(const std::string &fileName, NLMISC::I //Parse the parser output!!! CCDBNodeBranch *localNode = new CCDBNodeBranch("LOCAL"); localNode->init( read.getRootNode (), progressCallBack ); - _DbRootNode->attachChild(localNode,"LOCAL"); + _Database->attachChild(localNode,"LOCAL"); // Create the observers for auto-copy SERVER->LOCAL of inventory ServerToLocalAutoCopyInventory.init("INVENTORY"); @@ -6652,85 +6641,3 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) return true;; } -void CInterfaceManager::addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - - branchObservingHandler.addBranchObserver( b, observer, positiveLeafNameFilter ); -} - -void CInterfaceManager::addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter ) -{ - if( branch == NULL ) - return; - - branchObservingHandler.addBranchObserver( branch, observer, positiveLeafNameFilter ); -} - -void CInterfaceManager::addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - - branchObservingHandler.addBranchObserver( b, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); -} - -void CInterfaceManager::addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ) -{ - if( branch == NULL ) - return; - branchObservingHandler.addBranchObserver( branch, dbPathFromThisNode, observer, positiveLeafNameFilter, positiveLeafNameFilterSize ); -} - -void CInterfaceManager::removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - branchObservingHandler.removeBranchObserver( b, observer ); -} - -void CInterfaceManager::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ) -{ - if( branch == NULL ) - return; - branchObservingHandler.removeBranchObserver( branch, observer ); -} - -void CInterfaceManager::removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) -{ - CCDBNodeBranch *b = dynamic_cast< CCDBNodeBranch* >( _DbRootNode->getNode( ICDBNode::CTextId( std::string( branchName ) ), false ) ); - if( b == NULL ) - return; - branchObservingHandler.removeBranchObserver( b, dbPathFromThisNode, observer ); -} - -void CInterfaceManager::removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ) -{ - if( branch == NULL ) - return; - branchObservingHandler.removeBranchObserver( branch, dbPathFromThisNode, observer ); -} - -void CInterfaceManager::addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) -{ - if( observer == NULL ) - return; - branchObservingHandler.addFlushObserver( observer ); -} - -void CInterfaceManager::removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ) -{ - if( observer == NULL ) - return; - branchObservingHandler.removeFlushObserver( observer ); -} - -void CInterfaceManager::flushObserverCalls() -{ - branchObservingHandler.flushObserverCalls(); -} - diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index a98d4a8fc..cb162a24d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -20,6 +20,7 @@ #define NL_INTERFACE_MANAGER_H #include "nel/misc/types_nl.h" +#include "nel/misc/cdb_manager.h" #include "nel/3d/u_texture.h" #include "nel/3d/u_text_context.h" #include "interface_group.h" @@ -77,7 +78,7 @@ class CGroupMenu; * \author Nevrax France * \date 2002 */ -class CInterfaceManager : public CInterfaceParser +class CInterfaceManager : public CInterfaceParser, public NLMISC::CCDBManager { public: @@ -229,12 +230,10 @@ public: /// Get the root of the database - NLMISC::CCDBNodeBranch *getDB() const { return _DbRootNode; } + NLMISC::CCDBNodeBranch *getDB() const { return _Database; } // yoyo: should avoid to try creating DbPropr with this system... very dangerous NLMISC::CCDBNodeLeaf* getDbProp (const std::string & name, bool bCreate=true); void delDbProp(const std::string & name); - // get a Db Branch by its name. NULL if don't exist or not a branch (never try to create it) - NLMISC::CCDBNodeBranch *getDbBranch(const std::string &name); // return the DB as an int32. return 0 if the DB does not exist (never create) sint32 getDbValue32 (const std::string & name); @@ -959,9 +958,6 @@ private: NLMISC::CRGBA _GlobalColor; sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface - // root node for interfaces properties in the databases - NLMISC::CCDBNodeBranch *_DbRootNode; - // List of active Anims std::vector _ActiveAnims; @@ -1065,20 +1061,6 @@ private: void updateTooltipCoords(CCtrlBase *newCtrl); CInterfaceLink::CInterfaceLinkUpdater *interfaceLinkUpdater; - NLMISC::CCDBBranchObservingHandler branchObservingHandler; - -public: - void addBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); - void addBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() ); - void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 ); - void addBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize ); - void removeBranchObserver( const char *branchName, NLMISC::ICDBNode::IPropertyObserver* observer ); - void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, NLMISC::ICDBNode::IPropertyObserver* observer ); - void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); - void removeBranchObserver( NLMISC::CCDBNodeBranch *branch, const char *dbPathFromThisNode, NLMISC::ICDBNode::IPropertyObserver &observer ); - void addFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); - void removeFlushObserver( NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer ); - void flushObserverCalls(); }; #endif // NL_INTERFACE_MANAGER_H From c976419448d3bdaf8077a9ec0e5342858743cf21 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 10 May 2012 22:17:04 +0200 Subject: [PATCH 020/339] Created NELGUI library, moved the GUI event descriptors there. --- code/CMakeModules/nel.cmake | 1 + code/nel/include/nel/CMakeLists.txt | 4 ++++ code/nel/include/nel/gui/CMakeLists.txt | 3 +++ .../include/nel/gui}/event_descriptor.h | 0 code/nel/src/CMakeLists.txt | 4 ++++ code/nel/src/gui/CMakeLists.txt | 14 ++++++++++++++ .../src/gui}/event_descriptor.cpp | 5 ++--- code/ryzom/client/src/CMakeLists.txt | 1 + code/ryzom/client/src/interface_v3/ctrl_base.h | 2 +- .../src/interface_v3/input_handler_manager.h | 2 +- code/ryzom/client/src/r2/editor.cpp | 2 +- code/ryzom/client/src/r2/tool.cpp | 2 +- 12 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 code/nel/include/nel/gui/CMakeLists.txt rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/event_descriptor.h (100%) create mode 100644 code/nel/src/gui/CMakeLists.txt rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/event_descriptor.cpp (92%) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index e6bf57101..f54fae8d1 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -274,6 +274,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) ### OPTION(WITH_NET "Build NLNET" ON ) OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_GUI "Build GUI" ON ) OPTION(WITH_PACS "Build NLPACS" ON ) OPTION(WITH_GEORGES "Build NLGEORGES" ON ) OPTION(WITH_LIGO "Build NLLIGO" ON ) diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index 9e2d5586c..5f2bca43c 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -4,6 +4,10 @@ IF(WITH_3D) SUBDIRS(3d) ENDIF(WITH_3D) +IF(WITH_GUI) + ADD_SUBDIRECTORY(gui) +ENDIF(WITH_GUI) + IF(WITH_GEORGES) SUBDIRS(georges) ENDIF(WITH_GEORGES) diff --git a/code/nel/include/nel/gui/CMakeLists.txt b/code/nel/include/nel/gui/CMakeLists.txt new file mode 100644 index 000000000..ba66d4451 --- /dev/null +++ b/code/nel/include/nel/gui/CMakeLists.txt @@ -0,0 +1,3 @@ +FILE(GLOB HEADERS *.h) + +INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers) diff --git a/code/ryzom/client/src/interface_v3/event_descriptor.h b/code/nel/include/nel/gui/event_descriptor.h similarity index 100% rename from code/ryzom/client/src/interface_v3/event_descriptor.h rename to code/nel/include/nel/gui/event_descriptor.h diff --git a/code/nel/src/CMakeLists.txt b/code/nel/src/CMakeLists.txt index 4bf260c13..2f1099e60 100644 --- a/code/nel/src/CMakeLists.txt +++ b/code/nel/src/CMakeLists.txt @@ -4,6 +4,10 @@ IF(WITH_3D) ADD_SUBDIRECTORY(3d) ENDIF(WITH_3D) +IF(WITH_GUI) + ADD_SUBDIRECTORY(gui) +ENDIF(WITH_GUI) + IF(WITH_GEORGES) ADD_SUBDIRECTORY(georges) ENDIF(WITH_GEORGES) diff --git a/code/nel/src/gui/CMakeLists.txt b/code/nel/src/gui/CMakeLists.txt new file mode 100644 index 000000000..5359c1130 --- /dev/null +++ b/code/nel/src/gui/CMakeLists.txt @@ -0,0 +1,14 @@ +FILE(GLOB SRC *.cpp *.h) +FILE(GLOB HEADERS ../../include/nel/gui/*.h) + +NL_TARGET_LIB(nelgui ${HEADERS} ${SRC}) + +SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "") +NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI") +NL_ADD_RUNTIME_FLAGS(nelgui) + +NL_ADD_LIB_SUFFIX(nelgui) + +IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) + INSTALL(TARGETS nelgui LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries) +ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC) diff --git a/code/ryzom/client/src/interface_v3/event_descriptor.cpp b/code/nel/src/gui/event_descriptor.cpp similarity index 92% rename from code/ryzom/client/src/interface_v3/event_descriptor.cpp rename to code/nel/src/gui/event_descriptor.cpp index 2e72c69c2..f91f078bf 100644 --- a/code/ryzom/client/src/interface_v3/event_descriptor.cpp +++ b/code/nel/src/gui/event_descriptor.cpp @@ -16,9 +16,8 @@ -#include "stdpch.h" - -#include "event_descriptor.h" +#include "nel/misc/events.h" +#include "nel/gui/event_descriptor.h" void CEventDescriptorKey::init(const NLMISC::CEventKey &ev) { diff --git a/code/ryzom/client/src/CMakeLists.txt b/code/ryzom/client/src/CMakeLists.txt index 3971fb98f..4cd9373fc 100644 --- a/code/ryzom/client/src/CMakeLists.txt +++ b/code/ryzom/client/src/CMakeLists.txt @@ -81,6 +81,7 @@ TARGET_LINK_LIBRARIES(ryzom_client nelligo nelgeorges nel3d + nelgui nelsound ryzom_clientsheets ryzom_gameshare diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.h b/code/ryzom/client/src/interface_v3/ctrl_base.h index bf0f5f10c..b88716c53 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "view_base.h" -#include "event_descriptor.h" +#include "nel/gui/event_descriptor.h" class CCtrlBase : public CViewBase { diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.h b/code/ryzom/client/src/interface_v3/input_handler_manager.h index 7f0cc1c1c..23a5afeb5 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.h @@ -24,7 +24,7 @@ #include #include #include -#include "event_descriptor.h" +#include "nel/gui/event_descriptor.h" /** diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 1c355ca8a..e831cf8a2 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -54,7 +54,7 @@ #include "../entities.h" #include "../events_listener.h" #include "../interface_v3/group_list.h" -#include "../interface_v3/event_descriptor.h" +#include "nel/gui/event_descriptor.h" #include "../interface_v3/group_tree.h" #include "../client_cfg.h" #include "../interface_v3/lua_ihm.h" diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index 6f8861929..94854fd51 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -21,7 +21,7 @@ #include "r2_config.h" // #include "../interface_v3/interface_manager.h" -#include "../interface_v3/event_descriptor.h" +#include "nel/gui/event_descriptor.h" #include "../motion/user_controls.h" #include "../global.h" #include "../entities.h" From e3d72333dd4fa28ebd2f9e57dfc14feff9f53acc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 10 May 2012 23:31:39 +0200 Subject: [PATCH 021/339] Moved event descriptors under the NLGUI namespace. --- code/nel/include/nel/gui/event_descriptor.h | 4 + code/nel/src/gui/event_descriptor.cpp | 5 ++ .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../client/src/interface_v3/ctrl_base.cpp | 10 +-- .../ryzom/client/src/interface_v3/ctrl_base.h | 2 +- .../src/interface_v3/ctrl_base_button.cpp | 22 +++--- .../src/interface_v3/ctrl_base_button.h | 2 +- .../client/src/interface_v3/ctrl_button.h | 6 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 12 +-- .../client/src/interface_v3/ctrl_col_pick.h | 2 +- .../client/src/interface_v3/ctrl_polygon.cpp | 2 +- .../client/src/interface_v3/ctrl_polygon.h | 2 +- .../client/src/interface_v3/ctrl_quad.cpp | 2 +- .../ryzom/client/src/interface_v3/ctrl_quad.h | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 16 ++-- .../client/src/interface_v3/ctrl_scroll.h | 2 +- .../src/interface_v3/ctrl_text_button.h | 5 +- .../client/src/interface_v3/ctrl_tooltip.cpp | 2 +- .../client/src/interface_v3/ctrl_tooltip.h | 7 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 16 ++-- .../client/src/interface_v3/dbctrl_sheet.h | 2 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 10 +-- .../src/interface_v3/dbgroup_list_sheet.h | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 20 ++--- .../interface_v3/dbgroup_list_sheet_text.h | 2 +- .../interface_v3/dbgroup_select_number.cpp | 8 +- .../src/interface_v3/dbgroup_select_number.h | 2 +- .../client/src/interface_v3/group_compas.cpp | 8 +- .../client/src/interface_v3/group_compas.h | 2 +- .../src/interface_v3/group_container.cpp | 76 +++++++++---------- .../client/src/interface_v3/group_container.h | 15 ++-- .../client/src/interface_v3/group_editbox.cpp | 36 ++++----- .../client/src/interface_v3/group_editbox.h | 12 +-- .../client/src/interface_v3/group_header.cpp | 20 ++--- .../client/src/interface_v3/group_html.cpp | 8 +- .../client/src/interface_v3/group_html.h | 2 +- .../client/src/interface_v3/group_list.cpp | 6 +- .../client/src/interface_v3/group_list.h | 2 +- .../client/src/interface_v3/group_map.cpp | 44 +++++------ .../ryzom/client/src/interface_v3/group_map.h | 6 +- .../client/src/interface_v3/group_menu.cpp | 16 ++-- .../client/src/interface_v3/group_menu.h | 4 +- .../src/interface_v3/group_modal_get_key.cpp | 8 +- .../src/interface_v3/group_modal_get_key.h | 2 +- .../src/interface_v3/group_paragraph.cpp | 6 +- .../client/src/interface_v3/group_paragraph.h | 2 +- .../src/interface_v3/group_scrolltext.cpp | 8 +- .../src/interface_v3/group_scrolltext.h | 2 +- .../client/src/interface_v3/group_tab.cpp | 8 +- .../ryzom/client/src/interface_v3/group_tab.h | 2 +- .../client/src/interface_v3/group_tree.cpp | 10 +-- .../client/src/interface_v3/group_tree.h | 2 +- .../client/src/interface_v3/group_wheel.cpp | 8 +- .../client/src/interface_v3/group_wheel.h | 2 +- .../interface_v3/input_handler_manager.cpp | 34 ++++----- .../src/interface_v3/input_handler_manager.h | 6 +- .../src/interface_v3/interface_3d_scene.cpp | 24 +++--- .../src/interface_v3/interface_3d_scene.h | 2 +- .../src/interface_v3/interface_group.cpp | 24 +++--- .../client/src/interface_v3/interface_group.h | 4 +- .../src/interface_v3/interface_manager.cpp | 48 ++++++------ .../src/interface_v3/interface_manager.h | 6 +- .../client/src/r2/displayer_visual_group.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 10 +-- code/ryzom/client/src/r2/editor.h | 2 +- .../ryzom/client/src/r2/instance_map_deco.cpp | 2 +- code/ryzom/client/src/r2/instance_map_deco.h | 2 +- code/ryzom/client/src/r2/tool.cpp | 24 +++--- code/ryzom/client/src/r2/tool.h | 7 +- 69 files changed, 354 insertions(+), 329 deletions(-) diff --git a/code/nel/include/nel/gui/event_descriptor.h b/code/nel/include/nel/gui/event_descriptor.h index fc601806f..54b561e6a 100644 --- a/code/nel/include/nel/gui/event_descriptor.h +++ b/code/nel/include/nel/gui/event_descriptor.h @@ -21,6 +21,8 @@ #include "nel/misc/types_nl.h" +namespace NLGUI +{ // ---------------------------------------------------------------------------- class CEventDescriptor @@ -247,6 +249,8 @@ protected: bool _HasFocus; }; +} + #endif // RZ_EVENT_DESCRIPTOR_H /* End of event_descriptor.h */ diff --git a/code/nel/src/gui/event_descriptor.cpp b/code/nel/src/gui/event_descriptor.cpp index f91f078bf..851c0504b 100644 --- a/code/nel/src/gui/event_descriptor.cpp +++ b/code/nel/src/gui/event_descriptor.cpp @@ -19,6 +19,9 @@ #include "nel/misc/events.h" #include "nel/gui/event_descriptor.h" +namespace NLGUI +{ + void CEventDescriptorKey::init(const NLMISC::CEventKey &ev) { _CtrlState = (ev.Button & NLMISC::ctrlKeyButton) != 0; @@ -50,3 +53,5 @@ void CEventDescriptorKey::init(const NLMISC::CEventKey &ev) } } +} + diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 509dfcd62..b17021cde 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -2249,7 +2249,7 @@ class CAHConfirmTrade : public IActionHandler case 1: enableResale = true; break; default: // 2: comes only from Enter of Shift+Enter key from an edit box or in the modal window { - const CEventDescriptorKey& keyEvent = CInterfaceManager::getInstance()->getLastEventKeyDesc(); + const NLGUI::CEventDescriptorKey& keyEvent = CInterfaceManager::getInstance()->getLastEventKeyDesc(); enableResale = ! keyEvent.getKeyShift(); } } diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_base.cpp index f3c7dbbec..353b5d9e1 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base.cpp @@ -32,14 +32,14 @@ CCtrlBase::~CCtrlBase() } // *************************************************************************** -bool CCtrlBase::handleEvent(const CEventDescriptor &event) +bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - CEventDescriptorSystem &eds = (CEventDescriptorSystem&)event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::activecalledonparent) + NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) { - if (!((CEventDescriptorActiveCalledOnParent &) eds).getActive()) + if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive()) { // the mouse capture should be lost when the ctrl is hidden CInterfaceManager *manager = CInterfaceManager::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.h b/code/ryzom/client/src/interface_v3/ctrl_base.h index b88716c53..bc0caa7e4 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base.h @@ -58,7 +58,7 @@ public: /// Handle all events (implemented by derived classes) (return true to signal event handled) - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index 12db635bf..045e9cf5c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -199,18 +199,18 @@ void CCtrlBaseButton::setModulateGlobalColorAll(bool state) // *************************************************************************** -bool CCtrlBaseButton::handleEvent (const CEventDescriptor& event) +bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active || _Frozen) return false; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (pIM->getCapturePointerLeft() != this) return false; @@ -223,7 +223,7 @@ bool CCtrlBaseButton::handleEvent (const CEventDescriptor& event) (eventDesc.getY() <= (_YReal+ _HReal)))) return false; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if (_AHOnLeftDblClick) { @@ -246,7 +246,7 @@ bool CCtrlBaseButton::handleEvent (const CEventDescriptor& event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (pIM->getCapturePointerLeft() != this) return false; @@ -299,12 +299,12 @@ bool CCtrlBaseButton::handleEvent (const CEventDescriptor& event) // Always return true on LeftClick. return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { _LastLeftClickButton = NULL; return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { _LastLeftClickButton = NULL; bool handled= false; @@ -331,10 +331,10 @@ bool CCtrlBaseButton::handleEvent (const CEventDescriptor& event) } - else if (event.getType() == CEventDescriptor::system) + else if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &systemEvent = (const CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == CEventDescriptorSystem::clocktick) + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) { if (_AHOnClockTick != NULL) { diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.h b/code/ryzom/client/src/interface_v3/ctrl_base_button.h index c33f0c63e..eb7438e8b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.h @@ -40,7 +40,7 @@ public: CCtrlBaseButton(const TCtorParam ¶m); virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual bool handleEvent (const CEventDescriptor& event); + virtual bool handleEvent (const NLGUI::CEventDescriptor& event); /// \name Misc // @{ diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.h b/code/ryzom/client/src/interface_v3/ctrl_button.h index ff769e6c4..3b035b01c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_button.h @@ -22,8 +22,10 @@ #include "ctrl_base_button.h" #include "view_renderer.h" - -class CEventDescriptor; +namespace NLGUI +{ + class CEventDescriptor; +} class CInterfaceManager; /** diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index ece811773..70a1856e8 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -108,14 +108,14 @@ void CCtrlColPick::draw() } // ------------------------------------------------------------------------------------------------ -bool CCtrlColPick::handleEvent (const CEventDescriptor &event) +bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active) return false; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && (!((eventDesc.getX() >= _XReal) && (eventDesc.getX() < (_XReal + _WReal))&& @@ -123,18 +123,18 @@ bool CCtrlColPick::handleEvent (const CEventDescriptor &event) (eventDesc.getY() <= (_YReal+ _HReal))))) return false; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { _MouseDown = true; selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal); return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { _MouseDown = false; return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (_MouseDown) { diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h b/code/ryzom/client/src/interface_v3/ctrl_col_pick.h index ebfc0fd3f..741341b5f 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.h @@ -40,7 +40,7 @@ public: virtual void updateCoords(); virtual void draw(); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); sint32 getColorR () const { return _ColorSelect.R; } sint32 getColorG () const { return _ColorSelect.G; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp index 078059960..9bcc2411f 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp @@ -278,7 +278,7 @@ void CCtrlPolygon::setAlpha(sint32 a) } // ********************************************************************************* -bool CCtrlPolygon::handleEvent(const CEventDescriptor &/* event */) +bool CCtrlPolygon::handleEvent(const NLGUI::CEventDescriptor &/* event */) { H_AUTO(Rz_CCtrlPolygon_handleEvent) return false; diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.h b/code/ryzom/client/src/interface_v3/ctrl_polygon.h index 20b09ee0f..356f37e55 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.h +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.h @@ -64,7 +64,7 @@ public: //const NLMISC::CMatrix &getMatrix() const { return _Matrix; } // test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself) bool isValid() const { return _Valid; } - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); // no capturable by default (just tooltip capability wanted) virtual bool isCapturable() const { return false; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp index 23b6069ad..e517342bf 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp @@ -410,7 +410,7 @@ void CCtrlQuad::setCustomUVs(const CUV uvs[4]) } // ********************************************************************************* -bool CCtrlQuad::handleEvent(const CEventDescriptor &/* event */) +bool CCtrlQuad::handleEvent(const NLGUI::CEventDescriptor &/* event */) { H_AUTO(Rz_CCtrlQuad_handleEvent) return false; diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.h b/code/ryzom/client/src/interface_v3/ctrl_quad.h index 0422f99af..c2ce759cb 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.h +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.h @@ -85,7 +85,7 @@ public: // from CCtrlBase, no op by default - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); // see if this control contains the given point (in parent coords) bool contains(const NLMISC::CVector2f &pos) const; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index a95cda085..252ff3236 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -457,14 +457,14 @@ void CCtrlScroll::draw() } // ------------------------------------------------------------------------------------------------ -bool CCtrlScroll::handleEvent (const CEventDescriptor &event) +bool CCtrlScroll::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active || _Frozen) return false; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && (!((eventDesc.getX() >= _XReal) && (eventDesc.getX() < (_XReal + _WReal))&& @@ -472,7 +472,7 @@ bool CCtrlScroll::handleEvent (const CEventDescriptor &event) (eventDesc.getY() <= (_YReal+ _HReal))))) return false; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { _MouseDown = true; _InitialValue = getValue(); @@ -490,20 +490,20 @@ bool CCtrlScroll::handleEvent (const CEventDescriptor &event) } return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { _MouseDown = false; runAH(_AHOnScrollEnd, _AHOnScrollEndParams.empty() ? _AHOnScrollParams : _AHOnScrollEndParams); // backward compatibility return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown && _MouseDown && _Cancelable) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown && _MouseDown && _Cancelable) { _MouseDown = false; setValue(_InitialValue); runAH(_AHOnScrollCancel, _AHOnScrollCancelParams); // backward compatibility return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (_MouseDown) { @@ -514,7 +514,7 @@ bool CCtrlScroll::handleEvent (const CEventDescriptor &event) } return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel && _Vertical) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && _Vertical) { moveTrackY (eventDesc.getWheel() * 12); return true; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h index f86d0047d..f7aa19b72 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.h @@ -41,7 +41,7 @@ public: virtual void updateCoords(); virtual void draw(); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); void setTarget (CInterfaceGroup *pIG); diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h index 183ab3ab8..6383f3374 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.h @@ -23,7 +23,10 @@ #include "view_renderer.h" -class CEventDescriptor; +namespace NLGUI +{ + class CEventDescriptor; +} class CInterfaceManager; class CViewText; diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp index 5e276d886..3d50931a5 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp @@ -38,7 +38,7 @@ void CCtrlToolTip::draw () } // ---------------------------------------------------------------------------- -bool CCtrlToolTip::handleEvent (const CEventDescriptor& event) +bool CCtrlToolTip::handleEvent (const NLGUI::CEventDescriptor& event) { if (CCtrlBase::handleEvent(event)) return true; return false; diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h index 8be53ca8c..ddd0b42c1 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h @@ -22,7 +22,10 @@ #include "ctrl_base.h" #include "nel/3d/u_texture.h" -class CEventDescriptor; +namespace NLGUI +{ + class CEventDescriptor; +} class CInterfaceManager; /** @@ -37,7 +40,7 @@ public: /// Constructor CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {} - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); virtual void draw(); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); // Can do nothing with tooltip (but display it :) ) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 9c3b59c3f..46efd5514 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2590,18 +2590,18 @@ sint32 CDBCtrlSheet::drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 /* hSh } // ---------------------------------------------------------------------------- -bool CDBCtrlSheet::handleEvent (const CEventDescriptor &event) +bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // Handle drag'n'drop if (pIM->getCapturePointerLeft() == this) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown && !_Draging) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Draging) { _DragX = eventDesc.getX(); _DragY = eventDesc.getY(); @@ -2655,7 +2655,7 @@ bool CDBCtrlSheet::handleEvent (const CEventDescriptor &event) if (_Draging) { // If mouse left up, must end the Drag - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { bool handled = false; // get the ctrl under the drop @@ -2843,7 +2843,7 @@ bool CDBCtrlSheet::handleEvent (const CEventDescriptor &event) (eventDesc.getY() <= (_YReal+ _HReal)))) return false; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pIM->getCapturePointerLeft() != this) @@ -2865,12 +2865,12 @@ bool CDBCtrlSheet::handleEvent (const CEventDescriptor &event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { bool handled= false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 95bd7278c..f904e34a8 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -189,7 +189,7 @@ public: virtual void draw(); void drawSheet (sint32 scrX, sint32 scrY, bool draging, bool showSelectionBorder = true); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); void setActionOnLeftClick (const std::string &ActionHandlerName) { _AHOnLeftClick = getAH(ActionHandlerName, _AHLeftClickParams); } void setActionOnRightClick (const std::string &ActionHandlerName) { _AHOnRightClick = getAH(ActionHandlerName, _AHRightClickParams); } diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 93d525558..b8461c9c3 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -749,14 +749,14 @@ void CDBGroupListSheet::clearViews () } // *************************************************************************** -bool CDBGroupListSheet::handleEvent (const CEventDescriptor &event) +bool CDBGroupListSheet::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (isIn(eventDesc.getX(), eventDesc.getY())) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { if (_ScrollBar != NULL) { @@ -765,7 +765,7 @@ bool CDBGroupListSheet::handleEvent (const CEventDescriptor &event) return true; } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { CGroupContainer *pGC = getContainer(); if (pGC != NULL) pGC->setHighLighted(false); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index a1005f3b6..2af0ef02a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -49,7 +49,7 @@ public: virtual void checkCoords (); virtual void draw (); virtual void clearViews (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); // mod interface void changeNbRow(sint delta); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 557ede4e3..2ec39cd85 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -664,12 +664,12 @@ void CDBGroupListSheetText::clearViews () } // *************************************************************************** -bool CDBGroupListSheetText::handleEvent (const CEventDescriptor &event) +bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { _Scrolling = 0; - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (isIn(eventDesc.getX(), eventDesc.getY())) { // Drag'n'drop from a ctrl sheet that belongs to this list @@ -687,9 +687,9 @@ bool CDBGroupListSheetText::handleEvent (const CEventDescriptor &event) { pDraggedSheet = _SheetChildren[pos]->Ctrl; pIM->setCapturePointerLeft(pDraggedSheet); - CEventDescriptorMouse newEv = eventDesc; + NLGUI::CEventDescriptorMouse newEv = eventDesc; // Send this because not send (the captured button has processed the event mouseleftdown) - newEv.setEventTypeExtended(CEventDescriptorMouse::mouseleftdown); + newEv.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdown); pDraggedSheet->handleEvent(newEv); } } @@ -711,7 +711,7 @@ bool CDBGroupListSheetText::handleEvent (const CEventDescriptor &event) if(swapable()) { if (pDraggedSheet != NULL) - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { sint posdst = -1,possrc = -1; const vector &rV = pIM->getCtrlsUnderPointer(); @@ -733,7 +733,7 @@ bool CDBGroupListSheetText::handleEvent (const CEventDescriptor &event) } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { // If scroll ok, and if scroll possible if (_ScrollBar != NULL && _List != NULL && _List->getH()>_List->getMaxH()) @@ -752,10 +752,10 @@ bool CDBGroupListSheetText::handleEvent (const CEventDescriptor &event) } } } - else if (event.getType() == CEventDescriptor::system) + else if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &systemEvent = (const CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == CEventDescriptorSystem::clocktick) + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) { if (_Scrolling != 0) if (_ScrollBar != NULL && _List != NULL) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index 38d538df3..bf6d6be67 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -57,7 +57,7 @@ public: virtual void checkCoords (); virtual void draw (); virtual void clearViews (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); /// \name IListSheetBase implementation // @{ diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index 8ef0c3217..adce780f7 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -149,14 +149,14 @@ void CDBGroupSelectNumber::clearViews () } // *************************************************************************** -bool CDBGroupSelectNumber::handleEvent (const CEventDescriptor &event) +bool CDBGroupSelectNumber::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (isIn(eventDesc.getX(), eventDesc.getY())) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { changeValue (eventDesc.getWheel()); return true; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h index 39d3d3a54..0375e920d 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h @@ -51,7 +51,7 @@ public: virtual void checkCoords(); virtual void draw (); virtual void clearViews (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); // mod interface void changeValue(sint delta); diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index fa9d62d5a..10a8ac230 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -399,15 +399,15 @@ void CGroupCompas::draw() // *************************************************************************** -bool CGroupCompas::handleEvent (const CEventDescriptor &event) +bool CGroupCompas::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // if ((_RadarView != NULL) && (_RadarRangeView != NULL)) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); _RadarPos = pIM->getDbProp("UI:SAVE:RADARZOOM")->getValue32(); diff --git a/code/ryzom/client/src/interface_v3/group_compas.h b/code/ryzom/client/src/interface_v3/group_compas.h index 112b6ae68..9277c2e76 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.h +++ b/code/ryzom/client/src/interface_v3/group_compas.h @@ -86,7 +86,7 @@ public: virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); virtual void updateCoords(); virtual void draw(); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); void setTarget(const CCompassTarget &target); const CCompassTarget &getTarget() const { return _Target; } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index e494af8f2..3d76b1c80 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -151,18 +151,18 @@ void CCtrlResizer::draw () } // *************************************************************************** -bool CCtrlResizer::handleEvent (const CEventDescriptor &event) +bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active || !_Parent) return false; - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false && _MouseDown) { _MouseDown = false; @@ -172,15 +172,15 @@ bool CCtrlResizer::handleEvent (const CEventDescriptor &event) } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc.getX(), eventDesc.getY())) return false; CGroupContainer *gc = dynamic_cast(_Parent); - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { // must check that parent isn't closed if (gc) @@ -200,13 +200,13 @@ bool CCtrlResizer::handleEvent (const CEventDescriptor &event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { _MouseDown = false; _Parent->invalidateCoords(); return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (_MouseDown) { @@ -560,7 +560,7 @@ void CCtrlMover::draw () } // *************************************************************************** -bool CCtrlMover::handleEvent (const CEventDescriptor &event) +bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active) @@ -568,12 +568,12 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false && _Moving) { stopMove(pIM); @@ -582,9 +582,9 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // the ctrl must have been captured if (pIM->getCapturePointerLeft() != this) return false; @@ -599,7 +599,7 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown && _WaitToOpenClose) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && _WaitToOpenClose) { if (_WaitToOpenClose) { @@ -657,7 +657,7 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) if (_CanOpen || gc->isOpenWhenPopup()) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (!_Parent) return false; gc->setHighLighted(false); @@ -704,7 +704,7 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) if (_CanMove) { // Enter Moving? - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown ) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown ) { _MoveStartX= _Parent->getX()-eventDesc.getX(); _MoveStartY= _Parent->getY()-eventDesc.getY(); @@ -725,13 +725,13 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) else { // Leave Moving? - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup ) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup ) { stopMove(pIM); return true; } // Move - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove ) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ) { _HasMoved = true; if (gc) gc->touch(); @@ -911,10 +911,10 @@ bool CCtrlMover::handleEvent (const CEventDescriptor &event) } } } - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &systemEvent = (const CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == CEventDescriptorSystem::clocktick) + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) { if (_WaitToOpenClose) { @@ -1046,7 +1046,7 @@ bool CCtrlMover::runTitleActionHandler() } // *************************************************************************** -void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const CEventDescriptorMouse &eventDesc) +void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc) { gc->setHighLighted(false); sint32 deltaX = x - _Parent->getX(); @@ -1088,7 +1088,7 @@ void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceMan } // *************************************************************************** -void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, CInterfaceManager *pIM, const CEventDescriptorMouse &eventDesc) +void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc) { if (!gc) return; sint32 deltaY = y - gc->getY(); @@ -2267,7 +2267,7 @@ void CGroupContainer::clearViews() } // *************************************************************************** -bool CGroupContainer::handleEvent (const CEventDescriptor& event) +bool CGroupContainer::handleEvent (const NLGUI::CEventDescriptor& event) { if (!_Active) return false; @@ -2282,13 +2282,13 @@ bool CGroupContainer::handleEvent (const CEventDescriptor& event) if (!CInterfaceGroup::handleEvent(event)) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // MouseWheel mgt if ((_LayerSetup == 0) && (isIn(eventDesc.getX(), eventDesc.getY()))) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { if (_ScrollBar != NULL) _ScrollBar->moveTrackY (eventDesc.getWheel()*12); @@ -3776,21 +3776,21 @@ void CGroupContainer::addModalSon (CGroupContainer *pSon) } // *************************************************************************** -bool CGroupContainer::checkIfModal(const CEventDescriptor& event) +bool CGroupContainer::checkIfModal(const NLGUI::CEventDescriptor& event) { bool bRet = true; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; - if ((eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) || - (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)) + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if ((eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) { bRet = blinkAllSons(); } // Additionaly, if it is a UP, don't blink, but return false if some son active if (bRet && ( - (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) || - (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup)) + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)) ) { bRet= !isGrayed(); diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 43ae9f1db..ae899f9b9 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -22,7 +22,10 @@ #include "interface_group.h" #include "nel/misc/smart_ptr.h" +namespace NLGUI +{ class CEventDescriptorLocalised; +} class CInterfaceList; class CCtrlButton; class CCtrlScroll; @@ -48,7 +51,7 @@ public: CCtrlResizer(const TCtorParam ¶m); virtual void draw (); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); // Add a big delta so when the user is over the Resizer, always take it whatever other controls under virtual uint getDeltaDepth() const { return 100; } @@ -99,7 +102,7 @@ public: CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen); ~CCtrlMover(); virtual void draw (); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); bool canMove() { return _CanMove; } bool isMoving() const {return _Moving;} @@ -132,8 +135,8 @@ private: // static COptionsContainerInsertion *getInsertionOptions(); private: - void setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const CEventDescriptorMouse &eventDesc); - void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const CEventDescriptorMouse &eventDesc); + void setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc); + void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc); void updateInsertionIndex(const CGroupList *gl, sint32 posY); void stopMove(CInterfaceManager *pIM); bool runTitleActionHandler(); @@ -171,7 +174,7 @@ public: virtual void clearViews (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); virtual void launch (); @@ -446,7 +449,7 @@ public: void setModalParentList (const std::string &name); - bool checkIfModal(const CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) + bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) bool isGrayed() const; bool blinkAllSons(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 3f3e58a72..373eccb1c 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -551,7 +551,7 @@ void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd) } // ---------------------------------------------------------------------------- -void CGroupEditBox::handleEventChar(const CEventDescriptorKey &rEDK) +void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) { stopParentBlink(); switch(rEDK.getChar()) @@ -711,7 +711,7 @@ void CGroupEditBox::handleEventChar(const CEventDescriptorKey &rEDK) } // ---------------------------------------------------------------------------- -void CGroupEditBox::handleEventString(const CEventDescriptorKey &rEDK) +void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK) { appendStringFromClipboard(rEDK.getString()); } @@ -827,11 +827,11 @@ void CGroupEditBox::back() } // ---------------------------------------------------------------------------- -bool CGroupEditBox::handleEvent (const CEventDescriptor& event) +bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) { if (!_Active || !_ViewText) return false; - if (event.getType() == CEventDescriptor::key) + if (event.getType() == NLGUI::CEventDescriptor::key) { if (_BypassNextKey) { @@ -841,18 +841,18 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) /////////////// // KEY EVENT // /////////////// - const CEventDescriptorKey &rEDK = (const CEventDescriptorKey&)event; + const NLGUI::CEventDescriptorKey &rEDK = (const NLGUI::CEventDescriptorKey&)event; switch(rEDK.getKeyEventType()) { - case CEventDescriptorKey::keychar: handleEventChar(rEDK); break; - case CEventDescriptorKey::keystring: handleEventString(rEDK); break; + case NLGUI::CEventDescriptorKey::keychar: handleEventChar(rEDK); break; + case NLGUI::CEventDescriptorKey::keystring: handleEventString(rEDK); break; default: break; } // update the text setInputString(_InputString); // if event of type char or string, consider handle all of them - if( rEDK.getKeyEventType()==CEventDescriptorKey::keychar || rEDK.getKeyEventType()==CEventDescriptorKey::keystring ) + if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) return true; // Else filter the EventKeyDown AND EventKeyUp. else @@ -866,16 +866,16 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) } } else - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { ///////////////// // MOUSE EVENT // ///////////////// - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { if (pIM->getCapturePointerRight() == this) { @@ -901,7 +901,7 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) return false; // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown && !_Frozen) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) { _SelectingText = true; stopParentBlink(); @@ -920,7 +920,7 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) return true; } // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove && !_Frozen && _SelectingText) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove && !_Frozen && _SelectingText) { // set the right cursor position uint newCurPos; @@ -934,7 +934,7 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) } // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup && !_Frozen) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && !_Frozen) { _SelectingText = false; if (_SelectCursorPos == _CursorPos) @@ -943,7 +943,7 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { pIM->setCapturePointerRight(this); return true; @@ -954,10 +954,10 @@ bool CGroupEditBox::handleEvent (const CEventDescriptor& event) ////////////////// // SYSTEM EVENT // ////////////////// - const CEventDescriptorSystem &eventDesc = (const CEventDescriptorSystem &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorSystem::activecalledonparent) + const NLGUI::CEventDescriptorSystem &eventDesc = (const NLGUI::CEventDescriptorSystem &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) { - CEventDescriptorActiveCalledOnParent &activeEvent = (CEventDescriptorActiveCalledOnParent &) eventDesc; + NLGUI::CEventDescriptorActiveCalledOnParent &activeEvent = (NLGUI::CEventDescriptorActiveCalledOnParent &) eventDesc; if (activeEvent.getActive() == false && _ResetFocusOnHide) { CInterfaceManager::getInstance()->resetCaptureKeyboard(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index f2856709a..e86e2bdcd 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -22,8 +22,10 @@ #include "interface_group.h" #include "nel/3d/u_texture.h" - -class CEventDescriptor; +namespace NLGUI +{ + class CEventDescriptor; +} class CViewText; // ---------------------------------------------------------------------------- class CGroupEditBox : public CInterfaceGroup @@ -41,7 +43,7 @@ public: virtual void draw(); - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); /// Accessors ucstring getInputString() const { return _InputString; } @@ -290,8 +292,8 @@ protected: private: void setupDisplayText(); void makeTopWindow(); - void handleEventChar(const CEventDescriptorKey &event); - void handleEventString(const CEventDescriptorKey &event); + void handleEventChar(const NLGUI::CEventDescriptorKey &event); + void handleEventString(const NLGUI::CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); void appendStringFromClipboard(const ucstring &str); diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index d7b2969a1..eb8121ac3 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -255,17 +255,17 @@ public: if (getParent()->getParent() == _Parent->getParentPos()) return NULL; // leftmost header return dynamic_cast(getParent()->getParentPos()); } - bool handleEvent (const CEventDescriptor &event) + bool handleEvent (const NLGUI::CEventDescriptor &event) { CInterfaceManager *im = CInterfaceManager::getInstance(); if (_Parent) { - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false) { release(); @@ -273,10 +273,10 @@ public: } } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if (!this->isIn(eventDesc.getX(), eventDesc.getY())) return false; _TargetGroup = getTargetGroup(); @@ -286,11 +286,11 @@ public: _OffsetX = _TargetGroup->getW() - eventDesc.getX(); return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { release(); } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (_Moving && im->getCapturePointerLeft() == this) { diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index e17426a79..c8a54f602 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -2106,14 +2106,14 @@ bool CGroupHTML::parse(xmlNodePtr cur,CInterfaceGroup *parentGroup) // *************************************************************************** -bool CGroupHTML::handleEvent (const CEventDescriptor& eventDesc) +bool CGroupHTML::handleEvent (const NLGUI::CEventDescriptor& eventDesc) { bool traited = CGroupScrollText::handleEvent (eventDesc); - if (eventDesc.getType() == CEventDescriptor::system) + if (eventDesc.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &systemEvent = (const CEventDescriptorSystem &) eventDesc; - if (systemEvent.getEventTypeExtended() == CEventDescriptorSystem::clocktick) + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) eventDesc; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) { // Handle now handle (); diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 098fbb4ff..f8e3e09f9 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -73,7 +73,7 @@ public: virtual void draw (); // Events - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); // Browse virtual void browse (const char *url); diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 7a68be9d5..d157543a7 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -663,16 +663,16 @@ void CGroupList::draw () } // ---------------------------------------------------------------------------- -bool CGroupList::handleEvent (const CEventDescriptor& event) +bool CGroupList::handleEvent (const NLGUI::CEventDescriptor& event) { if (!_Active) return false; bool bReturn = CInterfaceGroup::handleEvent(event); - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; _OverElt = -1; if (!isIn(eventDesc.getX(), eventDesc.getY())) diff --git a/code/ryzom/client/src/interface_v3/group_list.h b/code/ryzom/client/src/interface_v3/group_list.h index 9f17caf53..1053a2241 100644 --- a/code/ryzom/client/src/interface_v3/group_list.h +++ b/code/ryzom/client/src/interface_v3/group_list.h @@ -121,7 +121,7 @@ public: virtual void draw(); - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); virtual void clearViews(); virtual void clearControls(); diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index e1d7b4ecd..a47541b21 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -171,15 +171,15 @@ CGroupMap::CPolyButton::CPolyButton() //============================================================================================================ -bool CGroupMap::CPolyButton::handleEvent (const CEventDescriptor &event) +bool CGroupMap::CPolyButton::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { CInterfaceManager *im = CInterfaceManager::getInstance(); - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (im->getCapturePointerLeft() != this) return false; @@ -205,7 +205,7 @@ bool CGroupMap::CPolyButton::handleEvent (const CEventDescriptor &event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if (contains(CVector2f((float)eventDesc.getX(), (float)eventDesc.getY()))) { @@ -1703,7 +1703,7 @@ void CGroupMap::draw() } //============================================================================================================ -bool CGroupMap::handleEvent(const CEventDescriptor &event) +bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) { CInterfaceManager *im = CInterfaceManager::getInstance(); // if R2 editor editor is on, give it a chance to handle the event first @@ -1712,11 +1712,11 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) bool handled = false; bool panEnd = false; // handle standard clicks - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; - panEnd = eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup && _Panning && _HasMoved; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup && !panEnd) + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + panEnd = eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && _Panning && _HasMoved; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && !panEnd) { //if (im->getCapturePointerLeft() == this) // NB : don't test capture of mouse here, because @@ -1745,7 +1745,7 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) } } } - else if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + else if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { if (im->getCapturePointerRight() == this) { @@ -1784,13 +1784,13 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) // left button can be used to 'pan' the map // mouse wheel can be used to zoom in/out - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { if (!_Active) return false; - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (im->getCapturePointerLeft() != this) { @@ -1801,13 +1801,13 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { im->setCapturePointerRight(this); return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if (isIn(eventDesc.getX(), eventDesc.getY())) { @@ -1843,7 +1843,7 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (im->getCapturePointerLeft() != this || !_Panning) return CInterfaceGroup::handleEvent(event); @@ -1873,7 +1873,7 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel && !_Panning) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && !_Panning) { sint32 wheel = eventDesc.getWheel(); float newScale = _UserScale; @@ -1907,7 +1907,7 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { // convert click pos into map pos if (_MapTexW == 0 || _MapTexH == 0) @@ -1931,10 +1931,10 @@ bool CGroupMap::handleEvent(const CEventDescriptor &event) } } } - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - CEventDescriptorSystem &es = (CEventDescriptorSystem &) event; - if (es.getEventTypeExtended() == CEventDescriptorSystem::activecalledonparent) + NLGUI::CEventDescriptorSystem &es = (NLGUI::CEventDescriptorSystem &) event; + if (es.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) { bool visible = getActive(); if (visible) diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index b192b0c2f..30a8b9ded 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -119,7 +119,7 @@ public: virtual void updateCoords(); virtual void checkCoords(); virtual void draw (); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); @@ -234,7 +234,7 @@ private: { public: CPolyButton(); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); virtual void updateCoords(); virtual void draw () {} void drawPolyButton(); @@ -258,7 +258,7 @@ private: CContLandMark::TContLMType Type; bool HandleEvents; public: - virtual bool handleEvent (const CEventDescriptor& event) + virtual bool handleEvent (const NLGUI::CEventDescriptor& event) { if (!HandleEvents) return false; return CCtrlButton::handleEvent(event); diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 8a1051e52..137dcec10 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -933,7 +933,7 @@ void CGroupSubMenu::draw() } // ------------------------------------------------------------------------------------------------ -bool CGroupSubMenu::handleEvent (const CEventDescriptor &event) +bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) { if (!_Active) return false; @@ -942,9 +942,9 @@ bool CGroupSubMenu::handleEvent (const CEventDescriptor &event) if(_GroupList) textDYPos= -(1+_GroupList->getSpace())/2; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; _Selected = -1; // TODO First check sub menus that can be not in the area of this menu @@ -976,7 +976,7 @@ bool CGroupSubMenu::handleEvent (const CEventDescriptor &event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { // If a line is selected and the line is not grayed if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed())) @@ -1004,13 +1004,13 @@ bool CGroupSubMenu::handleEvent (const CEventDescriptor &event) } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // if (_GroupList && _ScrollBar) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { if (isIn(eventDesc.getX(), eventDesc.getY())) { @@ -2082,7 +2082,7 @@ void CGroupMenu::draw () } // ------------------------------------------------------------------------------------------------ -bool CGroupMenu::handleEvent (const CEventDescriptor &event) +bool CGroupMenu::handleEvent (const NLGUI::CEventDescriptor &event) { if (!_Active) return false; diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index ff0985ec1..d0ec9f82c 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -107,7 +107,7 @@ public: virtual void draw (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); virtual CInterfaceElement* getElement (const std::string &id); @@ -300,7 +300,7 @@ public: void recurseDraw(CGroupSubMenu *pSubMenu); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); virtual CInterfaceElement* getElement (const std::string &id); diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp index 619a4c1e9..adf817b8d 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -68,12 +68,12 @@ void CGroupModalGetKey::setActive (bool state) } // *************************************************************************** -bool CGroupModalGetKey::handleEvent (const CEventDescriptor &event) +bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::key) + if (event.getType() == NLGUI::CEventDescriptor::key) { - CEventDescriptorKey &edk = (CEventDescriptorKey &)event; - if (edk.getKeyEventType() == CEventDescriptorKey::keydown) + NLGUI::CEventDescriptorKey &edk = (NLGUI::CEventDescriptorKey &)event; + if (edk.getKeyEventType() == NLGUI::CEventDescriptorKey::keydown) { // if ((edk.getKey() != KeyCONTROL) && (edk.getKey() != KeyMENU) && (edk.getKey() != KeySHIFT)) // { diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.h b/code/ryzom/client/src/interface_v3/group_modal_get_key.h index ee9cac9e8..54a594e7e 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.h +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.h @@ -38,7 +38,7 @@ public: /// Constructor CGroupModalGetKey(const TCtorParam ¶m); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); virtual void setActive(bool state); diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index 42def29d6..5cc17105e 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -841,16 +841,16 @@ void CGroupParagraph::draw () } // ---------------------------------------------------------------------------- -bool CGroupParagraph::handleEvent (const CEventDescriptor& event) +bool CGroupParagraph::handleEvent (const NLGUI::CEventDescriptor& event) { if (!_Active) return false; bool bReturn = CInterfaceGroup::handleEvent(event); - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; _OverElt = -1; if (!isIn(eventDesc.getX(), eventDesc.getY())) diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index be82c28a6..ab37a1814 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -139,7 +139,7 @@ public: virtual void draw(); - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); virtual void clearViews(); virtual void clearControls(); diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index 950ab9771..f9ddd85fd 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -121,15 +121,15 @@ void CGroupScrollText::clearViews() } //======================================================================== -bool CGroupScrollText::handleEvent(const CEventDescriptor &event) +bool CGroupScrollText::handleEvent(const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // if (_List && _ScrollBar) { - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { if (isIn(eventDesc.getX(), eventDesc.getY())) { diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h index c9e52d22a..c9baa1889 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.h @@ -47,7 +47,7 @@ public: virtual void checkCoords (); virtual void draw (); virtual void clearViews (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); // get the list associated to this group CGroupList *getList() const { return _List; } diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index d42855464..00cb26a83 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -788,12 +788,12 @@ void CCtrlTabButton::setActive(bool state) } // *************************************************************************** -bool CCtrlTabButton::handleEvent (const CEventDescriptor &event) +bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) { - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &systemEvent = (const CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == CEventDescriptorSystem::clocktick) + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) if (_Blinking) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/group_tab.h b/code/ryzom/client/src/interface_v3/group_tab.h index f7c99abe2..42914506e 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.h +++ b/code/ryzom/client/src/interface_v3/group_tab.h @@ -155,7 +155,7 @@ public: virtual void setActive(bool state); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); void setBlink (bool b); diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 9eb02ad10..7c0be8016 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -777,14 +777,14 @@ const std::string &CGroupTree::getSelectedNodeId() const } // ---------------------------------------------------------------------------- -bool CGroupTree::handleEvent (const CEventDescriptor& event) +bool CGroupTree::handleEvent (const NLGUI::CEventDescriptor& event) { if (!_Active) return false; if (CInterfaceGroup::handleEvent(event)) return true; // The line must be over (pre-selected) - if (event.getType() == CEventDescriptor::mouse && _OverLine>=0) + if (event.getType() == NLGUI::CEventDescriptor::mouse && _OverLine>=0) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (!isIn(eventDesc.getX(), eventDesc.getY())) return false; @@ -799,7 +799,7 @@ bool CGroupTree::handleEvent (const CEventDescriptor& event) (x < (_XReal+getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap())))) bIcon = true; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { if (bText) { @@ -807,7 +807,7 @@ bool CGroupTree::handleEvent (const CEventDescriptor& event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { // line selection if (bText) diff --git a/code/ryzom/client/src/interface_v3/group_tree.h b/code/ryzom/client/src/interface_v3/group_tree.h index c2a299c01..444a0fe4d 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.h +++ b/code/ryzom/client/src/interface_v3/group_tree.h @@ -213,7 +213,7 @@ public: virtual void draw(); - virtual bool handleEvent (const CEventDescriptor& eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); void reset(); diff --git a/code/ryzom/client/src/interface_v3/group_wheel.cpp b/code/ryzom/client/src/interface_v3/group_wheel.cpp index 51a6390f9..91cc53dd2 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.cpp +++ b/code/ryzom/client/src/interface_v3/group_wheel.cpp @@ -43,13 +43,13 @@ bool CInterfaceGroupWheel::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) } // ***************************************************************************************************************** -bool CInterfaceGroupWheel::handleEvent(const CEventDescriptor &event) +bool CInterfaceGroupWheel::handleEvent(const NLGUI::CEventDescriptor &event) { if (CInterfaceGroup::handleEvent(event)) return true; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { CInterfaceManager *im = CInterfaceManager::getInstance(); if (eventDesc.getWheel() > 0 && _AHWheelUp) diff --git a/code/ryzom/client/src/interface_v3/group_wheel.h b/code/ryzom/client/src/interface_v3/group_wheel.h index 67f7c9c09..a3b3f7c23 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.h +++ b/code/ryzom/client/src/interface_v3/group_wheel.h @@ -31,7 +31,7 @@ public: CInterfaceGroupWheel(const TCtorParam ¶m); /// Coming from CInterfaceElement virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); private: IActionHandler *_AHWheelUp; CStringShared _AHWheelUpParams; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 5723952ee..87a20d35a 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -163,12 +163,12 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // if there was some control capturing the mouse, warn them that they lost the focus if (pIM->getCapturePointerLeft()) { - pIM->getCapturePointerLeft()->handleEvent(CEventDescriptorSetFocus(pEvent->Get)); + pIM->getCapturePointerLeft()->handleEvent(NLGUI::CEventDescriptorSetFocus(pEvent->Get)); } pIM->setCapturePointerLeft(NULL); if (pIM->getCapturePointerRight()) { - pIM->getCapturePointerRight()->handleEvent(CEventDescriptorSetFocus(pEvent->Get)); + pIM->getCapturePointerRight()->handleEvent(NLGUI::CEventDescriptorSetFocus(pEvent->Get)); } pIM->setCapturePointerRight(NULL); UserControls.stopFreeLook(); @@ -191,7 +191,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) && (ClientCfg.R2EDEnabled || R2::getEditor().getCurrentTool()) ) { - R2::getEditor().handleEvent(CEventDescriptorSetFocus(pEvent->Get)); + R2::getEditor().handleEvent(NLGUI::CEventDescriptorSetFocus(pEvent->Get)); } } @@ -224,7 +224,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) event == EventStringId) { // if not handled, post to Action Manager - if( !pIM->handleEvent( CEventDescriptorKey((const CEventKey &) event) ) ) + if( !pIM->handleEvent( NLGUI::CEventDescriptorKey((const CEventKey &) event) ) ) { // See if handled by editor bool handled = false; @@ -232,7 +232,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) && (ClientCfg.R2EDEnabled || R2::getEditor().getCurrentTool()) ) { - handled = R2::getEditor().handleEvent(CEventDescriptorKey((const CEventKey &) event) ); + handled = R2::getEditor().handleEvent(NLGUI::CEventDescriptorKey((const CEventKey &) event) ); } if (!handled) { @@ -282,7 +282,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) CViewPointer &rIP = *pIM->getPointer(); - CEventDescriptorMouse eventDesc; + NLGUI::CEventDescriptorMouse eventDesc; sint32 x,y; rIP.getPointerDispPos (x, y); eventDesc.setX (x); @@ -326,12 +326,12 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // handle Event if(pEvent->Button & leftButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouseleftdown); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdown); handled|= pIM->handleEvent (eventDesc); } if(pEvent->Button & rightButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouserightdown); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightdown); handled|= pIM->handleEvent (eventDesc); } } @@ -350,12 +350,12 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // handle Event if(pEvent->Button & leftButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouseleftup); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftup); handled|= pIM->handleEvent (eventDesc); } if(pEvent->Button & rightButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouserightup); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightup); handled|= pIM->handleEvent (eventDesc); } } @@ -369,12 +369,12 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // handle Event if(pEvent->Button & leftButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouseleftdblclk); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdblclk); handled|= pIM->handleEvent (eventDesc); } if(pEvent->Button & rightButton) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mouserightdblclk); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightdblclk); handled|= pIM->handleEvent (eventDesc); } @@ -395,7 +395,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // handle Event now. if (_MouseWheel != 0) { - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mousewheel); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mousewheel); eventDesc.setWheel(_MouseWheel); handled|= pIM->handleEvent (eventDesc); _MouseWheel = 0; @@ -429,7 +429,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // *************************************************************************** -bool CInputHandlerManager::updateMousePos(NLMISC::CEventMouse &event, CEventDescriptorMouse &eventDesc) +bool CInputHandlerManager::updateMousePos(NLMISC::CEventMouse &event, NLGUI::CEventDescriptorMouse &eventDesc) { if (!IsMouseFreeLook()) { @@ -461,7 +461,7 @@ bool CInputHandlerManager::updateMousePos(NLMISC::CEventMouse &event, CEventDes eventDesc.setY (y); // handle Event now. - eventDesc.setEventTypeExtended(CEventDescriptorMouse::mousemove); + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mousemove); return pIM->handleEvent (eventDesc); } } @@ -470,7 +470,7 @@ bool CInputHandlerManager::updateMousePos(NLMISC::CEventMouse &event, CEventDes // *************************************************************************** -void CInputHandlerManager::CComboKey::init(const CEventDescriptorKey &rDK) +void CInputHandlerManager::CComboKey::init(const NLGUI::CEventDescriptorKey &rDK) { Key= rDK.getKey(); CtrlFlags= 0; @@ -493,7 +493,7 @@ bool CInputHandlerManager::CComboKey::operator<(const CComboKey &c) const // *************************************************************************** -bool CInputHandlerManager::isComboKeyChat(const CEventDescriptorKey &edk) const +bool CInputHandlerManager::isComboKeyChat(const NLGUI::CEventDescriptorKey &edk) const { CComboKey ckey; ckey.init(edk); diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.h b/code/ryzom/client/src/interface_v3/input_handler_manager.h index 23a5afeb5..9f152c87c 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.h @@ -96,7 +96,7 @@ public: * Basics events such as KeyA, KeyB etc.. should be in this config file. * Combo Keys like Ctrl+A (select all) should be in this config file too. */ - bool isComboKeyChat(const CEventDescriptorKey &edk) const; + bool isComboKeyChat(const NLGUI::CEventDescriptorKey &edk) const; /** Pump The Events of The setuped EventServer (ie Driver->EventServer). @@ -165,7 +165,7 @@ private: { CtrlFlags= 0; } - void init(const CEventDescriptorKey &rDK); + void init(const NLGUI::CEventDescriptorKey &rDK); bool operator<(const CComboKey &c) const; }; @@ -178,7 +178,7 @@ private: void parseKey(xmlNodePtr cur, std::vector &out); // return true if handled - bool updateMousePos(NLMISC::CEventMouse &event, CEventDescriptorMouse &eventDesc); + bool updateMousePos(NLMISC::CEventMouse &event, NLGUI::CEventDescriptorMouse &eventDesc); }; diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 23e7dda44..2d654a7ba 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -546,7 +546,7 @@ void CInterface3DScene::draw () } // ---------------------------------------------------------------------------- -bool CInterface3DScene::handleEvent (const CEventDescriptor &event) +bool CInterface3DScene::handleEvent (const NLGUI::CEventDescriptor &event) { if (!_UserInteraction) return false; @@ -554,12 +554,12 @@ bool CInterface3DScene::handleEvent (const CEventDescriptor &event) if (!_Active) return false; // if focus is lost then cancel rotation / zoom - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false) { _MouseLDown = false; @@ -568,9 +568,9 @@ bool CInterface3DScene::handleEvent (const CEventDescriptor &event) } } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && (CInterfaceManager::getInstance()->getCapturePointerRight() != this) && (!((eventDesc.getX() >= _XReal) && @@ -579,7 +579,7 @@ bool CInterface3DScene::handleEvent (const CEventDescriptor &event) (eventDesc.getY() <= (_YReal+ _HReal))))) return false; - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { _MouseLDown = true; _MouseLDownX = eventDesc.getX(); @@ -588,12 +588,12 @@ bool CInterface3DScene::handleEvent (const CEventDescriptor &event) pIM->setCapturePointerLeft(this); // Because we are not just a control return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { _MouseLDown = false; return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { _MouseRDown = true; _MouseRDownX = eventDesc.getX(); @@ -602,12 +602,12 @@ bool CInterface3DScene::handleEvent (const CEventDescriptor &event) pIM->setCapturePointerRight(this); // Because we are not just a control return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { _MouseRDown = false; return true; } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousemove) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { if (_MouseLDown) { diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.h b/code/ryzom/client/src/interface_v3/interface_3d_scene.h index 7c0e94854..339497f43 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.h +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.h @@ -60,7 +60,7 @@ public: virtual void draw (); - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); virtual CInterfaceElement* getElement (const std::string &id); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index a088b2c0c..1a75cf4cb 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -92,7 +92,7 @@ void CInterfaceGroup::setIdRecurse(const std::string &id) // ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::notifyActiveCalled(const CEventDescriptorActiveCalledOnParent &desc) +void CInterfaceGroup::notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc) { // notify children that the 'active' state of this group has changed for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) @@ -121,7 +121,7 @@ void CInterfaceGroup::setActive(bool state) pIM->runActionHandler (_AHOnDeactive, this, _AHOnDeactiveParams); } - notifyActiveCalled(CEventDescriptorActiveCalledOnParent(state)); + notifyActiveCalled(NLGUI::CEventDescriptorActiveCalledOnParent(state)); } } @@ -685,7 +685,7 @@ bool CInterfaceGroup::isChildGroup(const CInterfaceGroup *group) const } // ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::handleEvent (const CEventDescriptor &event) +bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) { if (CCtrlBase::handleEvent(event)) return true; if (!_Active) @@ -693,19 +693,19 @@ bool CInterfaceGroup::handleEvent (const CEventDescriptor &event) CInterfaceManager *im = CInterfaceManager::getInstance(); - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - CEventDescriptorSystem &eds = (CEventDescriptorSystem&)event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::activecalledonparent) + NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) { // notify all childrens - notifyActiveCalled((CEventDescriptorActiveCalledOnParent &) eds); + notifyActiveCalled((NLGUI::CEventDescriptorActiveCalledOnParent &) eds); } } - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - const CEventDescriptorMouse &eventDesc = (const CEventDescriptorMouse &)event; + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (!isIn(eventDesc.getX(), eventDesc.getY())) return false; @@ -733,7 +733,7 @@ bool CInterfaceGroup::handleEvent (const CEventDescriptor &event) } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if (_AHOnLeftClick != NULL) { @@ -742,7 +742,7 @@ bool CInterfaceGroup::handleEvent (const CEventDescriptor &event) } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { if (_AHOnRightClick != NULL) { @@ -750,7 +750,7 @@ bool CInterfaceGroup::handleEvent (const CEventDescriptor &event) return true; } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mousewheel) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { // handle the Mouse Wheel only if interesting if (_H>_MaxH) diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index 432176704..f9bc949eb 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -76,7 +76,7 @@ public: sint32 getMinUsedW() const; /// Coming from CCtrlBase - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); void executeControl (const std::string &sControlName); @@ -319,7 +319,7 @@ protected: void doUpdateCoords(); // notify children controls & groups that 'active' has been called on one of their parent - void notifyActiveCalled(const CEventDescriptorActiveCalledOnParent &desc); + void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc); protected: diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 12f08577e..41d736448 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1332,8 +1332,8 @@ void CInterfaceManager::updateFrameEvents() } // send clock tick msg to ctrl that are captured - CEventDescriptorSystem clockTick; - clockTick.setEventTypeExtended(CEventDescriptorSystem::clocktick); + NLGUI::CEventDescriptorSystem clockTick; + clockTick.setEventTypeExtended(NLGUI::CEventDescriptorSystem::clocktick); if (_CapturePointerLeft) { _CapturePointerLeft->handleEvent(clockTick); @@ -2671,7 +2671,7 @@ uint CInterfaceManager::getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentW } // ------------------------------------------------------------------------------------------------ -bool CInterfaceManager::handleEvent (const CEventDescriptor& event) +bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool handled= false; @@ -2680,18 +2680,18 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) if (_ActiveAnims[i]->isDisableButtons()) return false; - if (event.getType() == CEventDescriptor::key) + if (event.getType() == NLGUI::CEventDescriptor::key) { - CEventDescriptorKey &eventDesc = (CEventDescriptorKey&)event; + NLGUI::CEventDescriptorKey &eventDesc = (NLGUI::CEventDescriptorKey&)event; _LastEventKeyDesc = eventDesc; // Any Key event disable the ContextHelp disableContextHelp(); // Hide menu if the key is pushed -// if ((eventDesc.getKeyEventType() == CEventDescriptorKey::keydown) && !_ModalStack.empty() && !eventDesc.getKeyAlt() && !eventDesc.getKeyCtrl() && !eventDesc.getKeyShift()) +// if ((eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keydown) && !_ModalStack.empty() && !eventDesc.getKeyAlt() && !eventDesc.getKeyCtrl() && !eventDesc.getKeyShift()) // Hide menu (or popup menu) is ESCAPE pressed - if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) + if( eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) { if(_ModalStack.size() > 0) { @@ -2702,7 +2702,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) } // Manage "quit window" If the Key is ESCAPE, no captureKeyboard - if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) + if( eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) { // Get the last escapable active top window. NB: this is ergonomically better. CInterfaceGroup *win= getLastEscapableTopWindow(); @@ -2729,7 +2729,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) } // Manage complex "Enter" - if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == KeyRETURN) + if (eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyRETURN) { // If the top window has Enter AH CInterfaceGroup *tw= getTopWindow(); @@ -2802,9 +2802,9 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) return result; } } - else if (event.getType() == CEventDescriptor::mouse && _MouseHandlingEnabled ) + else if (event.getType() == NLGUI::CEventDescriptor::mouse && _MouseHandlingEnabled ) { - CEventDescriptorMouse &eventDesc = (CEventDescriptorMouse&)event; + NLGUI::CEventDescriptorMouse &eventDesc = (NLGUI::CEventDescriptorMouse&)event; // First thing to do : Capture handling if (_CapturePointerLeft != NULL) @@ -2817,7 +2817,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) _WindowUnder = ptr?ptr->getId():""; // Any Mouse event but move disable the ContextHelp - if(eventDesc.getEventTypeExtended() != CEventDescriptorMouse::mousemove) + if(eventDesc.getEventTypeExtended() != NLGUI::CEventDescriptorMouse::mousemove) { disableContextHelp(); } @@ -2844,8 +2844,8 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) { // If there is a handler on click out launch it if (pNewCurrentWnd != mwi.ModalWindow) - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown || - (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) if (!mwi.ModalHandlerClickOut.empty()) runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams); @@ -2855,8 +2855,8 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) // NB: don't force handle==true because to quit a modal does not avoid other actions // quit if click outside - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown || - (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown)) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) { clickedOutModalWindow = dynamic_cast((CInterfaceGroup*)mwi.ModalWindow); // disable the modal @@ -2885,7 +2885,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) } // Manage LeftClick. - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) { @@ -2937,7 +2937,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) } // Manage RightClick - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightdown) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) { @@ -2981,7 +2981,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) handled |= _CapturePointerRight->handleEvent(event); } } - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { if (!handled) if (pNewCurrentWnd != NULL) @@ -3001,7 +3001,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) { if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))) { - CEventDescriptorMouse ev2 = eventDesc; + NLGUI::CEventDescriptorMouse ev2 = eventDesc; sint32 x= eventDesc.getX(), y = eventDesc.getY(); if (pNewCurrentWnd) { @@ -3011,13 +3011,13 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) } // After handle event of a left click, may set window Top if movable (infos etc...) - //if( (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() ) + //if( (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() ) // setTopWindow(pNewCurrentWnd); } } // Put here to let a chance to the window to handle if the capture dont - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { if (_CapturePointerLeft != NULL) { @@ -3039,7 +3039,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) if(mwi.ModalExitClickR) { // quit if click right - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouserightup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) // disable the modal disableModalWindow(); } @@ -3048,7 +3048,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) if(mwi.ModalExitClickL) { // quit if click right - if (eventDesc.getEventTypeExtended() == CEventDescriptorMouse::mouseleftup) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) // disable the modal disableModalWindow(); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 577edbda7..7fe26fc3e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -338,7 +338,7 @@ public: /// Handle The Event. return true if the interfaceManager catch it and if must not send to the Game Action Manager - bool handleEvent (const CEventDescriptor &eventDesc); + bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); void runActionHandler (const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("")); void runActionHandler (IActionHandler *ah, CCtrlBase *pCaller, @@ -704,7 +704,7 @@ public: } // Description of the last key event that called an action handler - const CEventDescriptorKey& getLastEventKeyDesc() const { return _LastEventKeyDesc; } + const NLGUI::CEventDescriptorKey& getLastEventKeyDesc() const { return _LastEventKeyDesc; } void notifyMailAvailable(); void notifyForumUpdated(); @@ -1034,7 +1034,7 @@ private: sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS]; // Description of the last key event that called an action handler - CEventDescriptorKey _LastEventKeyDesc; + NLGUI::CEventDescriptorKey _LastEventKeyDesc; // observers for copying database branch changes CServerToLocalAutoCopy ServerToLocalAutoCopyInventory; diff --git a/code/ryzom/client/src/r2/displayer_visual_group.cpp b/code/ryzom/client/src/r2/displayer_visual_group.cpp index c5f3e19e3..fed72c85a 100644 --- a/code/ryzom/client/src/r2/displayer_visual_group.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_group.cpp @@ -131,7 +131,7 @@ public: _Parent->getCorner(winX, winY, _ParentPosRef); return contains(x - winX, y - winY); } - virtual bool handleEvent (const CEventDescriptor &/* event */) + virtual bool handleEvent (const NLGUI::CEventDescriptor &/* event */) { return false; } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index e831cf8a2..859b89520 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -4739,17 +4739,17 @@ void CEditor::autoSave() } // ********************************************************************************************************* -bool CEditor::handleEvent (const CEventDescriptor &eventDesc) +bool CEditor::handleEvent (const NLGUI::CEventDescriptor &eventDesc) { //H_AUTO(R2_CEditor_handleEvent ) CHECK_EDITOR if (ConnectionWanted || !_CurrentTool) return false; // TMP special case for connection - if (eventDesc.getType() == CEventDescriptor::system) + if (eventDesc.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) eventDesc; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) eventDesc; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false) { // cancel current tool diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h index 89b470db0..1c793b3d5 100644 --- a/code/ryzom/client/src/r2/editor.h +++ b/code/ryzom/client/src/r2/editor.h @@ -250,7 +250,7 @@ public: * Handle an user input event * \return true if the event was handled by the editor */ - bool handleEvent (const CEventDescriptor &eventDesc); + bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); // Handle copy, reaches the editor if no edit box is currently active void copy(); diff --git a/code/ryzom/client/src/r2/instance_map_deco.cpp b/code/ryzom/client/src/r2/instance_map_deco.cpp index ea351dca6..476326b19 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.cpp +++ b/code/ryzom/client/src/r2/instance_map_deco.cpp @@ -41,7 +41,7 @@ void CInstanceMapDeco::CCtrlButtonEntity::getContextHelp(ucstring &help) const } // ********************************************************************************************************* -bool CInstanceMapDeco::CCtrlButtonEntity::handleEvent(const CEventDescriptor &/* event */) +bool CInstanceMapDeco::CCtrlButtonEntity::handleEvent(const NLGUI::CEventDescriptor &/* event */) { //H_AUTO(R2_CCtrlButtonEntity_handleEvent) return false; // just a display with tooltip capability diff --git a/code/ryzom/client/src/r2/instance_map_deco.h b/code/ryzom/client/src/r2/instance_map_deco.h index f81a3f022..6f0f62977 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.h +++ b/code/ryzom/client/src/r2/instance_map_deco.h @@ -80,7 +80,7 @@ private: CCtrlButtonEntity(CInstance &instance) : CCtrlButton(TCtorParam()), _Instance(instance) {} // from IDisplayerUIHandle virtual CInstance &getDisplayedInstance() { return _Instance; } - virtual bool handleEvent (const CEventDescriptor &event); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); private: CInstance &_Instance; protected: diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index 94854fd51..a97296590 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -760,42 +760,42 @@ void CTool::setMouseCursor(const char *cursorTexture) } // *************************************************************** -bool CTool::handleEvent(const CEventDescriptor &event) +bool CTool::handleEvent(const NLGUI::CEventDescriptor &event) { //H_AUTO(R2_CTool_handleEvent) bool handled = false; - if (event.getType() == CEventDescriptor::mouse) + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - CEventDescriptorMouse &eventDesc = (CEventDescriptorMouse&)event; + NLGUI::CEventDescriptorMouse &eventDesc = (NLGUI::CEventDescriptorMouse&)event; switch(eventDesc.getEventTypeExtended()) { - case CEventDescriptorMouse::mousemove: + case NLGUI::CEventDescriptorMouse::mousemove: handled = onMouseMove(); break; - case CEventDescriptorMouse::mouseleftdown: + case NLGUI::CEventDescriptorMouse::mouseleftdown: handled = onMouseLeftButtonDown(); //if (handled) nlwarning("onMouseLeftButtonDown handled"); break; - case CEventDescriptorMouse::mouserightdown: + case NLGUI::CEventDescriptorMouse::mouserightdown: handled = onMouseRightButtonDown(); //if (handled) nlwarning("onMouseRightButtonDown handled"); break; - case CEventDescriptorMouse::mouseleftup: + case NLGUI::CEventDescriptorMouse::mouseleftup: handled = onMouseLeftButtonUp(); //if (handled) nlwarning("onMouseLeftButtonUp handled"); break; - case CEventDescriptorMouse::mouserightup: + case NLGUI::CEventDescriptorMouse::mouserightup: handled = onMouseRightButtonUp(); //if (handled) nlwarning("onMouseRightButtonUp handled"); break; } } - if (event.getType() == CEventDescriptor::system) + if (event.getType() == NLGUI::CEventDescriptor::system) { - const CEventDescriptorSystem &eds = (const CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == CEventDescriptorSystem::setfocus) + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) { - const CEventDescriptorSetFocus &edsf = (const CEventDescriptorSetFocus &) eds; + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == true) { onFocusGained(); diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index 05a62eb48..4e5613c55 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -26,7 +26,10 @@ // class CInterfaceManager; -class CEventDescriptor; +namespace NLGUI +{ + class CEventDescriptor; +} class CLuaObject; class CGroupMap; @@ -119,7 +122,7 @@ public: * * \return true if the event has been handled by the tool */ - virtual bool handleEvent (const CEventDescriptor &eventDesc); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); // virtual void onFocusGained() {} // the app window gained the focus (there's no 'focus lost' event here because it reset current tool, so 'CTooll::cancel' will be called instead) // IMPORTANT : Reacting to this should be unnecessary, as lost focus reset the current tool, From 88cc7df7551454d1f605e050a99cd5b4e91b40a3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 17 May 2012 03:28:50 +0200 Subject: [PATCH 022/339] Refactored the CEvent -> CEventDescriptor code in CInputHandlerManager. Extracted it as a new class CInputHandler, and moved some of it to CInterfaceManager. --- .../include/nel/gui/input_event_listener.h | 36 ++ code/nel/include/nel/gui/input_handler.h | 57 +++ code/nel/src/gui/input_handler.cpp | 212 ++++++++ code/ryzom/client/src/init.cpp | 13 +- .../interface_v3/input_handler_manager.cpp | 128 +---- .../src/interface_v3/input_handler_manager.h | 8 +- .../src/interface_v3/interface_manager.cpp | 469 ++++++++++-------- .../src/interface_v3/interface_manager.h | 5 +- 8 files changed, 598 insertions(+), 330 deletions(-) create mode 100644 code/nel/include/nel/gui/input_event_listener.h create mode 100644 code/nel/include/nel/gui/input_handler.h create mode 100644 code/nel/src/gui/input_handler.cpp diff --git a/code/nel/include/nel/gui/input_event_listener.h b/code/nel/include/nel/gui/input_event_listener.h new file mode 100644 index 000000000..753b4f337 --- /dev/null +++ b/code/nel/include/nel/gui/input_event_listener.h @@ -0,0 +1,36 @@ +// Ryzom - MMORPG Framework +// 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 INPUTEVENTLISTENER_H +#define INPUTEVENTLISTENER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/event_descriptor.h" + +namespace NLGUI +{ + /** + @brief Interface for accepting GUI input events. + */ + class IInputEventListener + { + public: + virtual ~IInputEventListener(){} + virtual bool handleEvent( const CEventDescriptor &eventDesc ) = 0; + }; +} + +#endif diff --git a/code/nel/include/nel/gui/input_handler.h b/code/nel/include/nel/gui/input_handler.h new file mode 100644 index 000000000..3ac66ac98 --- /dev/null +++ b/code/nel/include/nel/gui/input_handler.h @@ -0,0 +1,57 @@ +// Ryzom - MMORPG Framework +// 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 INPUT_HANDLER_H +#define INPUT_HANDLER_H + +#include "nel/misc/events.h" +#include "nel/gui/event_descriptor.h" +#include "nel/gui/input_event_listener.h" + +namespace NLGUI{ + + /** + @brief The input event entry point of the GUI library. + + Translates the NEL input events and forwards them. + */ + class CInputHandler + { + public: + CInputHandler(); + ~CInputHandler(); + + bool handleEvent( const NLMISC::CEvent &evnt ); + bool handleSetFocusEvent( const NLMISC::CEvent &evnt ); + bool handleKeyboardEvent( const NLMISC::CEvent &evnt ); + bool handleMouseEvent( const NLMISC::CEvent &evnt ); + bool handleMouseMoveEvent( const NLMISC::CEvent &evnt ); + bool handleMouseButtonDownEvent( const NLMISC::CEvent &evnt ); + bool handleMouseButtonUpEvent( const NLMISC::CEvent &evnt ); + bool handleMouseDblClickEvent( const NLMISC::CEvent &evnt ); + bool handleMouseWheelEvent( const NLMISC::CEvent &evnt ); + + void setListener( IInputEventListener* listener ); + + private: + IInputEventListener *listener; + }; + +} + +#endif + diff --git a/code/nel/src/gui/input_handler.cpp b/code/nel/src/gui/input_handler.cpp new file mode 100644 index 000000000..594773a3e --- /dev/null +++ b/code/nel/src/gui/input_handler.cpp @@ -0,0 +1,212 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/input_handler.h" + +namespace NLGUI +{ + CInputHandler::CInputHandler() + { + listener = NULL; + } + + CInputHandler::~CInputHandler() + { + listener = NULL; + } + + + bool CInputHandler::handleEvent( const NLMISC::CEvent &evnt ) + { + if( evnt == NLMISC::EventSetFocusId ) + return handleSetFocusEvent( evnt ); + else + if( evnt == NLMISC::EventKeyDownId || + evnt == NLMISC::EventKeyUpId || + evnt == NLMISC::EventCharId || + evnt == NLMISC::EventStringId ) + return handleKeyboardEvent( evnt ); + else + if( evnt == NLMISC::EventMouseMoveId || + evnt == NLMISC::EventMouseDownId || + evnt == NLMISC::EventMouseUpId || + evnt == NLMISC::EventMouseWheelId || + evnt == NLMISC::EventMouseDblClkId ) + return handleMouseEvent( evnt ); + + + return false; + } + + bool CInputHandler::handleSetFocusEvent( const NLMISC::CEvent &evnt ) + { + nlassert( evnt == NLMISC::EventSetFocusId ); + const NLMISC::CEventSetFocus *e = reinterpret_cast< const NLMISC::CEventSetFocus* >( &evnt ); + + return listener->handleEvent( CEventDescriptorSetFocus( e->Get ) ); + } + + bool CInputHandler::handleKeyboardEvent( const NLMISC::CEvent &evnt ) + { + bool ok = false; + if( evnt == NLMISC::EventKeyDownId || + evnt == NLMISC::EventKeyUpId || + evnt == NLMISC::EventCharId || + evnt == NLMISC::EventStringId ) + ok = true; + + nlassert( ok ); + + return listener->handleEvent( NLGUI::CEventDescriptorKey( reinterpret_cast< const NLMISC::CEventKey& >( evnt ) ) ); + } + + bool CInputHandler::handleMouseEvent( const NLMISC::CEvent &evnt ) + { + if( evnt == NLMISC::EventMouseMoveId ) + return handleMouseMoveEvent( evnt ); + else + if( evnt == NLMISC::EventMouseDownId ) + return handleMouseButtonDownEvent( evnt ); + else + if( evnt == NLMISC::EventMouseUpId ) + return handleMouseButtonUpEvent( evnt ); + else + if( evnt == NLMISC::EventMouseDblClkId ) + return handleMouseDblClickEvent( evnt ); + else + if( evnt == NLMISC::EventMouseWheelId ) + return handleMouseWheelEvent( evnt ); + + return false; + } + + bool CInputHandler::handleMouseMoveEvent( const NLMISC::CEvent &evnt ) + { + const NLMISC::CEventMouseMove &mouseMoveEvent = static_cast< const NLMISC::CEventMouseMove& >( evnt ); + + CEventDescriptorMouse eventDesc; + float x = mouseMoveEvent.X; + float y = mouseMoveEvent.Y; + + // These bloody hacks here are used so that we can send the x, and y float coordinates + // from the NEL mouse move event, to the GUI event listener, without having to change + // CEventDescriptorMouse or without having to couple with the consumer class + eventDesc.setX( *reinterpret_cast< sint32* >( &x ) ); + eventDesc.setY( *reinterpret_cast< sint32* >( &y ) ); + + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mousemove ); + + return listener->handleEvent( eventDesc ); + } + + bool CInputHandler::handleMouseButtonDownEvent( const NLMISC::CEvent &evnt ) + { + nlassert( evnt == NLMISC::EventMouseDownId ); + + CEventDescriptorMouse eventDesc; + + const NLMISC::CEventMouseDown *mouseDownEvent = static_cast< const NLMISC::CEventMouseDown* >( &evnt ); + + if( mouseDownEvent->Button & NLMISC::leftButton ) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mouseleftdown ); + return listener->handleEvent( eventDesc ); + } + + if(mouseDownEvent->Button & NLMISC::rightButton) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mouserightdown ); + return listener->handleEvent( eventDesc ); + } + + return false; + } + + bool CInputHandler::handleMouseButtonUpEvent( const NLMISC::CEvent &evnt ) + { + nlassert( evnt == NLMISC::EventMouseUpId ); + + CEventDescriptorMouse eventDesc; + + const NLMISC::CEventMouseUp *mouseUpEvent = static_cast< const NLMISC::CEventMouseUp* >( &evnt ); + + if( mouseUpEvent->Button & NLMISC::leftButton ) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mouseleftup ); + return listener->handleEvent( eventDesc ); + } + + if( mouseUpEvent->Button & NLMISC::rightButton ) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mouserightup ); + return listener->handleEvent( eventDesc ); + } + + return false; + } + + bool CInputHandler::handleMouseDblClickEvent( const NLMISC::CEvent &evnt ) + { + nlassert( evnt == NLMISC::EventMouseDblClkId ); + + CEventDescriptorMouse eventDesc; + + const NLMISC::CEventMouseDblClk *dblClickEvent = static_cast< const NLMISC::CEventMouseDblClk* >( &evnt ); + + if( dblClickEvent->Button & NLMISC::leftButton ) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mouseleftdblclk ); + return listener->handleEvent (eventDesc); + } + + if( dblClickEvent->Button & NLMISC::rightButton ) + { + eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightdblclk); + return listener->handleEvent (eventDesc); + } + + return false; + } + + bool CInputHandler::handleMouseWheelEvent( const NLMISC::CEvent &evnt ) + { + nlassert( evnt == NLMISC::EventMouseWheelId ); + + CEventDescriptorMouse eventDesc; + sint32 mouseWheel = 0; + + const NLMISC::CEventMouseWheel *wheelEvent = static_cast< const NLMISC::CEventMouseWheel* >( &evnt ); + + if( wheelEvent->Direction ) + mouseWheel = 1; + else + mouseWheel = -1; + + if( mouseWheel != 0 ) + { + eventDesc.setEventTypeExtended( CEventDescriptorMouse::mousewheel ); + eventDesc.setWheel( mouseWheel ); + return listener->handleEvent( eventDesc ); + } + + return false; + } + + void CInputHandler::setListener( IInputEventListener *listener ) + { + this->listener = listener; + } +} diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index e9d60774e..e64c0df94 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1067,6 +1067,13 @@ void prelogInit() if(GenericMat.empty()) nlerror("init: Cannot Create the generic material."); + + // Create a text context. We need to put the full path because we not already add search path +// resetTextContext ("bremenb.ttf", false); + resetTextContext ("ryzom.ttf", false); + + CInterfaceManager::create( Driver, TextContext ); + // Yoyo: initialize NOW the InputHandler for Event filtering. CInputHandlerManager *InputHandlerManager = CInputHandlerManager::getInstance(); InputHandlerManager->addToServer (&Driver->EventServer); @@ -1075,12 +1082,6 @@ void prelogInit() if( !filename.empty() ) InputHandlerManager->readInputConfigFile( filename ); - // Create a text context. We need to put the full path because we not already add search path -// resetTextContext ("bremenb.ttf", false); - resetTextContext ("ryzom.ttf", false); - - CInterfaceManager::create( Driver, TextContext ); - ProgressBar.setFontFactor(0.85f); nmsg = "Loading background..."; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 87a20d35a..18420ef82 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -59,14 +59,14 @@ CInputHandlerManager* CInputHandlerManager::_Instance = NULL; CInputHandlerManager::CInputHandlerManager() { _EventServer= NULL; - _MouseButtonsReleased = noButton; - _MouseButtonsDown = noButton; _MouseButtonsState = noButton; _MouseX = _MouseY = _MouseLastX = _MouseLastY = 0; _Focus = true; _MouseWheel = 0; _SkipInterfaceManager=false; _RecoverFocusLost = false; + + inputHandler.setListener( CInterfaceManager::getInstance() ); } // *************************************************************************** @@ -153,24 +153,13 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) if (!pEvent->Get) { // Deactivate all keys - _MouseButtonsDown = noButton; - _MouseButtonsReleased = noButton; _MouseButtonsState = noButton; _Focus = false; if (!_SkipInterfaceManager) { // if there was some control capturing the mouse, warn them that they lost the focus - if (pIM->getCapturePointerLeft()) - { - pIM->getCapturePointerLeft()->handleEvent(NLGUI::CEventDescriptorSetFocus(pEvent->Get)); - } - pIM->setCapturePointerLeft(NULL); - if (pIM->getCapturePointerRight()) - { - pIM->getCapturePointerRight()->handleEvent(NLGUI::CEventDescriptorSetFocus(pEvent->Get)); - } - pIM->setCapturePointerRight(NULL); + inputHandler.handleSetFocusEvent( event ); UserControls.stopFreeLook(); } // be nice with other app : let the mouse reappear (useful in direct 3D mode with no hardware cursor) @@ -214,7 +203,6 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) return; } - // **** Event Focus // **** Event Keyboard @@ -224,7 +212,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) event == EventStringId) { // if not handled, post to Action Manager - if( !pIM->handleEvent( NLGUI::CEventDescriptorKey((const CEventKey &) event) ) ) + if( !inputHandler.handleKeyboardEvent( event ) ) { // See if handled by editor bool handled = false; @@ -283,6 +271,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) CViewPointer &rIP = *pIM->getPointer(); NLGUI::CEventDescriptorMouse eventDesc; + sint32 x,y; rIP.getPointerDispPos (x, y); eventDesc.setX (x); @@ -313,71 +302,18 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) handled |= R2::getEditor().handleEvent(eventDesc); } } - - CEventMouseDown *pEvent=(CEventMouseDown*)&event; - - // update states - _MouseButtonsDown = (TMouseButton) (_MouseButtonsDown | pEvent->Button); - _MouseButtonsReleased =(TMouseButton) (_MouseButtonsReleased & ~(pEvent->Button)); - _MouseButtonsState = (TMouseButton) (_MouseButtonsState | pEvent->Button); - - rIP.setButtonState(_MouseButtonsState); - - // handle Event - if(pEvent->Button & leftButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdown); - handled|= pIM->handleEvent (eventDesc); - } - if(pEvent->Button & rightButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightdown); - handled|= pIM->handleEvent (eventDesc); - } + handled |= inputHandler.handleMouseButtonDownEvent( event ); } // button up ? else if (event==EventMouseUpId) { - CEventMouseUp *pEvent=(CEventMouseUp*)&event; - - // update states - _MouseButtonsReleased = (TMouseButton) (_MouseButtonsReleased | pEvent->Button); - _MouseButtonsDown =(TMouseButton) (_MouseButtonsDown & ~(pEvent->Button)); - _MouseButtonsState = (TMouseButton) (_MouseButtonsState & ~(pEvent->Button)); - - rIP.setButtonState(_MouseButtonsState); - - // handle Event - if(pEvent->Button & leftButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftup); - handled|= pIM->handleEvent (eventDesc); - } - if(pEvent->Button & rightButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightup); - handled|= pIM->handleEvent (eventDesc); - } + handled |= inputHandler.handleMouseButtonUpEvent( event ); } // db click ? else if (event == EventMouseDblClkId ) { // TODO: yoyo make it work if needed (for now, seems preferable to manage in each ActionHandler) - - CEventMouseDblClk* pEvent=(CEventMouseDblClk*)&event; - - // handle Event - if(pEvent->Button & leftButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdblclk); - handled|= pIM->handleEvent (eventDesc); - } - if(pEvent->Button & rightButton) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouserightdblclk); - handled|= pIM->handleEvent (eventDesc); - } - + handled |= inputHandler.handleMouseDblClickEvent( event ); } // mouse move? else if(event == EventMouseMoveId) @@ -386,20 +322,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) } else if (event == EventMouseWheelId) { - CEventMouseWheel *pEvent=(CEventMouseWheel*)&event; - if (pEvent->Direction) - _MouseWheel += 1; - else - _MouseWheel -= 1; - - // handle Event now. - if (_MouseWheel != 0) - { - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mousewheel); - eventDesc.setWheel(_MouseWheel); - handled|= pIM->handleEvent (eventDesc); - _MouseWheel = 0; - } + handled |= inputHandler.handleMouseWheelEvent( event ); } } @@ -432,39 +355,8 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) bool CInputHandlerManager::updateMousePos(NLMISC::CEventMouse &event, NLGUI::CEventDescriptorMouse &eventDesc) { if (!IsMouseFreeLook()) - { - CEventMouseMove* mouseEvent=(CEventMouseMove*)&event; - uint32 w, h; - CInterfaceManager::getInstance()->getViewRenderer().getScreenSize(w, h); + return inputHandler.handleMouseMoveEvent( event ); - // compute new coords - _MouseLastX = _MouseX; - _MouseLastY = _MouseY; - _MouseX = (sint32)(mouseEvent->X*w + 0.5f); - _MouseY = (sint32)(mouseEvent->Y*h + 0.5f); - - // Process Move message only if not Null move - if(_MouseX!=_MouseLastX || _MouseY!=_MouseLastY) - { - // Move the pointer - //pIM->movePointer (_MouseX-_MouseLastX, _MouseY-_MouseLastY); - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - - pIM->movePointerAbs(_MouseX, _MouseY); - - CViewPointer &rIP = *pIM->getPointer(); - // get new pointer pos. - sint32 x,y; - rIP.getPointerDispPos (x, y); - eventDesc.setX (x); - eventDesc.setY (y); - - // handle Event now. - eventDesc.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mousemove); - return pIM->handleEvent (eventDesc); - } - } return false; } diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.h b/code/ryzom/client/src/interface_v3/input_handler_manager.h index 9f152c87c..085806122 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.h @@ -25,6 +25,7 @@ #include #include #include "nel/gui/event_descriptor.h" +#include "nel/gui/input_handler.h" /** @@ -38,9 +39,6 @@ * \date 2002 */ -class CInputHandlerBase; -class CViewText; - class CInputHandlerManager : public NLMISC::IEventListener { @@ -133,8 +131,6 @@ private: NLMISC::CEventServer* _EventServer; // Mouse Infos - NLMISC::TMouseButton _MouseButtonsReleased; - NLMISC::TMouseButton _MouseButtonsDown; NLMISC::TMouseButton _MouseButtonsState; sint32 _MouseX, _MouseY; @@ -180,6 +176,8 @@ private: // return true if handled bool updateMousePos(NLMISC::CEventMouse &event, NLGUI::CEventDescriptorMouse &eventDesc); + NLGUI::CInputHandler inputHandler; + }; #endif // NL_INPUT_HANDLER_MANAGER_H diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 41d736448..135d6812a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2675,6 +2675,25 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool handled= false; + if( event.getType() == NLGUI::CEventDescriptor::system ) + { + const NLGUI::CEventDescriptorSystem &eventDesc = reinterpret_cast< const NLGUI::CEventDescriptorSystem& >( event ); + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus ) + { + if( _CapturePointerLeft != NULL ) + { + _CapturePointerLeft->handleEvent( event ); + setCapturePointerLeft( NULL ); + } + + if( _CapturePointerRight != NULL ) + { + _CapturePointerRight->handleEvent( event ); + setCapturePointerRight( NULL ); + } + } + } + // Check if we can receive events (no anims!) for (uint i = 0; i < _ActiveAnims.size(); ++i) if (_ActiveAnims[i]->isDisableButtons()) @@ -2802,260 +2821,280 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) return result; } } - else if (event.getType() == NLGUI::CEventDescriptor::mouse && _MouseHandlingEnabled ) + else if (event.getType() == NLGUI::CEventDescriptor::mouse ) { NLGUI::CEventDescriptorMouse &eventDesc = (NLGUI::CEventDescriptorMouse&)event; - // First thing to do : Capture handling - if (_CapturePointerLeft != NULL) - handled|= _CapturePointerLeft->handleEvent(event); + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown ) + _Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::leftButton ) ); + else + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown ) + _Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() | NLMISC::rightButton ) ); + else + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup ) + _Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::leftButton ) ); + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup ) + _Pointer->setButtonState( static_cast< NLMISC::TMouseButton >( _Pointer->getButtonState() & ~NLMISC::rightButton ) ); - if (_CapturePointerRight != NULL && _CapturePointerRight!=_CapturePointerLeft) - handled|= _CapturePointerRight->handleEvent(event); + if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ) + handleMouseMoveEvent( eventDesc ); - CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY()); - _WindowUnder = ptr?ptr->getId():""; + eventDesc.setX( _Pointer->getX() ); + eventDesc.setY( _Pointer->getY() ); - // Any Mouse event but move disable the ContextHelp - if(eventDesc.getEventTypeExtended() != NLGUI::CEventDescriptorMouse::mousemove) + if( _MouseHandlingEnabled ) { - disableContextHelp(); - } + // First thing to do : Capture handling + if (_CapturePointerLeft != NULL) + handled|= _CapturePointerLeft->handleEvent(event); - // get the group under the mouse - CInterfaceGroup *pNewCurrentWnd = _WindowUnder; - _MouseOverWindow= pNewCurrentWnd!=NULL; + if (_CapturePointerRight != NULL && _CapturePointerRight!=_CapturePointerLeft) + handled|= _CapturePointerRight->handleEvent(event); + CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY()); + _WindowUnder = ptr?ptr->getId():""; - NLMISC::CRefPtr clickedOutModalWindow; - - // modal special features - if (!_ModalStack.empty()) - { - CModalWndInfo mwi = _ModalStack.back(); - if(mwi.ModalWindow) + // Any Mouse event but move disable the ContextHelp + if(eventDesc.getEventTypeExtended() != NLGUI::CEventDescriptorMouse::mousemove) { - // If we are not in "click out" mode so we dont handle controls other than those of the modal - if (pNewCurrentWnd != mwi.ModalWindow && !mwi.ModalExitClickOut) - { - pNewCurrentWnd = NULL; - } - else - { - // If there is a handler on click out launch it - if (pNewCurrentWnd != mwi.ModalWindow) - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || - (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) - if (!mwi.ModalHandlerClickOut.empty()) - runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams); + disableContextHelp(); + } - // If the current window is not the modal and if must quit on click out - if(pNewCurrentWnd != mwi.ModalWindow && mwi.ModalExitClickOut) + // get the group under the mouse + CInterfaceGroup *pNewCurrentWnd = _WindowUnder; + _MouseOverWindow= pNewCurrentWnd!=NULL; + + + NLMISC::CRefPtr clickedOutModalWindow; + + // modal special features + if (!_ModalStack.empty()) + { + CModalWndInfo mwi = _ModalStack.back(); + if(mwi.ModalWindow) + { + // If we are not in "click out" mode so we dont handle controls other than those of the modal + if (pNewCurrentWnd != mwi.ModalWindow && !mwi.ModalExitClickOut) { - // NB: don't force handle==true because to quit a modal does not avoid other actions + pNewCurrentWnd = NULL; + } + else + { + // If there is a handler on click out launch it + if (pNewCurrentWnd != mwi.ModalWindow) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) + if (!mwi.ModalHandlerClickOut.empty()) + runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams); - // quit if click outside - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || - (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) + // If the current window is not the modal and if must quit on click out + if(pNewCurrentWnd != mwi.ModalWindow && mwi.ModalExitClickOut) { - clickedOutModalWindow = dynamic_cast((CInterfaceGroup*)mwi.ModalWindow); - // disable the modal - popModalWindow(); - if (!_ModalStack.empty()) + // NB: don't force handle==true because to quit a modal does not avoid other actions + + // quit if click outside + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) { - // don't handle event unless it is a previous modal window - uint k = 0; - for(k = 0; k < _ModalStack.size(); ++k) + clickedOutModalWindow = dynamic_cast((CInterfaceGroup*)mwi.ModalWindow); + // disable the modal + popModalWindow(); + if (!_ModalStack.empty()) { - if (_ModalStack[k].ModalWindow == pNewCurrentWnd) + // don't handle event unless it is a previous modal window + uint k = 0; + for(k = 0; k < _ModalStack.size(); ++k) { - break; + if (_ModalStack[k].ModalWindow == pNewCurrentWnd) + { + break; + } + } + if (k == _ModalStack.size()) + { + pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows } } - if (k == _ModalStack.size()) - { - pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows - } + movePointer (0,0); // Reget controls under pointer } - movePointer (0,0); // Reget controls under pointer } } } } - } - // Manage LeftClick. - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) + // Manage LeftClick. + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { - CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); - if (pGC != NULL) + if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) { - if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); + CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); + if (pGC != NULL) + { + if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); + } + else + { + setTopWindow(pNewCurrentWnd); + } } - else + + // must not capture a new element if a sheet is currentlty being dragged. + // This may happen when alt-tab has been used => the sheet is dragged but the left button is up + if (!CDBCtrlSheet::getDraggedSheet()) { - setTopWindow(pNewCurrentWnd); + // Take the top most control. + uint nMaxDepth = 0; + for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) + { + CCtrlBase *ctrl= _CtrlsUnderPointer[i]; + if (ctrl && ctrl->isCapturable() && isControlInWindow(ctrl, pNewCurrentWnd)) + { + uint d = getDepth(ctrl, pNewCurrentWnd); + if (d > nMaxDepth) + { + nMaxDepth = d; + _CapturePointerLeft = ctrl; + } + } + } + notifyElementCaptured(_CapturePointerLeft); + if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) + { + runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerLeft, clickedOutModalWindow->OnPostClickOutParams); + } + } + //if found + if (_CapturePointerLeft != NULL) + { + // consider clicking on a control implies handling of the event. + handled= true; + + // handle the capture + _CapturePointerLeft->handleEvent(event); } } - // must not capture a new element if a sheet is currentlty being dragged. - // This may happen when alt-tab has been used => the sheet is dragged but the left button is up - if (!CDBCtrlSheet::getDraggedSheet()) + // Manage RightClick + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { + if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) + { + CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); + if (pGC != NULL) + { + if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); + } + else + { + setTopWindow(pNewCurrentWnd); + } + } + // Take the top most control. - uint nMaxDepth = 0; - for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) { - CCtrlBase *ctrl= _CtrlsUnderPointer[i]; - if (ctrl && ctrl->isCapturable() && isControlInWindow(ctrl, pNewCurrentWnd)) + uint nMaxDepth = 0; + for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) { - uint d = getDepth(ctrl, pNewCurrentWnd); - if (d > nMaxDepth) + CCtrlBase *ctrl= _CtrlsUnderPointer[i]; + if (ctrl && ctrl->isCapturable() && isControlInWindow(ctrl, pNewCurrentWnd)) { - nMaxDepth = d; - _CapturePointerLeft = ctrl; + uint d = getDepth(ctrl , pNewCurrentWnd); + if (d > nMaxDepth) + { + nMaxDepth = d; + _CapturePointerRight = ctrl; + } } } - } - notifyElementCaptured(_CapturePointerLeft); - if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) - { - runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerLeft, clickedOutModalWindow->OnPostClickOutParams); - } - } - //if found - if (_CapturePointerLeft != NULL) - { - // consider clicking on a control implies handling of the event. - handled= true; - - // handle the capture - _CapturePointerLeft->handleEvent(event); - } - } - - // Manage RightClick - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) - { - if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) - { - CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); - if (pGC != NULL) - { - if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); - } - else - { - setTopWindow(pNewCurrentWnd); - } - } - - // Take the top most control. - { - uint nMaxDepth = 0; - for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) - { - CCtrlBase *ctrl= _CtrlsUnderPointer[i]; - if (ctrl && ctrl->isCapturable() && isControlInWindow(ctrl, pNewCurrentWnd)) + notifyElementCaptured(_CapturePointerRight); + if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) { - uint d = getDepth(ctrl , pNewCurrentWnd); - if (d > nMaxDepth) - { - nMaxDepth = d; - _CapturePointerRight = ctrl; - } + runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerRight, clickedOutModalWindow->OnPostClickOutParams); } } - notifyElementCaptured(_CapturePointerRight); - if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) + //if found + if (_CapturePointerRight != NULL) { - runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerRight, clickedOutModalWindow->OnPostClickOutParams); + // handle the capture + handled |= _CapturePointerRight->handleEvent(event); } } - //if found - if (_CapturePointerRight != NULL) - { - // handle the capture - handled |= _CapturePointerRight->handleEvent(event); + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + { + if (!handled) + if (pNewCurrentWnd != NULL) + pNewCurrentWnd->handleEvent(event); + if (_CapturePointerRight != NULL) + { + EventsListener.addUIHandledButtonMask(rightButton); // prevent 'click in scene' as mouse was previously captured + // (more a patch that anything, but 'UserControls' test for 'mouse up' + // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... + setCapturePointerRight(NULL); + handled= true; + } } - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) - { + + // window handling. if not handled by a control if (!handled) - if (pNewCurrentWnd != NULL) - pNewCurrentWnd->handleEvent(event); - if (_CapturePointerRight != NULL) { - EventsListener.addUIHandledButtonMask(rightButton); // prevent 'click in scene' as mouse was previously captured - // (more a patch that anything, but 'UserControls' test for 'mouse up' - // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... - setCapturePointerRight(NULL); - handled= true; - } - } - - // window handling. if not handled by a control - if (!handled) - { - if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))) - { - NLGUI::CEventDescriptorMouse ev2 = eventDesc; - sint32 x= eventDesc.getX(), y = eventDesc.getY(); - if (pNewCurrentWnd) + if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))) { - pNewCurrentWnd->absoluteToRelative (x, y); - ev2.setX (x); ev2.setY (y); - handled|= pNewCurrentWnd->handleEvent (ev2); + NLGUI::CEventDescriptorMouse ev2 = eventDesc; + sint32 x= eventDesc.getX(), y = eventDesc.getY(); + if (pNewCurrentWnd) + { + pNewCurrentWnd->absoluteToRelative (x, y); + ev2.setX (x); ev2.setY (y); + handled|= pNewCurrentWnd->handleEvent (ev2); + } + + // After handle event of a left click, may set window Top if movable (infos etc...) + //if( (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() ) + // setTopWindow(pNewCurrentWnd); + } + } + + // Put here to let a chance to the window to handle if the capture dont + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + if (_CapturePointerLeft != NULL) + { + EventsListener.addUIHandledButtonMask (leftButton); // prevent 'click in scene' as mouse was previously captured + // (more a patch that anything, but 'UserControls' test for 'mouse up' + // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... + setCapturePointerLeft(NULL); + //handled= true; + } + } + + + // If the current window is the modal, may Modal quit. Do it after standard event handle + if(!_ModalStack.empty() && pNewCurrentWnd == _ModalStack.back().ModalWindow) + { + // NB: don't force handle==true because to quit a modal does not avoid other actions + CModalWndInfo mwi = _ModalStack.back(); + // and if must quit on click right + if(mwi.ModalExitClickR) + { + // quit if click right + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + // disable the modal + disableModalWindow(); } - // After handle event of a left click, may set window Top if movable (infos etc...) - //if( (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) && pNewCurrentWnd->isMovable() ) - // setTopWindow(pNewCurrentWnd); + // and if must quit on click left + if(mwi.ModalExitClickL) + { + // quit if click right + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + // disable the modal + disableModalWindow(); + } } + + // If the mouse is over a window, always consider the event is taken (avoid click behind) + handled|= _MouseOverWindow; } - - // Put here to let a chance to the window to handle if the capture dont - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - if (_CapturePointerLeft != NULL) - { - EventsListener.addUIHandledButtonMask (leftButton); // prevent 'click in scene' as mouse was previously captured - // (more a patch that anything, but 'UserControls' test for 'mouse up' - // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... - setCapturePointerLeft(NULL); - //handled= true; - } - } - - - // If the current window is the modal, may Modal quit. Do it after standard event handle - if(!_ModalStack.empty() && pNewCurrentWnd == _ModalStack.back().ModalWindow) - { - // NB: don't force handle==true because to quit a modal does not avoid other actions - CModalWndInfo mwi = _ModalStack.back(); - // and if must quit on click right - if(mwi.ModalExitClickR) - { - // quit if click right - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) - // disable the modal - disableModalWindow(); - } - - // and if must quit on click left - if(mwi.ModalExitClickL) - { - // quit if click right - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - // disable the modal - disableModalWindow(); - } - } - - // If the mouse is over a window, always consider the event is taken (avoid click behind) - handled|= _MouseOverWindow; } IngameDbMngr.flushObserverCalls(); @@ -3064,6 +3103,36 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) return handled; } +bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eventDesc ) +{ + nlassert( eventDesc.getType() == NLGUI::CEventDescriptor::mouse ); + const NLGUI::CEventDescriptorMouse &e = static_cast< const NLGUI::CEventDescriptorMouse& >( eventDesc ); + nlassert( e.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ); + + uint32 screenW, screenH; + _ViewRenderer.getScreenSize( screenW, screenH ); + sint32 oldX = _Pointer->getX(); + sint32 oldY = _Pointer->getY(); + + sint32 x = e.getX(); + sint32 y = e.getY(); + + // These are floats packed in the sint32 from the NEL events that provide them as float + // see comment in CInputHandler::handleMouseMoveEvent + sint32 newX = static_cast< sint32 >( std::floor( *reinterpret_cast< float* >( &x ) * screenW + 0.5f ) ); + sint32 newY = static_cast< sint32 >( std::floor( *reinterpret_cast< float* >( &y ) * screenH + 0.5f ) ); + + if( ( oldX != newX ) || ( oldY != newY ) ) + { + movePointerAbs( newX, newY ); + NLGUI::CEventDescriptorMouse &ve = const_cast< NLGUI::CEventDescriptorMouse& >( e ); + ve.setX( _Pointer->getX() ); + ve.setY( _Pointer->getY() ); + } + + return true; +} + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::movePointer (sint32 dx, sint32 dy) { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 7fe26fc3e..3a5bccbb0 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -42,6 +42,8 @@ #include "interface_pointer.h" #include "flying_text_manager.h" +#include "nel/gui/input_event_listener.h" + // CLIENT #include "../string_manager_client.h" #include "yubo_chat.h" @@ -75,7 +77,7 @@ class CGroupMenu; * \author Nevrax France * \date 2002 */ -class CInterfaceManager : public CInterfaceParser, public NLMISC::CCDBManager +class CInterfaceManager : public CInterfaceParser, public NLMISC::CCDBManager, public NLGUI::IInputEventListener { public: @@ -339,6 +341,7 @@ public: /// Handle The Event. return true if the interfaceManager catch it and if must not send to the Game Action Manager bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + bool handleMouseMoveEvent( const NLGUI::CEventDescriptor &eventDesc ); void runActionHandler (const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("")); void runActionHandler (IActionHandler *ah, CCtrlBase *pCaller, From 653ff421eaa5faecc67c78df3912114799ab50b7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 17 May 2012 03:38:27 +0200 Subject: [PATCH 023/339] FIXED: Crash caused by CInterfaceLinkUpdater trying to remove itself after CInterfaceManager had been released. --- code/ryzom/client/src/interface_v3/interface_link.cpp | 1 - code/ryzom/client/src/interface_v3/interface_manager.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 7ab34ac8c..e8c2db540 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -137,7 +137,6 @@ CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() { - CInterfaceManager::getInstance()->removeFlushObserver( this ); } void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush() diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 135d6812a..580b25526 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -370,6 +370,8 @@ CInterfaceManager::~CInterfaceManager() // release the database observers releaseServerToLocalAutoCopyObservers(); + + removeFlushObserver( interfaceLinkUpdater ); delete interfaceLinkUpdater; interfaceLinkUpdater = NULL; } From e1b6690e6f216621a5f7627205f892bdcbf5112e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 19 May 2012 00:00:09 +0200 Subject: [PATCH 024/339] Moved some Lua related string formatting methods from CInterfaceManager to LuaHelperStuff namespace. --- code/nel/src/misc/cdb_manager.cpp | 2 +- code/ryzom/client/src/commands.cpp | 10 +++---- .../src/interface_v3/interface_manager.cpp | 26 +++++------------- .../src/interface_v3/interface_manager.h | 5 ---- .../client/src/interface_v3/lua_helper.cpp | 27 ++++++++++++++++--- .../client/src/interface_v3/lua_helper.h | 9 ++++++- .../ryzom/client/src/interface_v3/lua_ihm.cpp | 7 +++-- 7 files changed, 47 insertions(+), 39 deletions(-) diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp index a13527217..8fc8a6897 100644 --- a/code/nel/src/misc/cdb_manager.cpp +++ b/code/nel/src/misc/cdb_manager.cpp @@ -54,7 +54,7 @@ namespace NLMISC{ } - void CCDBManager::delDbNode( const stlpx_std::string &name ) + void CCDBManager::delDbNode( const std::string &name ) { if( name.empty() ) return; diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index efdee9bc9..6c804e93d 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5082,7 +5082,7 @@ NLMISC_COMMAND(luaReload, "reload all .lua script files", "") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5109,7 +5109,7 @@ NLMISC_COMMAND(luaScript, "Execute a lua script", "direct_script_code") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5130,7 +5130,7 @@ NLMISC_COMMAND(luaInfo, "Dump some information on LUA state", "detaillevel from } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5142,7 +5142,7 @@ NLMISC_COMMAND(luaObject, "Dump the content of a lua object", " [max CInterfaceManager *pIM= CInterfaceManager::getInstance(); if (!ClientCfg.AllowDebugLua) { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } CLuaState *luaState = pIM->getLuaState(); @@ -5189,7 +5189,7 @@ NLMISC_COMMAND(luaGC, "Force a garbage collector of lua", "") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 580b25526..313fc4300 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -5747,8 +5747,8 @@ bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smal if (sscanf(msg.c_str(), "%s: %s.lua:%d:",exceptionName, filename, &line) == 3) // NB: test not exact here, but should work in 99,9 % of cases { msg = CLuaIHM::createGotoFileButtonTag(filename, line) + msg; - nlwarning(formatLuaErrorNlWarn(msg).c_str()); - displaySystemInfo(formatLuaErrorSysInfo(msg)); + nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str()); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg)); } else // AJM: handle the other 0.1% of cases { @@ -5767,8 +5767,8 @@ bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smal else if (line >= 1 && contextList.size() >= line) msg = error[0]+": \n>>>"+contextList[line-1]+"\nError:"+error[2]+": "+error[3]; } - nlwarning(formatLuaErrorNlWarn(msg).c_str()); - displaySystemInfo(formatLuaErrorSysInfo(msg)); + nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str()); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg)); } return false; } @@ -5785,7 +5785,7 @@ void CInterfaceManager::reloadAllLuaFileScripts() // if fail to reload a script, display the error code if(!loadLUA(*it, error)) { - displaySystemInfo(formatLuaErrorSysInfo(error)); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(error)); } } } @@ -5837,25 +5837,11 @@ std::vector CInterfaceManager::getInGameXMLInterfaceFiles() return ret; } -// *************************************************************************** -void CInterfaceManager::formatLuaStackContext(std::string &stackContext) -{ - stackContext= string("@{FC8A}") + stackContext + "@{FC8F} "; -} -std::string CInterfaceManager::formatLuaErrorNlWarn(const std::string &error) -{ - // Remove color tags (see formatLuaErrorSC()) - std::string ret= error; - strFindReplace(ret, "@{FC8A}", ""); - strFindReplace(ret, "@{FC8F}", ""); - return ret; -} - // *************************************************************************** void CInterfaceManager::dumpLuaString(const std::string &str) { nlinfo(str.c_str()); - displaySystemInfo(formatLuaErrorSysInfo(str)); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(str)); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 3a5bccbb0..75a33cc29 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -633,11 +633,6 @@ public: class CLuaState *getLuaState() const {return _LuaState;} /// Reload all LUA scripts inserted through void reloadAllLuaFileScripts(); - /// for Debug: append some color TAG, to have a cool display in SystemInfo - std::string formatLuaErrorSysInfo(const std::string &error) {return std::string("@{FC8F}") + error;} - /// for Debug: append/remove some color TAG, to have a cool display in SystemInfo/nlwarning - void formatLuaStackContext(std::string &stackContext); - std::string formatLuaErrorNlWarn(const std::string &error); /// For debug: dump in the sysinfo and nlwarning state of lua. detail range from 0 to 2 (clamped). void dumpLuaState(uint detail); /// For debug: force a garbage collector diff --git a/code/ryzom/client/src/interface_v3/lua_helper.cpp b/code/ryzom/client/src/interface_v3/lua_helper.cpp index 9fa942d41..0299e66cc 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.cpp +++ b/code/ryzom/client/src/interface_v3/lua_helper.cpp @@ -18,7 +18,7 @@ #include "lua_helper.h" #include "nel/misc/file.h" -#include "interface_manager.h" +//#include "interface_manager.h" #include "../client_cfg.h" #ifdef LUA_NEVRAX_VERSION @@ -45,6 +45,28 @@ using namespace std; using namespace NLMISC; +namespace LuaHelperStuff +{ + void formatLuaStackContext( std::string &stackContext ) + { + stackContext = std::string( "@{FC8A}" ).append( stackContext ).append( "@{FC8F} " ); + } + + std::string formatLuaErrorSysInfo( const std::string &error ) + { + return std::string( "@{FC8F}" ).append( error ); + } + + std::string formatLuaErrorNlWarn( const std::string &error ) + { + // Remove color tags (see formatLuaErrorSC()) + std::string ret = error; + strFindReplace( ret, "@{FC8A}", "" ); + strFindReplace( ret, "@{FC8F}", "" ); + return ret; + } +} + // *************************************************************************** const char *CLuaState::_NELSmallScriptTableName= "NELSmallScriptTable"; uint CLuaStackChecker::_ExceptionContextCounter = 0; @@ -706,12 +728,11 @@ void ELuaWrappedFunctionException::init(CLuaState *ls, const std::string &reason { //H_AUTO(Lua_ELuaWrappedFunctionException_init) // Print first Lua Stack Context - CInterfaceManager *pIM= CInterfaceManager::getInstance(); if(ls) { ls->getStackContext(_Reason, 1); // 1 because 0 is the current C function => return 1 for script called // enclose with cool colors - pIM->formatLuaStackContext(_Reason); + LuaHelperStuff::formatLuaStackContext(_Reason); } // Append the reason diff --git a/code/ryzom/client/src/interface_v3/lua_helper.h b/code/ryzom/client/src/interface_v3/lua_helper.h index e6d50cb9d..71a3efe17 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.h +++ b/code/ryzom/client/src/interface_v3/lua_helper.h @@ -27,9 +27,16 @@ extern "C" #include "lua_loadlib.h" } - class CLuaState; +namespace LuaHelperStuff +{ + void formatLuaStackContext( std::string &stackContext ); + std::string formatLuaErrorSysInfo( const std::string &error ); + std::string formatLuaErrorNlWarn( const std::string &error ); +} + + // *************************************************************************** /** Helper class to see if a stack is restored at its initial size (or with n return results). * Check that the stack size remains unchanged when the object goes out of scope diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index 08b128b66..ebb374bd9 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -1806,7 +1806,7 @@ void CLuaIHM::rawDebugInfo(const std::string &dbg) } else { - NLMISC::InfoLog->displayRawNL(pIM->formatLuaErrorSysInfo(dbg).c_str()); + NLMISC::InfoLog->displayRawNL(LuaHelperStuff::formatLuaErrorSysInfo(dbg).c_str()); } #ifdef LUA_NEVRAX_VERSION if (LuaDebuggerIDE) @@ -1814,7 +1814,7 @@ void CLuaIHM::rawDebugInfo(const std::string &dbg) LuaDebuggerIDE->debugInfo(dbg.c_str()); } #endif - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(dbg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); } } @@ -3564,10 +3564,9 @@ bool CLuaIHM::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) int CLuaIHM::breakPoint(CLuaState &ls) { //H_AUTO(Lua_CLuaIHM_breakPoint) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); std::string reason; ls.getStackContext(reason, 1); // 1 because 0 is the current C function => return 1 for script called - pIM->formatLuaStackContext(reason); + LuaHelperStuff::formatLuaStackContext(reason); NLMISC::InfoLog->displayRawNL(reason.c_str()); static volatile bool doAssert = true; if (doAssert) // breakPoint can be discarded in case of looping assert From 2af7e250b2a2c12045e8a5ef62bf54d9300394b2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 19 May 2012 23:00:52 +0200 Subject: [PATCH 025/339] Moved some Lua stuff over to the NelGUI library. --- code/nel/include/nel/gui/lua_helper.h | 388 ++++++++ .../include/nel/gui}/lua_helper_inline.h | 0 .../include/nel/gui}/lua_loadlib.h | 0 code/nel/src/gui/lua_helper.cpp | 835 ++++++++++++++++++ .../src/gui}/lua_loadlib.c | 0 code/ryzom/client/src/debug_client.cpp | 3 +- .../src/interface_v3/interface_manager.cpp | 8 +- .../src/interface_v3/interface_parser.cpp | 5 +- .../src/interface_v3/interface_parser.h | 3 +- .../client/src/interface_v3/lua_helper.cpp | 829 ----------------- .../client/src/interface_v3/lua_helper.h | 385 -------- .../ryzom/client/src/interface_v3/lua_ihm.cpp | 3 +- code/ryzom/client/src/interface_v3/lua_ihm.h | 4 +- .../client/src/interface_v3/lua_object.cpp | 3 +- .../client/src/interface_v3/lua_object.h | 3 +- code/ryzom/client/src/interface_v3/reflect.h | 5 +- .../client/src/r2/dmc/com_lua_module.cpp | 3 +- code/ryzom/client/src/r2/dmc/com_lua_module.h | 2 +- code/ryzom/client/src/r2/dmc/dmc.h | 2 +- code/ryzom/client/src/r2/editor.cpp | 3 +- code/ryzom/client/src/r2/instance.h | 3 + .../ryzom/client/src/r2/lua_event_forwarder.h | 7 +- code/ryzom/client/src/session_browser_impl.h | 3 +- 23 files changed, 1264 insertions(+), 1233 deletions(-) create mode 100644 code/nel/include/nel/gui/lua_helper.h rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/lua_helper_inline.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/lua_loadlib.h (100%) create mode 100644 code/nel/src/gui/lua_helper.cpp rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/lua_loadlib.c (100%) delete mode 100644 code/ryzom/client/src/interface_v3/lua_helper.cpp delete mode 100644 code/ryzom/client/src/interface_v3/lua_helper.h diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h new file mode 100644 index 000000000..52707eadc --- /dev/null +++ b/code/nel/include/nel/gui/lua_helper.h @@ -0,0 +1,388 @@ +// Ryzom - MMORPG Framework +// 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 RZ_LUA_HELPER_H +#define RZ_LUA_HELPER_H + + +#include "nel/misc/types_nl.h" +#include "nel/misc/smart_ptr.h" + +extern "C" +{ + #include "lua_loadlib.h" +} + +namespace NLGUI +{ + + class CLuaState; + + namespace LuaHelperStuff + { + void formatLuaStackContext( std::string &stackContext ); + std::string formatLuaErrorSysInfo( const std::string &error ); + std::string formatLuaErrorNlWarn( const std::string &error ); + } + + + // *************************************************************************** + /** Helper class to see if a stack is restored at its initial size (or with n return results). + * Check that the stack size remains unchanged when the object goes out of scope + */ + class CLuaStackChecker + { + public: + CLuaStackChecker(CLuaState *state, int numWantedResults = 0); + ~CLuaStackChecker(); + /** Increment exception context counter + * When an exception is thrown, lua stack checker do any assert bu will + * rather restore the lua stack at its original size, and will + * let the exception a chance to propagate + */ + static void incrementExceptionContextCounter(); + static void decrementExceptionContextCounter(); + + private: + CLuaState *_State; + int _FinalWantedSize; + static uint _ExceptionContextCounter; + + }; + + // ************************************************************************** + /** Helper class to restore the lua stack to the desired size when this object goes out of scope + */ + class CLuaStackRestorer + { + public: + CLuaStackRestorer(CLuaState *state, int finalSize); + ~CLuaStackRestorer(); + private: + int _FinalSize; + CLuaState *_State; + }; + + //////////////// + // EXCEPTIONS // + //////////////// + + class ELuaError : public NLMISC::Exception + { + public: + ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); } + virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); } + ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); } + // what(), plus append the Reason + virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} + }; + + // A parse error occured + class ELuaParseError : public ELuaError + { + public: + ELuaParseError() {} + ELuaParseError(const std::string &reason) : ELuaError(reason) {} + virtual ~ELuaParseError() throw() { } + // what(), plus append the Reason + virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());} + }; + + /** Exception thrown when something went wrong inside a wrapped function called by lua + */ + class ELuaWrappedFunctionException : public ELuaError + { + public: + ELuaWrappedFunctionException(CLuaState *luaState); + ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason); + ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...); + virtual ~ELuaWrappedFunctionException() throw() { } + virtual const char *what() const throw() {return _Reason.c_str();} + protected: + void init(CLuaState *ls, const std::string &reason); + protected: + std::string _Reason; + }; + + // A execution error occured + class ELuaExecuteError : public ELuaError + { + public: + ELuaExecuteError() {} + ELuaExecuteError(const std::string &reason) : ELuaError(reason) {} + virtual ~ELuaExecuteError() throw() { } + // what(), plus append the Reason + virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} + }; + + // A bad cast occured when using lua_checkcast + class ELuaBadCast : public ELuaError + { + public: + ELuaBadCast() {} + ELuaBadCast(const std::string &reason) : ELuaError(reason) {} + // what(), plus append the Reason + virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaBadCast: %s", what());} + }; + + // Error when trying to indexate an object that is not a table + class ELuaNotATable : public ELuaError + { + public: + ELuaNotATable() {} + ELuaNotATable(const std::string &reason) : ELuaError(reason) {} + // what(), plus append the Reason + virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaNotATable: %s", what());} + }; + + + // *************************************************************************** + // a function to be used with a CLuaState instance + typedef int (* TLuaWrappedFunction) (CLuaState &ls); + + + // *************************************************************************** + /** C++ version of a lua state + */ + class CLuaState : public NLMISC::CRefCount + { + public: + typedef NLMISC::CRefPtr TRefPtr; + + // Create a new environement + CLuaState( bool debugger = false ); + ~CLuaState(); + + + /// \name Registering + // @{ + // register a wrapped function + void registerFunc(const char *name, TLuaWrappedFunction function); + // @} + + + /// \name Script execution + // @{ + + /** Parse a script and push as a function in top of the LUA stack + * \throw ELuaParseError + * \param dbgSrc is a string for debug. Should be a filename (preceded with '@'), or a short script. + */ + void loadScript(const std::string &code, const std::string &dbgSrc); + + /** Execute a script from a string, possibly throwing an exception if there's a parse error + * \throw ELuaParseError, ELuaExecuteError + */ + void executeScript(const std::string &code, int numRet = 0); + + /** Execute a script from a string. If an errors occurs it is printed in the log + * \return true if script execution was successful + */ + bool executeScriptNoThrow(const std::string &code, int numRet = 0); + + /** Load a Script from a File (maybe in a BNP), and execute it + * \return false if file not found + * \throw ELuaParseError, ELuaExecuteError + */ + bool executeFile(const std::string &pathName); + + /** execute a very Small Script (a function call for instance) + * It is different from doString() in such there is a cache (where the key is the script itself) + * so that the second time this script is executed, there is no parsing + * Note: I experienced optim with about 10 times faster than a executeScript() on a simple "a= a+1;" script + * \throw ELuaParseError, ELuaExecuteError + */ + void executeSmallScript(const std::string &script); + + // @} + + + /// \name Stack Manipulation + // @{ + // stack manipulation (indices start at 1) + void setTop(int index); // set new size of stack + void clear() { setTop(0); } + int getTop(); + bool empty() { return getTop() == 0; } + void pushValue(int index); // copie nth element of stack to the top of the stack + void remove(int index); // remove nth element of stack + void insert(int index); // insert last element of the stack before the given position + void replace(int index); // replace nth element of the stack with the top of the stack + void pop(int numElem = 1); // remove n elements from the top of the stack + // test the type of an element in the stack + // return one of the following values : + // LUA_TNIL + // LUA_TNUMBER + // LUA_TBOOLEAN + // LUA_TSTRING + // LUA_TTABLE + // LUA_TFUNCTION + // LUA_TUSERDATA + // LUA_TTHREAD + // LUA_TLIGHTUSERDATA + int type(int index = -1); + const char *getTypename(int type); + bool isNil(int index = -1); + bool isBoolean(int index = -1); + bool isNumber(int index = -1); + bool isString(int index = -1); + bool isTable(int index = -1); + bool isFunction(int index = -1); + bool isCFunction(int index = -1); + bool isUserData(int index = -1); + bool isLightUserData(int index = -1); + // converting then getting a value from the stack + bool toBoolean(int index = -1); + lua_Number toNumber(int index = -1); + const char *toString(int index = -1); + void toString(int index, std::string &str); // convert to a std::string, with a NULL check. + size_t strlen(int index = -1); + lua_CFunction toCFunction(int index = -1); + void *toUserData(int index = -1); + const void *toPointer(int index = -1); + /** Helper functions : get value of the wanted type in the top table after conversion + * A default value is used if the stack entry is NULL. + * If conversion fails then an exception is thrown (with optional msg) + */ + bool getTableBooleanValue(const char *name, bool defaultValue= false); + double getTableNumberValue(const char *name, double defaultValue= 0); + const char *getTableStringValue(const char *name, const char *defaultValue= NULL); + // pushing value onto the stack + void push(bool value); + void push(lua_Number value); + void push(const char *str); + void push(const char *str, int length); + void push(const std::string &str); + void pushNil(); + void push(lua_CFunction f); + void push(TLuaWrappedFunction function); + void pushLightUserData(void *); // push a light user data (use newUserData to push a full userdata) + // metatables + bool getMetaTable(int index = -1); + bool setMetaTable(int index = -1); // set the metatable at top of stack to the object at 'index' (usually -2), then pop the metatable + // even if asignment failed + // comparison + bool equal(int index1, int index2); + bool rawEqual(int index1, int index2); + bool lessThan(int index1, int index2); + // concatenation of the n element at the top of the stack (using lua semantic) + void concat(int numElem); + // tables + void newTable(); // create a new table at top of the stack + void getTable(int index); // get value from a table at index 'index' (key is at top) + void rawGet(int index); + void setTable(int index); // set (key, value) from top of the stack into the given table + // both key and value are poped + void rawSet(int index); + bool next(int index); // table traversal + // UserData + void *newUserData(uint size); + // seting value by int index in a table + void rawSetI(int index, int n); + void rawGetI(int index, int n); + /** Calling functions (it's up to the caller to clear the results) + * The function should have been pushed on the stack + */ + void call(int nargs, int nresults); + int pcall(int nargs, int nresults, int errfunc = 0); + /** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex' + * the behaviour is the same than with call of pcall. + */ + int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex = LUA_GLOBALSINDEX, int errfunc = 0); + + // push a C closure (pop n element from the stack and associate with the function) + void pushCClosure(lua_CFunction function, int n); + // @} + + + /// \name Misc + // @{ + /** Retrieve pointer to a CLuaState environment from its lua_State pointer, or NULL + * if there no such environment + */ + static CLuaState *fromStatePointer(lua_State *state); + // Get state pointer. The state should not be closed (this object has ownership) + lua_State *getStatePointer() const {return _State;} + // check that an index is valid when accessing the stack + // an assertion is raised if the index is not valid + void checkIndex(int index); + + // registering C function to use with a lua state pointer + void registerFunc(const char *name, lua_CFunction function); + + // Garbage collector + int getGCCount(); // get memory in use in KB + int getGCThreshold(); // get max memory in KB + void setGCThreshold(int kb); // set max memory in KB (no-op with ref-counted version) + + // handle garbage collector for ref-counted version of lua (no-op with standard version, in which case gc handling is automatic) + void handleGC(); + + /** For Debug: get the Stack context of execution (filename / line) + * \param stackLevel: get the context of execution of the given stackLevel. + * 0 for the current function + * 1 for the function that called 0 + * 2 .... + * NB: if called from a C function called from LUA, remember that stackLevel 0 is the current function. + * Hence if you want to know what LUA context called you, pass stackLevel=1! + * \param ret string cleared if any error, else filled with formated FileName / LineNumber + */ + void getStackContext(std::string &ret, uint stackLevel); + // @} + + // for debug : dump the current content of the stack (no recursion) + void dumpStack(); + static void dumpStack(lua_State *ls); + void getStackAsString(std::string &dest); + + + private: + lua_State *_State; + + #ifdef LUA_NEVRAX_VERSION + int _GCThreshold; // if refcounted gc is used, then garbage collector is handled manually + #endif + // Small Script Cache + uint _SmallScriptPool; + typedef std::map TSmallScriptCache; + TSmallScriptCache _SmallScriptCache; + static const char * _NELSmallScriptTableName; + + private: + // this object isn't intended to be copied + CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); } + CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; } + + void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0); + + }; + + + // Access to lua function + // one should not include lua.h directly because if a debugger is present, lua + // function pointer will be taken from a dynamic library. + + + + //============================================================================================= + // include implementation + #define RZ_INCLUDE_LUA_HELPER_INLINE + #include "lua_helper_inline.h" + #undef RZ_INCLUDE_LUA_HELPER_INLINE + +} + +#endif diff --git a/code/ryzom/client/src/interface_v3/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h similarity index 100% rename from code/ryzom/client/src/interface_v3/lua_helper_inline.h rename to code/nel/include/nel/gui/lua_helper_inline.h diff --git a/code/ryzom/client/src/interface_v3/lua_loadlib.h b/code/nel/include/nel/gui/lua_loadlib.h similarity index 100% rename from code/ryzom/client/src/interface_v3/lua_loadlib.h rename to code/nel/include/nel/gui/lua_loadlib.h diff --git a/code/nel/src/gui/lua_helper.cpp b/code/nel/src/gui/lua_helper.cpp new file mode 100644 index 000000000..1e67620d3 --- /dev/null +++ b/code/nel/src/gui/lua_helper.cpp @@ -0,0 +1,835 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/lua_helper.h" +#include "nel/misc/file.h" + +#ifdef LUA_NEVRAX_VERSION + #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger +#endif + + +#include "nel/gui/lua_loadlib.h" + +// to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages +#include +#ifdef assert + #undef assert +#endif + +#ifdef NL_DEBUG + #define assert(x) nlassert(x) +#else + #define assert(x) +#endif + +#include +#include +#include + +#ifdef NL_OS_WINDOWS +#include +#endif + +using namespace std; +using namespace NLMISC; + +namespace NLGUI +{ + + namespace LuaHelperStuff + { + void formatLuaStackContext( std::string &stackContext ) + { + stackContext = std::string( "@{FC8A}" ).append( stackContext ).append( "@{FC8F} " ); + } + + std::string formatLuaErrorSysInfo( const std::string &error ) + { + return std::string( "@{FC8F}" ).append( error ); + } + + std::string formatLuaErrorNlWarn( const std::string &error ) + { + // Remove color tags (see formatLuaErrorSC()) + std::string ret = error; + strFindReplace( ret, "@{FC8A}", "" ); + strFindReplace( ret, "@{FC8F}", "" ); + return ret; + } + } + + // *************************************************************************** + const char *CLuaState::_NELSmallScriptTableName= "NELSmallScriptTable"; + uint CLuaStackChecker::_ExceptionContextCounter = 0; + + // *************************************************************************** + void CLuaStackChecker::incrementExceptionContextCounter() + { + //H_AUTO(Lua_CLuaStackChecker_incrementExceptionContextCounter) + ++ _ExceptionContextCounter; + } + + // *************************************************************************** + void CLuaStackChecker::decrementExceptionContextCounter() + { + //H_AUTO(Lua_CLuaStackChecker_decrementExceptionContextCounter) + nlassert(_ExceptionContextCounter > 0); + -- _ExceptionContextCounter; + } + + + #ifdef LUA_NEVRAX_VERSION + ILuaIDEInterface *LuaDebuggerIDE = NULL; + static bool LuaDebuggerVisible = false; + #endif + + #ifdef NL_OS_WINDOWS + HMODULE LuaDebuggerModule = 0; + #endif + + void luaDebuggerMainLoop() + { + #ifdef LUA_NEVRAX_VERSION + if (!LuaDebuggerIDE) return; + if (!LuaDebuggerVisible) + { + LuaDebuggerIDE->showDebugger(true); + LuaDebuggerIDE->expandProjectTree(); + LuaDebuggerIDE->sortFiles(); + LuaDebuggerVisible = true; + } + LuaDebuggerIDE->doMainLoop(); + #endif + } + + + + static std::allocator l_stlAlloc; + + + static void l_free_func(void *block, int oldSize) + { + l_stlAlloc.deallocate((uint8 *) block, oldSize); + } + + static void *l_realloc_func(void *b, int os, int s) + { + if (os == s) return b; + void *newB = l_stlAlloc.allocate(s); + memcpy(newB, b, std::min(os, s)); + l_free_func(b, os); + return newB; + } + + + + const int MinGCThreshold = 128; // min value at which garbage collector will be triggered (in kilobytes) + // *************************************************************************** + CLuaState::CLuaState( bool debugger ) + { + _State = NULL; + + #ifdef LUA_NEVRAX_VERSION + _GCThreshold = MinGCThreshold; + #endif + + #ifdef NL_OS_WINDOWS + if( debugger ) + { + #ifndef LUA_NEVRAX_VERSION + static bool warningShown = false; + if (!warningShown) + { + nldebug( "Lua debugger was asked, but the static lua library against which the client was linked is too old. Please update to lua-5.0.2_nevrax. Debugging won't be available!" ); + //MessageBox (NULL, "Lua debugger was asked, but the static lua library against which the client was linked is too old. Please update to lua-5.0.2_nevrax. Debugging won't be available!", "Lua support", MB_OK); + warningShown = true; + } + #else + nlassert(LuaDebuggerIDE == NULL); // for now, only one debugger supported... + #ifdef NL_DEBUG + LuaDebuggerModule = ::LoadLibrary("lua_ide2_dll_d.dll"); + #else + LuaDebuggerModule = ::LoadLibrary("lua_ide2_dll_r.dll"); + #endif + if (LuaDebuggerModule) + { + TGetLuaIDEInterfaceVersion getVersion = (TGetLuaIDEInterfaceVersion) GetProcAddress(LuaDebuggerModule, "GetLuaIDEInterfaceVersion"); + nlassert(getVersion); + int dllInterfaceVersion = getVersion(); + if (dllInterfaceVersion > LUA_IDE_INTERFACE_VERSION) + { + MessageBox (NULL, "Lua debugger interface is newer than the application. Debugging will be disabled. Please update your client", "Lua support", MB_OK); + } + else if (dllInterfaceVersion < LUA_IDE_INTERFACE_VERSION) + { + MessageBox (NULL, "Lua debugger interface is too old. Lua debugging will be disabled. Please ask for a more recent dll.", "Lua support", MB_OK); + } + else + { + TGetLuaIDEInterface getter = (TGetLuaIDEInterface) GetProcAddress(LuaDebuggerModule, "GetLuaIDEInterface"); + nlassert(getter); + LuaDebuggerIDE = getter(); + LuaDebuggerIDE->prepareDebug("save\\___external_debug.lpr", l_realloc_func, l_free_func, Driver->getDisplay()); + _State = LuaDebuggerIDE->getLuaState(); + } + } + #endif + } + #endif + + if (!_State) + { + #ifdef LUA_NEVRAX_VERSION + _State = lua_open(l_realloc_func, l_free_func); + #else + _State = lua_open(); + #endif + nlassert(_State); + } + + // *** Load base libs + { + CLuaStackChecker lsc(this); + #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + luaL_openlibs(_State); + #else + luaopen_base (_State); + luaopen_table (_State); + luaopen_io (_State); + luaopen_string (_State); + luaopen_math (_State); + luaopen_debug (_State); + #endif + + // open are buggy???? + clear(); + } + + // *** Register basics + CLuaStackChecker lsc(this); + + // do: LUA_REGISTRYINDEX.(lightuserdata*)this.classes= {} + pushLightUserData((void *) this); + newTable(); + push("classes"); + newTable(); // registry class + setTable(-3); + setTable(LUA_REGISTRYINDEX); + + // add pointer from lua state to this CLuaState object + // do: LUA_REGISTRYINDEX.(lightuserdata*)_State= this + pushLightUserData((void *) _State); // NB : as creator of the state, we make the assumption that + // no one will be using this pointer in the registry (cf. ref manual about registry) + pushLightUserData((void *) this); + setTable(LUA_REGISTRYINDEX); + + // Create the Table that contains Function cache for small script execution + push(_NELSmallScriptTableName); // 1:TableName + newTable(); // 1:TableName 2:table + setTable(LUA_REGISTRYINDEX); // ... + _SmallScriptPool= 0; + + // *** luabind init + luabind::open(_State); + } + + + // *************************************************************************** + CLuaStackRestorer::CLuaStackRestorer(CLuaState *state, int finalSize) : _FinalSize(finalSize), _State(state) + { + } + + // *************************************************************************** + CLuaStackRestorer::~CLuaStackRestorer() + { + nlassert(_State); + _State->setTop(_FinalSize); + } + + #ifdef NL_OS_WINDOWS + static int NoOpReportHook( int /* reportType */, char * /* message */, int * /* returnValue */ ) + { + return TRUE; + } + #endif + + + // *************************************************************************** + CLuaState::~CLuaState() + { + nlassert(_State); + + #ifdef LUA_NEVRAX_VERSION + if (!LuaDebuggerIDE) + #else + if (1) + #endif + { + lua_close(_State); + } + else + { + #ifdef LUA_NEVRAX_VERSION + LuaDebuggerIDE->stopDebug(); // this will also close the lua state + LuaDebuggerIDE = NULL; + LuaDebuggerVisible = false; + #ifdef NL_OS_WINDOWS + nlassert(LuaDebuggerModule) + _CrtSetReportHook(NoOpReportHook); // prevent dump of memory leaks at this point + //::FreeLibrary(LuaDebuggerModule); // don't free the library now (seems that it destroy, the main window, causing + // a crash when the app window is destroyed for real... + // -> FreeLibrary will be called when the application is closed + LuaDebuggerModule = 0; + #endif + #endif + } + + // Clear Small Script Cache + _SmallScriptPool= 0; + _SmallScriptCache.clear(); + } + + // *************************************************************************** + CLuaState *CLuaState::fromStatePointer(lua_State *state) + { + //H_AUTO(Lua_CLuaState_fromStatePointer) + nlassert(state); + int initialStackSize = lua_gettop(state); + lua_checkstack(state, initialStackSize + 2); + lua_pushlightuserdata(state, (void *) state); + lua_gettable(state, LUA_REGISTRYINDEX); + if (!lua_islightuserdata(state, -1)) + { + lua_pop(state, 1); + return NULL; + } + CLuaState *ls = (CLuaState *) lua_touserdata(state, -1); + lua_pop(state, 1); + nlassert(initialStackSize == lua_gettop(state)); + return ls; + } + + // *************************************************************************** + struct CLuaReader + { + const std::string *Str; + bool Done; + }; + + + + + void CLuaState::loadScript(const std::string &code, const std::string &dbgSrc) + { + //H_AUTO(Lua_CLuaState_loadScript) + if (code.empty()) return; + struct CHelper + { + static const char *luaChunkReaderFromString(lua_State * /* L */, void *ud, size_t *sz) + { + CLuaReader *rd = (CLuaReader *) ud; + if (!rd->Done) + { + rd->Done = true; + *sz = rd->Str->size(); + return rd->Str->c_str(); + } + else + { + *sz = 0; + return NULL; + } + } + }; + CLuaReader rd; + rd.Str = &code; + rd.Done = false; + + int result = lua_load(_State, CHelper::luaChunkReaderFromString, (void *) &rd, dbgSrc.c_str()); + if (result !=0) + { + // pop the error code + string err= toString(); + pop(); + // throw error + throw ELuaParseError(err); + } + } + + // *************************************************************************** + void CLuaState::executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet) + { + //H_AUTO(Lua_CLuaState_executeScriptInternal) + CLuaStackChecker lsc(this, numRet); + + // load the script + loadScript(code, dbgSrc); + + // execute + if (pcall(0, numRet) != 0) + { + // pop the error code + string err= toString(); + pop(); + // throw error + throw ELuaExecuteError(err); + } + } + + // *************************************************************************** + void CLuaState::executeScript(const std::string &code, int numRet) + { + //H_AUTO(Lua_CLuaState_executeScript) + // run the script, with dbgSrc==script + executeScriptInternal(code, code, numRet); + } + + // *************************************************************************** + bool CLuaState::executeScriptNoThrow(const std::string &code, int numRet) + { + //H_AUTO(Lua_CLuaState_executeScriptNoThrow) + try + { + executeScript(code, numRet); + } + catch (const ELuaError &e) + { + nlwarning(e.what()); + return false; + } + return true; + } + + // *************************************************************************** + bool CLuaState::executeFile(const std::string &pathName) + { + //H_AUTO(Lua_CLuaState_executeFile) + + CIFile inputFile; + if(!inputFile.open(pathName)) + return false; + + #ifdef LUA_NEVRAX_VERSION + if (LuaDebuggerIDE) + { + std::string path = NLMISC::CPath::getCurrentPath() + "/" + pathName.c_str(); + path = CPath::standardizeDosPath(path); + LuaDebuggerIDE->addFile(path.c_str()); + } + #endif + + // load the script text + string script; + /* + while(!inputFile.eof()) + { + char tmpBuff[5000]; + inputFile.getline(tmpBuff, 5000); + script+= tmpBuff; + script+= "\n"; + } + */ + script.resize(CFile::getFileSize(pathName)); + inputFile.serialBuffer((uint8 *) &script[0], (uint)script.size()); + + + // execute the script text, with dbgSrc==filename (use @ for lua internal purpose) + executeScriptInternal(script, string("@") + CFile::getFilename(pathName)); + + return true; + } + + // *************************************************************************** + void CLuaState::executeSmallScript(const std::string &script) + { + //H_AUTO(Lua_CLuaState_executeSmallScript) + if (script.empty()) return; + // *** if the small script has not already been called before, parse it now + TSmallScriptCache::iterator it= _SmallScriptCache.find(script); + if(it==_SmallScriptCache.end()) + { + CLuaStackChecker lsc(this); + + // add it to a function + loadScript(script, script); + + // Assign the method to the NEL table: NELSmallScriptTable[_SmallScriptPool]= function + push(_NELSmallScriptTableName); // 1:function 2:NelTableName + getTable(LUA_REGISTRYINDEX); // 1:function 2:NelTable + insert(-2); // 1:NelTable 2:function + rawSetI(-2, _SmallScriptPool); // 1:NelTable + pop(); + + // bkup in cache map + it= _SmallScriptCache.insert(make_pair(script, _SmallScriptPool)).first; + + // next allocated + _SmallScriptPool++; + } + + // *** Execute the function associated to the script + CLuaStackChecker lsc(this); + push(_NELSmallScriptTableName); // 1:NelTableName + getTable(LUA_REGISTRYINDEX); // 1:NelTable + // get the function at the given index in the "NELSmallScriptTable" table + rawGetI(-1, it->second); // 1:NelTable 2:function + + // execute + if (pcall(0, 0) != 0) + { + // Stack: 1: NelTable 2:errorcode + // pop the error code, and clear stack + string err= toString(); + pop(); // 1:NelTable + pop(); // .... + // throw error + throw ELuaExecuteError(err); + } + else + { + // Stack: 1:NelTable + pop(); // .... + } + + } + + // *************************************************************************** + void CLuaState::registerFunc(const char *name, lua_CFunction function) + { + //H_AUTO(Lua_CLuaState_registerFunc) + lua_register(_State, name, function); + } + + // *************************************************************************** + void CLuaState::pushCClosure(lua_CFunction function, int n) + { + //H_AUTO(Lua_CLuaState_pushCClosure) + nlassert(function); + nlassert(getTop() >= n); + lua_pushcclosure(_State, function, n); + } + + // *************************************************************************** + void CLuaState::push(TLuaWrappedFunction function) + { + //H_AUTO(Lua_CLuaState_push) + struct CForwarder + { + static int callFunc(lua_State *ls) + { + nlassert(ls); + TLuaWrappedFunction func = (TLuaWrappedFunction) lua_touserdata(ls, lua_upvalueindex(1)); + CLuaState *state = (CLuaState *) lua_touserdata(ls, lua_upvalueindex(2)); + nlassert(func); + nlassert(state); + // get real function pointer from the values in the closure + int numResults = 0; + int initialStackSize = state->getTop(); + try + { + // call the actual function + numResults = func(*state); + } + catch(const std::exception &e) + { + // restore stack to its initial size + state->setTop(initialStackSize); + lua_pushstring(ls, e.what()); + // TODO : see if this is safe to call lua error there" ... (it does a long jump) + lua_error(ls); + } + return numResults; + } + }; + pushLightUserData((void *) function); + pushLightUserData((void *) this); + pushCClosure(CForwarder::callFunc, 2); + } + + // *************************************************************************** + // Wrapped function + void CLuaState::registerFunc(const char *name, TLuaWrappedFunction function) + { + //H_AUTO(Lua_CLuaState_registerFunc) + nlassert(function); + CLuaStackChecker lsc(this); + push(name); + push(function); + setTable(LUA_GLOBALSINDEX); + } + + + // *************************************************************************** + bool CLuaState::getTableBooleanValue(const char *name, bool defaultValue) + { + //H_AUTO(Lua_CLuaState_getTableBooleanValue) + nlassert(name); + push(name); + getTable(-2); + if (isNil()) + { + pop(); + return defaultValue; + } + bool result = toBoolean(-1); + pop(); + return result; + } + + // *************************************************************************** + double CLuaState::getTableNumberValue(const char *name, double defaultValue) + { + //H_AUTO(Lua_CLuaState_getTableNumberValue) + nlassert(name); + push(name); + getTable(-2); + if (isNil()) + { + pop(); + return defaultValue; + } + double result = toNumber(-1); + pop(); + return result; + } + + // *************************************************************************** + const char *CLuaState::getTableStringValue(const char *name, const char *defaultValue) + { + //H_AUTO(Lua_CLuaState_getTableStringValue) + nlassert(name); + push(name); + getTable(-2); + if (isNil()) + { + pop(); + return defaultValue; + } + const char *result = toString(-1); + pop(); + return result; + } + + // *************************************************************************** + void CLuaState::getStackContext(string &ret, uint stackLevel) + { + //H_AUTO(Lua_CLuaState_getStackContext) + nlassert(_State); + ret.clear(); + lua_Debug dbg; + if(lua_getstack (_State, stackLevel, &dbg)) + { + if(lua_getinfo(_State, "lS", &dbg)) + { + ret= NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); + } + } + } + + // *************************************************************************** + int CLuaState::pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex /*=LUA_GLOBALSINDEX*/, int errfunc /*= 0*/) + { + //H_AUTO(Lua_CLuaState_pcallByName) + int initialStackSize = getTop(); + nlassert(functionName); + nlassert(isTable(funcTableIndex)); + pushValue(funcTableIndex); + push(functionName); + getTable(-2); + remove(-2); // get rid of the table + nlassert(getTop() >= nargs); // not enough arguments on the stack + // insert function before its arguments + insert(- 1 - nargs); + int result = pcall(nargs, nresults, errfunc); + int currSize = getTop(); + if (result == 0) + { + nlassert(currSize == initialStackSize - nargs + nresults); + } + else + { + // errors, the stack contains a single string + if (errfunc == 0) + { + nlassert(currSize == initialStackSize - nargs + 1); + } + // else if there's an error handler, can't know the size of stack + } + return result; + } + + // *************************************************************************** + void CLuaState::dumpStack() + { + //H_AUTO(Lua_CLuaState_dumpStack) + nlinfo("LUA STACK CONTENT (size = %d)", getTop()); + nlinfo("================="); + CLuaStackChecker lsc(this); + for(int k = 1; k <= getTop(); ++k) + { + pushValue(k); + std::string value = toString(-1) ? toString(-1) : "?"; + nlinfo("Stack entry %d : type = %s, value = %s", k, getTypename(type(-1)), value.c_str()); + pop(); + } + } + + // *************************************************************************** + void CLuaState::getStackAsString(std::string &dest) + { + //H_AUTO(Lua_CLuaState_getStackAsString) + dest = NLMISC::toString("Stack size = %d\n", getTop()); + CLuaStackChecker lsc(this); + for(int k = 1; k <= getTop(); ++k) + { + pushValue(k); + std::string value = toString(-1) ? toString(-1) : "?"; + dest += NLMISC::toString("Stack entry %d : type = %s, value = %s\n", k, getTypename(type(-1)), value.c_str()); + pop(); + } + } + + //================================================================================ + CLuaStackChecker::~CLuaStackChecker() + { + nlassert(_State); + if (!_ExceptionContextCounter) + { + int currSize = _State->getTop(); + if (currSize != _FinalWantedSize) + { + static volatile bool assertWanted = true; + if (assertWanted) + { + nlwarning("Lua stack size error : expected size is %d, current size is %d", _FinalWantedSize, currSize); + _State->dumpStack(); + nlassert(0); + } + } + } + else + { + // this object dtor was called because an exception was thrown, so let the exception + // propagate (the stack must be broken, but because of the exception, not because of code error) + _State->setTop(_FinalWantedSize); + } + } + + // *************************************************************************** + void ELuaWrappedFunctionException::init(CLuaState *ls, const std::string &reason) + { + //H_AUTO(Lua_ELuaWrappedFunctionException_init) + // Print first Lua Stack Context + if(ls) + { + ls->getStackContext(_Reason, 1); // 1 because 0 is the current C function => return 1 for script called + // enclose with cool colors + LuaHelperStuff::formatLuaStackContext(_Reason); + } + + // Append the reason + _Reason+= reason; + } + + // *************************************************************************** + ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState) + { + //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) + init(luaState, ""); + } + + // *************************************************************************** + ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason) + { + //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) + init(luaState, reason); + } + + // *************************************************************************** + ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...) + { + //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) + std::string reason; + NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); + init(luaState, reason); + } + + //================================================================================ + void CLuaState::newTable() + { + //H_AUTO(Lua_CLuaState_newTable) + nlverify( lua_checkstack(_State, 1) ); + lua_newtable(_State); + } + + //================================================================================ + int CLuaState::getGCCount() + { + //H_AUTO(Lua_CLuaState_getGCCount) + return lua_getgccount(_State); + } + + //================================================================================ + int CLuaState::getGCThreshold() + { + //H_AUTO(Lua_CLuaState_getGCThreshold) + #ifdef LUA_NEVRAX_VERSION + return _GCThreshold; + #else + # if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + return lua_gc(_State, LUA_GCCOUNT, 0); + # else + return lua_getgcthreshold(_State); + # endif + #endif + } + + //================================================================================ + void CLuaState::setGCThreshold(int kb) + { + //H_AUTO(Lua_CLuaState_setGCThreshold) + #ifdef LUA_NEVRAX_VERSION + _GCThreshold = kb; + handleGC(); + #else + # if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 + lua_gc(_State, LUA_GCCOLLECT, kb); + # else + lua_setgcthreshold(_State, kb); + # endif + #endif + } + + //================================================================================ + void CLuaState::handleGC() + { + //H_AUTO(Lua_CLuaState_handleGC) + #ifdef LUA_NEVRAX_VERSION + // must handle gc manually with the refcounted version + int gcCount = getGCCount(); + if (gcCount >= _GCThreshold) + { + nlwarning("Triggering GC : memory in use = %d kb, current threshold = %d kb", gcCount, _GCThreshold); + lua_setgcthreshold(_State, 0); + gcCount = getGCCount(); + _GCThreshold = std::max(MinGCThreshold, gcCount * 2); + nlwarning("After GC : memory in use = %d kb, threshold = %d kb", gcCount, _GCThreshold); + } + #endif + } + +} diff --git a/code/ryzom/client/src/interface_v3/lua_loadlib.c b/code/nel/src/gui/lua_loadlib.c similarity index 100% rename from code/ryzom/client/src/interface_v3/lua_loadlib.c rename to code/nel/src/gui/lua_loadlib.c diff --git a/code/ryzom/client/src/debug_client.cpp b/code/ryzom/client/src/debug_client.cpp index 70c138cb6..c12b2d6e0 100644 --- a/code/ryzom/client/src/debug_client.cpp +++ b/code/ryzom/client/src/debug_client.cpp @@ -40,7 +40,8 @@ #include "interface_v3/interface_manager.h" #include "interface_v3/sphrase_manager.h" #include "entities.h" -#include "interface_v3/lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include "character_cl.h" #include "r2/editor.h" #include "r2/dmc/client_edition_module.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 313fc4300..d0445ce74 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -106,7 +106,12 @@ #include "chat_text_manager.h" #include "../npc_icon.h" -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +namespace NLGUI +{ + extern void luaDebuggerMainLoop(); +} +using namespace NLGUI; #include "lua_ihm.h" #include "add_on_manager.h" @@ -1359,7 +1364,6 @@ void CInterfaceManager::updateFrameEvents() pPM->update(); // if there's an external lua debugger, update it - extern void luaDebuggerMainLoop(); luaDebuggerMainLoop(); // handle gc for lua diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 6e93779ab..f8371d8d2 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -105,7 +105,8 @@ #include "inventory_manager.h" #include "task_bar_manager.h" #include "../commands.h" -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include "lua_ihm.h" #include "../r2/editor.h" @@ -4661,7 +4662,7 @@ void CInterfaceParser::initLUA() // create a new LUA environnement nlassert(_LuaState==NULL); - _LuaState= new CLuaState; + _LuaState= new CLuaState( ClientCfg.LoadLuaDebugger ); #ifdef LUA_NEVRAX_VERSION extern ILuaIDEInterface *LuaDebuggerIDE; diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 753432ddc..0c8b51940 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -25,7 +25,8 @@ #include "interface_link.h" #include "nel/misc/smart_ptr.h" #include "game_share/brick_types.h" -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; // *************************************************************************** class CInterfaceElement; diff --git a/code/ryzom/client/src/interface_v3/lua_helper.cpp b/code/ryzom/client/src/interface_v3/lua_helper.cpp deleted file mode 100644 index 0299e66cc..000000000 --- a/code/ryzom/client/src/interface_v3/lua_helper.cpp +++ /dev/null @@ -1,829 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "lua_helper.h" -#include "nel/misc/file.h" -//#include "interface_manager.h" -#include "../client_cfg.h" - -#ifdef LUA_NEVRAX_VERSION - #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger -#endif - - -#include "lua_loadlib.h" - -// to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages -#include -#ifdef assert - #undef assert -#endif - -#ifdef NL_DEBUG - #define assert(x) nlassert(x) -#else - #define assert(x) -#endif - -#include - -using namespace std; -using namespace NLMISC; - -namespace LuaHelperStuff -{ - void formatLuaStackContext( std::string &stackContext ) - { - stackContext = std::string( "@{FC8A}" ).append( stackContext ).append( "@{FC8F} " ); - } - - std::string formatLuaErrorSysInfo( const std::string &error ) - { - return std::string( "@{FC8F}" ).append( error ); - } - - std::string formatLuaErrorNlWarn( const std::string &error ) - { - // Remove color tags (see formatLuaErrorSC()) - std::string ret = error; - strFindReplace( ret, "@{FC8A}", "" ); - strFindReplace( ret, "@{FC8F}", "" ); - return ret; - } -} - -// *************************************************************************** -const char *CLuaState::_NELSmallScriptTableName= "NELSmallScriptTable"; -uint CLuaStackChecker::_ExceptionContextCounter = 0; - -// *************************************************************************** -void CLuaStackChecker::incrementExceptionContextCounter() -{ - //H_AUTO(Lua_CLuaStackChecker_incrementExceptionContextCounter) - ++ _ExceptionContextCounter; -} - -// *************************************************************************** -void CLuaStackChecker::decrementExceptionContextCounter() -{ - //H_AUTO(Lua_CLuaStackChecker_decrementExceptionContextCounter) - nlassert(_ExceptionContextCounter > 0); - -- _ExceptionContextCounter; -} - - -#ifdef LUA_NEVRAX_VERSION - ILuaIDEInterface *LuaDebuggerIDE = NULL; - static bool LuaDebuggerVisible = false; -#endif - -#ifdef NL_OS_WINDOWS - HMODULE LuaDebuggerModule = 0; -#endif - -void luaDebuggerMainLoop() -{ -#ifdef LUA_NEVRAX_VERSION - if (!LuaDebuggerIDE) return; - if (!LuaDebuggerVisible) - { - LuaDebuggerIDE->showDebugger(true); - LuaDebuggerIDE->expandProjectTree(); - LuaDebuggerIDE->sortFiles(); - LuaDebuggerVisible = true; - } - LuaDebuggerIDE->doMainLoop(); -#endif -} - - - -static std::allocator l_stlAlloc; - - -static void l_free_func(void *block, int oldSize) -{ - l_stlAlloc.deallocate((uint8 *) block, oldSize); -} - -static void *l_realloc_func(void *b, int os, int s) -{ - if (os == s) return b; - void *newB = l_stlAlloc.allocate(s); - memcpy(newB, b, std::min(os, s)); - l_free_func(b, os); - return newB; -} - - - -const int MinGCThreshold = 128; // min value at which garbage collector will be triggered (in kilobytes) -// *************************************************************************** -CLuaState::CLuaState() -{ - _State = NULL; - - #ifdef LUA_NEVRAX_VERSION - _GCThreshold = MinGCThreshold; - #endif - - #ifdef NL_OS_WINDOWS - if (ClientCfg.LoadLuaDebugger) - { - #ifndef LUA_NEVRAX_VERSION - static bool warningShown = false; - if (!warningShown) - { - MessageBox (NULL, "Lua debugger was asked, but the static lua library against which the client was linked is too old. Please update to lua-5.0.2_nevrax. Debugging won't be available!", "Lua support", MB_OK); - warningShown = true; - } - #else - nlassert(LuaDebuggerIDE == NULL); // for now, only one debugger supported... - #ifdef NL_DEBUG - LuaDebuggerModule = ::LoadLibrary("lua_ide2_dll_d.dll"); - #else - LuaDebuggerModule = ::LoadLibrary("lua_ide2_dll_r.dll"); - #endif - if (LuaDebuggerModule) - { - TGetLuaIDEInterfaceVersion getVersion = (TGetLuaIDEInterfaceVersion) GetProcAddress(LuaDebuggerModule, "GetLuaIDEInterfaceVersion"); - nlassert(getVersion); - int dllInterfaceVersion = getVersion(); - if (dllInterfaceVersion > LUA_IDE_INTERFACE_VERSION) - { - MessageBox (NULL, "Lua debugger interface is newer than the application. Debugging will be disabled. Please update your client", "Lua support", MB_OK); - } - else if (dllInterfaceVersion < LUA_IDE_INTERFACE_VERSION) - { - MessageBox (NULL, "Lua debugger interface is too old. Lua debugging will be disabled. Please ask for a more recent dll.", "Lua support", MB_OK); - } - else - { - TGetLuaIDEInterface getter = (TGetLuaIDEInterface) GetProcAddress(LuaDebuggerModule, "GetLuaIDEInterface"); - nlassert(getter); - LuaDebuggerIDE = getter(); - LuaDebuggerIDE->prepareDebug("save\\___external_debug.lpr", l_realloc_func, l_free_func, Driver->getDisplay()); - _State = LuaDebuggerIDE->getLuaState(); - } - } - #endif - } - #endif - - if (!_State) - { - #ifdef LUA_NEVRAX_VERSION - _State = lua_open(l_realloc_func, l_free_func); - #else - _State = lua_open(); - #endif - nlassert(_State); - } - - // *** Load base libs - { - CLuaStackChecker lsc(this); -#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 - luaL_openlibs(_State); -#else - luaopen_base (_State); - luaopen_table (_State); - luaopen_io (_State); - luaopen_string (_State); - luaopen_math (_State); - luaopen_debug (_State); -#endif - - // open are buggy???? - clear(); - } - - // *** Register basics - CLuaStackChecker lsc(this); - - // do: LUA_REGISTRYINDEX.(lightuserdata*)this.classes= {} - pushLightUserData((void *) this); - newTable(); - push("classes"); - newTable(); // registry class - setTable(-3); - setTable(LUA_REGISTRYINDEX); - - // add pointer from lua state to this CLuaState object - // do: LUA_REGISTRYINDEX.(lightuserdata*)_State= this - pushLightUserData((void *) _State); // NB : as creator of the state, we make the assumption that - // no one will be using this pointer in the registry (cf. ref manual about registry) - pushLightUserData((void *) this); - setTable(LUA_REGISTRYINDEX); - - // Create the Table that contains Function cache for small script execution - push(_NELSmallScriptTableName); // 1:TableName - newTable(); // 1:TableName 2:table - setTable(LUA_REGISTRYINDEX); // ... - _SmallScriptPool= 0; - - // *** luabind init - luabind::open(_State); -} - - -// *************************************************************************** -CLuaStackRestorer::CLuaStackRestorer(CLuaState *state, int finalSize) : _FinalSize(finalSize), _State(state) -{ -} - -// *************************************************************************** -CLuaStackRestorer::~CLuaStackRestorer() -{ - nlassert(_State); - _State->setTop(_FinalSize); -} - -#ifdef NL_OS_WINDOWS - static int NoOpReportHook( int /* reportType */, char * /* message */, int * /* returnValue */ ) - { - return TRUE; - } -#endif - - -// *************************************************************************** -CLuaState::~CLuaState() -{ - nlassert(_State); - - #ifdef LUA_NEVRAX_VERSION - if (!LuaDebuggerIDE) - #else - if (1) - #endif - { - lua_close(_State); - } - else - { - #ifdef LUA_NEVRAX_VERSION - LuaDebuggerIDE->stopDebug(); // this will also close the lua state - LuaDebuggerIDE = NULL; - LuaDebuggerVisible = false; - #ifdef NL_OS_WINDOWS - nlassert(LuaDebuggerModule) - _CrtSetReportHook(NoOpReportHook); // prevent dump of memory leaks at this point - //::FreeLibrary(LuaDebuggerModule); // don't free the library now (seems that it destroy, the main window, causing - // a crash when the app window is destroyed for real... - // -> FreeLibrary will be called when the application is closed - LuaDebuggerModule = 0; - #endif - #endif - } - - // Clear Small Script Cache - _SmallScriptPool= 0; - _SmallScriptCache.clear(); -} - -// *************************************************************************** -CLuaState *CLuaState::fromStatePointer(lua_State *state) -{ - //H_AUTO(Lua_CLuaState_fromStatePointer) - nlassert(state); - int initialStackSize = lua_gettop(state); - lua_checkstack(state, initialStackSize + 2); - lua_pushlightuserdata(state, (void *) state); - lua_gettable(state, LUA_REGISTRYINDEX); - if (!lua_islightuserdata(state, -1)) - { - lua_pop(state, 1); - return NULL; - } - CLuaState *ls = (CLuaState *) lua_touserdata(state, -1); - lua_pop(state, 1); - nlassert(initialStackSize == lua_gettop(state)); - return ls; -} - -// *************************************************************************** -struct CLuaReader -{ - const std::string *Str; - bool Done; -}; - - - - -void CLuaState::loadScript(const std::string &code, const std::string &dbgSrc) -{ - //H_AUTO(Lua_CLuaState_loadScript) - if (code.empty()) return; - struct CHelper - { - static const char *luaChunkReaderFromString(lua_State * /* L */, void *ud, size_t *sz) - { - CLuaReader *rd = (CLuaReader *) ud; - if (!rd->Done) - { - rd->Done = true; - *sz = rd->Str->size(); - return rd->Str->c_str(); - } - else - { - *sz = 0; - return NULL; - } - } - }; - CLuaReader rd; - rd.Str = &code; - rd.Done = false; - - int result = lua_load(_State, CHelper::luaChunkReaderFromString, (void *) &rd, dbgSrc.c_str()); - if (result !=0) - { - // pop the error code - string err= toString(); - pop(); - // throw error - throw ELuaParseError(err); - } -} - -// *************************************************************************** -void CLuaState::executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet) -{ - //H_AUTO(Lua_CLuaState_executeScriptInternal) - CLuaStackChecker lsc(this, numRet); - - // load the script - loadScript(code, dbgSrc); - - // execute - if (pcall(0, numRet) != 0) - { - // pop the error code - string err= toString(); - pop(); - // throw error - throw ELuaExecuteError(err); - } -} - -// *************************************************************************** -void CLuaState::executeScript(const std::string &code, int numRet) -{ - //H_AUTO(Lua_CLuaState_executeScript) - // run the script, with dbgSrc==script - executeScriptInternal(code, code, numRet); -} - -// *************************************************************************** -bool CLuaState::executeScriptNoThrow(const std::string &code, int numRet) -{ - //H_AUTO(Lua_CLuaState_executeScriptNoThrow) - try - { - executeScript(code, numRet); - } - catch (const ELuaError &e) - { - nlwarning(e.what()); - return false; - } - return true; -} - -// *************************************************************************** -bool CLuaState::executeFile(const std::string &pathName) -{ - //H_AUTO(Lua_CLuaState_executeFile) - - CIFile inputFile; - if(!inputFile.open(pathName)) - return false; - - #ifdef LUA_NEVRAX_VERSION - if (LuaDebuggerIDE) - { - std::string path = NLMISC::CPath::getCurrentPath() + "/" + pathName.c_str(); - path = CPath::standardizeDosPath(path); - LuaDebuggerIDE->addFile(path.c_str()); - } - #endif - - // load the script text - string script; - /* - while(!inputFile.eof()) - { - char tmpBuff[5000]; - inputFile.getline(tmpBuff, 5000); - script+= tmpBuff; - script+= "\n"; - } - */ - script.resize(CFile::getFileSize(pathName)); - inputFile.serialBuffer((uint8 *) &script[0], (uint)script.size()); - - - // execute the script text, with dbgSrc==filename (use @ for lua internal purpose) - executeScriptInternal(script, string("@") + CFile::getFilename(pathName)); - - return true; -} - -// *************************************************************************** -void CLuaState::executeSmallScript(const std::string &script) -{ - //H_AUTO(Lua_CLuaState_executeSmallScript) - if (script.empty()) return; - // *** if the small script has not already been called before, parse it now - TSmallScriptCache::iterator it= _SmallScriptCache.find(script); - if(it==_SmallScriptCache.end()) - { - CLuaStackChecker lsc(this); - - // add it to a function - loadScript(script, script); - - // Assign the method to the NEL table: NELSmallScriptTable[_SmallScriptPool]= function - push(_NELSmallScriptTableName); // 1:function 2:NelTableName - getTable(LUA_REGISTRYINDEX); // 1:function 2:NelTable - insert(-2); // 1:NelTable 2:function - rawSetI(-2, _SmallScriptPool); // 1:NelTable - pop(); - - // bkup in cache map - it= _SmallScriptCache.insert(make_pair(script, _SmallScriptPool)).first; - - // next allocated - _SmallScriptPool++; - } - - // *** Execute the function associated to the script - CLuaStackChecker lsc(this); - push(_NELSmallScriptTableName); // 1:NelTableName - getTable(LUA_REGISTRYINDEX); // 1:NelTable - // get the function at the given index in the "NELSmallScriptTable" table - rawGetI(-1, it->second); // 1:NelTable 2:function - - // execute - if (pcall(0, 0) != 0) - { - // Stack: 1: NelTable 2:errorcode - // pop the error code, and clear stack - string err= toString(); - pop(); // 1:NelTable - pop(); // .... - // throw error - throw ELuaExecuteError(err); - } - else - { - // Stack: 1:NelTable - pop(); // .... - } - -} - -// *************************************************************************** -void CLuaState::registerFunc(const char *name, lua_CFunction function) -{ - //H_AUTO(Lua_CLuaState_registerFunc) - lua_register(_State, name, function); -} - -// *************************************************************************** -void CLuaState::pushCClosure(lua_CFunction function, int n) -{ - //H_AUTO(Lua_CLuaState_pushCClosure) - nlassert(function); - nlassert(getTop() >= n); - lua_pushcclosure(_State, function, n); -} - -// *************************************************************************** -void CLuaState::push(TLuaWrappedFunction function) -{ - //H_AUTO(Lua_CLuaState_push) - struct CForwarder - { - static int callFunc(lua_State *ls) - { - nlassert(ls); - TLuaWrappedFunction func = (TLuaWrappedFunction) lua_touserdata(ls, lua_upvalueindex(1)); - CLuaState *state = (CLuaState *) lua_touserdata(ls, lua_upvalueindex(2)); - nlassert(func); - nlassert(state); - // get real function pointer from the values in the closure - int numResults = 0; - int initialStackSize = state->getTop(); - try - { - // call the actual function - numResults = func(*state); - } - catch(const std::exception &e) - { - // restore stack to its initial size - state->setTop(initialStackSize); - lua_pushstring(ls, e.what()); - // TODO : see if this is safe to call lua error there" ... (it does a long jump) - lua_error(ls); - } - return numResults; - } - }; - pushLightUserData((void *) function); - pushLightUserData((void *) this); - pushCClosure(CForwarder::callFunc, 2); -} - -// *************************************************************************** -// Wrapped function -void CLuaState::registerFunc(const char *name, TLuaWrappedFunction function) -{ - //H_AUTO(Lua_CLuaState_registerFunc) - nlassert(function); - CLuaStackChecker lsc(this); - push(name); - push(function); - setTable(LUA_GLOBALSINDEX); -} - - -// *************************************************************************** -bool CLuaState::getTableBooleanValue(const char *name, bool defaultValue) -{ - //H_AUTO(Lua_CLuaState_getTableBooleanValue) - nlassert(name); - push(name); - getTable(-2); - if (isNil()) - { - pop(); - return defaultValue; - } - bool result = toBoolean(-1); - pop(); - return result; -} - -// *************************************************************************** -double CLuaState::getTableNumberValue(const char *name, double defaultValue) -{ - //H_AUTO(Lua_CLuaState_getTableNumberValue) - nlassert(name); - push(name); - getTable(-2); - if (isNil()) - { - pop(); - return defaultValue; - } - double result = toNumber(-1); - pop(); - return result; -} - -// *************************************************************************** -const char *CLuaState::getTableStringValue(const char *name, const char *defaultValue) -{ - //H_AUTO(Lua_CLuaState_getTableStringValue) - nlassert(name); - push(name); - getTable(-2); - if (isNil()) - { - pop(); - return defaultValue; - } - const char *result = toString(-1); - pop(); - return result; -} - -// *************************************************************************** -void CLuaState::getStackContext(string &ret, uint stackLevel) -{ - //H_AUTO(Lua_CLuaState_getStackContext) - nlassert(_State); - ret.clear(); - lua_Debug dbg; - if(lua_getstack (_State, stackLevel, &dbg)) - { - if(lua_getinfo(_State, "lS", &dbg)) - { - ret= NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); - } - } -} - -// *************************************************************************** -int CLuaState::pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex /*=LUA_GLOBALSINDEX*/, int errfunc /*= 0*/) -{ - //H_AUTO(Lua_CLuaState_pcallByName) - int initialStackSize = getTop(); - nlassert(functionName); - nlassert(isTable(funcTableIndex)); - pushValue(funcTableIndex); - push(functionName); - getTable(-2); - remove(-2); // get rid of the table - nlassert(getTop() >= nargs); // not enough arguments on the stack - // insert function before its arguments - insert(- 1 - nargs); - int result = pcall(nargs, nresults, errfunc); - int currSize = getTop(); - if (result == 0) - { - nlassert(currSize == initialStackSize - nargs + nresults); - } - else - { - // errors, the stack contains a single string - if (errfunc == 0) - { - nlassert(currSize == initialStackSize - nargs + 1); - } - // else if there's an error handler, can't know the size of stack - } - return result; -} - -// *************************************************************************** -void CLuaState::dumpStack() -{ - //H_AUTO(Lua_CLuaState_dumpStack) - nlinfo("LUA STACK CONTENT (size = %d)", getTop()); - nlinfo("================="); - CLuaStackChecker lsc(this); - for(int k = 1; k <= getTop(); ++k) - { - pushValue(k); - std::string value = toString(-1) ? toString(-1) : "?"; - nlinfo("Stack entry %d : type = %s, value = %s", k, getTypename(type(-1)), value.c_str()); - pop(); - } -} - -// *************************************************************************** -void CLuaState::getStackAsString(std::string &dest) -{ - //H_AUTO(Lua_CLuaState_getStackAsString) - dest = NLMISC::toString("Stack size = %d\n", getTop()); - CLuaStackChecker lsc(this); - for(int k = 1; k <= getTop(); ++k) - { - pushValue(k); - std::string value = toString(-1) ? toString(-1) : "?"; - dest += NLMISC::toString("Stack entry %d : type = %s, value = %s\n", k, getTypename(type(-1)), value.c_str()); - pop(); - } -} - -//================================================================================ -CLuaStackChecker::~CLuaStackChecker() -{ - nlassert(_State); - if (!_ExceptionContextCounter) - { - int currSize = _State->getTop(); - if (currSize != _FinalWantedSize) - { - static volatile bool assertWanted = true; - if (assertWanted) - { - nlwarning("Lua stack size error : expected size is %d, current size is %d", _FinalWantedSize, currSize); - _State->dumpStack(); - nlassert(0); - } - } - } - else - { - // this object dtor was called because an exception was thrown, so let the exception - // propagate (the stack must be broken, but because of the exception, not because of code error) - _State->setTop(_FinalWantedSize); - } -} - -// *************************************************************************** -void ELuaWrappedFunctionException::init(CLuaState *ls, const std::string &reason) -{ - //H_AUTO(Lua_ELuaWrappedFunctionException_init) - // Print first Lua Stack Context - if(ls) - { - ls->getStackContext(_Reason, 1); // 1 because 0 is the current C function => return 1 for script called - // enclose with cool colors - LuaHelperStuff::formatLuaStackContext(_Reason); - } - - // Append the reason - _Reason+= reason; -} - -// *************************************************************************** -ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState) -{ - //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) - init(luaState, ""); -} - -// *************************************************************************** -ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason) -{ - //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) - init(luaState, reason); -} - -// *************************************************************************** -ELuaWrappedFunctionException::ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...) -{ - //H_AUTO(Lua_ELuaWrappedFunctionException_ELuaWrappedFunctionException) - std::string reason; - NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); - init(luaState, reason); -} - -//================================================================================ -void CLuaState::newTable() -{ - //H_AUTO(Lua_CLuaState_newTable) - nlverify( lua_checkstack(_State, 1) ); - lua_newtable(_State); -} - -//================================================================================ -int CLuaState::getGCCount() -{ - //H_AUTO(Lua_CLuaState_getGCCount) - return lua_getgccount(_State); -} - -//================================================================================ -int CLuaState::getGCThreshold() -{ - //H_AUTO(Lua_CLuaState_getGCThreshold) -#ifdef LUA_NEVRAX_VERSION - return _GCThreshold; -#else -# if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 - return lua_gc(_State, LUA_GCCOUNT, 0); -# else - return lua_getgcthreshold(_State); -# endif -#endif -} - -//================================================================================ -void CLuaState::setGCThreshold(int kb) -{ - //H_AUTO(Lua_CLuaState_setGCThreshold) -#ifdef LUA_NEVRAX_VERSION - _GCThreshold = kb; - handleGC(); -#else -# if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 - lua_gc(_State, LUA_GCCOLLECT, kb); -# else - lua_setgcthreshold(_State, kb); -# endif -#endif -} - -//================================================================================ -void CLuaState::handleGC() -{ - //H_AUTO(Lua_CLuaState_handleGC) - #ifdef LUA_NEVRAX_VERSION - // must handle gc manually with the refcounted version - int gcCount = getGCCount(); - if (gcCount >= _GCThreshold) - { - nlwarning("Triggering GC : memory in use = %d kb, current threshold = %d kb", gcCount, _GCThreshold); - lua_setgcthreshold(_State, 0); - gcCount = getGCCount(); - _GCThreshold = std::max(MinGCThreshold, gcCount * 2); - nlwarning("After GC : memory in use = %d kb, threshold = %d kb", gcCount, _GCThreshold); - } - #endif -} - - diff --git a/code/ryzom/client/src/interface_v3/lua_helper.h b/code/ryzom/client/src/interface_v3/lua_helper.h deleted file mode 100644 index 71a3efe17..000000000 --- a/code/ryzom/client/src/interface_v3/lua_helper.h +++ /dev/null @@ -1,385 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_LUA_HELPER_H -#define RZ_LUA_HELPER_H - - -#include "nel/misc/types_nl.h" -#include "nel/misc/smart_ptr.h" - - -extern "C" -{ - #include "lua_loadlib.h" -} - -class CLuaState; - -namespace LuaHelperStuff -{ - void formatLuaStackContext( std::string &stackContext ); - std::string formatLuaErrorSysInfo( const std::string &error ); - std::string formatLuaErrorNlWarn( const std::string &error ); -} - - -// *************************************************************************** -/** Helper class to see if a stack is restored at its initial size (or with n return results). - * Check that the stack size remains unchanged when the object goes out of scope - */ -class CLuaStackChecker -{ -public: - CLuaStackChecker(CLuaState *state, int numWantedResults = 0); - ~CLuaStackChecker(); - /** Increment exception context counter - * When an exception is thrown, lua stack checker do any assert bu will - * rather restore the lua stack at its original size, and will - * let the exception a chance to propagate - */ - static void incrementExceptionContextCounter(); - static void decrementExceptionContextCounter(); - -private: - CLuaState *_State; - int _FinalWantedSize; - static uint _ExceptionContextCounter; - -}; - -// ************************************************************************** -/** Helper class to restore the lua stack to the desired size when this object goes out of scope - */ -class CLuaStackRestorer -{ -public: - CLuaStackRestorer(CLuaState *state, int finalSize); - ~CLuaStackRestorer(); -private: - int _FinalSize; - CLuaState *_State; -}; - -//////////////// -// EXCEPTIONS // -//////////////// - -class ELuaError : public NLMISC::Exception -{ -public: - ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); } - virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); } - ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); } - // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} -}; - -// A parse error occured -class ELuaParseError : public ELuaError -{ -public: - ELuaParseError() {} - ELuaParseError(const std::string &reason) : ELuaError(reason) {} - virtual ~ELuaParseError() throw() { } - // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());} -}; - -/** Exception thrown when something went wrong inside a wrapped function called by lua - */ -class ELuaWrappedFunctionException : public ELuaError -{ -public: - ELuaWrappedFunctionException(CLuaState *luaState); - ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason); - ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...); - virtual ~ELuaWrappedFunctionException() throw() { } - virtual const char *what() const throw() {return _Reason.c_str();} -protected: - void init(CLuaState *ls, const std::string &reason); -protected: - std::string _Reason; -}; - -// A execution error occured -class ELuaExecuteError : public ELuaError -{ -public: - ELuaExecuteError() {} - ELuaExecuteError(const std::string &reason) : ELuaError(reason) {} - virtual ~ELuaExecuteError() throw() { } - // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} -}; - -// A bad cast occured when using lua_checkcast -class ELuaBadCast : public ELuaError -{ -public: - ELuaBadCast() {} - ELuaBadCast(const std::string &reason) : ELuaError(reason) {} - // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaBadCast: %s", what());} -}; - -// Error when trying to indexate an object that is not a table -class ELuaNotATable : public ELuaError -{ -public: - ELuaNotATable() {} - ELuaNotATable(const std::string &reason) : ELuaError(reason) {} - // what(), plus append the Reason - virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaNotATable: %s", what());} -}; - - -// *************************************************************************** -// a function to be used with a CLuaState instance -typedef int (* TLuaWrappedFunction) (CLuaState &ls); - - -// *************************************************************************** -/** C++ version of a lua state - */ -class CLuaState : public NLMISC::CRefCount -{ -public: - typedef NLMISC::CRefPtr TRefPtr; - - // Create a new environement - CLuaState(); - ~CLuaState(); - - - /// \name Registering - // @{ - // register a wrapped function - void registerFunc(const char *name, TLuaWrappedFunction function); - // @} - - - /// \name Script execution - // @{ - - /** Parse a script and push as a function in top of the LUA stack - * \throw ELuaParseError - * \param dbgSrc is a string for debug. Should be a filename (preceded with '@'), or a short script. - */ - void loadScript(const std::string &code, const std::string &dbgSrc); - - /** Execute a script from a string, possibly throwing an exception if there's a parse error - * \throw ELuaParseError, ELuaExecuteError - */ - void executeScript(const std::string &code, int numRet = 0); - - /** Execute a script from a string. If an errors occurs it is printed in the log - * \return true if script execution was successful - */ - bool executeScriptNoThrow(const std::string &code, int numRet = 0); - - /** Load a Script from a File (maybe in a BNP), and execute it - * \return false if file not found - * \throw ELuaParseError, ELuaExecuteError - */ - bool executeFile(const std::string &pathName); - - /** execute a very Small Script (a function call for instance) - * It is different from doString() in such there is a cache (where the key is the script itself) - * so that the second time this script is executed, there is no parsing - * Note: I experienced optim with about 10 times faster than a executeScript() on a simple "a= a+1;" script - * \throw ELuaParseError, ELuaExecuteError - */ - void executeSmallScript(const std::string &script); - - // @} - - - /// \name Stack Manipulation - // @{ - // stack manipulation (indices start at 1) - void setTop(int index); // set new size of stack - void clear() { setTop(0); } - int getTop(); - bool empty() { return getTop() == 0; } - void pushValue(int index); // copie nth element of stack to the top of the stack - void remove(int index); // remove nth element of stack - void insert(int index); // insert last element of the stack before the given position - void replace(int index); // replace nth element of the stack with the top of the stack - void pop(int numElem = 1); // remove n elements from the top of the stack - // test the type of an element in the stack - // return one of the following values : - // LUA_TNIL - // LUA_TNUMBER - // LUA_TBOOLEAN - // LUA_TSTRING - // LUA_TTABLE - // LUA_TFUNCTION - // LUA_TUSERDATA - // LUA_TTHREAD - // LUA_TLIGHTUSERDATA - int type(int index = -1); - const char *getTypename(int type); - bool isNil(int index = -1); - bool isBoolean(int index = -1); - bool isNumber(int index = -1); - bool isString(int index = -1); - bool isTable(int index = -1); - bool isFunction(int index = -1); - bool isCFunction(int index = -1); - bool isUserData(int index = -1); - bool isLightUserData(int index = -1); - // converting then getting a value from the stack - bool toBoolean(int index = -1); - lua_Number toNumber(int index = -1); - const char *toString(int index = -1); - void toString(int index, std::string &str); // convert to a std::string, with a NULL check. - size_t strlen(int index = -1); - lua_CFunction toCFunction(int index = -1); - void *toUserData(int index = -1); - const void *toPointer(int index = -1); - /** Helper functions : get value of the wanted type in the top table after conversion - * A default value is used if the stack entry is NULL. - * If conversion fails then an exception is thrown (with optional msg) - */ - bool getTableBooleanValue(const char *name, bool defaultValue= false); - double getTableNumberValue(const char *name, double defaultValue= 0); - const char *getTableStringValue(const char *name, const char *defaultValue= NULL); - // pushing value onto the stack - void push(bool value); - void push(lua_Number value); - void push(const char *str); - void push(const char *str, int length); - void push(const std::string &str); - void pushNil(); - void push(lua_CFunction f); - void push(TLuaWrappedFunction function); - void pushLightUserData(void *); // push a light user data (use newUserData to push a full userdata) - // metatables - bool getMetaTable(int index = -1); - bool setMetaTable(int index = -1); // set the metatable at top of stack to the object at 'index' (usually -2), then pop the metatable - // even if asignment failed - // comparison - bool equal(int index1, int index2); - bool rawEqual(int index1, int index2); - bool lessThan(int index1, int index2); - // concatenation of the n element at the top of the stack (using lua semantic) - void concat(int numElem); - // tables - void newTable(); // create a new table at top of the stack - void getTable(int index); // get value from a table at index 'index' (key is at top) - void rawGet(int index); - void setTable(int index); // set (key, value) from top of the stack into the given table - // both key and value are poped - void rawSet(int index); - bool next(int index); // table traversal - // UserData - void *newUserData(uint size); - // seting value by int index in a table - void rawSetI(int index, int n); - void rawGetI(int index, int n); - /** Calling functions (it's up to the caller to clear the results) - * The function should have been pushed on the stack - */ - void call(int nargs, int nresults); - int pcall(int nargs, int nresults, int errfunc = 0); - /** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex' - * the behaviour is the same than with call of pcall. - */ - int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex = LUA_GLOBALSINDEX, int errfunc = 0); - - // push a C closure (pop n element from the stack and associate with the function) - void pushCClosure(lua_CFunction function, int n); - // @} - - - /// \name Misc - // @{ - /** Retrieve pointer to a CLuaState environment from its lua_State pointer, or NULL - * if there no such environment - */ - static CLuaState *fromStatePointer(lua_State *state); - // Get state pointer. The state should not be closed (this object has ownership) - lua_State *getStatePointer() const {return _State;} - // check that an index is valid when accessing the stack - // an assertion is raised if the index is not valid - void checkIndex(int index); - - // registering C function to use with a lua state pointer - void registerFunc(const char *name, lua_CFunction function); - - // Garbage collector - int getGCCount(); // get memory in use in KB - int getGCThreshold(); // get max memory in KB - void setGCThreshold(int kb); // set max memory in KB (no-op with ref-counted version) - - // handle garbage collector for ref-counted version of lua (no-op with standard version, in which case gc handling is automatic) - void handleGC(); - - /** For Debug: get the Stack context of execution (filename / line) - * \param stackLevel: get the context of execution of the given stackLevel. - * 0 for the current function - * 1 for the function that called 0 - * 2 .... - * NB: if called from a C function called from LUA, remember that stackLevel 0 is the current function. - * Hence if you want to know what LUA context called you, pass stackLevel=1! - * \param ret string cleared if any error, else filled with formated FileName / LineNumber - */ - void getStackContext(std::string &ret, uint stackLevel); - // @} - - // for debug : dump the current content of the stack (no recursion) - void dumpStack(); - static void dumpStack(lua_State *ls); - void getStackAsString(std::string &dest); - - -private: - lua_State *_State; - - #ifdef LUA_NEVRAX_VERSION - int _GCThreshold; // if refcounted gc is used, then garbage collector is handled manually - #endif - // Small Script Cache - uint _SmallScriptPool; - typedef std::map TSmallScriptCache; - TSmallScriptCache _SmallScriptCache; - static const char * _NELSmallScriptTableName; - -private: - // this object isn't intended to be copied - CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); } - CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; } - - void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0); - -}; - - -// Access to lua function -// one should not include lua.h directly because if a debugger is present, lua -// function pointer will be taken from a dynamic library. - - - -//============================================================================================= -// include implementation -#define RZ_INCLUDE_LUA_HELPER_INLINE - #include "lua_helper_inline.h" -#undef RZ_INCLUDE_LUA_HELPER_INLINE - - -#endif diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index ebb374bd9..61b1b4d2c 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -16,7 +16,8 @@ #include "stdpch.h" -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.h b/code/ryzom/client/src/interface_v3/lua_ihm.h index 12d8b5459..2826c1ac7 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm.h @@ -18,8 +18,8 @@ #define NL_LUA_IHM_H #include "nel/misc/types_nl.h" -#include "lua_helper.h" - +#include "nel/gui/lua_helper.h" +using namespace NLGUI; namespace NLMISC diff --git a/code/ryzom/client/src/interface_v3/lua_object.cpp b/code/ryzom/client/src/interface_v3/lua_object.cpp index eb5f76c4f..d2d4da1e1 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.cpp +++ b/code/ryzom/client/src/interface_v3/lua_object.cpp @@ -17,7 +17,8 @@ #include "stdpch.h" #include "lua_object.h" #include "lua_ihm.h" -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; // #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/lua_object.h b/code/ryzom/client/src/interface_v3/lua_object.h index e4cfee3d9..28d2e73b7 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.h +++ b/code/ryzom/client/src/interface_v3/lua_object.h @@ -21,7 +21,8 @@ #include "nel/misc/smart_ptr.h" #include "nel/misc/rgba.h" // -#include "lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; diff --git a/code/ryzom/client/src/interface_v3/reflect.h b/code/ryzom/client/src/interface_v3/reflect.h index dfc4af5fa..5dbdbe554 100644 --- a/code/ryzom/client/src/interface_v3/reflect.h +++ b/code/ryzom/client/src/interface_v3/reflect.h @@ -26,7 +26,10 @@ #include class CReflectable; -class CLuaState; +namespace NLGUI +{ + class CLuaState; +} struct CClassInfo; /** A property of a reflectable object diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp index 69223a2ae..2d15b18f6 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -48,7 +48,8 @@ #include -#include "../../interface_v3/lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include "../../interface_v3/lua_ihm.h" #include "../../entities.h" diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.h b/code/ryzom/client/src/r2/dmc/com_lua_module.h index 91c532fda..24bbfb9fd 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.h +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.h @@ -22,7 +22,7 @@ extern "C" { - #include "../../interface_v3/lua_loadlib.h" + #include "nel/gui/lua_loadlib.h" } diff --git a/code/ryzom/client/src/r2/dmc/dmc.h b/code/ryzom/client/src/r2/dmc/dmc.h index 24d2893de..fa9235586 100644 --- a/code/ryzom/client/src/r2/dmc/dmc.h +++ b/code/ryzom/client/src/r2/dmc/dmc.h @@ -27,7 +27,7 @@ extern "C" { - #include "../../interface_v3/lua_loadlib.h" + #include "nel/gui/lua_loadlib.h" } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 859b89520..9daa5db70 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -46,7 +46,8 @@ #include "editor.h" // -#include "../interface_v3/lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include "../interface_v3/group_tree.h" #include "../interface_v3/interface_manager.h" #include "../contextual_cursor.h" diff --git a/code/ryzom/client/src/r2/instance.h b/code/ryzom/client/src/r2/instance.h index d10c37532..8825c6946 100644 --- a/code/ryzom/client/src/r2/instance.h +++ b/code/ryzom/client/src/r2/instance.h @@ -27,7 +27,10 @@ #include "lua_event_forwarder.h" class CEntityCL; +namespace NLGUI +{ class CLuaState; +} namespace R2 { diff --git a/code/ryzom/client/src/r2/lua_event_forwarder.h b/code/ryzom/client/src/r2/lua_event_forwarder.h index 4ad8139e1..bd16cd57c 100644 --- a/code/ryzom/client/src/r2/lua_event_forwarder.h +++ b/code/ryzom/client/src/r2/lua_event_forwarder.h @@ -17,7 +17,10 @@ #ifndef R2_LUA_EVENT_FORWARDER_H #define R2_LUA_EVENT_FORWARDER_H -class CLuaState; +namespace NLGUI +{ + class CLuaState; +} class CLuaString; namespace R2 @@ -53,7 +56,7 @@ public: const std::string &targetAttrName, sint32 targetAttrIndex); protected: // for derivers - virtual CLuaState *getLua() = 0; + virtual NLGUI::CLuaState *getLua() = 0; virtual void executeHandler(const CLuaString &eventName, int numArgs) = 0; }; diff --git a/code/ryzom/client/src/session_browser_impl.h b/code/ryzom/client/src/session_browser_impl.h index d22d6a1cf..cd56cb482 100644 --- a/code/ryzom/client/src/session_browser_impl.h +++ b/code/ryzom/client/src/session_browser_impl.h @@ -20,7 +20,8 @@ #include "session_browser.h" #include "game_share/ring_session_manager_itf.h" -#include "interface_v3/lua_helper.h" +#include "nel/gui/lua_helper.h" +using namespace NLGUI; #include "far_tp.h" class CSessionBrowserImpl : public CSessionBrowser, From ed3d565dda6f76a9100f5d88494708a884ec74c1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 20 May 2012 00:59:31 +0200 Subject: [PATCH 026/339] CLuaString will no longer depend on CInterfaceManager. --- .../client/src/interface_v3/lua_object.cpp | 49 ------------------- .../client/src/interface_v3/lua_object.h | 25 +++++----- code/ryzom/client/src/r2/displayer_lua.cpp | 4 +- code/ryzom/client/src/r2/instance.cpp | 2 +- 4 files changed, 15 insertions(+), 65 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_object.cpp b/code/ryzom/client/src/interface_v3/lua_object.cpp index d2d4da1e1..17b703457 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.cpp +++ b/code/ryzom/client/src/interface_v3/lua_object.cpp @@ -653,52 +653,3 @@ void CLuaEnumeration::next() } } - - -CLuaString::CLuaString(const char *value) -{ - _LuaState = NULL; - nlassert(value); - _Ptr = NULL; - _Str = value; -} - - -inline CLuaState &CLuaString::getLua() const -{ - if( _LuaState ) - return *_LuaState; - CInterfaceManager *im = CInterfaceManager::getInstance(); - nlassert(im); - _LuaState = im->getLuaState(); - nlassert(_LuaState); - return *_LuaState; -} - -inline void CLuaString::build() const -{ - if (_Ptr &&_LuaState) return; - CLuaStackChecker lsc(&getLua()); - getLua().push(_Str); - _Ptr = getLua().toString(); - _InLua.pop(getLua()); -} - -const char *CLuaString::getPtr() const -{ - build(); - return _Ptr; -} - - -void CLuaString::pushOnStack() const -{ - build(); - _InLua.push(); -} - - - - - - diff --git a/code/ryzom/client/src/interface_v3/lua_object.h b/code/ryzom/client/src/interface_v3/lua_object.h index 28d2e73b7..7e2d19370 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.h +++ b/code/ryzom/client/src/interface_v3/lua_object.h @@ -246,42 +246,41 @@ private: class CLuaString { public: - explicit CLuaString(const char *value = ""); - const char *getPtr() const; - void pushOnStack() const; - operator const char *() const { return getPtr(); } + explicit CLuaString(const char *value = "") + { + nlassert( value != NULL ); + _Str = value; + } + const std::string& getStr() const{ return _Str; } private: - const char *_Str; - mutable const char *_Ptr; + std::string _Str; mutable CLuaState::TRefPtr _LuaState; // ref ptr so that statics get rebuilt on lua restart mutable CLuaObject _InLua; - CLuaState &getLua() const; - void build() const; }; inline bool operator==(const char* lh, const CLuaString& rh) { - return std::string(lh) == std::string(rh.getPtr()); + return std::string(lh) == rh.getStr(); } inline bool operator==( const CLuaString& lh, const CLuaString& rh) { - return std::string(lh.getPtr()) == std::string(rh.getPtr()); + return lh.getStr() == rh.getStr(); } inline bool operator==(const CLuaString& lh, const char* rh) { - return std::string(rh) == std::string(lh.getPtr()); + return std::string(rh) == lh.getStr(); } inline bool operator==( const CLuaString& lh, const std::string& rh) { - return std::string(lh.getPtr()) == rh; + return lh.getStr() == rh; } inline bool operator==(const std::string& lh, const CLuaString& rh) { - return lh == std::string(rh.getPtr()); + return lh == rh.getStr(); } class CLuaHashMapTraits diff --git a/code/ryzom/client/src/r2/displayer_lua.cpp b/code/ryzom/client/src/r2/displayer_lua.cpp index cb823c033..540e1ea1f 100644 --- a/code/ryzom/client/src/r2/displayer_lua.cpp +++ b/code/ryzom/client/src/r2/displayer_lua.cpp @@ -76,10 +76,10 @@ void CDisplayerLua::CToLua::executeHandler(const CLuaString &eventName, int numA CLuaStackRestorer lsr(&ls, ls.getTop() - numArgs); // if (!_LuaTable.isValid()) return; // init failed - if (_LuaTable[eventName].isNil()) return; // event not handled + if (_LuaTable[ eventName.getStr().c_str() ].isNil()) return; // event not handled static volatile bool dumpStackWanted = false; if (dumpStackWanted) ls.dumpStack(); - _LuaTable[eventName].push(); + _LuaTable[ eventName.getStr().c_str() ].push(); if (dumpStackWanted) ls.dumpStack(); // put method before its args ls.insert(- numArgs - 1); diff --git a/code/ryzom/client/src/r2/instance.cpp b/code/ryzom/client/src/r2/instance.cpp index d30d2bd9b..c4287928a 100644 --- a/code/ryzom/client/src/r2/instance.cpp +++ b/code/ryzom/client/src/r2/instance.cpp @@ -620,7 +620,7 @@ void CInstance::CToLua::executeHandler(const CLuaString &name, int numArgs) // static volatile bool dumpStackWanted = false; if (dumpStackWanted) ls.dumpStack(); - _Class[name].push(); + _Class[ name.getStr().c_str() ].push(); if (ls.isNil(-1)) return; // not handled if (dumpStackWanted) ls.dumpStack(); // put method before its args From 0d0fe51a0d95a1d57d9e955dcd912431f1d5c0e9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 21 May 2012 03:35:05 +0200 Subject: [PATCH 027/339] Some more Lua refactoring, started to break CLuaIHM into 2 parts. CLuaIHM will be generic, CLuaIHMRyzom will contain the Ryzom only code. --- code/ryzom/client/src/commands.cpp | 3 +- .../src/interface_v3/interface_manager.cpp | 3 +- .../src/interface_v3/interface_parser.cpp | 2 + .../ryzom/client/src/interface_v3/lua_ihm.cpp | 3108 +--------------- code/ryzom/client/src/interface_v3/lua_ihm.h | 243 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 3271 +++++++++++++++++ .../client/src/interface_v3/lua_ihm_ryzom.h | 257 ++ .../client/src/interface_v3/lua_object.cpp | 7 +- .../client/src/interface_v3/view_text.cpp | 7 +- code/ryzom/client/src/r2/displayer_lua.cpp | 5 +- .../client/src/r2/dmc/com_lua_module.cpp | 3 +- code/ryzom/client/src/r2/editor.cpp | 13 +- code/ryzom/client/src/r2/instance.cpp | 3 +- .../client/src/r2/object_factory_client.cpp | 3 +- 14 files changed, 3578 insertions(+), 3350 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp create mode 100644 code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 6c804e93d..433bd2d49 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -94,6 +94,7 @@ #include "connection.h" #include "interface_v3/lua_object.h" #include "interface_v3/lua_ihm.h" +#include "interface_v3/lua_ihm_ryzom.h" #include "init.h" #include "interface_v3/people_interraction.h" #include "far_tp.h" @@ -5157,7 +5158,7 @@ NLMISC_COMMAND(luaObject, "Dump the content of a lua object", "
[max } catch(const ELuaError &e) { - CLuaIHM::debugInfo(e.what()); + CLuaIHMRyzom::debugInfo(e.what()); return false; } luaState->pushValue(LUA_GLOBALSINDEX); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index d0445ce74..e162df279 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -113,6 +113,7 @@ namespace NLGUI } using namespace NLGUI; #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "add_on_manager.h" @@ -5750,7 +5751,7 @@ bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smal // Hamster: quick fix on AJM code but sscanf is still awfull if (sscanf(msg.c_str(), "%s: %s.lua:%d:",exceptionName, filename, &line) == 3) // NB: test not exact here, but should work in 99,9 % of cases { - msg = CLuaIHM::createGotoFileButtonTag(filename, line) + msg; + msg = CLuaIHMRyzom::createGotoFileButtonTag(filename, line) + msg; nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str()); displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg)); } diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index f8371d8d2..16232de19 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -108,6 +108,7 @@ #include "nel/gui/lua_helper.h" using namespace NLGUI; #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "../r2/editor.h" #ifdef LUA_NEVRAX_VERSION @@ -4671,6 +4672,7 @@ void CInterfaceParser::initLUA() // register LUA methods CLuaIHM::registerAll(*_LuaState); + CLuaIHMRyzom::RegisterRyzomFunctions( *_LuaState ); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index 61b1b4d2c..c6cf16b37 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -218,6 +218,20 @@ const CReflectedProperty *CReflectableLuaRef::getProp(const char *luaStringPtr) return prop; } +// *************************************************************************** +static sint32 getTargetSlotNr() +{ + const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; + CInterfaceManager *im = CInterfaceManager::getInstance(); + CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + if (!node) return 0; + if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) + { + return 0; + } + return node->getValue32(); +} + // *************************************************************************** bool CLuaIHM::pop(CLuaState &ls, NLMISC::CRGBA &dest) { @@ -324,44 +338,6 @@ void CLuaIHM::push(CLuaState &ls, const ucstring &value) // *************************************************************************** -// *************************************************************************** -class CHandlerLUA : public IActionHandler -{ -public: - void execute (CCtrlBase *pCaller, const std::string &sParams) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - - // For getUI() LUA function, push the UI caller - if(pCaller) - _UICallerStack.push_back(pCaller); - - // execute a small script. NB: use a small script here because - // most often action handlers are called from xml files => lot of redundant script - pIM->executeLuaScript(sParams, true); - - // pop UI caller - if(pCaller) - _UICallerStack.pop_back(); - } - - // get the top of stack Caller to this LUA script - static CCtrlBase *getUICaller(); - -private: - static std::deque > _UICallerStack; -}; -REGISTER_ACTION_HANDLER( CHandlerLUA, "lua"); -std::deque > CHandlerLUA::_UICallerStack; - -CCtrlBase *CHandlerLUA::getUICaller() -{ - if(_UICallerStack.empty()) - return NULL; - else - return _UICallerStack.back(); -} - // *************************************************************************** // Allow also to call script from expression @@ -1125,63 +1101,6 @@ int CLuaIHM::luaUINext(CLuaState &ls) return 0; } -int CLuaIHM::getClientCfgVar(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getClientCfgVar) - const char *funcName = "getClientCfgVar"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::string varName = ls.toString(1); - - CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(varName); - if (!v) return 0; - if(v->size()==1) - { - switch(v->Type) - { - case CConfigFile::CVar::T_REAL: - ls.push((double) v->asDouble()); - return 1; - break; - case CConfigFile::CVar::T_STRING: - ls.push(v->asString()); - return 1; - break; - default: // handle both T_INT && T_BOOL - case CConfigFile::CVar::T_INT: - ls.push((double) v->asInt()); - return 1; - break; - } - } - else - { - ls.newTable(); - CLuaObject result(ls); - uint count = 0; - for(uint i = 0; iStrValues.size(); i++) - { - result.setValue(toString(count).c_str(), v->StrValues[i]); - count++; - } - for(uint i = 0; iIntValues.size(); i++) - { - result.setValue(toString(count).c_str(), (double)v->IntValues[i]); - count++; - } - for(uint i = 0; iRealValues.size(); i++) - { - result.setValue(toString(count).c_str(), (double)v->RealValues[i]); - count++; - } - result.push(); - return 1; - } - - return 0; -} - - // *************************************************************************** int CLuaIHM::luaClientCfgIndex(CLuaState &ls) { @@ -1307,165 +1226,17 @@ void CLuaIHM::registerIHM(CLuaState &ls) // *** Register Functions - // Through std LUA API - ls.registerFunc("setOnDraw", setOnDraw); - ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); - ls.registerFunc("resetCaptureKeyboard", resetCaptureKeyboard); - ls.registerFunc("validMessageBox", validMessageBox); - ls.registerFunc("setTopWindow", setTopWindow); - ls.registerFunc("concatUCString", concatUCString); - ls.registerFunc("concatString", concatString); - ls.registerFunc("tableToString", tableToString); - ls.registerFunc("addOnDbChange", addOnDbChange); - ls.registerFunc("removeOnDbChange", removeOnDbChange); - ls.registerFunc("getUICaller", getUICaller); - ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder); - ls.registerFunc("getUI", getUI); - ls.registerFunc("getIndexInDB", getIndexInDB); - ls.registerFunc("getUIId", getUIId); - ls.registerFunc("createGroupInstance", createGroupInstance); - ls.registerFunc("createRootGroupInstance", createRootGroupInstance); - ls.registerFunc("createUIElement", createUIElement); - ls.registerFunc("launchContextMenuInGame", launchContextMenuInGame); - ls.registerFunc("parseInterfaceFromString", parseInterfaceFromString); - ls.registerFunc("updateAllLocalisedElements", updateAllLocalisedElements); - ls.registerFunc("runAH", runAH); - ls.registerFunc("runExpr", runExpr); - ls.registerFunc("runFct", runFct); - ls.registerFunc("runCommand", runCommand); - ls.registerFunc("formatUI", formatUI); - ls.registerFunc("formatDB", formatDB); - ls.registerFunc("deleteUI", deleteUI); - ls.registerFunc("deleteReflectable", deleteReflectable); - ls.registerFunc("dumpUI", dumpUI); - ls.registerFunc("setKeyboardContext", setKeyboardContext); - ls.registerFunc("breakPoint", breakPoint); - ls.registerFunc("getWindowSize", getWindowSize); - ls.registerFunc("setTextFormatTaged", setTextFormatTaged); - ls.registerFunc("initEmotesMenu", initEmotesMenu); - ls.registerFunc("isUCString", isUCString); - ls.registerFunc("hideAllWindows", hideAllWindows); - ls.registerFunc("hideAllNonSavableWindows", hideAllNonSavableWindows); - ls.registerFunc("getDesktopIndex", getDesktopIndex); - ls.registerFunc("setLuaBreakPoint", setLuaBreakPoint); - ls.registerFunc("getMainPageURL", getMainPageURL); - ls.registerFunc("getCharSlot", getCharSlot); - ls.registerFunc("getPathContent", getPathContent); - ls.registerFunc("getServerSeason", getServerSeason); - ls.registerFunc("computeCurrSeason", computeCurrSeason); - ls.registerFunc("getAutoSeason", getAutoSeason); - ls.registerFunc("getTextureSize", getTextureSize); - ls.registerFunc("enableModalWindow", enableModalWindow); - ls.registerFunc("disableModalWindow", disableModalWindow); - ls.registerFunc("getPlayerPos", getPlayerPos); - ls.registerFunc("getPlayerFront", getPlayerFront); - ls.registerFunc("getPlayerDirection", getPlayerDirection); - ls.registerFunc("getPlayerGender", getPlayerGender); - ls.registerFunc("getPlayerName", getPlayerName); - ls.registerFunc("getPlayerTitleRaw", getPlayerTitleRaw); - ls.registerFunc("getPlayerTitle", getPlayerTitle); - ls.registerFunc("getTargetPos", getTargetPos); - ls.registerFunc("getTargetFront", getTargetFront); - ls.registerFunc("getTargetDirection", getTargetDirection); - ls.registerFunc("getTargetGender", getTargetGender); - ls.registerFunc("getTargetName", getTargetName); - ls.registerFunc("getTargetTitleRaw", getTargetTitleRaw); - ls.registerFunc("getTargetTitle", getTargetTitle); - ls.registerFunc("addSearchPathUser", addSearchPathUser); - ls.registerFunc("displaySystemInfo", displaySystemInfo); - ls.registerFunc("disableContextHelpForControl", disableContextHelpForControl); - ls.registerFunc("disableContextHelp", disableContextHelp); - ls.registerFunc("setWeatherValue", setWeatherValue); - ls.registerFunc("getWeatherValue", getWeatherValue); - ls.registerFunc("getCompleteIslands", getCompleteIslands); - ls.registerFunc("displayBubble", displayBubble); - ls.registerFunc("getIslandId", getIslandId); - ls.registerFunc("getClientCfgVar", getClientCfgVar); - ls.registerFunc("isPlayerFreeTrial", isPlayerFreeTrial); - ls.registerFunc("isPlayerNewbie", isPlayerNewbie); - ls.registerFunc("isInRingMode", isInRingMode); - ls.registerFunc("getUserRace", getUserRace); - ls.registerFunc("getSheet2idx", getSheet2idx); - ls.registerFunc("getTargetSlot", getTargetSlot); - ls.registerFunc("getSlotDataSetId", getSlotDataSetId); // Through LUABind API lua_State *L= ls.getStatePointer(); luabind::module(L) [ - LUABIND_FUNC(addDbProp), - LUABIND_FUNC(getDbProp), - LUABIND_FUNC(setDbProp), - LUABIND_FUNC(delDbProp), - LUABIND_FUNC(debugInfo), - LUABIND_FUNC(rawDebugInfo), - LUABIND_FUNC(dumpCallStack), - LUABIND_FUNC(getDefine), - LUABIND_FUNC(setContextHelpText), - luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox), - luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), - luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), - luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), - luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), luabind::def("findReplaceAll", (std::string(*)(const std::string &, const std::string &, const std::string &)) &findReplaceAll), luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const ucstring &)) &findReplaceAll), luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const std::string &)) &findReplaceAll), luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const std::string &)) &findReplaceAll), luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const ucstring &)) &findReplaceAll), - LUABIND_FUNC(getPlayerSelectedSlot), - LUABIND_FUNC(isInGame), - LUABIND_FUNC(pauseBGDownloader), - LUABIND_FUNC(unpauseBGDownloader), - LUABIND_FUNC(requestBGDownloaderPriority), - LUABIND_FUNC(getBGDownloaderPriority), - LUABIND_FUNC(getPatchLastErrorMessage), - LUABIND_FUNC(isPlayerSlotNewbieLand), - LUABIND_FUNC(getSkillIdFromName), - LUABIND_FUNC(getSkillLocalizedName), - LUABIND_FUNC(getMaxSkillValue), - LUABIND_FUNC(getBaseSkillValueMaxChildren), - LUABIND_FUNC(getMagicResistChance), - LUABIND_FUNC(getDodgeParryChance), - LUABIND_FUNC(browseNpcWebPage), - LUABIND_FUNC(clearHtmlUndoRedo), - LUABIND_FUNC(getDynString), - LUABIND_FUNC(isDynStringAvailable), - LUABIND_FUNC(isFullyPatched), - LUABIND_FUNC(getSheetType), - LUABIND_FUNC(getSheetName), - LUABIND_FUNC(getFameIndex), - LUABIND_FUNC(getFameName), - LUABIND_FUNC(getFameDBIndex), - LUABIND_FUNC(getFirstTribeFameIndex), - LUABIND_FUNC(getNbTribeFameIndex), - LUABIND_FUNC(getClientCfg), - LUABIND_FUNC(fileExists), - LUABIND_FUNC(sendMsgToServer), - LUABIND_FUNC(sendMsgToServerPvpTag), - LUABIND_FUNC(isGuildQuitAvailable), - LUABIND_FUNC(sortGuildMembers), - LUABIND_FUNC(getNbGuildMembers), - LUABIND_FUNC(getGuildMemberName), - LUABIND_FUNC(getGuildMemberGrade), - LUABIND_FUNC(isR2Player), - LUABIND_FUNC(getR2PlayerRace), - LUABIND_FUNC(isR2PlayerMale), - LUABIND_FUNC(getCharacterSheetSkel), - LUABIND_FUNC(getSheetId), - LUABIND_FUNC(getCharacterSheetRegionForce), - LUABIND_FUNC(getCharacterSheetRegionLevel), - LUABIND_FUNC(replacePvpEffectParam), - LUABIND_FUNC(getRegionByAlias), - LUABIND_FUNC(tell), - LUABIND_FUNC(isRingAccessPointInReach), - LUABIND_FUNC(updateTooltipCoords), - LUABIND_FUNC(secondsSince1970ToHour), - LUABIND_FUNC(isCtrlKeyDown), - LUABIND_FUNC(encodeURLUnicodeParam), #if !FINAL_VERSION LUABIND_FUNC(openDoc), @@ -1473,29 +1244,9 @@ void CLuaIHM::registerIHM(CLuaState &ls) #endif luabind::def("fileLookup", CMiscFunctions::fileLookup), - luabind::def("shellExecute", CMiscFunctions::shellExecute), - - LUABIND_FUNC(getPlayerLevel), - LUABIND_FUNC(getPlayerVpa), - LUABIND_FUNC(getPlayerVpb), - LUABIND_FUNC(getPlayerVpc), - LUABIND_FUNC(getTargetLevel), - LUABIND_FUNC(getTargetForceRegion), - LUABIND_FUNC(getTargetLevelForce), - LUABIND_FUNC(getTargetSheet), - LUABIND_FUNC(getTargetVpa), - LUABIND_FUNC(getTargetVpb), - LUABIND_FUNC(getTargetVpc), - LUABIND_FUNC(isTargetNPC), - LUABIND_FUNC(isTargetPlayer), // return 'true' if the target is an npc - LUABIND_FUNC(isTargetUser), - LUABIND_FUNC(isPlayerInPVPMode), - LUABIND_FUNC(isTargetInPVPMode) + luabind::def("shellExecute", CMiscFunctions::shellExecute) ]; - LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString); - LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString); - // inside i18n table luabind::module(L, "i18n") [ @@ -1677,281 +1428,6 @@ uint32 CLuaIHM::getLocalTime() return (uint32) NLMISC::CTime::getLocalTime(); } -// *************************************************************************** -sint32 CLuaIHM::getDbProp(const std::string &dbProp) -{ - //H_AUTO(Lua_CLuaIHM_getDbProp) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); - if(node) - return node->getValue32(); - else - { - debugInfo(toString("getDbProp(): '%s' dbProp Not found", dbProp.c_str())); - return 0; - } -} - -void CLuaIHM::setDbProp(const std::string &dbProp, sint32 value) -{ - //H_AUTO(Lua_CLuaIHM_setDbProp) - // Do not allow Write on SERVER: or LOCAL: - static const std::string dbServer= "SERVER:"; - static const std::string dbLocal= "LOCAL:"; - static const std::string dbLocalR2= "LOCAL:R2"; - if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || - (0==dbProp.compare(0, dbLocal.size(), dbLocal)) - ) - { - if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) - { - nlstop; - throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); - } - } - - // Write to the DB if found - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); - - if(node) - node->setValue32(value); - else - debugInfo(toString("setDbProp(): '%s' dbProp Not found", dbProp.c_str())); -} - -void CLuaIHM::delDbProp(const string &dbProp) -{ - //H_AUTO(Lua_CLuaIHM_setDbProp) - // Do not allow Write on SERVER: or LOCAL: - static const string dbServer= "SERVER:"; - static const string dbLocal= "LOCAL:"; - static const string dbLocalR2= "LOCAL:R2"; - if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || - (0==dbProp.compare(0, dbLocal.size(), dbLocal)) - ) - { - if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) - { - nlstop; - throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); - } - } - - // Write to the DB if found - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->delDbProp(dbProp); -} - -void CLuaIHM::addDbProp(const std::string &dbProp, sint32 value) -{ - //H_AUTO(Lua_CLuaIHM_setDbProp) - // Do not allow Write on SERVER: or LOCAL: - static const std::string dbServer= "SERVER:"; - static const std::string dbLocal= "LOCAL:"; - static const std::string dbLocalR2= "LOCAL:R2"; - if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || - (0==dbProp.compare(0, dbLocal.size(), dbLocal)) - ) - { - if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) - { - nlstop; - throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); - } - } - - // Write to the DB if found - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, true); - if(node) - node->setValue32(value); -} - -// *************************************************************************** -void CLuaIHM::debugInfo(const std::string &cstDbg) -{ - //H_AUTO(Lua_CLuaIHM_debugInfo) - if(ClientCfg.DisplayLuaDebugInfo) - { - std::string dbg = cstDbg; - if (ClientCfg.LuaDebugInfoGotoButtonEnabled) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); - lua_Debug luaDbg; - if(lua_getstack (ls, 1, &luaDbg)) - { - if(lua_getinfo(ls, "lS", &luaDbg)) - { - // add a command button to jump to the wanted file - dbg = createGotoFileButtonTag(luaDbg.short_src, luaDbg.currentline) + dbg; - } - } - } - rawDebugInfo(dbg); - } -} - -// *************************************************************************** -void CLuaIHM::rawDebugInfo(const std::string &dbg) -{ - //H_AUTO(Lua_CLuaIHM_rawDebugInfo) - if(ClientCfg.DisplayLuaDebugInfo) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - if (!dbg.empty() && dbg[0] == '@') - { - // if color is already given use the message as it - NLMISC::InfoLog->displayRawNL(dbg.c_str()); - } - else - { - NLMISC::InfoLog->displayRawNL(LuaHelperStuff::formatLuaErrorSysInfo(dbg).c_str()); - } - #ifdef LUA_NEVRAX_VERSION - if (LuaDebuggerIDE) - { - LuaDebuggerIDE->debugInfo(dbg.c_str()); - } - #endif - pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); - } -} - -// *************************************************************************** -int CLuaIHM::displaySystemInfo(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_displaySystemInfo) - const char *funcName = "displaySystemInfo"; - checkArgCount(ls, funcName, 2); - checkArgTypeUCString(ls, funcName, 1); - checkArgType(ls, funcName, 2, LUA_TSTRING); - ucstring msg; - nlverify(getUCStringOnStack(ls, 1, msg)); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->displaySystemInfo(msg, ls.toString(2)); - return 0; -} - -// *************************************************************************** -int CLuaIHM::setWeatherValue(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setWeatherValue) - const char *funcName = "setWeatherValue"; - checkArgMin(ls, funcName, 1); - checkArgMax(ls, funcName, 2); - checkArgType(ls, funcName, 1, LUA_TBOOLEAN); -// bool autoWeather = ls.toBoolean(1); - ClientCfg.ManualWeatherSetup = !ls.toBoolean(1); - if (ls.getTop() == 2) - { - checkArgType(ls, funcName, 2, LUA_TNUMBER); - ManualWeatherValue = (float) ls.toNumber(2); - } - return 0; -} - -// *************************************************************************** -int CLuaIHM::getWeatherValue(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getWeatherValue) - const char *funcName = "getWeatherValue"; - checkArgCount(ls, funcName, 0); - uint64 currDay = RT.getRyzomDay(); - float currHour = (float) RT.getRyzomTime(); - ls.push(::getBlendedWeather(currDay, currHour, *WeatherFunctionParams, ContinentMngr.cur()->WeatherFunction)); - return 1; -} - -void CLuaIHM::dumpCallStack(int startStackLevel) -{ - //H_AUTO(Lua_CLuaIHM_dumpCallStack) - if(ClientCfg.DisplayLuaDebugInfo) - { - lua_Debug dbg; - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); - int stackLevel = startStackLevel; - rawDebugInfo("Call stack : "); - rawDebugInfo("-------------"); - while (lua_getstack (ls, stackLevel, &dbg)) - { - if(lua_getinfo(ls, "lS", &dbg)) - { - std::string result = createGotoFileButtonTag(dbg.short_src, dbg.currentline) + NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); - rawDebugInfo(result); - } - ++ stackLevel; - } - } -} - -// *************************************************************************** -void CLuaIHM::getCallStackAsString(int startStackLevel /*=0*/,std::string &result) -{ - //H_AUTO(Lua_CLuaIHM_getCallStackAsString) - result.clear(); - lua_Debug dbg; - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); - int stackLevel = startStackLevel; - result += "Call stack : \n"; - result += "-------------"; - while (lua_getstack (ls, stackLevel, &dbg)) - { - if(lua_getinfo(ls, "lS", &dbg)) - { - result += NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); - } - ++ stackLevel; - } -} - -// *************************************************************************** -std::string CLuaIHM::createGotoFileButtonTag(const char *fileName, uint line) -{ - //H_AUTO(Lua_CLuaIHM_createGotoFileButtonTag) - if (ClientCfg.LuaDebugInfoGotoButtonEnabled) - { - // TODO nico : put this in the interface - // add a command button to jump to the wanted file - return toString("/$$%s|%s|lua|%s('%s', %d)$$/", - ClientCfg.LuaDebugInfoGotoButtonTemplate.c_str(), - ClientCfg.LuaDebugInfoGotoButtonCaption.c_str(), - ClientCfg.LuaDebugInfoGotoButtonFunction.c_str(), - fileName, - line - ); - } - return ""; -} - -// *************************************************************************** -std::string CLuaIHM::getDefine(const std::string &def) -{ - //H_AUTO(Lua_CLuaIHM_getDefine) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - if(ClientCfg.DisplayLuaDebugInfo && !pIM->isDefineExist(def)) - debugInfo(toString("getDefine(): '%s' not found", def.c_str())); - return pIM->getDefine(def); -} - - - -// *************************************************************************** -static sint32 getTargetSlotNr() -{ - const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); - if (!node) return 0; - if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) - { - return 0; - } - return node->getValue32(); -} // *************************************************************************** static CEntityCL *getTargetEntity() @@ -1973,356 +1449,6 @@ static CEntityCL *getSlotEntity(uint slot) return EntitiesMngr.entity(slot); } -// *************************************************************************** -sint32 CLuaIHM::getPlayerLevel() -{ - if (!UserEntity) return -1; - CSkillManager *pSM= CSkillManager::getInstance(); - uint32 maxskill = pSM->getBestSkillValue(SKILLS::SC); - maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SF)); - maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SH)); - maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SM)); - return sint32(maxskill); -} - -// *************************************************************************** -sint64 CLuaIHM::getPlayerVpa() -{ - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - return prop; -} - -// *************************************************************************** -sint64 CLuaIHM::getPlayerVpb() -{ - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return prop; -} - -// *************************************************************************** -sint64 CLuaIHM::getPlayerVpc() -{ - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - return prop; -} - -// *************************************************************************** -sint32 CLuaIHM::getTargetLevel() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return -1; - if ( target->isPlayer() ) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); - return pDbPlayerLevel ? pDbPlayerLevel->getValue32() : -1; - } - else - { - CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); - if(!pCS) return -1; - // only display the consider if the target is attackable #523 - if(!pCS->Attackable) return -1; - if(!target->properties().attackable()) return -1; - return sint32(pCS->Level); - } - return -1; -} - -// *************************************************************************** -ucstring CLuaIHM::getTargetSheet() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return ucstring(); - - return target->sheetId().toString(); -} - -// *************************************************************************** -sint64 CLuaIHM::getTargetVpa() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); - - return prop; -} - -// *************************************************************************** -sint64 CLuaIHM::getTargetVpb() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - - return prop; -} - -// *************************************************************************** -sint64 CLuaIHM::getTargetVpc() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); - - return prop; -} - -// *************************************************************************** -sint32 CLuaIHM::getTargetForceRegion() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return -1; - if ( target->isPlayer() ) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); - if (!pDbPlayerLevel) return -1; - sint nLevel = pDbPlayerLevel->getValue32(); - if ( nLevel < 250 ) - { - return (sint32) ((nLevel < 20) ? 1 : (nLevel / 50) + 2); - } - else - { - return 8; - } - } - else - { - CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); - return pCS ? (sint32) pCS->RegionForce : -1; - } - return 0; -} - -// *************************************************************************** -sint32 CLuaIHM::getTargetLevelForce() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return -1; - if ( target->isPlayer() ) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); - if (!pDbPlayerLevel) return -1; - sint nLevel = pDbPlayerLevel->getValue32(); - if ( nLevel < 250 ) - { - return (sint32) (((nLevel % 50) * 5 / 50) + 1); - } - else - { - return 6; - } - } - else - { - CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); - return pCS ? (sint32) pCS->ForceLevel : -1; - } - return 0; -} - -// *************************************************************************** -bool CLuaIHM::isTargetNPC() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return false; - return target->isNPC(); -} - -// *************************************************************************** -bool CLuaIHM::isTargetPlayer() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return false; - return target->isPlayer(); -} - - -// *************************************************************************** -bool CLuaIHM::isTargetUser() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return false; - return target->isUser(); -} - -// *************************************************************************** -bool CLuaIHM::isPlayerInPVPMode() -{ - if (!UserEntity) return false; - return (UserEntity->getPvpMode() & PVP_MODE::PvpFaction || UserEntity->getPvpMode() & PVP_MODE::PvpFactionFlagged || UserEntity->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; -} - -// *************************************************************************** -bool CLuaIHM::isTargetInPVPMode() -{ - CEntityCL *target = getTargetEntity(); - if (!target) return false; - return (target->getPvpMode() & PVP_MODE::PvpFaction || target->getPvpMode() & PVP_MODE::PvpFactionFlagged || target->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; -} - -// *************************************************************************** -void CLuaIHM::pauseBGDownloader() -{ - ::pauseBGDownloader(); -} - -// *************************************************************************** -void CLuaIHM::unpauseBGDownloader() -{ - ::unpauseBGDownloader(); -} - -// *************************************************************************** -void CLuaIHM::requestBGDownloaderPriority(uint priority) -{ - if (priority >= BGDownloader::ThreadPriority_Count) - { - throw NLMISC::Exception("requestBGDownloaderPriority() : invalid priority"); - } - CBGDownloaderAccess::getInstance().requestDownloadThreadPriority((BGDownloader::TThreadPriority) priority, false); -} - -// *************************************************************************** -sint CLuaIHM::getBGDownloaderPriority() -{ - return CBGDownloaderAccess::getInstance().getDownloadThreadPriority(); -} - -// *************************************************************************** -ucstring CLuaIHM::getPatchLastErrorMessage() -{ - if (isBGDownloadEnabled()) - { - return CBGDownloaderAccess::getInstance().getLastErrorMessage(); - } - else - { - CPatchManager *pPM = CPatchManager::getInstance(); - return pPM->getLastErrorMessage(); - } -} - -// *************************************************************************** -bool CLuaIHM::isInGame() -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - return pIM->isInGame(); -} - -// *************************************************************************** -uint32 CLuaIHM::getPlayerSelectedSlot() -{ - return (uint32) PlayerSelectedSlot; -} - -// *************************************************************************** -bool CLuaIHM::isPlayerSlotNewbieLand(uint32 slot) -{ - if (slot > CharacterSummaries.size()) - { - throw ELuaIHMException("isPlayerSlotNewbieLand(): Invalid slot %d", (int) slot); - } - return CharacterSummaries[slot].InNewbieland; -} - - -// *************************************************************************** -void CLuaIHM::messageBox(const ucstring &text) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBox(text); -} - -// *************************************************************************** -void CLuaIHM::messageBox(const ucstring &text, const std::string &masterGroup) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup); -} - -// *************************************************************************** -void CLuaIHM::messageBox(const ucstring &text, const std::string &masterGroup, int caseMode) -{ - if (caseMode < 0 || caseMode >= CaseCount) - { - throw ELuaIHMException("messageBox: case mode value is invalid."); - } - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); -} - -// *************************************************************************** -void CLuaIHM::messageBox(const std::string &text) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - static volatile bool dumpCallStack = false; - if (dumpCallStack) - { - CLuaIHM::dumpCallStack(0); - } - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBox(text); -} - -// *************************************************************************** -void CLuaIHM::messageBoxWithHelp(const ucstring &text) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text); -} - -// *************************************************************************** -void CLuaIHM::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup); -} - -// *************************************************************************** -void CLuaIHM::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) -{ - if (caseMode < 0 || caseMode >= CaseCount) - { - throw ELuaIHMException("messageBoxWithHelp: case mode value is invalid."); - } - //H_AUTO(Lua_CLuaIHM_messageBox) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text, masterGroup, "" ,"", (TCaseMode) caseMode); -} - -// *************************************************************************** -void CLuaIHM::messageBoxWithHelp(const std::string &text) -{ - //H_AUTO(Lua_CLuaIHM_messageBox) - static volatile bool dumpCallStack = false; - if (dumpCallStack) - { - CLuaIHM::dumpCallStack(0); - } - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->messageBoxWithHelp(text); -} - -// *************************************************************************** -void CLuaIHM::setContextHelpText(const ucstring &text) -{ - //H_AUTO(Lua_CLuaIHM_setContextHelpText) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->setContextHelpText(text); -} - // *************************************************************************** std::string CLuaIHM::findReplaceAll(const std::string &str, const std::string &search, const std::string &replace) { @@ -2362,547 +1488,6 @@ ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, return findReplaceAll(str, ucstring(search), ucstring(replace)); } -// *************************************************************************** -int CLuaIHM::getUICaller(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getUICaller) - CLuaStackChecker lsc(&ls, 1); - - // params: none. - // return: CInterfaceElement* (nil if error) - CInterfaceElement *pIE= CHandlerLUA::getUICaller(); - if(!pIE) - { - ls.pushNil(); - debugInfo(toString("getUICaller(): No UICaller found. return Nil")); - } - else - { - pushUIOnStack(ls, pIE); - } - return 1; -} - -// *************************************************************************** -int CLuaIHM::getCurrentWindowUnder(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getCurrentWindowUnder) - CLuaStackChecker lsc(&ls, 1); - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *pIE= im->getCurrentWindowUnder(); - if(!pIE) - { - ls.pushNil(); - debugInfo(toString("getCurrentWindowUnder(): No UICaller found. return Nil")); - } - else - { - pushUIOnStack(ls, pIE); - } - return 1; -} -int CLuaIHM::getUI(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getUI) - // params: "ui:interface:...". - // return: CInterfaceElement* (nil if error) - const char *funcName = "getUI"; - check(ls, ls.getTop() == 1 || ls.getTop() == 2, funcName); - checkArgType(ls, funcName, 1, LUA_TSTRING); - bool verbose = true; - if (ls.getTop() > 1) - { - checkArgType(ls, funcName, 2, LUA_TBOOLEAN); - verbose = ls.toBoolean(2); - } - - // get the string - std::string eltStr; - ls.toString(1, eltStr); - - // return the element - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceElement *pIE= pIM->getElementFromId(eltStr); - if(!pIE) - { - ls.pushNil(); - if (verbose) - { - std::string stackContext; - ls.getStackContext(stackContext, 1); - debugInfo(toString("%s : getUI(): '%s' not found", stackContext.c_str(), eltStr.c_str())); - } - } - else - { - pushUIOnStack(ls, pIE); - } - return 1; -} - -// *************************************************************************** -int CLuaIHM::getUIId(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getUIId) - CLuaStackChecker lsc(&ls, 1); - - // params: CInterfaceElement* - // return: "ui:interface:...". (empty if error) - checkArgCount(ls, "getUIId", 1); - check(ls, isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - - // convert to id - if(pIE) - ls.push(pIE->getId()); - else - ls.push(""); - - return 1; -} - -// *************************************************************************** -int CLuaIHM::getIndexInDB(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getIndexInDB) - CLuaStackChecker lsc(&ls, 1); - - // params: CDBCtrlSheet* - // return: index in DB of a dbctrlsheet (empty if error) - checkArgCount(ls, "getIndexInDB", 1); - check(ls, isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - CDBCtrlSheet *pCS= dynamic_cast(pIE); - - // get the index in db - if(pCS) - ls.push((double)pCS->getIndexInDB()); - else - ls.push(0.0); - - return 1; -} - -// *************************************************************************** -int CLuaIHM::createGroupInstance(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_createGroupInstance) - const char *funcName = "createGroupInstance"; - CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); - std::vector > templateParams; - CLuaObject params; - params.pop(ls); - ENUM_LUA_TABLE(params, it) - { - if (!it.nextKey().isString()) - { - nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); - continue; - } - if (!it.nextValue().isString()) - { - nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); - continue; - } - templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *result = im->createGroupInstance(ls.toString(1), ls.toString(2), templateParams); - if (!result) - { - ls.pushNil(); - } - else - { - CLuaIHM::pushUIOnStack(ls, result); - } - return 1; -} - -// *************************************************************************** -int CLuaIHM::createRootGroupInstance(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_createGroupInstance) - const char *funcName = "createRootGroupInstance"; - CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); - std::vector > templateParams; - CLuaObject params; - params.pop(ls); - ENUM_LUA_TABLE(params, it) - { - if (!it.nextKey().isString()) - { - nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); - continue; - } - if (!it.nextValue().isString()) - { - nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); - continue; - } - templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *result = im->createGroupInstance(ls.toString(1), "ui:interface:"+string(ls.toString(2)), templateParams); - if (!result) - { - ls.pushNil(); - } - else - { - result->setId("ui:interface:"+string(ls.toString(2))); - result->updateCoords(); - im->addWindowToMasterGroup("ui:interface", result); - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); - result->setParent(pRoot); - if (pRoot) - pRoot->addGroup(result); - result->setActive(true); - CLuaIHM::pushUIOnStack(ls, result); - } - return 1; -} - -// *************************************************************************** -int CLuaIHM::createUIElement(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_createUIElement) - const char *funcName = "addUIElement"; - CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); - std::vector > templateParams; - CLuaObject params; - params.pop(ls); - ENUM_LUA_TABLE(params, it) - { - if (!it.nextKey().isString()) - { - nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); - continue; - } - if (!it.nextValue().isString()) - { - nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); - continue; - } - templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *result = im->createUIElement(ls.toString(1), ls.toString(2), templateParams); - if (!result) - { - ls.pushNil(); - } - else - { - CLuaIHM::pushUIOnStack(ls, result); - } - return 1; -} - - -// *************************************************************************** -int CLuaIHM::displayBubble(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_createUIElement) - const char *funcName = "displayBubble"; - CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); - std::vector strs; - std::vector links; - CLuaObject params; - params.pop(ls); - ENUM_LUA_TABLE(params, it) - { - if (!it.nextKey().isString()) - { - nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); - continue; - } - if (!it.nextValue().isString()) - { - nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); - continue; - } - links.push_back(it.nextValue().toString()); - strs.push_back(it.nextKey().toString()); - } - - InSceneBubbleManager.webIgChatOpen((uint32)ls.toNumber(1), ls.toString(2), strs, links); - - return 1; -} - - -// *************************************************************************** -int CLuaIHM::getCompleteIslands(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getCompleteIslands) - const char *funcName = "getCompleteIslands"; - CLuaIHM::checkArgCount(ls, funcName, 0); - - ls.newTable(); - CLuaObject result(ls); - - // load entryPoints - CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); - const CScenarioEntryPoints::TCompleteIslands& islands = scenarioEntryPoints.getCompleteIslands(); - - CScenarioEntryPoints::TCompleteIslands::const_iterator island(islands.begin()), lastIsland(islands.end()); - for( ; island != lastIsland ; ++island) - { - ls.newTable(); - CLuaObject islandTable(ls); - islandTable.setValue("continent", island->Continent); - islandTable.setValue("xmin", (double)island->XMin); - islandTable.setValue("ymin", (double)island->YMin); - islandTable.setValue("xmax", (double)island->XMax); - islandTable.setValue("ymax", (double)island->YMax); - - ls.newTable(); - CLuaObject entrypointsTable(ls); - - for(uint e=0; eEntryPoints.size(); e++) - { - const CScenarioEntryPoints::CShortEntryPoint & entryPoint = island->EntryPoints[e]; - ls.newTable(); - CLuaObject entrypointTable(ls); - entrypointTable.setValue("x", (double)entryPoint.X); - entrypointTable.setValue("y", (double)entryPoint.Y); - - entrypointsTable.setValue(entryPoint.Location, entrypointTable); - } - islandTable.setValue("entrypoints", entrypointsTable); - - result.setValue(island->Island, islandTable); - } - - result.push(); - - return 1; -} - -// *************************************************************************** -int CLuaIHM::getIslandId(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getIslandId) - const char *funcName = "getIslandId"; - CLuaIHM::checkArgCount(ls, funcName, 1); - check(ls, ls.isString(1), "getIslandId() requires a string in param 1"); - - - CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); - uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1)); - ls.push((double)id); - - return 1; -} - -// *************************************************************************** -int CLuaIHM::launchContextMenuInGame(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_launchContextMenuInGame) - CLuaStackChecker lsc(&ls); - checkArgCount(ls, "launchContextMenuInGame", 1); - check(ls, ls.isString(1), "launchContextMenuInGame() requires a string in param 1"); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->launchContextMenuInGame(ls.toString(1)); - return 0; -} - -// *************************************************************************** -int CLuaIHM::parseInterfaceFromString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_parseInterfaceFromString) - CLuaStackChecker lsc(&ls, 1); - checkArgCount(ls, "parseInterfaceFromString", 1); - check(ls, ls.isString(1), "parseInterfaceFromString() requires a string in param 1"); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - std::vector script(1); - script[0] = ls.toString(1); - ls.push(pIM->parseInterface(script, true, false)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::updateAllLocalisedElements(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_updateAllLocalisedElements) - TTime startTime = CTime::getLocalTime(); - // - CLuaStackChecker lsc(&ls); - checkArgCount(ls, "updateAllLocalisedElements", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->updateAllLocalisedElements(); - // - TTime endTime = CTime::getLocalTime(); - if (ClientCfg.R2EDVerboseParseTime) - { - nlinfo("%.2f seconds for 'updateAllLocalisedElements'", (endTime - startTime) / 1000.f); - } - return 0; -} - -// *************************************************************************** -int CLuaIHM::setCaptureKeyboard(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) - const char *funcName = "setCaptureKeyboard"; - checkArgCount(ls, funcName, 1); - checkArgTypeUIElement(ls, funcName, 1); - CCtrlBase *ctrl = dynamic_cast(getUIOnStack(ls, 1)); - if (!ctrl) - { - fails(ls, "%s waits a ui control as arg 1", funcName); - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setCaptureKeyboard(ctrl); - return 0; -} - -// *************************************************************************** -int CLuaIHM::resetCaptureKeyboard(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_resetCaptureKeyboard) - const char *funcName = "resetCaptureKeyboard"; - checkArgCount(ls, funcName, 0); - CInterfaceManager *im = CInterfaceManager::getInstance(); - im->resetCaptureKeyboard(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::setOnDraw(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setOnDraw) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "script". - // return: none - checkArgCount(ls, "setOnDraw", 2); - check(ls, isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); - check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - std::string script; - ls.toString(2, script); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("setOnDraw(): '%s' is not a group", pIE->getId().c_str()); - // Set the script to be executed at each draw - group->setLuaScriptOnDraw(script); - - return 0; -} - -// *************************************************************************** -int CLuaIHM::addOnDbChange(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_addOnDbChange) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "dblist", "script". - // return: none - checkArgCount(ls, "addOnDbChange", 3); - check(ls, isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); - check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); - check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - std::string dbList, script; - ls.toString(2, dbList); - ls.toString(3, script); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("addOnDbChange(): '%s' is not a group", pIE->getId().c_str()); - // Set the script to be executed when the given DB change - group->addLuaScriptOnDBChange(dbList, script); - - return 0; -} - - -// *************************************************************************** -int CLuaIHM::removeOnDbChange(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_removeOnDbChange) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "dbList" - // return: none - checkArgCount(ls, "removeOnDbChange", 2); - check(ls, isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); - check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - std::string dbList; - ls.toString(2, dbList); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("removeOnDbChange(): '%s' is not a group", pIE->getId().c_str()); - // Remove the script to be executed when the given DB change - group->removeLuaScriptOnDBChange(dbList); - - return 0; -} - - -// *************************************************************************** -int CLuaIHM::runAH(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runAH) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement *, "ah", "params". - // return: none - checkArgCount(ls, "runAH", 3); - check(ls, isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); - check(ls, ls.isString(2), "runAH() requires a string in param 2"); - check(ls, ls.isString(3), "runAH() requires a string in param 3"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - std::string ah, params; - ls.toString(2, ah); - ls.toString(3, params); - - // run AH - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - // The element must be ctrl (or NULL) - CCtrlBase *ctrl= NULL; - if(pIE) - { - ctrl= dynamic_cast(pIE); - if(!ctrl) - throw ELuaIHMException("runAH(): '%s' is not a ctrl", pIE->getId().c_str()); - } - pIM->runActionHandler(ah, ctrl, params); - - return 0; -} // *************************************************************************** int CLuaIHM::runExprAndPushResult(CLuaState &ls, const std::string &expr) @@ -2976,294 +1561,6 @@ int CLuaIHM::runExprAndPushResult(CLuaState &ls, const std::string &expr) return 1; } -// *************************************************************************** -int CLuaIHM::runExpr(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runExpr) - CLuaStackChecker lsc(&ls, 1); - - // params: "expr". - // return: any of: nil, bool, string, number, RGBA, UCString - checkArgCount(ls, "runExpr", 1); - check(ls, ls.isString(1), "runExpr() requires a string in param 1"); - - // retrieve args - std::string expr; - ls.toString(1, expr); - - // run expression and push result - return runExprAndPushResult(ls, expr); -} - -// *************************************************************************** -int CLuaIHM::runFct(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runFct) - CLuaStackChecker lsc(&ls, 1); - - // params: "expr", param1, param2... - // return: any of: nil, bool, string, number, RGBA, UCString - checkArgMin(ls, "runFct", 1); - check(ls, ls.isString(1), "runExpr() requires a string in param 1"); - - // retrieve fct - std::string expr; - ls.toString(1, expr); - expr+= "("; - - // retrieve params - uint top= ls.getTop(); - for(uint i=2;i<=top;i++) - { - if(i>2) - expr+= ", "; - - // If it is a number - if(ls.type(i)==LUA_TNUMBER) - { - std::string paramValue; - ls.toString(i, paramValue); // nb: transformed to a string in the stack - expr+= paramValue; - } - // else suppose a string - else - { - // must enclose with "'" - std::string paramValue; - ls.toString(i, paramValue); - expr+= std::string("'") + paramValue + std::string("'") ; - } - } - - // end fct call - expr+= ")"; - - - // run expression and push result - return runExprAndPushResult(ls, expr); -} - -// *************************************************************************** -int CLuaIHM::runCommand(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runCommand) - CLuaStackChecker lsc(&ls, 1); - if (ls.empty()) - { - nlwarning("'runCommand' : Command name expected"); - ls.push(false); - return 1; - } - const char *commandName = ls.toString(1); - if (!commandName) - { - nlwarning("'runCommand' : Bad command name"); - ls.push(false); - return 1; - } - if (!NLMISC::ICommand::LocalCommands || !NLMISC::ICommand::LocalCommands->count(ls.toString(1))) - { - nlwarning("'runCommand' : Command %s not found", ls.toString(1)); - ls.push(false); - return 1; - } - std::string rawCommandString = ls.toString(1); - NLMISC::ICommand *command = (*NLMISC::ICommand::LocalCommands)[ls.toString(1)]; - nlassert(command); - std::vector args(ls.getTop() - 1); - for(uint k = 2; k <= (uint) ls.getTop(); ++k) - { - if (ls.toString(k)) - { - args[k - 2] = ls.toString(k); - rawCommandString += " " + std::string(ls.toString(k)); - } - } - - ls.push(command->execute(rawCommandString, args, g_log, false, true)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::formatUI(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_formatUI) - CLuaStackChecker lsc(&ls, 1); - - // params: "expr", param1, param2.... - // return: string with # and % parsed - checkArgMin(ls, "formatUI", 1); - check(ls, ls.isString(1), "formatUI() require a string in param1"); - - // get the string to format - std::string propVal; - ls.toString(1, propVal); - - // *** format with % - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - std::string newPropVal, defError; - if(!pIM->solveDefine(propVal, newPropVal, defError)) - { - throw ELuaIHMException("formatUI(): Can't find define: '%s'", defError.c_str()); - } - - // *** format with any additional parameter and #1, #2, #3 etc... - // search backward, starting from bigger param to replace (thus avoid to replace #1 before #13 for instance...) - sint stackIndex= ls.getTop(); - while(stackIndex>1) - { - std::string paramValue; - ls.toString(stackIndex, paramValue); - - // For stack param 4, the param index is 3 (because stack param 2 is the param No 1) - sint paramIndex= stackIndex-1; - while(NLMISC::strFindReplace(newPropVal, toString("#%d", paramIndex), paramValue)); - - // next - stackIndex--; - } - - // return result - ls.push(newPropVal); - return 1; -} - -// *************************************************************************** -int CLuaIHM::formatDB(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_formatDB) - CLuaStackChecker lsc(&ls, 1); - - // params: param1, param2.... - // return: string with @ and , added - checkArgMin(ls, "formatDB", 1); - uint top= ls.getTop(); - - std::string dbRes; - for(uint i=1;i<=top;i++) - { - if(i==1) - dbRes= "@"; - else - dbRes+= ", @"; - - std::string paramValue; - ls.toString(i, paramValue); - dbRes+= paramValue; - } - - // return result - ls.push(dbRes); - return 1; -} - -// *************************************************************************** -int CLuaIHM::deleteUI(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_deleteUI) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement * - // return: none - checkArgCount(ls, "deleteUI", 1); - check(ls, isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - if(!pIE) - return 0; - - // has a parent? - CInterfaceGroup *parent= pIE->getParent(); - if(parent) - { - // correctly remove from parent - parent->delElement(pIE); - } - else - { - // just delete - delete pIE; - } - - return 0; -} - -// *************************************************************************** -int CLuaIHM::deleteReflectable(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_deleteReflectable) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement * - // return: none - checkArgCount(ls, "deleteReflectable", 1); - check(ls, isReflectableOnStack(ls, 1), "deleteReflectable() requires a reflectable C++ object in param 1"); - - // retrieve args - CReflectableRefPtrTarget *pRPT= getReflectableOnStack(ls, 1); - if(!pRPT) - return 0; - - - CInterfaceElement *pIE = dynamic_cast(pRPT); - - if (pIE) - { - // has a parent? - CInterfaceGroup *parent= pIE->getParent(); - if(parent) - { - // correctly remove from parent - parent->delElement(pIE); - } - } - - // just delete - delete pIE; - - return 0; -} - -// *************************************************************************** -int CLuaIHM::dumpUI(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_dumpUI) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement * - // return: none - checkArgCount(ls, "dumpUI", 1); - check(ls, isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - if(!pIE) - debugInfo("UI: NULL"); - else - { - // Display also Information on RefPtr (warning: don't modify pinfo!!!) - nlassert(pIE->pinfo); - debugInfo(NLMISC::toString("UI: %x. %s. RefPtrCount: %d", pIE, pIE->getId().c_str(), - pIE->pinfo->IsNullPtrInfo?0:pIE->pinfo->RefCount)); - } - - return 0; -} - -// *************************************************************************** -int CLuaIHM::setKeyboardContext(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setKeyboardContext) - const char *funcName = "setKeyboardContext"; - checkArgMin(ls, funcName, 1); - checkArgType(ls, funcName, 1, LUA_TSTRING); - - ActionsContext.setContext(ls.toString(1)); - - return 0; -} - // *************************************************************************** void CLuaIHM::fails(CLuaState &ls, const char *format, ...) { @@ -3276,6 +1573,7 @@ void CLuaIHM::fails(CLuaState &ls, const char *format, ...) throw ELuaIHMException("%s. Lua stack = \n %s", reason.c_str(), stack.c_str()); } + // *************************************************************************** void CLuaIHM::checkArgCount(CLuaState &ls, const char* funcName, uint nArgs) { @@ -3381,203 +1679,6 @@ void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint ind } -// *************************************************************************** -int CLuaIHM::validMessageBox(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_validMessageBox) - const char *funcName = "validMessageBox"; - checkArgCount(ls, funcName, 6); - ucstring msg; - ls.pushValue(1); // copy ucstring at the end of stack to pop it - check(ls, pop(ls, msg), "validMessageBox : ucstring wanted as first parameter"); - checkArgType(ls, funcName, 2, LUA_TSTRING); - checkArgType(ls, funcName, 3, LUA_TSTRING); - checkArgType(ls, funcName, 4, LUA_TSTRING); - checkArgType(ls, funcName, 5, LUA_TSTRING); - checkArgType(ls, funcName, 6, LUA_TSTRING); - CInterfaceManager *im = CInterfaceManager::getInstance(); - im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg, ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); - return 0; -} - -// *************************************************************************** -int CLuaIHM::setTopWindow(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setTopWindow) - const char *funcName = "setTopWindow"; - checkArgCount(ls, funcName, 1); - CInterfaceGroup *wnd = dynamic_cast(getUIOnStack(ls, 1)); - if (!wnd) - { - fails(ls, "%s : interface group expected as arg 1", funcName); - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setTopWindow(wnd); - return 0; -} - -// *************************************************************************** -int CLuaIHM::concatUCString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_concatUCString) - const char *funcName = "concatUCString"; - ucstring result; - for (uint k = 1; k <= (uint) ls.getTop(); ++k) - { - //nlwarning("arg %d = %s", k, ls.getTypename(ls.type(k))); - ucstring part; - if (ls.isString(k)) - { - part.fromUtf8(ls.toString(k)); - } - else - { - CLuaIHM::checkArgTypeUCString(ls, funcName, k); - nlverify(getUCStringOnStack(ls, k, part)); - } - result += part; - } - push(ls, result); - return 1; -} - -// *************************************************************************** -int CLuaIHM::concatString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_concatUCString) - const char *funcName = "concatString"; - std::string result; - uint stackSize = ls.getTop(); - for (uint k = 1; k <= stackSize; ++k) - { - CLuaIHM::checkArgType(ls, funcName, k, LUA_TSTRING); - result += ls.toString(k); - } - ls.push(result); - return 1; -} - -// *************************************************************************** -int CLuaIHM::tableToString(CLuaState &ls) -{ - const char *funcName = "tableToString"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TTABLE); - uint length = 0; - // compute size - ls.pushNil(); - while (ls.next(-2)) - { - ls.toString(-1); - length += (uint)ls.strlen(-1); - ls.pop(2); - } - std::string result; - result.resize(length); - char *dest = &result[0]; - // concatenate - ls.pushNil(); - while (ls.next(-2)) - { - uint length = (uint)ls.strlen(-1); - if (length) - { - memcpy(dest, ls.toString(-1), length); - } - dest += length; - ls.pop(2); - } - ls.push(result); - return 1; -} - -// *************************************************************************** -sint32 CLuaIHM::getSkillIdFromName(const std::string &def) -{ - //H_AUTO(Lua_CLuaIHM_getSkillIdFromName) - SKILLS::ESkills e= SKILLS::toSkill(def); - // Avoid any bug, return SF if not found - if(e>=SKILLS::unknown) - e= SKILLS::SF; - return e; -} - -// *************************************************************************** -ucstring CLuaIHM::getSkillLocalizedName(sint32 skillId) -{ - //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) - return ucstring(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); -} - -// *************************************************************************** -sint32 CLuaIHM::getMaxSkillValue(sint32 skillId) -{ - //H_AUTO(Lua_CLuaIHM_getMaxSkillValue) - CSkillManager *pSM= CSkillManager::getInstance(); - return pSM->getMaxSkillValue((SKILLS::ESkills)skillId); -} - -// *************************************************************************** -sint32 CLuaIHM::getBaseSkillValueMaxChildren(sint32 skillId) -{ - //H_AUTO(Lua_CLuaIHM_getBaseSkillValueMaxChildren) - CSkillManager *pSM= CSkillManager::getInstance(); - return pSM->getBaseSkillValueMaxChildren((SKILLS::ESkills)skillId); -} - -// *************************************************************************** -bool CLuaIHM::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) -{ - //H_AUTO(Lua_CLuaIHM_executeFunctionOnStack) - static volatile bool dumpFunction = false; - if (dumpFunction) - { - CLuaStackRestorer lsr(&ls, ls.getTop()); - lua_Debug ar; - ls.pushValue(-1 - numArgs); - lua_getinfo (ls.getStatePointer(), ">lS", &ar); - nlwarning((std::string(ar.what) + ", at line " + toString(ar.linedefined) + " in " + std::string(ar.source)).c_str()); - } - int result = ls.pcall(numArgs, numRet); - switch (result) - { - case LUA_ERRRUN: - case LUA_ERRMEM: - case LUA_ERRERR: - { - CLuaIHM::debugInfo(ls.toString(-1)); - ls.pop(); - return false; - } - break; - case 0: - return true; - break; - default: - nlassert(0); - break; - } - return false; -} - - -// *************************************************************************** -int CLuaIHM::breakPoint(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_breakPoint) - std::string reason; - ls.getStackContext(reason, 1); // 1 because 0 is the current C function => return 1 for script called - LuaHelperStuff::formatLuaStackContext(reason); - NLMISC::InfoLog->displayRawNL(reason.c_str()); - static volatile bool doAssert = true; - if (doAssert) // breakPoint can be discarded in case of looping assert - { - NLMISC_BREAKPOINT; - } - return 0; -} - - // *************************************************************************** bool CLuaIHM::popString(CLuaState &ls, std::string & dest) @@ -3623,1103 +1724,6 @@ bool CLuaIHM::popSINT32(CLuaState &ls, sint32 & dest) return true; } - -// *************************************************************************** -int CLuaIHM::getWindowSize(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getWindowSize) - checkArgCount(ls, "getWindowSize", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - uint32 w, h; - pIM->getViewRenderer().getScreenSize(w, h); - ls.push((double) w); - ls.push((double) h); - return 2; -} - - -// *************************************************************************** -int CLuaIHM::setTextFormatTaged(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setTextFormatTaged) - // params: CViewText*, "text" (or ucstring) - // return: none - checkArgCount(ls, "setTextFormatTaged", 2); - - // *** check and retrieve param 1 - check(ls, isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); - CInterfaceElement *pIE= getUIOnStack(ls, 1); - - // *** check and retrieve param 2. must be a string or a ucstring - ucstring text; - if(ls.isString(2)) - { - std::string str; - ls.toString(2, str); - text= str; - } - else - { - // try to pop a ucstring from the stack - // fail? - if(!pop(ls, text)) - { - check(ls, false, "setTextFormatTaged() requires a string or a ucstring in param 2"); - } - } - - // must be a view text - CViewText *vt= dynamic_cast(pIE); - if(!vt) - throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); - - // Set the text as format - vt->setTextFormatTaged(text); - - return 0; -} - -// *************************************************************************** -sint32 CLuaIHM::getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl) -{ - //H_AUTO(Lua_CLuaIHM_getMagicResistChance) - CSPhraseManager *pPM= CSPhraseManager::getInstance(); - casterSpellLvl= std::max(casterSpellLvl, sint32(0)); - victimResistLvl= std::max(victimResistLvl, sint32(0)); - /* The success rate in the table is actually the "Casting Success Chance". - Thus, the relativeLevel is casterSpellLvl - victimResistLvl - Moreover, must take the "PartialSuccessMaxDraw" line because the spell is not resisted if success>0 - */ - sint32 chanceToHit= pPM->getSuccessRate(elementalSpell?CSPhraseManager::STResistMagic:CSPhraseManager::STResistMagicLink, - casterSpellLvl-victimResistLvl, true); - clamp(chanceToHit, 0, 100); - - // Thus, the resist chance is 100 - hit chance. - return 100 - chanceToHit; -} - -// *************************************************************************** -sint32 CLuaIHM::getDodgeParryChance(sint32 attLvl, sint32 defLvl) -{ - //H_AUTO(Lua_CLuaIHM_getDodgeParryChance) - CSPhraseManager *pPM = CSPhraseManager::getInstance(); - attLvl= std::max(attLvl, sint32(0)); - defLvl= std::max(defLvl, sint32(0)); - - sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl-attLvl, false); - clamp(chance, 0, 100); - - return chance; -} - -// *************************************************************************** -void CLuaIHM::browseNpcWebPage(const std::string &htmlId, const std::string &urlIn, bool addParameters, double timeout) -{ - //H_AUTO(Lua_CLuaIHM_browseNpcWebPage) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); - if(groupHtml) - { - // if true, it means that we want to display a web page that use webig auth - bool webig = urlIn.find("http://") == 0; - - string url; - // append the WebServer to the url - if (urlIn.find("ring_access_point=1") != std::string::npos) - { - url = RingMainURL + "?" + urlIn; - } - else if(webig) - { - url = urlIn; - } - else - { - url = WebServer + urlIn; - } - - if (addParameters && !webig) - { - // append shardid, playername and language code - string userName; - string guildName; - if(UserEntity) - { - userName = UserEntity->getDisplayName ().toString(); - STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - ucstring ucsTmp; - pSMC->getString (UserEntity->getGuildNameID(), ucsTmp); - guildName = ucsTmp.toString(); - - while (guildName.find(' ') != string::npos) - { - guildName[guildName.find(' ')] = '_'; - } - } - - url += ((url.find('?') != string::npos) ? "&" : "?") + - string("shard=") + toString(ShardId) + - string("&user_login=") + userName + - string("&lang=") + ClientCfg.getHtmlLanguageCode() + - string("&guild_name=") + guildName; - } -/* Already added by GroupHtml - if(webig) - { - // append special webig auth params - addWebIGParams(url); - } -*/ - // set the wanted timeout - groupHtml->setTimeout((float)std::max(0.0, timeout)); - - // Browse the url - groupHtml->clean(); - groupHtml->browse(url.c_str()); - // Set top of the page - CCtrlScroll *pScroll = groupHtml->getScrollBar(); - if (pScroll != NULL) - pScroll->moveTrackY(10000); - } -} - -// *************************************************************************** -void CLuaIHM::clearHtmlUndoRedo(const std::string &htmlId) -{ - //H_AUTO(Lua_CLuaIHM_clearHtmlUndoRedo) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); - if(groupHtml) - groupHtml->clearUndoRedo(); -} - -// *************************************************************************** -ucstring CLuaIHM::getDynString(sint32 dynStringId) -{ - //H_AUTO(Lua_CLuaIHM_getDynString) - ucstring result; - STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); - return result; -} - -// *************************************************************************** -bool CLuaIHM::isDynStringAvailable(sint32 dynStringId) -{ - //H_AUTO(Lua_CLuaIHM_isDynStringAvailable) - ucstring result; - bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); - return res; -} - -// *************************************************************************** -bool CLuaIHM::isFullyPatched() -{ - return AvailablePatchs == 0; -} - -// *************************************************************************** -std::string CLuaIHM::getSheetType(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_getSheetType) - const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); - if (!sheetPtr) return ""; - return CEntitySheet::typeToString(sheetPtr->Type); -} - - -// *************************************************************************** -std::string CLuaIHM::getSheetName(uint32 sheetId) -{ - return CSheetId(sheetId).toString(); -} - -// *************************************************************************** -sint32 CLuaIHM::getFameIndex(const std::string &factionName) -{ - //H_AUTO(Lua_CLuaIHM_getFameIndex) - return CStaticFames::getInstance().getFactionIndex(factionName); -} - -// *************************************************************************** -std::string CLuaIHM::getFameName(sint32 fameIndex) -{ - //H_AUTO(Lua_CLuaIHM_getFameName) - return CStaticFames::getInstance().getFactionName(fameIndex); -} - -// *************************************************************************** -sint32 CLuaIHM::getFameDBIndex(sint32 fameIndex) -{ - //H_AUTO(Lua_CLuaIHM_getFameDBIndex) - // Yoyo: avoid crash if fames not initialized - if(CStaticFames::getInstance().getNbFame()==0) - return 0; - else - return CStaticFames::getInstance().getDatabaseIndex(fameIndex); -} - -// *************************************************************************** -sint32 CLuaIHM::getFirstTribeFameIndex() -{ - //H_AUTO(Lua_CLuaIHM_getFirstTribeFameIndex) - return CStaticFames::getInstance().getFirstTribeFameIndex(); -} - -// *************************************************************************** -sint32 CLuaIHM::getNbTribeFameIndex() -{ - //H_AUTO(Lua_CLuaIHM_getNbTribeFameIndex) - // Yoyo: avoid crash if fames not initialized. at leasst one tribe - return std::max(1U, CStaticFames::getInstance().getNbTribeFameIndex()); -} - -// *************************************************************************** -bool CLuaIHM::fileExists(const string &fileName) -{ - //H_AUTO(Lua_CLuaIHM_fileExists) - return CPath::exists(fileName); -} - -// *************************************************************************** -string CLuaIHM::getClientCfg(const string &varName) -{ - //H_AUTO(Lua_CLuaIHM_getClientCfg) - return ClientCfg.readString(varName); -} - -// *************************************************************************** -void CLuaIHM::sendMsgToServer(const std::string &sMsg) -{ - //H_AUTO(Lua_CLuaIHM_sendMsgToServer) - ::sendMsgToServer(sMsg); -} - -// *************************************************************************** -void CLuaIHM::sendMsgToServerPvpTag(bool pvpTag) -{ - //H_AUTO(Lua_CLuaIHM_sendMsgToServerPvpTag) - uint8 tag = (uint8)pvpTag; - ::sendMsgToServer("PVP:PVP_TAG", tag); -} - - -// *************************************************************************** -bool CLuaIHM::isGuildQuitAvailable() -{ - //H_AUTO(Lua_CLuaIHM_isGuildQuitAvailable) - return CGuildManager::getInstance()->getGuild().QuitGuildAvailable; -} - -// *************************************************************************** -void CLuaIHM::sortGuildMembers() -{ - //H_AUTO(Lua_CLuaIHM_sortGuildMembers) - CGuildManager::getInstance()->sortGuildMembers(); -} - -// *************************************************************************** -sint32 CLuaIHM::getNbGuildMembers() -{ - //H_AUTO(Lua_CLuaIHM_getNbGuildMembers) - return (sint32)CGuildManager::getInstance()->getGuildMembers().size(); -} - -// *************************************************************************** -string CLuaIHM::getGuildMemberName(sint32 nMemberId) -{ - //H_AUTO(Lua_CLuaIHM_getGuildMemberName) - if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) - return ""; - return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name.toString(); -} - -// *************************************************************************** -string CLuaIHM::getGuildMemberGrade(sint32 nMemberId) -{ - //H_AUTO(Lua_CLuaIHM_getGuildMemberGrade) - if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) - return ""; - return EGSPD::CGuildGrade::toString(CGuildManager::getInstance()->getGuildMembers()[nMemberId].Grade); -} - -// *************************************************************************** -bool CLuaIHM::isR2Player(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_isR2Player) - const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); - if (!entitySheet) return false; - const CCharacterSheet *chSheet = dynamic_cast(entitySheet); - if(!chSheet) return false; - return chSheet->R2Npc; -} - -// *************************************************************************** -std::string CLuaIHM::getR2PlayerRace(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_getR2PlayerRace) - const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); - if (!entitySheet) return ""; - const CCharacterSheet *chSheet = dynamic_cast(entitySheet); - if(!chSheet) return ""; - return EGSPD::CPeople::toString(chSheet->Race); -} - -// *************************************************************************** -bool CLuaIHM::isR2PlayerMale(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_isR2PlayerMale) - const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); - if (!entitySheet) return true; - const CCharacterSheet *chSheet = dynamic_cast(entitySheet); - if(!chSheet) return true; - - return (chSheet->Gender == GSGENDER::male); -} - -// *************************************************************************** -std::string CLuaIHM::getCharacterSheetSkel(const std::string &sheet, bool isMale) -{ - //H_AUTO(Lua_CLuaIHM_getCharacterSheetSkel) - const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); - const CCharacterSheet *charSheet = dynamic_cast(sheetPtr); - if (charSheet) return charSheet->getSkelFilename(); - const CRaceStatsSheet *raceStatSheet = dynamic_cast(sheetPtr); - if (raceStatSheet) return raceStatSheet->GenderInfos[isMale ? 0 : 1].Skelfilename; - return ""; -} - -// *************************************************************************** -sint32 CLuaIHM::getSheetId(const std::string &itemName) -{ - //H_AUTO(Lua_CLuaIHM_getSheetId) - return (sint32)CSheetId(itemName).asInt(); -} - -// *************************************************************************** -sint CLuaIHM::getCharacterSheetRegionForce(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionForce) - const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet))); - if (!charSheet) return 0; - return charSheet->RegionForce; -} - -// *************************************************************************** -sint CLuaIHM::getCharacterSheetRegionLevel(const std::string &sheet) -{ - //H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionLevel) - const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet))); - if (!charSheet) return 0; - return charSheet->RegionForce; -} - -// *************************************************************************** -bool CLuaIHM::isCtrlKeyDown() -{ - //H_AUTO(Lua_CLuaIHM_isCtrlKeyDown) - bool ctrlDown = Driver->AsyncListener.isKeyDown(KeyLCONTROL) || - Driver->AsyncListener.isKeyDown(KeyRCONTROL); - if (ctrlDown) nlwarning("ctrl down"); - else nlwarning("ctrl up"); - return ctrlDown; -} - -// *************************************************************************** -std::string CLuaIHM::encodeURLUnicodeParam(const ucstring &text) -{ - //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) - return convertToHTML(text.toUtf8()); -} - -// *************************************************************************** -ucstring CLuaIHM::replacePvpEffectParam(const ucstring &str, sint32 parameter) -{ - //H_AUTO(Lua_CLuaIHM_replacePvpEffectParam) - ucstring result = str; - CSString s = str.toString(); - std::string p, paramString; - - // Locate parameter and store it - p = s.splitTo('%', true); - while (p.size() > 0 && s.size() > 0) - { - if (s[0] == 'p' || s[0] == 'n' || s[0] == 'r') - { - paramString = "%"; - paramString += s[0]; - break; - } - p = s.splitTo('%', true); - } - - // Return original string if param isn't found - if (paramString.size() < 2) - return str; - - // Replace parameter based on its type - switch (paramString[1]) - { - case 'p': - p = toString("%.1f %%", parameter/100.0); - break; - case 'n': - p = toString(parameter); - break; - case 'r': - p = toString("%.1f", parameter/100.0); - break; - default: - debugInfo("Bad arguments in " + str.toString() + " : " + paramString); - } - - strFindReplace(result, paramString.c_str(), p); - - return result; -} - -// *************************************************************************** -string CLuaIHM::getRegionByAlias(uint32 alias) -{ - //H_AUTO(Lua_CLuaIHM_getRegionByAlias) - return ContinentMngr.getRegionNameByAlias(alias); -} - -struct CEmoteStruct -{ - string EmoteId; - string Path; - string Anim; - bool UsableFromClientUI; - - bool operator< (const CEmoteStruct & entry) const - { - string path1 = Path; - string path2 = entry.Path; - - for(;;) - { - string::size_type pos1 = path1.find('|'); - string::size_type pos2 = path2.find('|'); - - ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); - ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); - - sint result = s1.compare(s2); - if (result != 0) - return (result < 0); - - if (pos1 == string::npos) - return (pos2 != string::npos); - if (pos2 == string::npos) - return false; - - path1 = path1.substr(pos1 + 1); - path2 = path2.substr(pos2 + 1); - } - return false; - } -}; - -// *************************************************************************** -int CLuaIHM::initEmotesMenu(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_initEmotesMenu) - CLuaIHM::checkArgCount(ls, "initEmotesMenu", 2); - CLuaIHM::checkArgType(ls, "initEmotesMenu", 2, LUA_TSTRING); - const std::string & emoteMenu = ls.toString(1); - const std::string & luaParams = ls.toString(2); - - ls.newTable(); - CLuaObject result(ls); - std::map emoteList; - uint maxVisibleLine=10; - - CTextEmotListSheet *pTELS = dynamic_cast(SheetMngr.get(CSheetId("list.text_emotes"))); - if (pTELS == NULL) - return 0; - - std::list entries; - if (entries.empty()) - { - for (uint i = 0; i < pTELS->TextEmotList.size(); i++) - { - CEmoteStruct entry; - entry.EmoteId = pTELS->TextEmotList[i].EmoteId; - entry.Path = pTELS->TextEmotList[i].Path; - entry.Anim = pTELS->TextEmotList[i].Anim; - entry.UsableFromClientUI = pTELS->TextEmotList[i].UsableFromClientUI; - entries.push_back(entry); - } - entries.sort(); - } - - // The list of behaviour missnames emotList - CEmotListSheet *pEmotList = dynamic_cast(SheetMngr.get(CSheetId("list.emot"))); - nlassert (pEmotList != NULL); - nlassert (pEmotList->Emots.size() <= 255); - - // Get the focus beta tester flag - bool betaTester = false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CSkillManager *pSM = CSkillManager::getInstance(); - - betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT); - - CGroupMenu *pInitRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); - pInitRootMenu->reset(); - - for (std::list::const_iterator it = entries.begin(); it != entries.end(); it++) - { - std::string sEmoteId = (*it).EmoteId; - std::string sState = (*it).Anim; - std::string sName = (*it).Path; - - // Check that the emote can be added to UI - // --------------------------------------- - if( (*it).UsableFromClientUI == false ) - { - continue; - } - - // Check the emote reserved for FBT (hardcoded) - // -------------------------------------------- - if (sState == "FBT" && !betaTester) - continue; - - uint32 i, j; - // Add to the game context menu - // ---------------------------- - uint32 nbToken = 1; - for (i = 0; i < sName.size(); ++i) - if (sName[i] == '|') - nbToken++; - - CGroupMenu *pRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); - CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); - - for (i = 0; i < nbToken; ++i) - { - if(i==0) - { - sName = sName.substr(sName.find('|')+1,sName.size()); - } - else - { - string sTmp; - if (i != (nbToken-1)) - sTmp = sName.substr(0,sName.find('|')); - else - sTmp = sName; - - - - // Look if this part of the path is already present - bool bFound = false; - for (j = 0; j < pMenu->getNumLine(); ++j) - { - if (sTmp == pMenu->getLineId(j)) - { - bFound = true; - break; - } - } - - if (!bFound) // Create it - { - if (i != (nbToken-1)) - { - pMenu->addLine (CI18N::get(sTmp), "", "", sTmp); - // Create a sub menu - CGroupSubMenu *pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); - pMenu->setSubMenu(j, pNewSubMenu); - } - else - { - // Create a line - pMenu->addLine (CI18N::get(sTmp), "lua", - luaParams+"('"+sEmoteId+"', '"+toString(CI18N::get(sTmp))+"')", sTmp); - emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))).toUtf8(); - } - } - - // Jump to sub menu - if (i != (nbToken-1)) - { - pMenu = pMenu->getSubMenu(j); - sName = sName.substr(sName.find('|')+1,sName.size()); - } - } - } - pMenu->setMaxVisibleLine(maxVisibleLine); - } - pInitRootMenu->setMaxVisibleLine(maxVisibleLine); - - std::map::iterator it; - for(it=emoteList.begin(); it!=emoteList.end(); it++) - { - result.setValue(it->first, it->second); - } - result.push(); - - return 1; -} - -// *************************************************************************** -int CLuaIHM::isUCString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_isUCString) - const char *funcName = "isUCString"; - checkArgCount(ls, funcName, 1); - ls.push(isUCStringOnStack(ls, 1)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::hideAllWindows(CLuaState &/* ls */) -{ - //H_AUTO(Lua_CLuaIHM_hideAllWindows) - CInterfaceManager::getInstance()->hideAllWindows(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::hideAllNonSavableWindows(CLuaState &/* ls */) -{ - //H_AUTO(Lua_CLuaIHM_hideAllNonSavableWindows) - CInterfaceManager::getInstance()->hideAllNonSavableWindows(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::getDesktopIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getDesktopIndex) - ls.push((double) CInterfaceManager::getInstance()->getMode()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::setLuaBreakPoint(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setLuaBreakPoint) - const char *funcName = "setLuaBreakPoint"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - - - #ifdef LUA_NEVRAX_VERSION - if (LuaDebuggerIDE) - { - LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toNumber(2)); - } - #endif - - return 0; -} - -// *************************************************************************** -int CLuaIHM::getMainPageURL(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getMainPageURL) - const char *funcName = "getMainPageURL"; - CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push(RingMainURL); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getCharSlot(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getCharSlot) - const char *funcName = "getCharSlot"; - CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push(double(PlayerSelectedSlot)); - return 1; -} - -// *************************************************************************** -sint32 CLuaIHM::secondsSince1970ToHour(sint32 seconds) -{ - //H_AUTO(Lua_CLuaIHM_secondsSince1970ToHour) - // convert to readable form - struct tm *tstruct; - time_t tval= seconds; - tstruct= gmtime(&tval); - if(!tstruct) - { - debugInfo(toString("Bad Date Received: %d", seconds)); - return 0; - } - - return tstruct->tm_hour; // 0-23 -} - -int CLuaIHM::getPathContent(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getPathContent) - const char *funcName = "getPathContent"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::vector files; - NLMISC::CPath::getPathContent(ls.toString(1), false, false, true, files); - ls.newTable(); - for(uint k = 0; k < files.size(); ++k) - { - ls.push((double) k); - ls.push(files[k]); - ls.setTable(-3); - } - return 1; -} - -int CLuaIHM::getServerSeason(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getServerSeason) - const char *funcName = "getServerSeason"; - CLuaIHM::checkArgCount(ls, funcName, 0); - extern uint8 ServerSeasonValue; - ls.push((double) ServerSeasonValue); - return 1; -} - -int CLuaIHM::computeCurrSeason(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_computeCurrSeason) - const char *funcName = "computeCurrSeason"; - CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) (::computeCurrSeason() + 1)); - return 1; -} - -int CLuaIHM::getAutoSeason(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getAutoSeason) - const char *funcName = "getAutoSeason"; - CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) (StartupSeason + 1)); - return 1; -} - - - -int CLuaIHM::getTextureSize(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getTextureSize) - const char *funcName = "getTextureSize"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::string textureName = ls.toString(1); - - CBitmap bitmap; - CIFile fs(CPath::lookup(textureName).c_str()); - bitmap.load(fs); - - ls.push((double) bitmap.getWidth()); - ls.push((double) bitmap.getHeight()); - - return 2; -} - - -int CLuaIHM::enableModalWindow(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_enableModalWindow) - const char *funcName = "enableModalWindow"; - CLuaIHM::checkArgCount(ls, funcName, 2); - - check(ls, isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - - CInterfaceElement *pIE= getUIOnStack(ls, 1); - std::string modalId = ls.toString(2); - - // convert to id - if(pIE) - { - CCtrlBase * ctrl = dynamic_cast(pIE); - if(ctrl) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId(modalId) ); - if(group) - { - UserControls.stopFreeLook(); - - // enable the modal - pIM->enableModalWindow(ctrl, group); - } - else - { - nlwarning(" Couldn't find group %s", modalId.c_str()); - } - - } - } - - return 0; -} - -// *************************************************************************** -int CLuaIHM::disableModalWindow(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_disableModalWindow) - checkArgCount(ls, "disableModalWindow", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->disableModalWindow(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::getPlayerPos(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getPlayerPos) - checkArgCount(ls, "getPlayerPos", 0); - ls.push(UserEntity->pos().x); - ls.push(UserEntity->pos().y); - ls.push(UserEntity->pos().z); - return 3; -} - -// *************************************************************************** -int CLuaIHM::getPlayerFront(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerFront", 0); - ls.push(atan2(UserEntity->front().y, UserEntity->front().x)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getPlayerDirection(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerDirection", 0); - ls.push(atan2(UserEntity->dir().y, UserEntity->dir().x)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getPlayerGender(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerGender", 0); - ls.push((lua_Number)(UserEntity->getGender())); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getPlayerName(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerName", 0); - ls.push(UserEntity->getEntityName().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getPlayerTitleRaw(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerTitleRaw", 0); - ls.push(UserEntity->getTitleRaw().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getPlayerTitle(CLuaState &ls) -{ - checkArgCount(ls, "getPlayerTitle", 0); - ls.push(UserEntity->getTitle().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetPos(CLuaState &ls) -{ - checkArgCount(ls, "getTargetPos", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(target->pos().x); - ls.push(target->pos().y); - ls.push(target->pos().z); - return 3; -} - -// *************************************************************************** -int CLuaIHM::getTargetFront(CLuaState &ls) -{ - checkArgCount(ls, "getTargetFront", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(atan2(target->front().y, target->front().x)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetDirection(CLuaState &ls) -{ - checkArgCount(ls, "getTargetDirection", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(atan2(target->dir().y, target->dir().x)); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetGender(CLuaState &ls) -{ - checkArgCount(ls, "getTargetGender", 0); - CCharacterCL* target = (CCharacterCL*)getTargetEntity(); - if (!target) return (int)GSGENDER::unknown; - ls.push((lua_Number)(target->getGender())); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetName(CLuaState &ls) -{ - checkArgCount(ls, "getTargetName", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(target->getEntityName().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetTitleRaw(CLuaState &ls) -{ - checkArgCount(ls, "getTargetTitleRaw", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(target->getTitleRaw().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetTitle(CLuaState &ls) -{ - checkArgCount(ls, "getTargetTitle", 0); - CEntityCL *target = getTargetEntity(); - if (!target) return 0; - ls.push(target->getTitle().toUtf8()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::addSearchPathUser(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_addSearchPathUser) - bool memoryCompressed = CPath::isMemoryCompressed(); - if (memoryCompressed) - { - CPath::memoryUncompress(); - } - CPath::addSearchPath("user/", true, false, NULL); - if (memoryCompressed) - { - CPath::memoryCompress(); - } - return 0; -} - -// *************************************************************************** -int CLuaIHM::isPlayerFreeTrial(CLuaState &ls) -{ - checkArgCount(ls, "isPlayerFreeTrial", 0); - ls.push(FreeTrial); - return 1; -} - - - -// *************************************************************************** -int CLuaIHM::disableContextHelp(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_disableContextHelp) - CLuaStackChecker lsc(&ls, 0); - checkArgCount(ls, "disableContextHelp", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->disableContextHelp(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::disableContextHelpForControl(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_disableContextHelpForControl) - CLuaStackChecker lsc(&ls, 0); - - // params: CCtrlBase* - // return: none - checkArgCount(ls, "disableContextHelpForControl", 1); - check(ls, isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); - - // go - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->disableContextHelpForControl(dynamic_cast(pIE)); - - return 0; -} - -// *************************************************************************** -void CLuaIHM::tell(const ucstring &player, const ucstring &msg) -{ - //H_AUTO(Lua_CLuaIHM_tell) - // display a /tell command in the main chat - if (!player.empty()) - { - if (!msg.empty()) - { - // Parse any tokens in the message. - ucstring msg_modified = msg; - // Parse any tokens in the text - if ( ! CInterfaceManager::parseTokens(msg_modified)) - { - return; - } - ChatMngr.tell(player.toUtf8(), msg_modified); - } - else - { - CChatWindow *w = PeopleInterraction.ChatGroup.Window; - if (w) - { - CInterfaceManager *im = CInterfaceManager::getInstance(); - w->setKeyboardFocus(); - w->enableBlink(1); - w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false); - CGroupEditBox *eb = w->getEditBox(); - if (eb != NULL) - { - eb->bypassNextKey(); - } - if (w->getContainer()) - { - w->getContainer()->setActive(true); - im->setTopWindow(w->getContainer()); - } - } - } - } -} - -// *************************************************************************** -bool CLuaIHM::isRingAccessPointInReach() -{ - //H_AUTO(Lua_CLuaIHM_isRingAccessPointInReach) - if (BotChatPageAll->RingSessions->RingAccessPointPos == CVector::Null) return false; - const CVectorD &vect1 = BotChatPageAll->RingSessions->RingAccessPointPos; - CVectorD vect2 = UserEntity->pos(); - double distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2); - return distanceSquare <= MaxTalkingDistSquare; -} - -// *************************************************************************** -void CLuaIHM::updateTooltipCoords() -{ - CInterfaceManager::getInstance()->updateTooltipCoords(); -} - // *************************************************************************** void CLuaIHM::getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest) { @@ -4732,88 +1736,12 @@ void CLuaIHM::getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &de { it.nextValue().push(); NLMISC::CVector2f pos; - if (!CLuaIHM::pop(ls, pos)) + if (!pop(ls, pos)) { - CLuaIHM::fails(ls, "2D polygon expects CVector2f for poly coordinates"); + fails(ls, "2D polygon expects CVector2f for poly coordinates"); } dest.Vertices.push_back(pos); } } -// *************************************************************************** -int CLuaIHM::isPlayerNewbie(CLuaState &ls) -{ - checkArgCount(ls, "isPlayerNewbie", 0); - CInterfaceManager *im = CInterfaceManager::getInstance(); - ls.push(im->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool()); - return 1; -} - - -// *************************************************************************** -int CLuaIHM::isInRingMode(CLuaState &ls) -{ - checkArgCount(ls, "isInRingMode", 0); - extern bool IsInRingMode(); - ls.push(IsInRingMode()); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getUserRace(CLuaState &ls) -{ - checkArgCount(ls, "getUserRace", 0); - if (!UserEntity || !UserEntity->playerSheet()) - { - ls.push("Unknwown"); - } - else - { - ls.push(EGSPD::CPeople::toString(UserEntity->playerSheet()->People)); - } - return 1; -} - -// *************************************************************************** -int CLuaIHM::getSheet2idx(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getSheet2idx", 2); - CLuaIHM::checkArgType(ls, "getSheet2idx", 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER); - - const std::string & sheedtName = ls.toString(1); - uint32 slotId = (uint32)ls.toNumber(2); - - NLMISC::CSheetId sheetId; - - if (sheetId.buildSheetId(sheedtName)) - { - uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)slotId); - ls.push((lua_Number)idx); - } - else - return 0; - return 1; -} - -// *************************************************************************** -int CLuaIHM::getTargetSlot(CLuaState &ls) -{ - uint32 slot = (uint32)getTargetSlotNr(); - ls.push((lua_Number)slot); - return 1; -} - -// *************************************************************************** -int CLuaIHM::getSlotDataSetId(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1); - CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER); - - uint32 slot = (uint32)ls.toNumber(1); - CEntityCL *e = getSlotEntity(slot); - string id = toString(e->dataSetId()); - ls.push(id); - return 1; -} diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.h b/code/ryzom/client/src/interface_v3/lua_ihm.h index 2826c1ac7..6894cc224 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm.h @@ -103,30 +103,6 @@ public: // helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail) static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest); - // Print a message in the log. - // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1) - // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then - // a button will be created near the line to allow to goto the lua line that issued the message - // by using an external editor - static void debugInfo(const std::string &dbg); - // Print a message in the log - // No 'goto file' button is created - // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1) - static void rawDebugInfo(const std::string &dbg); - // Dump callstack in the console - // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then - // buttons will be created in fonr of eahc line to allow to goto the lua line that issued the message - // by using an external editor - static void dumpCallStack(int startStackLevel = 0); - static void getCallStackAsString(int startStackLevel, std::string &result); - - // Create a special tag that will add a 'goto' button for the given file and line - // The tag should be appended in front of a string to use with 'rawDebugInfo'. - // when the final string will be printed, a button will be created in front of it - // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else - // a, empty tag is returned - static std::string createGotoFileButtonTag(const char *fileName, uint line); - // argument checkin helpers static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required @@ -141,12 +117,6 @@ public: */ static void fails(CLuaState &ls, const char *format, ...); - /** execute function that is currently on the stack, possibly outputing error messages to the log - * \return true if execution succeeded - */ - static bool executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet); - - // pop a sint32 from a lua stack, throw an exception on fail static bool popSINT32(CLuaState &ls, sint32 & dest); bool popString(CLuaState &ls, std::string & dest); @@ -184,231 +154,24 @@ private: // @{ // LUA exported Functions with luabind - static sint32 getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging) - static sint64 getPlayerVpa(); - static sint64 getPlayerVpb(); - static sint64 getPlayerVpc(); - static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target - static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target - static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target - static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') - static sint64 getTargetVpa(); - static sint64 getTargetVpb(); - static sint64 getTargetVpc(); - static bool isTargetNPC(); // return 'true' if the target is an npc - static bool isTargetPlayer(); // return 'true' if the target is a player - static bool isTargetUser(); // return 'true' if the target is the user - static bool isPlayerInPVPMode(); - static bool isTargetInPVPMode(); - - static void pauseBGDownloader(); - static void unpauseBGDownloader(); - static void requestBGDownloaderPriority(uint priority); - static sint getBGDownloaderPriority(); - static ucstring getPatchLastErrorMessage(); - static bool isInGame(); - static uint32 getPlayerSelectedSlot(); - static bool isPlayerSlotNewbieLand(uint32 slot); // test if one of the player slot is a newbieland one, if not so, client must be patched in order to continue static uint32 getLocalTime(); static double getPreciseLocalTime(); - static sint32 getDbProp(const std::string &dbProp); // return 0 if not found. - static void setDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is not created if not present. - static void addDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is created if not present. - static void delDbProp(const std::string &dbProp); - static std::string getDefine(const std::string &def); - static void messageBox(const ucstring &text); - static void messageBox(const ucstring &text, const std::string &masterGroup); - static void messageBox(const ucstring &text, const std::string &masterGroup, int caseMode); - static void messageBox(const std::string &text); - static void messageBoxWithHelp(const ucstring &text); - static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup); - static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode); - static void messageBoxWithHelp(const std::string &text); + static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace); static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace); - static bool fileExists(const std::string &fileName); // just for ease of use static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace); static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace); static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace); - static void setContextHelpText(const ucstring &text); - // GameInfo - static sint32 getSkillIdFromName(const std::string &def); - static ucstring getSkillLocalizedName(sint32 skillId); - static sint32 getMaxSkillValue(sint32 skillId); - static sint32 getBaseSkillValueMaxChildren(sint32 skillId); - static sint32 getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl); - static sint32 getDodgeParryChance(sint32 attLvl, sint32 defLvl); - static void browseNpcWebPage(const std::string &htmlId, const std::string &url, bool addParameters, double timeout); - static void clearHtmlUndoRedo(const std::string &htmlId); - static ucstring getDynString(sint32 dynStringId); - static bool isDynStringAvailable(sint32 dynStringId); - static bool isFullyPatched(); - static std::string getSheetType(const std::string &sheet); - static std::string getSheetName(uint32 sheetId); - static sint32 getFameIndex(const std::string &factionName); - static std::string getFameName(sint32 fameIndex); - static sint32 getFameDBIndex(sint32 fameIndex); // convert from the fame index - static sint32 getFirstTribeFameIndex(); // fame index of the 1st tribe - static sint32 getNbTribeFameIndex(); // number of tribe fame index (which are contiguous) - static std::string getClientCfg(const std::string &varName); - static void sendMsgToServer(const std::string &msgName); - static void sendMsgToServerPvpTag(bool pvpTag); - static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); - static std::string getRegionByAlias(uint32 alias); - - static void tell(const ucstring &player, const ucstring &msg); // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly - // else, current command of the chat window will be replaced with tell 'player' - - static bool isGuildQuitAvailable(); - static void sortGuildMembers(); - static sint32 getNbGuildMembers(); - static std::string getGuildMemberName(sint32 nMemberId); - static std::string getGuildMemberGrade(sint32 nMemberId); - static sint32 secondsSince1970ToHour(sint32 seconds); - - // sheet access - // TODO nico : using the reflection system on sheets would allow to export them to lua without these functions ... - static std::string getCharacterSheetSkel(const std::string &sheet, bool isMale); - static sint32 getSheetId(const std::string &itemName); - static bool isR2Player(const std::string &sheet); - static std::string getR2PlayerRace(const std::string &sheet); - static bool isR2PlayerMale(const std::string &sheet); - static sint getCharacterSheetRegionForce(const std::string &sheet); - static sint getCharacterSheetRegionLevel(const std::string &sheet); - - static bool isCtrlKeyDown(); // test if the ctrl key is down (NB nico : I didn't add other key, - // because it would be too easy to write a key recorder ...) - - static std::string encodeURLUnicodeParam(const ucstring &text); - static bool isRingAccessPointInReach(); - - static void updateTooltipCoords(); - - - // LUA exported Functions with standard lua (because use ui object, use variable param number, or return dynamic-typed object) - static int setCaptureKeyboard(CLuaState &ls); - static int resetCaptureKeyboard(CLuaState &ls); - static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none - static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none - static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none - static int getUICaller(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if error) - static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none) - static int getUI(CLuaState &ls); // params: "ui:interface:...". return: CInterfaceElement* (nil if error), an additionnal boolean parameter - // can specify verbose display when the element is note found (default is true) - static int createGroupInstance(CLuaState &ls); // params : param 1 = template name, - // param 2 = id of parent where the instance will be inserted - // param 3 = table with ("template_param", "template_param_value") key/value pairs - // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail - static int createRootGroupInstance(CLuaState &ls); // params : param 1 = template name, - // param 2 = id of parent where the instance will be inserted - // param 3 = table with ("template_param", "template_param_value") key/value pairs - // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail - static int createUIElement(CLuaState &ls); // params : param 1 = template name, - // param 2 = id of parent where the instance will be inserted - // param 3 = table with ("template_param", "template_param_value") key/value pairs - // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail - - static int displayBubble(CLuaState &ls); // params : param 1 = bot id - // param 2 = text - // param 3 = table with all strings and urls - // {"main text"="http:///", "text option 1"="http:///", "text option 2"="http:///") etc... - static int getIndexInDB(CLuaState &ls); // params: CDBCtrlSheet*.... return: index, or 0 if error - static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error) - static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none - static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString - static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString - static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false - static int formatUI(CLuaState &ls); // params: "expr", param1, param2.... return: string with # and % parsed - static int formatDB(CLuaState &ls); // params: param1, param2.... return: string with @ and , added - static int launchContextMenuInGame(CLuaState &ls); // params : menu name - static int parseInterfaceFromString(CLuaState &ls); // params : intreface script - static int updateAllLocalisedElements(CLuaState &ls); - static int breakPoint(CLuaState &ls); - static int getWindowSize(CLuaState &ls); - static int i18n(CLuaState &ls); // retrieve an unicode string from CI18N - static int setTextFormatTaged(CLuaState &ls); // set a text that may contains Tag Format infos - static int validMessageBox(CLuaState &ls); // ok/cancel type message box (can't get it to work through luabind) - static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ... - static int concatString(CLuaState &ls); // speedup concatenation of several strings - static int tableToString(CLuaState &ls); // concat element of a table to build a string - static int setTopWindow(CLuaState &ls); // set the top window - static int initEmotesMenu(CLuaState &ls); - static int isUCString(CLuaState &ls); - static int hideAllWindows(CLuaState &ls); - static int hideAllNonSavableWindows(CLuaState &ls); - static int getDesktopIndex(CLuaState &ls); - static int setLuaBreakPoint(CLuaState &ls); // set a breakpoint in lua external debugger (file, line) - static int getMainPageURL(CLuaState &ls); - static int getCharSlot(CLuaState &ls); - static int displaySystemInfo(CLuaState &ls); - static int setWeatherValue(CLuaState &ls); // first value is a boolean to say automatic, second value ranges from of to 1 and gives the weather - static int getWeatherValue(CLuaState &ls); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored - static int disableContextHelpForControl(CLuaState &ls); // params: CCtrlBase*. return: none - static int disableContextHelp(CLuaState &ls); - static int getPathContent(CLuaState &ls); - static int getServerSeason(CLuaState &ls); // get the last season sent by the server - // 0->auto, computed locally from the current day (or not received from server yet) - // 1->server force spring - // 2->' ' ' summer - // 3->' ' ' autumn - // 4->' ' ' winter - static int computeCurrSeason(CLuaState &ls); // compute current displayed season (1->spring, etc .) - static int getAutoSeason(CLuaState &ls); // compute automatic season that would be at this time (1->spring, etc .) - - - static int getTextureSize(CLuaState &ls); - static int enableModalWindow(CLuaState &ls); - static int disableModalWindow(CLuaState &ls); - static int getPlayerPos(CLuaState &ls); - static int getPlayerFront(CLuaState &ls); - static int getPlayerDirection(CLuaState &ls); - static int getPlayerGender(CLuaState &ls); - static int getPlayerName(CLuaState &ls); - static int getPlayerTitleRaw(CLuaState &ls); - static int getPlayerTitle(CLuaState &ls); - static int getTargetPos(CLuaState &ls); - static int getTargetFront(CLuaState &ls); - static int getTargetDirection(CLuaState &ls); - static int getTargetGender(CLuaState &ls); - static int getTargetName(CLuaState &ls); - static int getTargetTitleRaw(CLuaState &ls); - static int getTargetTitle(CLuaState &ls); - static int addSearchPathUser(CLuaState &ls); - static int getClientCfgVar(CLuaState &ls); - static int isPlayerFreeTrial(CLuaState &ls); - static int isPlayerNewbie(CLuaState &ls); - static int isInRingMode(CLuaState &ls); - static int getUserRace(CLuaState &ls); - static int getSheet2idx(CLuaState &ls); - static int getTargetSlot(CLuaState &ls); - static int getSlotDataSetId(CLuaState &ls); - - - // LUA functions exported for Dev only (debug) - static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none - static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none - static int dumpUI(CLuaState &ls); // params: CInterfaceElement*.... return: none - static int setKeyboardContext(CLuaState &ls); - - - - // @} - - // Function export tools - static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct - // Function to forward lua call to C++ to a 'lua method' exported from a reflected object static int luaMethodCall(lua_State *ls); - static int getCompleteIslands(CLuaState &ls); - static int getIslandId(CLuaState &ls);//TEMP - - +public: + static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct }; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp new file mode 100644 index 000000000..cb9ceae2e --- /dev/null +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -0,0 +1,3271 @@ +#include + +// to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages +#include +#ifdef assert + #undef assert +#endif + +// Warning: cannot use namespace std, when using luabind +#ifdef NL_OS_WINDOWS +# ifndef NL_EXTENDED_FOR_SCOPE +# undef for +# endif +#endif + +#ifdef NL_DEBUG +# define assert(x) nlassert(x) +#else +# define assert(x) +#endif + +#include +// in luabind > 0.6, LUABIND_MAX_ARITY is set to 10 +#if LUABIND_MAX_ARITY == 10 +# include +// only luabind > 0.7 have version.hpp (file checked with build system) +# ifdef HAVE_LUABIND_VERSION +# include +# endif +# ifndef LUABIND_VERSION +// luabind 0.7 doesn't define LUABIND_VERSION +# define LUABIND_VERSION 700 +# endif +// luabind 0.6 doesn't define LUABIND_VERSION but LUABIND_MAX_ARITY is set to 5 +#elif LUABIND_MAX_ARITY == 5 +# define LUABIND_VERSION 600 +#else +# pragma error("luabind version not recognized") +#endif + +#include "lua_ihm_ryzom.h" +#include "interface_manager.h" +#include "nel/gui/lua_helper.h" +#include "lua_object.h" + +#include "lua_ihm.h" +#include "reflect.h" +#include "action_handler.h" +#include "action_handler_tools.h" +#include "interface_manager.h" +#include "interface_group.h" +#include "view_text.h" +#include "game_share/people_pd.h" +#include "group_tree.h" +#include "interface_link.h" +#include "interface_expr.h" +#include "people_interraction.h" +#include "nel/misc/algo.h" +#include "nel/misc/file.h" +#include "nel/misc/i18n.h" +#include "nel/misc/time_nl.h" +#include "skill_manager.h" +#include "group_html.h" +#include "../net_manager.h" +#include "../user_entity.h" +#include "sphrase_manager.h" +#include "guild_manager.h" +#include "../client_cfg.h" +#include "../sheet_manager.h" +#include "lua_object.h" +#include "game_share/emote_list_parser.h" +#include "game_share/pvp_clan.h" +#include "../weather.h" +#include "../continent_manager.h" +#include "../zone_util.h" +#include "../motion/user_controls.h" +#include "group_html_cs.h" +#include "bonus_malus.h" +#include "group_editbox.h" +#include "../entities.h" +#include "../sheet_manager.h" // for emotes +#include "../global.h" // for emotes +#include "../entity_animation_manager.h" // for emotes +#include "../net_manager.h" // for emotes +#include "../client_chat_manager.h" // for emotes +#include "../login.h" +#include "lua_object.h" +#include "../actions.h" +#include "../bg_downloader_access.h" +#include "../connection.h" +#include "../login_patch.h" + +#include "bot_chat_page_all.h" +#include "bot_chat_page_ring_sessions.h" +#include "nel/georges/u_form_loader.h" +#include "nel/georges/u_form.h" +#include "nel/georges/u_form_elm.h" +#include "nel/misc/polygon.h" +#include "game_share/scenario_entry_points.h" +#include "game_share/bg_downloader_msg.h" +#include "game_share/constants.h" +#include "game_share/visual_slot_manager.h" + +#ifdef LUA_NEVRAX_VERSION + #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger +#endif + + +#ifdef LUA_NEVRAX_VERSION + extern ILuaIDEInterface *LuaDebuggerIDE; +#endif + +using namespace NLMISC; +using namespace NLGUI; +using namespace R2; + +extern NLMISC::CLog g_log; +extern CContinentManager ContinentMngr; +extern CClientChatManager ChatMngr; + +// *************************************************************************** +class CHandlerLUA : public IActionHandler +{ +public: + void execute (CCtrlBase *pCaller, const std::string &sParams) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + + // For getUI() LUA function, push the UI caller + if(pCaller) + _UICallerStack.push_back(pCaller); + + // execute a small script. NB: use a small script here because + // most often action handlers are called from xml files => lot of redundant script + pIM->executeLuaScript(sParams, true); + + // pop UI caller + if(pCaller) + _UICallerStack.pop_back(); + } + + // get the top of stack Caller to this LUA script + static CCtrlBase *getUICaller(); + +private: + static std::deque > _UICallerStack; +}; +REGISTER_ACTION_HANDLER( CHandlerLUA, "lua"); +std::deque > CHandlerLUA::_UICallerStack; + +CCtrlBase *CHandlerLUA::getUICaller() +{ + if(_UICallerStack.empty()) + return NULL; + else + return _UICallerStack.back(); +} + +#define LUABIND_ENUM(__enum__, __name__, __num__, __toStringFunc__) \ + createLuaEnumTable(ls, __name__); \ + for (uint e=0 ; e<__num__ ; e++) \ + { \ + std::string str = __toStringFunc__((__enum__)e); \ + std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \ + ls.executeScript(temp); \ + } \ + + + +#define LUABIND_FUNC(__func__) luabind::def(#__func__, &__func__) + +// *************************************************************************** +void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str) +{ + //H_AUTO(Lua_CLuaIHM_createLuaEnumTable) + std::string path = "", script, p; + CSString s = str; + // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') + p = s.splitTo('.', true); + while (p.size() > 0) + { + if (path == "") + path = p; + else + path += "." + p; + script = "if (" + path + " == nil) then " + path + " = {}; end"; + ls.executeScript(script); + p = s.splitTo('.', true); + } +} + +void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) +{ + CLuaStackChecker lsc( &ls ); + + ls.registerFunc( "getUI", getUI ); + ls.registerFunc("setOnDraw", setOnDraw); + ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); + ls.registerFunc("resetCaptureKeyboard", resetCaptureKeyboard); + ls.registerFunc("validMessageBox", validMessageBox); + ls.registerFunc("setTopWindow", setTopWindow); + ls.registerFunc("concatUCString", concatUCString); + ls.registerFunc("concatString", concatString); + ls.registerFunc("tableToString", tableToString); + ls.registerFunc("addOnDbChange", addOnDbChange); + ls.registerFunc("removeOnDbChange", removeOnDbChange); + ls.registerFunc("getUICaller", getUICaller); + ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder); + ls.registerFunc("getUI", getUI); + ls.registerFunc("getIndexInDB", getIndexInDB); + ls.registerFunc("getUIId", getUIId); + ls.registerFunc("createGroupInstance", createGroupInstance); + ls.registerFunc("createRootGroupInstance", createRootGroupInstance); + ls.registerFunc("createUIElement", createUIElement); + ls.registerFunc("launchContextMenuInGame", launchContextMenuInGame); + ls.registerFunc("parseInterfaceFromString", parseInterfaceFromString); + ls.registerFunc("updateAllLocalisedElements", updateAllLocalisedElements); + ls.registerFunc("runAH", runAH); + ls.registerFunc("runExpr", runExpr); + ls.registerFunc("runFct", runFct); + ls.registerFunc("runCommand", runCommand); + ls.registerFunc("formatUI", formatUI); + ls.registerFunc("formatDB", formatDB); + ls.registerFunc("deleteUI", deleteUI); + ls.registerFunc("deleteReflectable", deleteReflectable); + ls.registerFunc("dumpUI", dumpUI); + ls.registerFunc("setKeyboardContext", setKeyboardContext); + ls.registerFunc("breakPoint", breakPoint); + ls.registerFunc("getWindowSize", getWindowSize); + ls.registerFunc("setTextFormatTaged", setTextFormatTaged); + ls.registerFunc("initEmotesMenu", initEmotesMenu); + ls.registerFunc("isUCString", isUCString); + ls.registerFunc("hideAllWindows", hideAllWindows); + ls.registerFunc("hideAllNonSavableWindows", hideAllNonSavableWindows); + ls.registerFunc("getDesktopIndex", getDesktopIndex); + ls.registerFunc("setLuaBreakPoint", setLuaBreakPoint); + ls.registerFunc("getMainPageURL", getMainPageURL); + ls.registerFunc("getCharSlot", getCharSlot); + ls.registerFunc("getPathContent", getPathContent); + ls.registerFunc("getServerSeason", getServerSeason); + ls.registerFunc("computeCurrSeason", computeCurrSeason); + ls.registerFunc("getAutoSeason", getAutoSeason); + ls.registerFunc("getTextureSize", getTextureSize); + ls.registerFunc("enableModalWindow", enableModalWindow); + ls.registerFunc("disableModalWindow", disableModalWindow); + ls.registerFunc("getPlayerPos", getPlayerPos); + ls.registerFunc("getPlayerFront", getPlayerFront); + ls.registerFunc("getPlayerDirection", getPlayerDirection); + ls.registerFunc("getPlayerGender", getPlayerGender); + ls.registerFunc("getPlayerName", getPlayerName); + ls.registerFunc("getPlayerTitleRaw", getPlayerTitleRaw); + ls.registerFunc("getPlayerTitle", getPlayerTitle); + ls.registerFunc("getTargetPos", getTargetPos); + ls.registerFunc("getTargetFront", getTargetFront); + ls.registerFunc("getTargetDirection", getTargetDirection); + ls.registerFunc("getTargetGender", getTargetGender); + ls.registerFunc("getTargetName", getTargetName); + ls.registerFunc("getTargetTitleRaw", getTargetTitleRaw); + ls.registerFunc("getTargetTitle", getTargetTitle); + ls.registerFunc("addSearchPathUser", addSearchPathUser); + ls.registerFunc("displaySystemInfo", displaySystemInfo); + ls.registerFunc("disableContextHelpForControl", disableContextHelpForControl); + ls.registerFunc("disableContextHelp", disableContextHelp); + ls.registerFunc("setWeatherValue", setWeatherValue); + ls.registerFunc("getWeatherValue", getWeatherValue); + ls.registerFunc("getCompleteIslands", getCompleteIslands); + ls.registerFunc("displayBubble", displayBubble); + ls.registerFunc("getIslandId", getIslandId); + ls.registerFunc("getClientCfgVar", getClientCfgVar); + ls.registerFunc("isPlayerFreeTrial", isPlayerFreeTrial); + ls.registerFunc("isPlayerNewbie", isPlayerNewbie); + ls.registerFunc("isInRingMode", isInRingMode); + ls.registerFunc("getUserRace", getUserRace); + ls.registerFunc("getSheet2idx", getSheet2idx); + ls.registerFunc("getTargetSlot", getTargetSlot); + ls.registerFunc("getSlotDataSetId", getSlotDataSetId); + + + lua_State *L= ls.getStatePointer(); + + LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString); + LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString); + + luabind::module(L) + [ + LUABIND_FUNC(getDbProp), + LUABIND_FUNC(setDbProp), + LUABIND_FUNC(addDbProp), + LUABIND_FUNC(delDbProp), + LUABIND_FUNC(debugInfo), + LUABIND_FUNC(rawDebugInfo), + LUABIND_FUNC(dumpCallStack), + LUABIND_FUNC(getDefine), + LUABIND_FUNC(setContextHelpText), + luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox), + luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), + luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), + luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), + LUABIND_FUNC(replacePvpEffectParam), + LUABIND_FUNC(secondsSince1970ToHour), + LUABIND_FUNC(pauseBGDownloader), + LUABIND_FUNC(unpauseBGDownloader), + LUABIND_FUNC(requestBGDownloaderPriority), + LUABIND_FUNC(getBGDownloaderPriority), + LUABIND_FUNC(getPatchLastErrorMessage), + LUABIND_FUNC(getPlayerSelectedSlot), + LUABIND_FUNC(isInGame), + LUABIND_FUNC(isPlayerSlotNewbieLand), + LUABIND_FUNC(getSkillIdFromName), + LUABIND_FUNC(getSkillLocalizedName), + LUABIND_FUNC(getMaxSkillValue), + LUABIND_FUNC(getBaseSkillValueMaxChildren), + LUABIND_FUNC(getMagicResistChance), + LUABIND_FUNC(getDodgeParryChance), + LUABIND_FUNC(browseNpcWebPage), + LUABIND_FUNC(clearHtmlUndoRedo), + LUABIND_FUNC(getDynString), + LUABIND_FUNC(isDynStringAvailable), + LUABIND_FUNC(isFullyPatched), + LUABIND_FUNC(getSheetType), + LUABIND_FUNC(getSheetName), + LUABIND_FUNC(getFameIndex), + LUABIND_FUNC(getFameName), + LUABIND_FUNC(getFameDBIndex), + LUABIND_FUNC(getFirstTribeFameIndex), + LUABIND_FUNC(getNbTribeFameIndex), + LUABIND_FUNC(getClientCfg), + LUABIND_FUNC(fileExists), + LUABIND_FUNC(sendMsgToServer), + LUABIND_FUNC(sendMsgToServerPvpTag), + LUABIND_FUNC(isGuildQuitAvailable), + LUABIND_FUNC(sortGuildMembers), + LUABIND_FUNC(getNbGuildMembers), + LUABIND_FUNC(getGuildMemberName), + LUABIND_FUNC(getGuildMemberGrade), + LUABIND_FUNC(isR2Player), + LUABIND_FUNC(getR2PlayerRace), + LUABIND_FUNC(isR2PlayerMale), + LUABIND_FUNC(getCharacterSheetSkel), + LUABIND_FUNC(getSheetId), + LUABIND_FUNC(getCharacterSheetRegionForce), + LUABIND_FUNC(getCharacterSheetRegionLevel), + LUABIND_FUNC(getRegionByAlias), + LUABIND_FUNC(tell), + LUABIND_FUNC(isRingAccessPointInReach), + LUABIND_FUNC(updateTooltipCoords), + LUABIND_FUNC(isCtrlKeyDown), + LUABIND_FUNC(encodeURLUnicodeParam), + LUABIND_FUNC(getPlayerLevel), + LUABIND_FUNC(getPlayerVpa), + LUABIND_FUNC(getPlayerVpb), + LUABIND_FUNC(getPlayerVpc), + LUABIND_FUNC(getTargetLevel), + LUABIND_FUNC(getTargetForceRegion), + LUABIND_FUNC(getTargetLevelForce), + LUABIND_FUNC(getTargetSheet), + LUABIND_FUNC(getTargetVpa), + LUABIND_FUNC(getTargetVpb), + LUABIND_FUNC(getTargetVpc), + LUABIND_FUNC(isTargetNPC), + LUABIND_FUNC(isTargetPlayer), + LUABIND_FUNC(isTargetUser), + LUABIND_FUNC(isPlayerInPVPMode), + LUABIND_FUNC(isTargetInPVPMode) + ]; + +} + +// *************************************************************************** +static sint32 getTargetSlotNr() +{ + const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; + CInterfaceManager *im = CInterfaceManager::getInstance(); + CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + if (!node) return 0; + if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) + { + return 0; + } + return node->getValue32(); +} + +static CEntityCL *getTargetEntity() +{ + const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; + CInterfaceManager *im = CInterfaceManager::getInstance(); + CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + if (!node) return NULL; + if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) + { + return NULL; + } + return EntitiesMngr.entity((uint) node->getValue32()); +} + + +static CEntityCL *getSlotEntity(uint slot) +{ + return EntitiesMngr.entity(slot); +} + + +int CLuaIHMRyzom::getUI(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getUI) + // params: "ui:interface:...". + // return: CInterfaceElement* (nil if error) + const char *funcName = "getUI"; + CLuaIHM::check(ls, ls.getTop() == 1 || ls.getTop() == 2, funcName); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + bool verbose = true; + if (ls.getTop() > 1) + { + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN); + verbose = ls.toBoolean(2); + } + + // get the string + std::string eltStr; + ls.toString(1, eltStr); + + // return the element + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CInterfaceElement *pIE= pIM->getElementFromId(eltStr); + if(!pIE) + { + ls.pushNil(); + if (verbose) + { + std::string stackContext; + ls.getStackContext(stackContext, 1); + debugInfo( NLMISC::toString("%s : getUI(): '%s' not found", stackContext.c_str(), eltStr.c_str())); + } + } + else + { + CLuaIHM::pushUIOnStack(ls, pIE); + } + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::setCaptureKeyboard(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) + const char *funcName = "setCaptureKeyboard"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); + CCtrlBase *ctrl = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); + if (!ctrl) + { + CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); + } + CInterfaceManager *im = CInterfaceManager::getInstance(); + im->setCaptureKeyboard(ctrl); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::resetCaptureKeyboard(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_resetCaptureKeyboard) + const char *funcName = "resetCaptureKeyboard"; + CLuaIHM::checkArgCount(ls, funcName, 0); + CInterfaceManager *im = CInterfaceManager::getInstance(); + im->resetCaptureKeyboard(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::setOnDraw(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setOnDraw) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "script". + // return: none + CLuaIHM::checkArgCount(ls, "setOnDraw", 2); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string script; + ls.toString(2, script); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("setOnDraw(): '%s' is not a group", pIE->getId().c_str()); + // Set the script to be executed at each draw + group->setLuaScriptOnDraw(script); + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::addOnDbChange(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_addOnDbChange) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "dblist", "script". + // return: none + CLuaIHM::checkArgCount(ls, "addOnDbChange", 3); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); + CLuaIHM::check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string dbList, script; + ls.toString(2, dbList); + ls.toString(3, script); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("addOnDbChange(): '%s' is not a group", pIE->getId().c_str()); + // Set the script to be executed when the given DB change + group->addLuaScriptOnDBChange(dbList, script); + + return 0; +} + + +// *************************************************************************** +int CLuaIHMRyzom::removeOnDbChange(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_removeOnDbChange) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "dbList" + // return: none + CLuaIHM::checkArgCount(ls, "removeOnDbChange", 2); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string dbList; + ls.toString(2, dbList); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("removeOnDbChange(): '%s' is not a group", pIE->getId().c_str()); + // Remove the script to be executed when the given DB change + group->removeLuaScriptOnDBChange(dbList); + + return 0; +} + + +// *************************************************************************** +int CLuaIHMRyzom::runAH(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_runAH) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement *, "ah", "params". + // return: none + CLuaIHM::checkArgCount(ls, "runAH", 3); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); + CLuaIHM::check(ls, ls.isString(2), "runAH() requires a string in param 2"); + CLuaIHM::check(ls, ls.isString(3), "runAH() requires a string in param 3"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string ah, params; + ls.toString(2, ah); + ls.toString(3, params); + + // run AH + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + // The element must be ctrl (or NULL) + CCtrlBase *ctrl= NULL; + if(pIE) + { + ctrl= dynamic_cast(pIE); + if(!ctrl) + throw ELuaIHMException("runAH(): '%s' is not a ctrl", pIE->getId().c_str()); + } + pIM->runActionHandler(ah, ctrl, params); + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::runExpr(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_runExpr) + CLuaStackChecker lsc(&ls, 1); + + // params: "expr". + // return: any of: nil, bool, string, number, RGBA, UCString + CLuaIHM::checkArgCount(ls, "runExpr", 1); + CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); + + // retrieve args + std::string expr; + ls.toString(1, expr); + + // run expression and push result + return CLuaIHM::runExprAndPushResult(ls, expr); +} + +// *************************************************************************** +int CLuaIHMRyzom::runFct(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_runFct) + CLuaStackChecker lsc(&ls, 1); + + // params: "expr", param1, param2... + // return: any of: nil, bool, string, number, RGBA, UCString + CLuaIHM::checkArgMin(ls, "runFct", 1); + CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); + + // retrieve fct + std::string expr; + ls.toString(1, expr); + expr+= "("; + + // retrieve params + uint top= ls.getTop(); + for(uint i=2;i<=top;i++) + { + if(i>2) + expr+= ", "; + + // If it is a number + if(ls.type(i)==LUA_TNUMBER) + { + std::string paramValue; + ls.toString(i, paramValue); // nb: transformed to a string in the stack + expr+= paramValue; + } + // else suppose a string + else + { + // must enclose with "'" + std::string paramValue; + ls.toString(i, paramValue); + expr+= std::string("'") + paramValue + std::string("'") ; + } + } + + // end fct call + expr+= ")"; + + + // run expression and push result + return CLuaIHM::runExprAndPushResult(ls, expr); +} + +// *************************************************************************** +int CLuaIHMRyzom::runCommand(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_runCommand) + CLuaStackChecker lsc(&ls, 1); + if (ls.empty()) + { + nlwarning("'runCommand' : Command name expected"); + ls.push(false); + return 1; + } + const char *commandName = ls.toString(1); + if (!commandName) + { + nlwarning("'runCommand' : Bad command name"); + ls.push(false); + return 1; + } + if (!NLMISC::ICommand::LocalCommands || !NLMISC::ICommand::LocalCommands->count(ls.toString(1))) + { + nlwarning("'runCommand' : Command %s not found", ls.toString(1)); + ls.push(false); + return 1; + } + std::string rawCommandString = ls.toString(1); + NLMISC::ICommand *command = (*NLMISC::ICommand::LocalCommands)[ls.toString(1)]; + nlassert(command); + std::vector args(ls.getTop() - 1); + for(uint k = 2; k <= (uint) ls.getTop(); ++k) + { + if (ls.toString(k)) + { + args[k - 2] = ls.toString(k); + rawCommandString += " " + std::string(ls.toString(k)); + } + } + + ls.push(command->execute(rawCommandString, args, g_log, false, true)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::formatUI(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_formatUI) + CLuaStackChecker lsc(&ls, 1); + + // params: "expr", param1, param2.... + // return: string with # and % parsed + CLuaIHM::checkArgMin(ls, "formatUI", 1); + CLuaIHM::check(ls, ls.isString(1), "formatUI() require a string in param1"); + + // get the string to format + std::string propVal; + ls.toString(1, propVal); + + // *** format with % + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + std::string newPropVal, defError; + if(!pIM->solveDefine(propVal, newPropVal, defError)) + { + throw ELuaIHMException("formatUI(): Can't find define: '%s'", defError.c_str()); + } + + // *** format with any additional parameter and #1, #2, #3 etc... + // search backward, starting from bigger param to replace (thus avoid to replace #1 before #13 for instance...) + sint stackIndex= ls.getTop(); + while(stackIndex>1) + { + std::string paramValue; + ls.toString(stackIndex, paramValue); + + // For stack param 4, the param index is 3 (because stack param 2 is the param No 1) + sint paramIndex= stackIndex-1; + while(NLMISC::strFindReplace(newPropVal, NLMISC::toString("#%d", paramIndex), paramValue)); + + // next + stackIndex--; + } + + // return result + ls.push(newPropVal); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::formatDB(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_formatDB) + CLuaStackChecker lsc(&ls, 1); + + // params: param1, param2.... + // return: string with @ and , added + CLuaIHM::checkArgMin(ls, "formatDB", 1); + uint top= ls.getTop(); + + std::string dbRes; + for(uint i=1;i<=top;i++) + { + if(i==1) + dbRes= "@"; + else + dbRes+= ", @"; + + std::string paramValue; + ls.toString(i, paramValue); + dbRes+= paramValue; + } + + // return result + ls.push(dbRes); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::deleteUI(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_deleteUI) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement * + // return: none + CLuaIHM::checkArgCount(ls, "deleteUI", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + if(!pIE) + return 0; + + // has a parent? + CInterfaceGroup *parent= pIE->getParent(); + if(parent) + { + // correctly remove from parent + parent->delElement(pIE); + } + else + { + // just delete + delete pIE; + } + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::deleteReflectable(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_deleteReflectable) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement * + // return: none + CLuaIHM::checkArgCount(ls, "deleteReflectable", 1); + CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "deleteReflectable() requires a reflectable C++ object in param 1"); + + // retrieve args + CReflectableRefPtrTarget *pRPT= CLuaIHM::getReflectableOnStack(ls, 1); + if(!pRPT) + return 0; + + + CInterfaceElement *pIE = dynamic_cast(pRPT); + + if (pIE) + { + // has a parent? + CInterfaceGroup *parent= pIE->getParent(); + if(parent) + { + // correctly remove from parent + parent->delElement(pIE); + } + } + + // just delete + delete pIE; + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::dumpUI(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_dumpUI) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement * + // return: none + CLuaIHM::checkArgCount(ls, "dumpUI", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + if(!pIE) + debugInfo("UI: NULL"); + else + { + // Display also Information on RefPtr (warning: don't modify pinfo!!!) + nlassert(pIE->pinfo); + debugInfo(NLMISC::toString("UI: %x. %s. RefPtrCount: %d", pIE, pIE->getId().c_str(), + pIE->pinfo->IsNullPtrInfo?0:pIE->pinfo->RefCount)); + } + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::setKeyboardContext(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setKeyboardContext) + const char *funcName = "setKeyboardContext"; + CLuaIHM::checkArgMin(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + + ActionsContext.setContext(ls.toString(1)); + + return 0; +} + + +// *************************************************************************** +int CLuaIHMRyzom::validMessageBox(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_validMessageBox) + const char *funcName = "validMessageBox"; + CLuaIHM::checkArgCount(ls, funcName, 6); + ucstring msg; + ls.pushValue(1); // copy ucstring at the end of stack to pop it + CLuaIHM::check(ls, CLuaIHM::pop(ls, msg), "validMessageBox : ucstring wanted as first parameter"); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 6, LUA_TSTRING); + CInterfaceManager *im = CInterfaceManager::getInstance(); + im->validMessageBox(CInterfaceManager::QuestionIconMsg, msg, ls.toString(2), ls.toString(3), ls.toString(4), ls.toString(5), ls.toString(6)); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::setTopWindow(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setTopWindow) + const char *funcName = "setTopWindow"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CInterfaceGroup *wnd = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (!wnd) + { + CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); + } + CInterfaceManager *im = CInterfaceManager::getInstance(); + im->setTopWindow(wnd); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::concatUCString(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_concatUCString) + const char *funcName = "concatUCString"; + ucstring result; + for (uint k = 1; k <= (uint) ls.getTop(); ++k) + { + //nlwarning("arg %d = %s", k, ls.getTypename(ls.type(k))); + ucstring part; + if (ls.isString(k)) + { + part.fromUtf8(ls.toString(k)); + } + else + { + CLuaIHM::checkArgTypeUCString(ls, funcName, k); + nlverify(CLuaIHM::getUCStringOnStack(ls, k, part)); + } + result += part; + } + CLuaIHM::push(ls, result); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::concatString(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_concatUCString) + const char *funcName = "concatString"; + std::string result; + uint stackSize = ls.getTop(); + for (uint k = 1; k <= stackSize; ++k) + { + CLuaIHM::checkArgType(ls, funcName, k, LUA_TSTRING); + result += ls.toString(k); + } + ls.push(result); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::tableToString(CLuaState &ls) +{ + const char *funcName = "tableToString"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TTABLE); + uint length = 0; + // compute size + ls.pushNil(); + while (ls.next(-2)) + { + ls.toString(-1); + length += (uint)ls.strlen(-1); + ls.pop(2); + } + std::string result; + result.resize(length); + char *dest = &result[0]; + // concatenate + ls.pushNil(); + while (ls.next(-2)) + { + uint length = (uint)ls.strlen(-1); + if (length) + { + memcpy(dest, ls.toString(-1), length); + } + dest += length; + ls.pop(2); + } + ls.push(result); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::breakPoint(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_breakPoint) + std::string reason; + ls.getStackContext(reason, 1); // 1 because 0 is the current C function => return 1 for script called + LuaHelperStuff::formatLuaStackContext(reason); + NLMISC::InfoLog->displayRawNL(reason.c_str()); + static volatile bool doAssert = true; + if (doAssert) // breakPoint can be discarded in case of looping assert + { + NLMISC_BREAKPOINT; + } + return 0; +} + + + +// *************************************************************************** +int CLuaIHMRyzom::getWindowSize(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getWindowSize) + CLuaIHM::checkArgCount(ls, "getWindowSize", 0); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + uint32 w, h; + pIM->getViewRenderer().getScreenSize(w, h); + ls.push((double) w); + ls.push((double) h); + return 2; +} + + +// *************************************************************************** +int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setTextFormatTaged) + // params: CViewText*, "text" (or ucstring) + // return: none + CLuaIHM::checkArgCount(ls, "setTextFormatTaged", 2); + + // *** check and retrieve param 1 + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + + // *** check and retrieve param 2. must be a string or a ucstring + ucstring text; + if(ls.isString(2)) + { + std::string str; + ls.toString(2, str); + text= str; + } + else + { + // try to pop a ucstring from the stack + // fail? + if(!CLuaIHM::pop(ls, text)) + { + CLuaIHM::check(ls, false, "setTextFormatTaged() requires a string or a ucstring in param 2"); + } + } + + // must be a view text + CViewText *vt= dynamic_cast(pIE); + if(!vt) + throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str()); + + // Set the text as format + vt->setTextFormatTaged(text); + + return 0; +} + + +struct CEmoteStruct +{ + string EmoteId; + string Path; + string Anim; + bool UsableFromClientUI; + + bool operator< (const CEmoteStruct & entry) const + { + string path1 = Path; + string path2 = entry.Path; + + for(;;) + { + string::size_type pos1 = path1.find('|'); + string::size_type pos2 = path2.find('|'); + + ucstring s1 = toUpper(CI18N::get(path1.substr(0, pos1))); + ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2))); + + sint result = s1.compare(s2); + if (result != 0) + return (result < 0); + + if (pos1 == string::npos) + return (pos2 != string::npos); + if (pos2 == string::npos) + return false; + + path1 = path1.substr(pos1 + 1); + path2 = path2.substr(pos2 + 1); + } + return false; + } +}; + +// *************************************************************************** +int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_initEmotesMenu) + CLuaIHM::checkArgCount(ls, "initEmotesMenu", 2); + CLuaIHM::checkArgType(ls, "initEmotesMenu", 2, LUA_TSTRING); + const std::string & emoteMenu = ls.toString(1); + const std::string & luaParams = ls.toString(2); + + ls.newTable(); + CLuaObject result(ls); + std::map emoteList; + uint maxVisibleLine=10; + + CTextEmotListSheet *pTELS = dynamic_cast(SheetMngr.get(CSheetId("list.text_emotes"))); + if (pTELS == NULL) + return 0; + + std::list entries; + if (entries.empty()) + { + for (uint i = 0; i < pTELS->TextEmotList.size(); i++) + { + CEmoteStruct entry; + entry.EmoteId = pTELS->TextEmotList[i].EmoteId; + entry.Path = pTELS->TextEmotList[i].Path; + entry.Anim = pTELS->TextEmotList[i].Anim; + entry.UsableFromClientUI = pTELS->TextEmotList[i].UsableFromClientUI; + entries.push_back(entry); + } + entries.sort(); + } + + // The list of behaviour missnames emotList + CEmotListSheet *pEmotList = dynamic_cast(SheetMngr.get(CSheetId("list.emot"))); + nlassert (pEmotList != NULL); + nlassert (pEmotList->Emots.size() <= 255); + + // Get the focus beta tester flag + bool betaTester = false; + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CSkillManager *pSM = CSkillManager::getInstance(); + + betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT); + + CGroupMenu *pInitRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); + pInitRootMenu->reset(); + + for (std::list::const_iterator it = entries.begin(); it != entries.end(); it++) + { + std::string sEmoteId = (*it).EmoteId; + std::string sState = (*it).Anim; + std::string sName = (*it).Path; + + // Check that the emote can be added to UI + // --------------------------------------- + if( (*it).UsableFromClientUI == false ) + { + continue; + } + + // Check the emote reserved for FBT (hardcoded) + // -------------------------------------------- + if (sState == "FBT" && !betaTester) + continue; + + uint32 i, j; + // Add to the game context menu + // ---------------------------- + uint32 nbToken = 1; + for (i = 0; i < sName.size(); ++i) + if (sName[i] == '|') + nbToken++; + + CGroupMenu *pRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); + CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); + + for (i = 0; i < nbToken; ++i) + { + if(i==0) + { + sName = sName.substr(sName.find('|')+1,sName.size()); + } + else + { + string sTmp; + if (i != (nbToken-1)) + sTmp = sName.substr(0,sName.find('|')); + else + sTmp = sName; + + + + // Look if this part of the path is already present + bool bFound = false; + for (j = 0; j < pMenu->getNumLine(); ++j) + { + if (sTmp == pMenu->getLineId(j)) + { + bFound = true; + break; + } + } + + if (!bFound) // Create it + { + if (i != (nbToken-1)) + { + pMenu->addLine (CI18N::get(sTmp), "", "", sTmp); + // Create a sub menu + CGroupSubMenu *pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); + pMenu->setSubMenu(j, pNewSubMenu); + } + else + { + // Create a line + pMenu->addLine (CI18N::get(sTmp), "lua", + luaParams+"('"+sEmoteId+"', '"+toString(CI18N::get(sTmp))+"')", sTmp); + emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))).toUtf8(); + } + } + + // Jump to sub menu + if (i != (nbToken-1)) + { + pMenu = pMenu->getSubMenu(j); + sName = sName.substr(sName.find('|')+1,sName.size()); + } + } + } + pMenu->setMaxVisibleLine(maxVisibleLine); + } + pInitRootMenu->setMaxVisibleLine(maxVisibleLine); + + std::map::iterator it; + for(it=emoteList.begin(); it!=emoteList.end(); it++) + { + result.setValue(it->first, it->second); + } + result.push(); + + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::isUCString(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_isUCString) + const char *funcName = "isUCString"; + CLuaIHM::checkArgCount(ls, funcName, 1); + ls.push(CLuaIHM::isUCStringOnStack(ls, 1)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::hideAllWindows(CLuaState &/* ls */) +{ + //H_AUTO(Lua_CLuaIHM_hideAllWindows) + CInterfaceManager::getInstance()->hideAllWindows(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::hideAllNonSavableWindows(CLuaState &/* ls */) +{ + //H_AUTO(Lua_CLuaIHM_hideAllNonSavableWindows) + CInterfaceManager::getInstance()->hideAllNonSavableWindows(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::getDesktopIndex(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getDesktopIndex) + ls.push((double) CInterfaceManager::getInstance()->getMode()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::setLuaBreakPoint(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setLuaBreakPoint) + const char *funcName = "setLuaBreakPoint"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + + + #ifdef LUA_NEVRAX_VERSION + if (LuaDebuggerIDE) + { + LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toNumber(2)); + } + #endif + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::getMainPageURL(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getMainPageURL) + const char *funcName = "getMainPageURL"; + CLuaIHM::checkArgCount(ls, funcName, 0); + ls.push(RingMainURL); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getCharSlot(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getCharSlot) + const char *funcName = "getCharSlot"; + CLuaIHM::checkArgCount(ls, funcName, 0); + ls.push(double(PlayerSelectedSlot)); + return 1; +} + + +int CLuaIHMRyzom::getPathContent(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getPathContent) + const char *funcName = "getPathContent"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::vector files; + NLMISC::CPath::getPathContent(ls.toString(1), false, false, true, files); + ls.newTable(); + for(uint k = 0; k < files.size(); ++k) + { + ls.push((double) k); + ls.push(files[k]); + ls.setTable(-3); + } + return 1; +} + +int CLuaIHMRyzom::getServerSeason(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getServerSeason) + const char *funcName = "getServerSeason"; + CLuaIHM::checkArgCount(ls, funcName, 0); + extern uint8 ServerSeasonValue; + ls.push((double) ServerSeasonValue); + return 1; +} + +int CLuaIHMRyzom::computeCurrSeason(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_computeCurrSeason) + const char *funcName = "computeCurrSeason"; + CLuaIHM::checkArgCount(ls, funcName, 0); + ls.push((double) (::computeCurrSeason() + 1)); + return 1; +} + +int CLuaIHMRyzom::getAutoSeason(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getAutoSeason) + const char *funcName = "getAutoSeason"; + CLuaIHM::checkArgCount(ls, funcName, 0); + ls.push((double) (StartupSeason + 1)); + return 1; +} + + + +int CLuaIHMRyzom::getTextureSize(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getTextureSize) + const char *funcName = "getTextureSize"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string textureName = ls.toString(1); + + CBitmap bitmap; + CIFile fs(CPath::lookup(textureName).c_str()); + bitmap.load(fs); + + ls.push((double) bitmap.getWidth()); + ls.push((double) bitmap.getHeight()); + + return 2; +} + + +int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_enableModalWindow) + const char *funcName = "enableModalWindow"; + CLuaIHM::checkArgCount(ls, funcName, 2); + + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string modalId = ls.toString(2); + + // convert to id + if(pIE) + { + CCtrlBase * ctrl = dynamic_cast(pIE); + if(ctrl) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId(modalId) ); + if(group) + { + UserControls.stopFreeLook(); + + // enable the modal + pIM->enableModalWindow(ctrl, group); + } + else + { + nlwarning(" Couldn't find group %s", modalId.c_str()); + } + + } + } + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::disableModalWindow(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_disableModalWindow) + CLuaIHM::checkArgCount(ls, "disableModalWindow", 0); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->disableModalWindow(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerPos(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getPlayerPos) + CLuaIHM::checkArgCount(ls, "getPlayerPos", 0); + ls.push(UserEntity->pos().x); + ls.push(UserEntity->pos().y); + ls.push(UserEntity->pos().z); + return 3; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerFront(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerFront", 0); + ls.push(atan2(UserEntity->front().y, UserEntity->front().x)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerDirection(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerDirection", 0); + ls.push(atan2(UserEntity->dir().y, UserEntity->dir().x)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerGender(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerGender", 0); + ls.push((lua_Number)(UserEntity->getGender())); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerName(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerName", 0); + ls.push(UserEntity->getEntityName().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerTitleRaw(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerTitleRaw", 0); + ls.push(UserEntity->getTitleRaw().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getPlayerTitle(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getPlayerTitle", 0); + ls.push(UserEntity->getTitle().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetPos(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetPos", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(target->pos().x); + ls.push(target->pos().y); + ls.push(target->pos().z); + return 3; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetFront(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetFront", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(atan2(target->front().y, target->front().x)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetDirection(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetDirection", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(atan2(target->dir().y, target->dir().x)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetGender(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetGender", 0); + CCharacterCL* target = (CCharacterCL*)getTargetEntity(); + if (!target) return (int)GSGENDER::unknown; + ls.push((lua_Number)(target->getGender())); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetName(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetName", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(target->getEntityName().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetTitleRaw(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetTitleRaw", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(target->getTitleRaw().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetTitle(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getTargetTitle", 0); + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + ls.push(target->getTitle().toUtf8()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::addSearchPathUser(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_addSearchPathUser) + bool memoryCompressed = CPath::isMemoryCompressed(); + if (memoryCompressed) + { + CPath::memoryUncompress(); + } + CPath::addSearchPath("user/", true, false, NULL); + if (memoryCompressed) + { + CPath::memoryCompress(); + } + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::isPlayerFreeTrial(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "isPlayerFreeTrial", 0); + ls.push(FreeTrial); + return 1; +} + + + +// *************************************************************************** +int CLuaIHMRyzom::disableContextHelp(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_disableContextHelp) + CLuaStackChecker lsc(&ls, 0); + CLuaIHM::checkArgCount(ls, "disableContextHelp", 0); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->disableContextHelp(); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::disableContextHelpForControl(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_disableContextHelpForControl) + CLuaStackChecker lsc(&ls, 0); + + // params: CCtrlBase* + // return: none + CLuaIHM::checkArgCount(ls, "disableContextHelpForControl", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + + // go + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->disableContextHelpForControl(dynamic_cast(pIE)); + + return 0; +} + + +// *************************************************************************** +int CLuaIHMRyzom::isPlayerNewbie(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "isPlayerNewbie", 0); + CInterfaceManager *im = CInterfaceManager::getInstance(); + ls.push(im->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool()); + return 1; +} + + +// *************************************************************************** +int CLuaIHMRyzom::isInRingMode(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "isInRingMode", 0); + extern bool IsInRingMode(); + ls.push(IsInRingMode()); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getUserRace(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getUserRace", 0); + if (!UserEntity || !UserEntity->playerSheet()) + { + ls.push("Unknwown"); + } + else + { + ls.push(EGSPD::CPeople::toString(UserEntity->playerSheet()->People)); + } + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getSheet2idx(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getSheet2idx", 2); + CLuaIHM::checkArgType(ls, "getSheet2idx", 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER); + + const std::string & sheedtName = ls.toString(1); + uint32 slotId = (uint32)ls.toNumber(2); + + NLMISC::CSheetId sheetId; + + if (sheetId.buildSheetId(sheedtName)) + { + uint32 idx = CVisualSlotManager::getInstance()->sheet2Index(sheetId, (SLOTTYPE::EVisualSlot)slotId); + ls.push((lua_Number)idx); + } + else + return 0; + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getTargetSlot(CLuaState &ls) +{ + uint32 slot = (uint32)getTargetSlotNr(); + ls.push((lua_Number)slot); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getSlotDataSetId(CLuaState &ls) +{ + CLuaIHM::checkArgCount(ls, "getSlotDataSetId", 1); + CLuaIHM::checkArgType(ls, "getSlotDataSetId", 1, LUA_TNUMBER); + + uint32 slot = (uint32)ls.toNumber(1); + CEntityCL *e = getSlotEntity(slot); + string id = toString(e->dataSetId()); + ls.push(id); + return 1; +} + +int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getClientCfgVar) + const char *funcName = "getClientCfgVar"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string varName = ls.toString(1); + + CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(varName); + if (!v) return 0; + if(v->size()==1) + { + switch(v->Type) + { + case CConfigFile::CVar::T_REAL: + ls.push((double) v->asDouble()); + return 1; + break; + case CConfigFile::CVar::T_STRING: + ls.push(v->asString()); + return 1; + break; + default: // handle both T_INT && T_BOOL + case CConfigFile::CVar::T_INT: + ls.push((double) v->asInt()); + return 1; + break; + } + } + else + { + ls.newTable(); + CLuaObject result(ls); + uint count = 0; + for(uint i = 0; iStrValues.size(); i++) + { + result.setValue(toString(count).c_str(), v->StrValues[i]); + count++; + } + for(uint i = 0; iIntValues.size(); i++) + { + result.setValue(toString(count).c_str(), (double)v->IntValues[i]); + count++; + } + for(uint i = 0; iRealValues.size(); i++) + { + result.setValue(toString(count).c_str(), (double)v->RealValues[i]); + count++; + } + result.push(); + return 1; + } + + return 0; +} + +int CLuaIHMRyzom::displaySystemInfo(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_displaySystemInfo) + const char *funcName = "displaySystemInfo"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgTypeUCString(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + ucstring msg; + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, msg)); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->displaySystemInfo(msg, ls.toString(2)); + return 0; +} + +int CLuaIHMRyzom::setWeatherValue(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_setWeatherValue) + const char *funcName = "setWeatherValue"; + CLuaIHM::checkArgMin(ls, funcName, 1); + CLuaIHM::checkArgMax(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TBOOLEAN); +// bool autoWeather = ls.toBoolean(1); + ClientCfg.ManualWeatherSetup = !ls.toBoolean(1); + if (ls.getTop() == 2) + { + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + ManualWeatherValue = (float) ls.toNumber(2); + } + return 0; +} + +int CLuaIHMRyzom::getWeatherValue(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getWeatherValue) + const char *funcName = "getWeatherValue"; + CLuaIHM::checkArgCount(ls, funcName, 0); + uint64 currDay = RT.getRyzomDay(); + float currHour = (float) RT.getRyzomTime(); + ls.push(::getBlendedWeather(currDay, currHour, *WeatherFunctionParams, ContinentMngr.cur()->WeatherFunction)); + return 1; +} + +int CLuaIHMRyzom::getUICaller(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getUICaller) + CLuaStackChecker lsc(&ls, 1); + + // params: none. + // return: CInterfaceElement* (nil if error) + CInterfaceElement *pIE= CHandlerLUA::getUICaller(); + if(!pIE) + { + ls.pushNil(); + debugInfo(toString("getUICaller(): No UICaller found. return Nil")); + } + else + { + CLuaIHM::pushUIOnStack(ls, pIE); + } + return 1; +} + +int CLuaIHMRyzom::getCurrentWindowUnder(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getCurrentWindowUnder) + CLuaStackChecker lsc(&ls, 1); + CInterfaceManager *im = CInterfaceManager::getInstance(); + CInterfaceElement *pIE= im->getCurrentWindowUnder(); + if(!pIE) + { + ls.pushNil(); + debugInfo(toString("getCurrentWindowUnder(): No UICaller found. return Nil")); + } + else + { + CLuaIHM::pushUIOnStack(ls, pIE); + } + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getUIId(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getUIId) + CLuaStackChecker lsc(&ls, 1); + + // params: CInterfaceElement* + // return: "ui:interface:...". (empty if error) + CLuaIHM::checkArgCount(ls, "getUIId", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + + // convert to id + if(pIE) + ls.push(pIE->getId()); + else + ls.push(""); + + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getIndexInDB(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getIndexInDB) + CLuaStackChecker lsc(&ls, 1); + + // params: CDBCtrlSheet* + // return: index in DB of a dbctrlsheet (empty if error) + CLuaIHM::checkArgCount(ls, "getIndexInDB", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CDBCtrlSheet *pCS= dynamic_cast(pIE); + + // get the index in db + if(pCS) + ls.push((double)pCS->getIndexInDB()); + else + ls.push(0.0); + + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::createGroupInstance(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_createGroupInstance) + const char *funcName = "createGroupInstance"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); + std::vector > templateParams; + CLuaObject params; + params.pop(ls); + ENUM_LUA_TABLE(params, it) + { + if (!it.nextKey().isString()) + { + nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); + continue; + } + if (!it.nextValue().isString()) + { + nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); + continue; + } + templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( + } + CInterfaceManager *im = CInterfaceManager::getInstance(); + CInterfaceGroup *result = im->createGroupInstance(ls.toString(1), ls.toString(2), templateParams); + if (!result) + { + ls.pushNil(); + } + else + { + CLuaIHM::pushUIOnStack(ls, result); + } + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_createGroupInstance) + const char *funcName = "createRootGroupInstance"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); + std::vector > templateParams; + CLuaObject params; + params.pop(ls); + ENUM_LUA_TABLE(params, it) + { + if (!it.nextKey().isString()) + { + nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); + continue; + } + if (!it.nextValue().isString()) + { + nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); + continue; + } + templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( + } + CInterfaceManager *im = CInterfaceManager::getInstance(); + CInterfaceGroup *result = im->createGroupInstance(ls.toString(1), "ui:interface:"+string(ls.toString(2)), templateParams); + if (!result) + { + ls.pushNil(); + } + else + { + result->setId("ui:interface:"+string(ls.toString(2))); + result->updateCoords(); + im->addWindowToMasterGroup("ui:interface", result); + CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + result->setParent(pRoot); + if (pRoot) + pRoot->addGroup(result); + result->setActive(true); + CLuaIHM::pushUIOnStack(ls, result); + } + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::createUIElement(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_createUIElement) + const char *funcName = "addUIElement"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); + std::vector > templateParams; + CLuaObject params; + params.pop(ls); + ENUM_LUA_TABLE(params, it) + { + if (!it.nextKey().isString()) + { + nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); + continue; + } + if (!it.nextValue().isString()) + { + nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); + continue; + } + templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :( + } + CInterfaceManager *im = CInterfaceManager::getInstance(); + CInterfaceElement *result = im->createUIElement(ls.toString(1), ls.toString(2), templateParams); + if (!result) + { + ls.pushNil(); + } + else + { + CLuaIHM::pushUIOnStack(ls, result); + } + return 1; +} + + +// *************************************************************************** +int CLuaIHMRyzom::displayBubble(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_createUIElement) + const char *funcName = "displayBubble"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TTABLE); + std::vector strs; + std::vector links; + CLuaObject params; + params.pop(ls); + ENUM_LUA_TABLE(params, it) + { + if (!it.nextKey().isString()) + { + nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename()); + continue; + } + if (!it.nextValue().isString()) + { + nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str()); + continue; + } + links.push_back(it.nextValue().toString()); + strs.push_back(it.nextKey().toString()); + } + + InSceneBubbleManager.webIgChatOpen((uint32)ls.toNumber(1), ls.toString(2), strs, links); + + return 1; +} + +int CLuaIHMRyzom::launchContextMenuInGame(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_launchContextMenuInGame) + CLuaStackChecker lsc(&ls); + CLuaIHM::checkArgCount(ls, "launchContextMenuInGame", 1); + CLuaIHM::check(ls, ls.isString(1), "launchContextMenuInGame() requires a string in param 1"); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->launchContextMenuInGame(ls.toString(1)); + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::parseInterfaceFromString(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_parseInterfaceFromString) + CLuaStackChecker lsc(&ls, 1); + CLuaIHM::checkArgCount(ls, "parseInterfaceFromString", 1); + CLuaIHM::check(ls, ls.isString(1), "parseInterfaceFromString() requires a string in param 1"); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + std::vector script(1); + script[0] = ls.toString(1); + ls.push(pIM->parseInterface(script, true, false)); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::updateAllLocalisedElements(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_updateAllLocalisedElements) + TTime startTime = CTime::getLocalTime(); + // + CLuaStackChecker lsc(&ls); + CLuaIHM::checkArgCount(ls, "updateAllLocalisedElements", 0); + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->updateAllLocalisedElements(); + // + TTime endTime = CTime::getLocalTime(); + if (ClientCfg.R2EDVerboseParseTime) + { + nlinfo("%.2f seconds for 'updateAllLocalisedElements'", (endTime - startTime) / 1000.f); + } + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getCompleteIslands) + const char *funcName = "getCompleteIslands"; + CLuaIHM::checkArgCount(ls, funcName, 0); + + ls.newTable(); + CLuaObject result(ls); + + // load entryPoints + CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); + const CScenarioEntryPoints::TCompleteIslands& islands = scenarioEntryPoints.getCompleteIslands(); + + CScenarioEntryPoints::TCompleteIslands::const_iterator island(islands.begin()), lastIsland(islands.end()); + for( ; island != lastIsland ; ++island) + { + ls.newTable(); + CLuaObject islandTable(ls); + islandTable.setValue("continent", island->Continent); + islandTable.setValue("xmin", (double)island->XMin); + islandTable.setValue("ymin", (double)island->YMin); + islandTable.setValue("xmax", (double)island->XMax); + islandTable.setValue("ymax", (double)island->YMax); + + ls.newTable(); + CLuaObject entrypointsTable(ls); + + for(uint e=0; eEntryPoints.size(); e++) + { + const CScenarioEntryPoints::CShortEntryPoint & entryPoint = island->EntryPoints[e]; + ls.newTable(); + CLuaObject entrypointTable(ls); + entrypointTable.setValue("x", (double)entryPoint.X); + entrypointTable.setValue("y", (double)entryPoint.Y); + + entrypointsTable.setValue(entryPoint.Location, entrypointTable); + } + islandTable.setValue("entrypoints", entrypointsTable); + + result.setValue(island->Island, islandTable); + } + + result.push(); + + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::getIslandId(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_getIslandId) + const char *funcName = "getIslandId"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::check(ls, ls.isString(1), "getIslandId() requires a string in param 1"); + + + CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance(); + uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1)); + ls.push((double)id); + + return 1; +} + +////////////////////////////////////////// Standard Lua stuff ends here ////////////////////////////////////// + +// *************************************************************************** +sint32 CLuaIHMRyzom::getDbProp(const std::string &dbProp) +{ + //H_AUTO(Lua_CLuaIHM_getDbProp) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); + if(node) + return node->getValue32(); + else + { + debugInfo(toString("getDbProp(): '%s' dbProp Not found", dbProp.c_str())); + return 0; + } +} + +void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value) +{ + //H_AUTO(Lua_CLuaIHM_setDbProp) + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer= "SERVER:"; + static const std::string dbLocal= "LOCAL:"; + static const std::string dbLocalR2= "LOCAL:R2"; + if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || + (0==dbProp.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) + { + nlstop; + throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + } + } + + // Write to the DB if found + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); + + if(node) + node->setValue32(value); + else + debugInfo(toString("setDbProp(): '%s' dbProp Not found", dbProp.c_str())); +} + +void CLuaIHMRyzom::delDbProp(const string &dbProp) +{ + //H_AUTO(Lua_CLuaIHM_setDbProp) + // Do not allow Write on SERVER: or LOCAL: + static const string dbServer= "SERVER:"; + static const string dbLocal= "LOCAL:"; + static const string dbLocalR2= "LOCAL:R2"; + if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || + (0==dbProp.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) + { + nlstop; + throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + } + } + + // Write to the DB if found + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->delDbProp(dbProp); +} + +void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value) +{ + //H_AUTO(Lua_CLuaIHM_setDbProp) + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer= "SERVER:"; + static const std::string dbLocal= "LOCAL:"; + static const std::string dbLocalR2= "LOCAL:R2"; + if( (0==dbProp.compare(0, dbServer.size(), dbServer)) || + (0==dbProp.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2)) + { + nlstop; + throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + } + } + + // Write to the DB if found + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CCDBNodeLeaf *node= pIM->getDbProp(dbProp, true); + if(node) + node->setValue32(value); +} + +// *************************************************************************** +void CLuaIHMRyzom::debugInfo(const std::string &cstDbg) +{ + //H_AUTO(Lua_CLuaIHM_debugInfo) + if(ClientCfg.DisplayLuaDebugInfo) + { + std::string dbg = cstDbg; + if (ClientCfg.LuaDebugInfoGotoButtonEnabled) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + lua_State *ls = pIM->getLuaState()->getStatePointer(); + lua_Debug luaDbg; + if(lua_getstack (ls, 1, &luaDbg)) + { + if(lua_getinfo(ls, "lS", &luaDbg)) + { + // add a command button to jump to the wanted file + dbg = createGotoFileButtonTag(luaDbg.short_src, luaDbg.currentline) + dbg; + } + } + } + rawDebugInfo(dbg); + } +} + +// *************************************************************************** +void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg) +{ + //H_AUTO(Lua_CLuaIHM_rawDebugInfo) + if(ClientCfg.DisplayLuaDebugInfo) + { + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + if (!dbg.empty() && dbg[0] == '@') + { + // if color is already given use the message as it + NLMISC::InfoLog->displayRawNL(dbg.c_str()); + } + else + { + NLMISC::InfoLog->displayRawNL(LuaHelperStuff::formatLuaErrorSysInfo(dbg).c_str()); + } + #ifdef LUA_NEVRAX_VERSION + if (LuaDebuggerIDE) + { + LuaDebuggerIDE->debugInfo(dbg.c_str()); + } + #endif + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); + } +} + + +void CLuaIHMRyzom::dumpCallStack(int startStackLevel) +{ + //H_AUTO(Lua_CLuaIHM_dumpCallStack) + if(ClientCfg.DisplayLuaDebugInfo) + { + lua_Debug dbg; + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + lua_State *ls = pIM->getLuaState()->getStatePointer(); + int stackLevel = startStackLevel; + rawDebugInfo("Call stack : "); + rawDebugInfo("-------------"); + while (lua_getstack (ls, stackLevel, &dbg)) + { + if(lua_getinfo(ls, "lS", &dbg)) + { + std::string result = createGotoFileButtonTag(dbg.short_src, dbg.currentline) + NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); + rawDebugInfo(result); + } + ++ stackLevel; + } + } +} + +// *************************************************************************** +void CLuaIHMRyzom::getCallStackAsString(int startStackLevel /*=0*/,std::string &result) +{ + //H_AUTO(Lua_CLuaIHM_getCallStackAsString) + result.clear(); + lua_Debug dbg; + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + lua_State *ls = pIM->getLuaState()->getStatePointer(); + int stackLevel = startStackLevel; + result += "Call stack : \n"; + result += "-------------"; + while (lua_getstack (ls, stackLevel, &dbg)) + { + if(lua_getinfo(ls, "lS", &dbg)) + { + result += NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline); + } + ++ stackLevel; + } +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getDefine(const std::string &def) +{ + //H_AUTO(Lua_CLuaIHM_getDefine) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + if(ClientCfg.DisplayLuaDebugInfo && !pIM->isDefineExist(def)) + debugInfo(toString("getDefine(): '%s' not found", def.c_str())); + return pIM->getDefine(def); +} + +// *************************************************************************** +void CLuaIHMRyzom::setContextHelpText(const ucstring &text) +{ + //H_AUTO(Lua_CLuaIHM_setContextHelpText) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->setContextHelpText(text); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const ucstring &text) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBox(text); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGroup) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBox(text, masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGroup, int caseMode) +{ + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBox: case mode value is invalid."); + } + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBox(text, masterGroup, (TCaseMode) caseMode); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBox(const std::string &text) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + static volatile bool dumpCallStack = false; + if (dumpCallStack) + { + CLuaIHMRyzom::dumpCallStack(0); + } + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBox(text); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode) +{ + if (caseMode < 0 || caseMode >= CaseCount) + { + throw ELuaIHMException("messageBoxWithHelp: case mode value is invalid."); + } + //H_AUTO(Lua_CLuaIHM_messageBox) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text, masterGroup, "" ,"", (TCaseMode) caseMode); +} + +// *************************************************************************** +void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text) +{ + //H_AUTO(Lua_CLuaIHM_messageBox) + static volatile bool dumpCallStack = false; + if (dumpCallStack) + { + CLuaIHMRyzom::dumpCallStack(0); + } + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + pIM->messageBoxWithHelp(text); +} + +// *************************************************************************** +bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) +{ + //H_AUTO(Lua_CLuaIHM_executeFunctionOnStack) + static volatile bool dumpFunction = false; + if (dumpFunction) + { + CLuaStackRestorer lsr(&ls, ls.getTop()); + lua_Debug ar; + ls.pushValue(-1 - numArgs); + lua_getinfo (ls.getStatePointer(), ">lS", &ar); + nlwarning((std::string(ar.what) + ", at line " + toString(ar.linedefined) + " in " + std::string(ar.source)).c_str()); + } + int result = ls.pcall(numArgs, numRet); + switch (result) + { + case LUA_ERRRUN: + case LUA_ERRMEM: + case LUA_ERRERR: + { + debugInfo(ls.toString(-1)); + ls.pop(); + return false; + } + break; + case 0: + return true; + break; + default: + nlassert(0); + break; + } + return false; +} + +// *************************************************************************** +ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 parameter) +{ + //H_AUTO(Lua_CLuaIHM_replacePvpEffectParam) + ucstring result = str; + CSString s = str.toString(); + std::string p, paramString; + + // Locate parameter and store it + p = s.splitTo('%', true); + while (p.size() > 0 && s.size() > 0) + { + if (s[0] == 'p' || s[0] == 'n' || s[0] == 'r') + { + paramString = "%"; + paramString += s[0]; + break; + } + p = s.splitTo('%', true); + } + + // Return original string if param isn't found + if (paramString.size() < 2) + return str; + + // Replace parameter based on its type + switch (paramString[1]) + { + case 'p': + p = toString("%.1f %%", parameter/100.0); + break; + case 'n': + p = toString(parameter); + break; + case 'r': + p = toString("%.1f", parameter/100.0); + break; + default: + debugInfo("Bad arguments in " + str.toString() + " : " + paramString); + } + + strFindReplace(result, paramString.c_str(), p); + + return result; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::secondsSince1970ToHour(sint32 seconds) +{ + //H_AUTO(Lua_CLuaIHM_secondsSince1970ToHour) + // convert to readable form + struct tm *tstruct; + time_t tval= seconds; + tstruct= gmtime(&tval); + if(!tstruct) + { + debugInfo(toString("Bad Date Received: %d", seconds)); + return 0; + } + + return tstruct->tm_hour; // 0-23 +} + +// *************************************************************************** +void CLuaIHMRyzom::pauseBGDownloader() +{ + ::pauseBGDownloader(); +} + +// *************************************************************************** +void CLuaIHMRyzom::unpauseBGDownloader() +{ + ::unpauseBGDownloader(); +} + +// *************************************************************************** +void CLuaIHMRyzom::requestBGDownloaderPriority(uint priority) +{ + if (priority >= BGDownloader::ThreadPriority_Count) + { + throw NLMISC::Exception("requestBGDownloaderPriority() : invalid priority"); + } + CBGDownloaderAccess::getInstance().requestDownloadThreadPriority((BGDownloader::TThreadPriority) priority, false); +} + +// *************************************************************************** +sint CLuaIHMRyzom::getBGDownloaderPriority() +{ + return CBGDownloaderAccess::getInstance().getDownloadThreadPriority(); +} + +// *************************************************************************** +ucstring CLuaIHMRyzom::getPatchLastErrorMessage() +{ + if (isBGDownloadEnabled()) + { + return CBGDownloaderAccess::getInstance().getLastErrorMessage(); + } + else + { + CPatchManager *pPM = CPatchManager::getInstance(); + return pPM->getLastErrorMessage(); + } +} + +// *************************************************************************** +bool CLuaIHMRyzom::isInGame() +{ + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + return pIM->isInGame(); +} + +// *************************************************************************** +uint32 CLuaIHMRyzom::getPlayerSelectedSlot() +{ + return (uint32) PlayerSelectedSlot; +} + +// *************************************************************************** +bool CLuaIHMRyzom::isPlayerSlotNewbieLand(uint32 slot) +{ + if (slot > CharacterSummaries.size()) + { + throw ELuaIHMException("isPlayerSlotNewbieLand(): Invalid slot %d", (int) slot); + } + return CharacterSummaries[slot].InNewbieland; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getSkillIdFromName(const std::string &def) +{ + //H_AUTO(Lua_CLuaIHM_getSkillIdFromName) + SKILLS::ESkills e= SKILLS::toSkill(def); + // Avoid any bug, return SF if not found + if(e>=SKILLS::unknown) + e= SKILLS::SF; + return e; +} + +// *************************************************************************** +ucstring CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId) +{ + //H_AUTO(Lua_CLuaIHM_getSkillLocalizedName) + return ucstring(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId)); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getMaxSkillValue(sint32 skillId) +{ + //H_AUTO(Lua_CLuaIHM_getMaxSkillValue) + CSkillManager *pSM= CSkillManager::getInstance(); + return pSM->getMaxSkillValue((SKILLS::ESkills)skillId); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getBaseSkillValueMaxChildren(sint32 skillId) +{ + //H_AUTO(Lua_CLuaIHM_getBaseSkillValueMaxChildren) + CSkillManager *pSM= CSkillManager::getInstance(); + return pSM->getBaseSkillValueMaxChildren((SKILLS::ESkills)skillId); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl) +{ + //H_AUTO(Lua_CLuaIHM_getMagicResistChance) + CSPhraseManager *pPM= CSPhraseManager::getInstance(); + casterSpellLvl= std::max(casterSpellLvl, sint32(0)); + victimResistLvl= std::max(victimResistLvl, sint32(0)); + /* The success rate in the table is actually the "Casting Success Chance". + Thus, the relativeLevel is casterSpellLvl - victimResistLvl + Moreover, must take the "PartialSuccessMaxDraw" line because the spell is not resisted if success>0 + */ + sint32 chanceToHit= pPM->getSuccessRate(elementalSpell?CSPhraseManager::STResistMagic:CSPhraseManager::STResistMagicLink, + casterSpellLvl-victimResistLvl, true); + clamp(chanceToHit, 0, 100); + + // Thus, the resist chance is 100 - hit chance. + return 100 - chanceToHit; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getDodgeParryChance(sint32 attLvl, sint32 defLvl) +{ + //H_AUTO(Lua_CLuaIHM_getDodgeParryChance) + CSPhraseManager *pPM = CSPhraseManager::getInstance(); + attLvl= std::max(attLvl, sint32(0)); + defLvl= std::max(defLvl, sint32(0)); + + sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl-attLvl, false); + clamp(chance, 0, 100); + + return chance; +} + +// *************************************************************************** +void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string &urlIn, bool addParameters, double timeout) +{ + //H_AUTO(Lua_CLuaIHM_browseNpcWebPage) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); + if(groupHtml) + { + // if true, it means that we want to display a web page that use webig auth + bool webig = urlIn.find("http://") == 0; + + string url; + // append the WebServer to the url + if (urlIn.find("ring_access_point=1") != std::string::npos) + { + url = RingMainURL + "?" + urlIn; + } + else if(webig) + { + url = urlIn; + } + else + { + url = WebServer + urlIn; + } + + if (addParameters && !webig) + { + // append shardid, playername and language code + string userName; + string guildName; + if(UserEntity) + { + userName = UserEntity->getDisplayName ().toString(); + STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); + ucstring ucsTmp; + pSMC->getString (UserEntity->getGuildNameID(), ucsTmp); + guildName = ucsTmp.toString(); + + while (guildName.find(' ') != string::npos) + { + guildName[guildName.find(' ')] = '_'; + } + } + + url += ((url.find('?') != string::npos) ? "&" : "?") + + string("shard=") + toString(ShardId) + + string("&user_login=") + userName + + string("&lang=") + ClientCfg.getHtmlLanguageCode() + + string("&guild_name=") + guildName; + } +/* Already added by GroupHtml + if(webig) + { + // append special webig auth params + addWebIGParams(url); + } +*/ + // set the wanted timeout + groupHtml->setTimeout((float)std::max(0.0, timeout)); + + // Browse the url + groupHtml->clean(); + groupHtml->browse(url.c_str()); + // Set top of the page + CCtrlScroll *pScroll = groupHtml->getScrollBar(); + if (pScroll != NULL) + pScroll->moveTrackY(10000); + } +} + + +// *************************************************************************** +void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId) +{ + //H_AUTO(Lua_CLuaIHM_clearHtmlUndoRedo) + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); + if(groupHtml) + groupHtml->clearUndoRedo(); +} + +// *************************************************************************** +ucstring CLuaIHMRyzom::getDynString(sint32 dynStringId) +{ + //H_AUTO(Lua_CLuaIHM_getDynString) + ucstring result; + STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); + return result; +} + +// *************************************************************************** +bool CLuaIHMRyzom::isDynStringAvailable(sint32 dynStringId) +{ + //H_AUTO(Lua_CLuaIHM_isDynStringAvailable) + ucstring result; + bool res = STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynStringId, result); + return res; +} + +// *************************************************************************** +bool CLuaIHMRyzom::isFullyPatched() +{ + return AvailablePatchs == 0; +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getSheetType(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getSheetType) + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + if (!sheetPtr) return ""; + return CEntitySheet::typeToString(sheetPtr->Type); +} + + +// *************************************************************************** +std::string CLuaIHMRyzom::getSheetName(uint32 sheetId) +{ + return CSheetId(sheetId).toString(); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getFameIndex(const std::string &factionName) +{ + //H_AUTO(Lua_CLuaIHM_getFameIndex) + return CStaticFames::getInstance().getFactionIndex(factionName); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getFameName(sint32 fameIndex) +{ + //H_AUTO(Lua_CLuaIHM_getFameName) + return CStaticFames::getInstance().getFactionName(fameIndex); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getFameDBIndex(sint32 fameIndex) +{ + //H_AUTO(Lua_CLuaIHM_getFameDBIndex) + // Yoyo: avoid crash if fames not initialized + if(CStaticFames::getInstance().getNbFame()==0) + return 0; + else + return CStaticFames::getInstance().getDatabaseIndex(fameIndex); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getFirstTribeFameIndex() +{ + //H_AUTO(Lua_CLuaIHM_getFirstTribeFameIndex) + return CStaticFames::getInstance().getFirstTribeFameIndex(); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getNbTribeFameIndex() +{ + //H_AUTO(Lua_CLuaIHM_getNbTribeFameIndex) + // Yoyo: avoid crash if fames not initialized. at leasst one tribe + return std::max(1U, CStaticFames::getInstance().getNbTribeFameIndex()); +} + +// *************************************************************************** +string CLuaIHMRyzom::getClientCfg(const string &varName) +{ + //H_AUTO(Lua_CLuaIHM_getClientCfg) + return ClientCfg.readString(varName); +} + +// *************************************************************************** +bool CLuaIHMRyzom::fileExists(const string &fileName) +{ + //H_AUTO(Lua_CLuaIHM_fileExists) + return CPath::exists(fileName); +} + +// *************************************************************************** +void CLuaIHMRyzom::sendMsgToServer(const std::string &sMsg) +{ + //H_AUTO(Lua_CLuaIHM_sendMsgToServer) + ::sendMsgToServer(sMsg); +} + +// *************************************************************************** +void CLuaIHMRyzom::sendMsgToServerPvpTag(bool pvpTag) +{ + //H_AUTO(Lua_CLuaIHM_sendMsgToServerPvpTag) + uint8 tag = (uint8)pvpTag; + ::sendMsgToServer("PVP:PVP_TAG", tag); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isGuildQuitAvailable() +{ + //H_AUTO(Lua_CLuaIHM_isGuildQuitAvailable) + return CGuildManager::getInstance()->getGuild().QuitGuildAvailable; +} + +// *************************************************************************** +void CLuaIHMRyzom::sortGuildMembers() +{ + //H_AUTO(Lua_CLuaIHM_sortGuildMembers) + CGuildManager::getInstance()->sortGuildMembers(); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getNbGuildMembers() +{ + //H_AUTO(Lua_CLuaIHM_getNbGuildMembers) + return (sint32)CGuildManager::getInstance()->getGuildMembers().size(); +} + +// *************************************************************************** +string CLuaIHMRyzom::getGuildMemberName(sint32 nMemberId) +{ + //H_AUTO(Lua_CLuaIHM_getGuildMemberName) + if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) + return ""; + return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name.toString(); +} + +// *************************************************************************** +string CLuaIHMRyzom::getGuildMemberGrade(sint32 nMemberId) +{ + //H_AUTO(Lua_CLuaIHM_getGuildMemberGrade) + if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers())) + return ""; + return EGSPD::CGuildGrade::toString(CGuildManager::getInstance()->getGuildMembers()[nMemberId].Grade); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isR2Player(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_isR2Player) + const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); + if (!entitySheet) return false; + const CCharacterSheet *chSheet = dynamic_cast(entitySheet); + if(!chSheet) return false; + return chSheet->R2Npc; +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getR2PlayerRace(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getR2PlayerRace) + const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); + if (!entitySheet) return ""; + const CCharacterSheet *chSheet = dynamic_cast(entitySheet); + if(!chSheet) return ""; + return EGSPD::CPeople::toString(chSheet->Race); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isR2PlayerMale(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_isR2PlayerMale) + const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet)); + if (!entitySheet) return true; + const CCharacterSheet *chSheet = dynamic_cast(entitySheet); + if(!chSheet) return true; + + return (chSheet->Gender == GSGENDER::male); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getCharacterSheetSkel(const std::string &sheet, bool isMale) +{ + //H_AUTO(Lua_CLuaIHM_getCharacterSheetSkel) + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + const CCharacterSheet *charSheet = dynamic_cast(sheetPtr); + if (charSheet) return charSheet->getSkelFilename(); + const CRaceStatsSheet *raceStatSheet = dynamic_cast(sheetPtr); + if (raceStatSheet) return raceStatSheet->GenderInfos[isMale ? 0 : 1].Skelfilename; + return ""; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getSheetId(const std::string &itemName) +{ + //H_AUTO(Lua_CLuaIHM_getSheetId) + return (sint32)CSheetId(itemName).asInt(); +} + +// *************************************************************************** +sint CLuaIHMRyzom::getCharacterSheetRegionForce(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionForce) + const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet))); + if (!charSheet) return 0; + return charSheet->RegionForce; +} + +// *************************************************************************** +sint CLuaIHMRyzom::getCharacterSheetRegionLevel(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionLevel) + const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet))); + if (!charSheet) return 0; + return charSheet->RegionForce; +} + +// *************************************************************************** +string CLuaIHMRyzom::getRegionByAlias(uint32 alias) +{ + //H_AUTO(Lua_CLuaIHM_getRegionByAlias) + return ContinentMngr.getRegionNameByAlias(alias); +} + +// *************************************************************************** +void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) +{ + //H_AUTO(Lua_CLuaIHM_tell) + // display a /tell command in the main chat + if (!player.empty()) + { + if (!msg.empty()) + { + // Parse any tokens in the message. + ucstring msg_modified = msg; + // Parse any tokens in the text + if ( ! CInterfaceManager::parseTokens(msg_modified)) + { + return; + } + ChatMngr.tell(player.toUtf8(), msg_modified); + } + else + { + CChatWindow *w = PeopleInterraction.ChatGroup.Window; + if (w) + { + CInterfaceManager *im = CInterfaceManager::getInstance(); + w->setKeyboardFocus(); + w->enableBlink(1); + w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false); + CGroupEditBox *eb = w->getEditBox(); + if (eb != NULL) + { + eb->bypassNextKey(); + } + if (w->getContainer()) + { + w->getContainer()->setActive(true); + im->setTopWindow(w->getContainer()); + } + } + } + } +} + +// *************************************************************************** +bool CLuaIHMRyzom::isRingAccessPointInReach() +{ + //H_AUTO(Lua_CLuaIHM_isRingAccessPointInReach) + if (BotChatPageAll->RingSessions->RingAccessPointPos == CVector::Null) return false; + const CVectorD &vect1 = BotChatPageAll->RingSessions->RingAccessPointPos; + CVectorD vect2 = UserEntity->pos(); + double distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2); + return distanceSquare <= MaxTalkingDistSquare; +} + +// *************************************************************************** +void CLuaIHMRyzom::updateTooltipCoords() +{ + CInterfaceManager::getInstance()->updateTooltipCoords(); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isCtrlKeyDown() +{ + //H_AUTO(Lua_CLuaIHM_isCtrlKeyDown) + bool ctrlDown = Driver->AsyncListener.isKeyDown(KeyLCONTROL) || + Driver->AsyncListener.isKeyDown(KeyRCONTROL); + if (ctrlDown) nlwarning("ctrl down"); + else nlwarning("ctrl up"); + return ctrlDown; +} + +// *************************************************************************** +std::string CLuaIHMRyzom::encodeURLUnicodeParam(const ucstring &text) +{ + //H_AUTO(Lua_CLuaIHM_encodeURLUnicodeParam) + return convertToHTML(text.toUtf8()); +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getPlayerLevel() +{ + if (!UserEntity) return -1; + CSkillManager *pSM= CSkillManager::getInstance(); + uint32 maxskill = pSM->getBestSkillValue(SKILLS::SC); + maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SF)); + maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SH)); + maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SM)); + return sint32(maxskill); +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getPlayerVpa() +{ + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return prop; +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getPlayerVpb() +{ + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return prop; +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getPlayerVpc() +{ + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return prop; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getTargetLevel() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return -1; + if ( target->isPlayer() ) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + return pDbPlayerLevel ? pDbPlayerLevel->getValue32() : -1; + } + else + { + CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); + if(!pCS) return -1; + // only display the consider if the target is attackable #523 + if(!pCS->Attackable) return -1; + if(!target->properties().attackable()) return -1; + return sint32(pCS->Level); + } + return -1; +} + +// *************************************************************************** +ucstring CLuaIHMRyzom::getTargetSheet() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return ucstring(); + + return target->sheetId().toString(); +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getTargetVpa() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + + return prop; +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getTargetVpb() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + + return prop; +} + +// *************************************************************************** +sint64 CLuaIHMRyzom::getTargetVpc() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + + return prop; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getTargetForceRegion() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return -1; + if ( target->isPlayer() ) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + if (!pDbPlayerLevel) return -1; + sint nLevel = pDbPlayerLevel->getValue32(); + if ( nLevel < 250 ) + { + return (sint32) ((nLevel < 20) ? 1 : (nLevel / 50) + 2); + } + else + { + return 8; + } + } + else + { + CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); + return pCS ? (sint32) pCS->RegionForce : -1; + } + return 0; +} + +// *************************************************************************** +sint32 CLuaIHMRyzom::getTargetLevelForce() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return -1; + if ( target->isPlayer() ) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + if (!pDbPlayerLevel) return -1; + sint nLevel = pDbPlayerLevel->getValue32(); + if ( nLevel < 250 ) + { + return (sint32) (((nLevel % 50) * 5 / 50) + 1); + } + else + { + return 6; + } + } + else + { + CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId())); + return pCS ? (sint32) pCS->ForceLevel : -1; + } + return 0; +} + +// *************************************************************************** +bool CLuaIHMRyzom::isTargetNPC() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return false; + return target->isNPC(); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isTargetPlayer() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return false; + return target->isPlayer(); +} + + +// *************************************************************************** +bool CLuaIHMRyzom::isTargetUser() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return false; + return target->isUser(); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isPlayerInPVPMode() +{ + if (!UserEntity) return false; + return (UserEntity->getPvpMode() & PVP_MODE::PvpFaction || UserEntity->getPvpMode() & PVP_MODE::PvpFactionFlagged || UserEntity->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; +} + +// *************************************************************************** +bool CLuaIHMRyzom::isTargetInPVPMode() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return false; + return (target->getPvpMode() & PVP_MODE::PvpFaction || target->getPvpMode() & PVP_MODE::PvpFactionFlagged || target->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; +} + +// *************************************************************************** +std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint line) +{ + //H_AUTO(Lua_CLuaIHM_createGotoFileButtonTag) + if (ClientCfg.LuaDebugInfoGotoButtonEnabled) + { + // TODO nico : put this in the interface + // add a command button to jump to the wanted file + return toString("/$$%s|%s|lua|%s('%s', %d)$$/", + ClientCfg.LuaDebugInfoGotoButtonTemplate.c_str(), + ClientCfg.LuaDebugInfoGotoButtonCaption.c_str(), + ClientCfg.LuaDebugInfoGotoButtonFunction.c_str(), + fileName, + line + ); + } + return ""; +} diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h new file mode 100644 index 000000000..200adbab6 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -0,0 +1,257 @@ +#ifndef LUA_IHM_RYZOM_H +#define LUA_IHM_RYZOM_H + +#include "lua_ihm.h" + +class CLuaIHMRyzom +{ +public: + static void RegisterRyzomFunctions( NLGUI::CLuaState &ls ); + +private: + static void createLuaEnumTable(CLuaState &ls, const std::string &str); + + + static int getUI(CLuaState &ls); // params: "ui:interface:...". return: CInterfaceElement* (nil if error), an additionnal boolean parameter + // LUA exported Functions with standard lua (because use ui object, use variable param number, or return dynamic-typed object) + static int setCaptureKeyboard(CLuaState &ls); + static int resetCaptureKeyboard(CLuaState &ls); + static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none + static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none + static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none + static int getUICaller(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if error) + static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none) + // can specify verbose display when the element is note found (default is true) + static int createGroupInstance(CLuaState &ls); // params : param 1 = template name, + // param 2 = id of parent where the instance will be inserted + // param 3 = table with ("template_param", "template_param_value") key/value pairs + // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail + static int createRootGroupInstance(CLuaState &ls); // params : param 1 = template name, + // param 2 = id of parent where the instance will be inserted + // param 3 = table with ("template_param", "template_param_value") key/value pairs + // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail + static int createUIElement(CLuaState &ls); // params : param 1 = template name, + // param 2 = id of parent where the instance will be inserted + // param 3 = table with ("template_param", "template_param_value") key/value pairs + // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail + + static int displayBubble(CLuaState &ls); // params : param 1 = bot id + // param 2 = text + // param 3 = table with all strings and urls + // {"main text"="http:///", "text option 1"="http:///", "text option 2"="http:///") etc... + static int getIndexInDB(CLuaState &ls); // params: CDBCtrlSheet*.... return: index, or 0 if error + static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error) + static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none + static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString + static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString + static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false + static int formatUI(CLuaState &ls); // params: "expr", param1, param2.... return: string with # and % parsed + static int formatDB(CLuaState &ls); // params: param1, param2.... return: string with @ and , added + static int launchContextMenuInGame(CLuaState &ls); // params : menu name + static int parseInterfaceFromString(CLuaState &ls); // params : intreface script + static int updateAllLocalisedElements(CLuaState &ls); + static int breakPoint(CLuaState &ls); + static int getWindowSize(CLuaState &ls); + static int i18n(CLuaState &ls); // retrieve an unicode string from CI18N + static int setTextFormatTaged(CLuaState &ls); // set a text that may contains Tag Format infos + static int validMessageBox(CLuaState &ls); // ok/cancel type message box (can't get it to work through luabind) + static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ... + static int concatString(CLuaState &ls); // speedup concatenation of several strings + static int tableToString(CLuaState &ls); // concat element of a table to build a string + static int setTopWindow(CLuaState &ls); // set the top window + static int initEmotesMenu(CLuaState &ls); + static int isUCString(CLuaState &ls); + static int hideAllWindows(CLuaState &ls); + static int hideAllNonSavableWindows(CLuaState &ls); + static int getDesktopIndex(CLuaState &ls); + static int setLuaBreakPoint(CLuaState &ls); // set a breakpoint in lua external debugger (file, line) + static int getMainPageURL(CLuaState &ls); + static int getCharSlot(CLuaState &ls); + static int displaySystemInfo(CLuaState &ls); + static int setWeatherValue(CLuaState &ls); // first value is a boolean to say automatic, second value ranges from of to 1 and gives the weather + static int getWeatherValue(CLuaState &ls); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored + static int disableContextHelpForControl(CLuaState &ls); // params: CCtrlBase*. return: none + static int disableContextHelp(CLuaState &ls); + static int getPathContent(CLuaState &ls); + static int getServerSeason(CLuaState &ls); // get the last season sent by the server + // 0->auto, computed locally from the current day (or not received from server yet) + // 1->server force spring + // 2->' ' ' summer + // 3->' ' ' autumn + // 4->' ' ' winter + static int computeCurrSeason(CLuaState &ls); // compute current displayed season (1->spring, etc .) + static int getAutoSeason(CLuaState &ls); // compute automatic season that would be at this time (1->spring, etc .) + + + static int getTextureSize(CLuaState &ls); + static int enableModalWindow(CLuaState &ls); + static int disableModalWindow(CLuaState &ls); + static int getPlayerPos(CLuaState &ls); + static int getPlayerFront(CLuaState &ls); + static int getPlayerDirection(CLuaState &ls); + static int getPlayerGender(CLuaState &ls); + static int getPlayerName(CLuaState &ls); + static int getPlayerTitleRaw(CLuaState &ls); + static int getPlayerTitle(CLuaState &ls); + static int getTargetPos(CLuaState &ls); + static int getTargetFront(CLuaState &ls); + static int getTargetDirection(CLuaState &ls); + static int getTargetGender(CLuaState &ls); + static int getTargetName(CLuaState &ls); + static int getTargetTitleRaw(CLuaState &ls); + static int getTargetTitle(CLuaState &ls); + static int addSearchPathUser(CLuaState &ls); + static int getClientCfgVar(CLuaState &ls); + static int isPlayerFreeTrial(CLuaState &ls); + static int isPlayerNewbie(CLuaState &ls); + static int isInRingMode(CLuaState &ls); + static int getUserRace(CLuaState &ls); + static int getSheet2idx(CLuaState &ls); + static int getTargetSlot(CLuaState &ls); + static int getSlotDataSetId(CLuaState &ls); + + // LUA functions exported for Dev only (debug) + static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none + static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none + static int dumpUI(CLuaState &ls); // params: CInterfaceElement*.... return: none + static int setKeyboardContext(CLuaState &ls); + + static int getCompleteIslands(CLuaState &ls); + static int getIslandId(CLuaState &ls);//TEMP + + + ///////////////////////////// Standard Lua stuff ends here ////////////////////////////////////////////// + + static sint32 getDbProp(const std::string &dbProp); // return 0 if not found. + static void setDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is not created if not present. + static void addDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is created if not present. + static void delDbProp(const std::string &dbProp); + +public: + // Print a message in the log. + // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1) + // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then + // a button will be created near the line to allow to goto the lua line that issued the message + // by using an external editor + static void debugInfo(const std::string &dbg); + // Print a message in the log + // No 'goto file' button is created + // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1) + + static void dumpCallStack(int startStackLevel = 0); + + /** execute function that is currently on the stack, possibly outputing error messages to the log + * \return true if execution succeeded + */ + static bool executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet); + +private: + static void rawDebugInfo(const std::string &dbg); + // Dump callstack in the console + // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then + // buttons will be created in fonr of eahc line to allow to goto the lua line that issued the message + // by using an external editor + + static void getCallStackAsString(int startStackLevel, std::string &result); + static std::string getDefine(const std::string &def); + static void setContextHelpText(const ucstring &text); + + + static void messageBox(const ucstring &text); + static void messageBox(const ucstring &text, const std::string &masterGroup); + static void messageBox(const ucstring &text, const std::string &masterGroup, int caseMode); + static void messageBox(const std::string &text); + static void messageBoxWithHelp(const ucstring &text); + static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup); + static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode); + static void messageBoxWithHelp(const std::string &text); + + static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); + static sint32 secondsSince1970ToHour(sint32 seconds); + static void pauseBGDownloader(); + static void unpauseBGDownloader(); + static void requestBGDownloaderPriority(uint priority); + static sint getBGDownloaderPriority(); + static ucstring getPatchLastErrorMessage(); + static bool isInGame(); + static uint32 getPlayerSelectedSlot(); + static bool isPlayerSlotNewbieLand(uint32 slot); // test if one of the player slot is a newbieland one, if not so, client must be patched in order to continue + + // GameInfo + static sint32 getSkillIdFromName(const std::string &def); + static ucstring getSkillLocalizedName(sint32 skillId); + static sint32 getMaxSkillValue(sint32 skillId); + static sint32 getBaseSkillValueMaxChildren(sint32 skillId); + static sint32 getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl); + static sint32 getDodgeParryChance(sint32 attLvl, sint32 defLvl); + static void browseNpcWebPage(const std::string &htmlId, const std::string &url, bool addParameters, double timeout); + static void clearHtmlUndoRedo(const std::string &htmlId); + static ucstring getDynString(sint32 dynStringId); + static bool isDynStringAvailable(sint32 dynStringId); + static bool isFullyPatched(); + static std::string getSheetType(const std::string &sheet); + static std::string getSheetName(uint32 sheetId); + static sint32 getFameIndex(const std::string &factionName); + static std::string getFameName(sint32 fameIndex); + static sint32 getFameDBIndex(sint32 fameIndex); // convert from the fame index + static sint32 getFirstTribeFameIndex(); // fame index of the 1st tribe + static sint32 getNbTribeFameIndex(); // number of tribe fame index (which are contiguous) + static std::string getClientCfg(const std::string &varName); + static bool fileExists(const std::string &fileName); + static void sendMsgToServer(const std::string &msgName); + static void sendMsgToServerPvpTag(bool pvpTag); + static bool isGuildQuitAvailable(); + static void sortGuildMembers(); + static sint32 getNbGuildMembers(); + static std::string getGuildMemberName(sint32 nMemberId); + static std::string getGuildMemberGrade(sint32 nMemberId); + static bool isR2Player(const std::string &sheet); + static std::string getR2PlayerRace(const std::string &sheet); + static bool isR2PlayerMale(const std::string &sheet); + // sheet access + // TODO nico : using the reflection system on sheets would allow to export them to lua without these functions ... + static std::string getCharacterSheetSkel(const std::string &sheet, bool isMale); + static sint32 getSheetId(const std::string &itemName); + static sint getCharacterSheetRegionForce(const std::string &sheet); + static sint getCharacterSheetRegionLevel(const std::string &sheet); + static std::string getRegionByAlias(uint32 alias); + // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly + // else, current command of the chat window will be replaced with tell 'player' + static void tell(const ucstring &player, const ucstring &msg); + static bool isRingAccessPointInReach(); + static void updateTooltipCoords(); + // test if the ctrl key is down (NB nico : I didn't add other key, + // because it would be too easy to write a key recorder ...) + static bool isCtrlKeyDown(); + static std::string encodeURLUnicodeParam(const ucstring &text); + + static sint32 getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging) + static sint64 getPlayerVpa(); + static sint64 getPlayerVpb(); + static sint64 getPlayerVpc(); + static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target + static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target + static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target + static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') + static sint64 getTargetVpa(); + static sint64 getTargetVpb(); + static sint64 getTargetVpc(); + static bool isTargetNPC(); // return 'true' if the target is an npc + static bool isTargetPlayer(); // return 'true' if the target is a player + static bool isTargetUser(); // return 'true' if the target is the user + static bool isPlayerInPVPMode(); + static bool isTargetInPVPMode(); + + +public: + + // Create a special tag that will add a 'goto' button for the given file and line + // The tag should be appended in front of a string to use with 'rawDebugInfo'. + // when the final string will be printed, a button will be created in front of it + // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else + // a, empty tag is returned + static std::string createGotoFileButtonTag(const char *fileName, uint line); +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/lua_object.cpp b/code/ryzom/client/src/interface_v3/lua_object.cpp index 17b703457..209d7ba0c 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.cpp +++ b/code/ryzom/client/src/interface_v3/lua_object.cpp @@ -14,13 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdpch.h" +//#include "stdpch.h" #include "lua_object.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/gui/lua_helper.h" using namespace NLGUI; // -#include "interface_manager.h" +//#include "interface_manager.h" //////////////// // CLuaObject // @@ -616,7 +617,7 @@ void CLuaObject::dump(uint maxDepth /*= 20*/, std::set *alreadySee } catch(const std::exception &e) { - CLuaIHM::dumpCallStack(); + CLuaIHMRyzom::dumpCallStack(); nlwarning(e.what()); } } diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 6a4dc36d6..e05349985 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -28,8 +28,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" - -#include "lua_ihm.h" +#include "lua_ihm_ryzom.h" using namespace std; using namespace NLMISC; @@ -2416,7 +2415,7 @@ void CViewText::setTextFormatTaged(const ucstring &text) // color format is available only if multilined if (!_MultiLine) - CLuaIHM::debugInfo(toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str())); + CLuaIHMRyzom::debugInfo(toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str())); } @@ -2473,7 +2472,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text) // this color format is available only if not multilined if (_MultiLine) - CLuaIHM::debugInfo(toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str())); + CLuaIHMRyzom::debugInfo(toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str())); } diff --git a/code/ryzom/client/src/r2/displayer_lua.cpp b/code/ryzom/client/src/r2/displayer_lua.cpp index 540e1ea1f..f73960f3a 100644 --- a/code/ryzom/client/src/r2/displayer_lua.cpp +++ b/code/ryzom/client/src/r2/displayer_lua.cpp @@ -17,6 +17,7 @@ #include "stdpch.h" #include "displayer_lua.h" #include "../interface_v3/lua_ihm.h" +#include "../interface_v3/lua_ihm_ryzom.h" #include "editor.h" namespace R2 @@ -45,7 +46,7 @@ bool CDisplayerLua::init(const CLuaObject ¶meters) } CLuaState &ls = *parameters.getLuaState(); getEditor().getEnv().push(); // this is a method call - if (CLuaIHM::executeFunctionOnStack(ls, 1, 1)) + if (CLuaIHMRyzom::executeFunctionOnStack(ls, 1, 1)) { _ToLua._LuaTable.pop(ls); } @@ -94,7 +95,7 @@ void CDisplayerLua::CToLua::executeHandler(const CLuaString &eventName, int numA getEnclosing()->getDisplayedInstance()->getLuaProjection().push(); ls.insert(- numArgs - 1); if (dumpStackWanted) ls.dumpStack(); - CLuaIHM::executeFunctionOnStack(*_LuaTable.getLuaState(), numArgs + 2, 0); + CLuaIHMRyzom::executeFunctionOnStack(*_LuaTable.getLuaState(), numArgs + 2, 0); if (dumpStackWanted) ls.dumpStack(); } diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp index 2d15b18f6..7c94d7560 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -37,6 +37,7 @@ #include "../editor.h" #include "../../net_manager.h" #include "../../interface_v3/lua_ihm.h" +#include "../../interface_v3/lua_ihm_ryzom.h" #include "game_share/object.h" #include "../r2_lua.h" @@ -797,7 +798,7 @@ sint CComLuaModule::luaRequestSetNode(lua_State* state) static volatile bool dumpCallstack = false; if (dumpCallstack) { - CLuaIHM::dumpCallStack(); + CLuaIHMRyzom::dumpCallStack(); } return requestSetNode(state, false); } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 9daa5db70..f2a6119e6 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -59,6 +59,7 @@ using namespace NLGUI; #include "../interface_v3/group_tree.h" #include "../client_cfg.h" #include "../interface_v3/lua_ihm.h" +#include "../interface_v3/lua_ihm_ryzom.h" #include "../interface_v3/lua_object.h" #include "../global.h" #include "../connection.h" @@ -3213,7 +3214,7 @@ void CEditor::initObjectProjectionMetatable() ls.push(true); return 1; } - CLuaIHM::dumpCallStack(); + CLuaIHMRyzom::dumpCallStack(); // object has been deleted but the script maintains a reference on it throw ELuaWrappedFunctionException(&ls, "Attempt to access an erased object"); } @@ -3230,14 +3231,14 @@ void CEditor::initObjectProjectionMetatable() else { // 'bad index' message already printed by CObject::getValue - CLuaIHM::dumpCallStack(); + CLuaIHMRyzom::dumpCallStack(); } } if (!ls.isString(2)) { nlwarning("String expected when accessing an object property, %s found instead", ls.getTypename(2)); - CLuaIHM::dumpCallStack(0); + CLuaIHMRyzom::dumpCallStack(0); return 0; } @@ -3554,7 +3555,7 @@ void CEditor::initObjectProjectionMetatable() { nlwarning("Duplicated key of type string found while attempting to enumerate an instance content."); nlwarning("key is %s", key.c_str()); - CLuaIHM::dumpCallStack(1); + CLuaIHMRyzom::dumpCallStack(1); CLuaIHM::fails(ls, "Aborting to avoid infinite loop."); } keys.insert(key); @@ -3623,7 +3624,7 @@ void CEditor::initObjectProjectionMetatable() static volatile bool from = false; if (from) { - CLuaIHM::dumpCallStack(0); + CLuaIHMRyzom::dumpCallStack(0); } nlassert(ls.getTop() == 2); if (!checkTag(ls)) return false; @@ -4432,7 +4433,7 @@ bool CEditor::doLuaScript(const char *filename, const char *fileDescText) std::string filename = msg.substr(0, extPos + 4); // extract filename including extension int line; fromString(&*(msg.begin() + extPos + 5), line); // line number follows - nlwarning((CLuaIHM::createGotoFileButtonTag(filename.c_str(), line) + e.what()).c_str()); + nlwarning((CLuaIHMRyzom::createGotoFileButtonTag(filename.c_str(), line) + e.what()).c_str()); } else { diff --git a/code/ryzom/client/src/r2/instance.cpp b/code/ryzom/client/src/r2/instance.cpp index c4287928a..00d32e750 100644 --- a/code/ryzom/client/src/r2/instance.cpp +++ b/code/ryzom/client/src/r2/instance.cpp @@ -26,6 +26,7 @@ #include "../entities.h" #include "../interface_v3/interface_manager.h" #include "../interface_v3/lua_ihm.h" +#include "../interface_v3/lua_ihm_ryzom.h" // #include "displayer_visual_entity.h" @@ -631,7 +632,7 @@ void CInstance::CToLua::executeHandler(const CLuaString &name, int numArgs) ls.insert(- numArgs - 1); // if (dumpStackWanted) ls.dumpStack(); - CLuaIHM::executeFunctionOnStack(ls, numArgs + 1, 0); + CLuaIHMRyzom::executeFunctionOnStack(ls, numArgs + 1, 0); if (dumpStackWanted) ls.dumpStack(); } diff --git a/code/ryzom/client/src/r2/object_factory_client.cpp b/code/ryzom/client/src/r2/object_factory_client.cpp index a8ad45e3d..81d4c085d 100644 --- a/code/ryzom/client/src/r2/object_factory_client.cpp +++ b/code/ryzom/client/src/r2/object_factory_client.cpp @@ -19,6 +19,7 @@ #include "editor.h" #include "instance.h" #include "../interface_v3/lua_ihm.h" +#include "../interface_v3/lua_ihm_ryzom.h" namespace R2 { @@ -287,7 +288,7 @@ void CObjectRefIdClient::getNameInParent(std::string &name, sint32 &indexInArray } // TMP TMP nlwarning("========================================="); - CLuaIHM::dumpCallStack(); + CLuaIHMRyzom::dumpCallStack(); nlwarning("========================================="); nlwarning("ObservedObject = %s", getValue().c_str()); CInstance *obsInstance = getEditor().getInstanceFromId(getValue().c_str()); From 4db9e47d1324e57e8add9688004941aab40527a5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 23 May 2012 02:41:43 +0200 Subject: [PATCH 028/339] Added: #1471 CLuaManager, Singleton for the Lua state, the code parts that depend on a globally available Lua state now depend on this instead of CInterfaceManager. Also refactored the code so it's ready to be moved to the NELGUI lib. --- code/ryzom/client/src/commands.cpp | 3 +- code/ryzom/client/src/debug_client.cpp | 3 +- code/ryzom/client/src/init_main_loop.cpp | 3 +- .../client/src/interface_v3/ctrl_scroll.cpp | 5 +- .../src/interface_v3/ctrl_text_button.cpp | 3 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 9 +- .../client/src/interface_v3/group_list.cpp | 19 +- .../client/src/interface_v3/group_menu.cpp | 19 +- .../client/src/interface_v3/group_tab.cpp | 9 +- .../client/src/interface_v3/group_tree.cpp | 3 +- .../src/interface_v3/interface_element.cpp | 26 +- .../src/interface_v3/interface_element.h | 13 - .../src/interface_v3/interface_group.cpp | 16 +- .../src/interface_v3/interface_manager.cpp | 4 +- .../src/interface_v3/interface_manager.h | 2 - .../src/interface_v3/interface_parser.cpp | 11 +- .../ryzom/client/src/interface_v3/lua_ihm.cpp | 826 +----------------- code/ryzom/client/src/interface_v3/lua_ihm.h | 19 - .../client/src/interface_v3/lua_ihm_ryzom.cpp | 738 +++++++++++++++- .../client/src/interface_v3/lua_ihm_ryzom.h | 21 + .../client/src/interface_v3/lua_manager.cpp | 34 + .../client/src/interface_v3/lua_manager.h | 57 ++ .../client/src/interface_v3/lua_object.cpp | 4 +- .../ryzom/client/src/interface_v3/reflect.cpp | 62 +- code/ryzom/client/src/interface_v3/reflect.h | 25 +- code/ryzom/client/src/main_loop.cpp | 16 +- code/ryzom/client/src/r2/editor.cpp | 5 +- code/ryzom/client/src/release.cpp | 3 + 28 files changed, 978 insertions(+), 980 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/lua_manager.cpp create mode 100644 code/ryzom/client/src/interface_v3/lua_manager.h diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 433bd2d49..3f0855f87 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -99,6 +99,7 @@ #include "interface_v3/people_interraction.h" #include "far_tp.h" #include "zone_util.h" +#include "interface_v3/lua_manager.h" // @@ -5146,7 +5147,7 @@ NLMISC_COMMAND(luaObject, "Dump the content of a lua object", "
[max pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } - CLuaState *luaState = pIM->getLuaState(); + CLuaState *luaState = CLuaManager::getInstance().getLuaState(); if (!luaState) return false; CLuaStackChecker lsc(luaState); // get the table diff --git a/code/ryzom/client/src/debug_client.cpp b/code/ryzom/client/src/debug_client.cpp index c12b2d6e0..c989a09f5 100644 --- a/code/ryzom/client/src/debug_client.cpp +++ b/code/ryzom/client/src/debug_client.cpp @@ -45,6 +45,7 @@ using namespace NLGUI; #include "character_cl.h" #include "r2/editor.h" #include "r2/dmc/client_edition_module.h" +#include "interface_v3/lua_manager.h" /////////// // USING // @@ -327,7 +328,7 @@ void displayStreamingDebug () SpfGraph.addOneValue (1000.f*(float)deltaTime); // lua memory - LuaMemGraph.addOneValue(CInterfaceManager::getInstance()->getLuaState()->getGCCount() / 1024.f); + LuaMemGraph.addOneValue(CLuaManager::getInstance().getLuaState()->getGCCount() / 1024.f); // Count of waitinf instance CurrentTaskGraph.addOneValue (CAsyncFileManager::getInstance().isTaskRunning()?1.f:0.f); diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 45fa7b59e..fafb7ef34 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -104,6 +104,7 @@ #include "landscape_poly_drawer.h" #include "session_browser_impl.h" +#include "interface_v3/lua_manager.h" // ProgressBar steps in init main loop @@ -1320,7 +1321,7 @@ void initMainLoop() // init CSessionBrowserImpl - CSessionBrowserImpl::getInstance().init(CInterfaceManager::getInstance()->getLuaState()); + CSessionBrowserImpl::getInstance().init(CLuaManager::getInstance().getLuaState()); // active/desactive welcome window initWelcomeWindow(); diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 252ff3236..f9abe1f3a 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -23,6 +23,7 @@ #include "group_menu.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" using namespace NLMISC; using namespace std; @@ -916,7 +917,7 @@ int CCtrlScroll::luaEnsureVisible(CLuaState &ls) { const char *funcName = "ensureVisible"; CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); + CLuaIHMRyzom::checkArgTypeUIElement(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); THotSpot hs[2]; @@ -967,7 +968,7 @@ int CCtrlScroll::luaEnsureVisible(CLuaState &ls) } } } - ensureVisible(CLuaIHM::getUIOnStack(ls, 1), hs[0], hs[1]); + ensureVisible(CLuaIHMRyzom::getUIOnStack(ls, 1), hs[0], hs[1]); return 0; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index de302dbb1..17e713992 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -27,6 +27,7 @@ #include "view_text_id.h" #include "group_container.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" // *************************************************************************** @@ -548,7 +549,7 @@ int CCtrlTextButton::luaGetViewText(CLuaState &ls) { const char *funcName = "getViewText"; CLuaIHM::checkArgCount(ls, funcName, 0); - CLuaIHM::pushUIOnStack(ls, getViewText()); + CLuaIHMRyzom::pushUIOnStack(ls, getViewText()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 46efd5514..06f16e379 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -45,10 +45,13 @@ #include "../client_sheets/sphrase_sheet.h" #include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "game_share/bot_chat_types.h" #include "../r2/editor.h" +#include "lua_manager.h" + extern CSheetManager SheetMngr; using namespace std; @@ -101,7 +104,7 @@ ucstring CControlSheetTooltipInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet, // delegate setup of context he help ( & window ) to lua CInterfaceManager *im = CInterfaceManager::getInstance(); - CLuaState *ls= im->getLuaState(); + CLuaState *ls= CLuaManager::getInstance().getLuaState(); { CLuaStackRestorer lsr(ls, 0); @@ -128,7 +131,7 @@ ucstring CControlSheetTooltipInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet, // *************************************************************************** int CDBCtrlSheet::luaGetDraggedSheet(CLuaState &ls) { - CLuaIHM::pushUIOnStack(ls, dynamic_cast(_LastDraggedSheet)); + CLuaIHMRyzom::pushUIOnStack(ls, dynamic_cast(_LastDraggedSheet)); return 1; } @@ -3160,7 +3163,7 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const { // delegate setup of context he help ( & window ) to lua CInterfaceManager *im = CInterfaceManager::getInstance(); - CLuaState *ls= im->getLuaState(); + CLuaState *ls= CLuaManager::getInstance().getLuaState(); { CLuaStackRestorer lsr(ls, 0); CSPhraseManager *pPM= CSPhraseManager::getInstance(); diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index d157543a7..792958295 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -26,8 +26,7 @@ #include "view_text_id.h" #include "group_container.h" #include "lua_ihm.h" - -#include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/misc/xml_auto_ptr.h" @@ -916,7 +915,7 @@ sint32 CGroupList::getElementIndex(CViewBase* child) const int CGroupList::luaGetElementIndex(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getElementIndex", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); ls.push((double) getElementIndex(viewBase)); return 1; } @@ -968,7 +967,7 @@ void CGroupList::swapChildren(uint index1, uint index2) int CGroupList::luaUpChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "upChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); sint32 indexUpChild = getElementIndex(viewBase); if(indexUpChild > 0) { @@ -981,7 +980,7 @@ int CGroupList::luaUpChild(CLuaState &ls) int CGroupList::luaDownChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "downChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); sint32 indexDownChild = getElementIndex(viewBase); if(indexDownChild < (sint32) (_Elements.size()-1)) { @@ -1002,7 +1001,7 @@ int CGroupList::luaGetChild(CLuaState &ls) CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements", index, getId().c_str(), (int) _Elements.size()); } - CLuaIHM::pushUIOnStack(ls, getChild((uint) index)); + CLuaIHMRyzom::pushUIOnStack(ls, getChild((uint) index)); return 1; } @@ -1091,7 +1090,7 @@ int CGroupList::luaAddChild(CLuaState &ls) { const char *funcName = "addChild"; CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (!vb) { CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); @@ -1109,7 +1108,7 @@ int CGroupList::luaAddChildAtIndex(CLuaState &ls) const char *funcName = "addChildAtIndex"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (!vb) { CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); @@ -1126,7 +1125,7 @@ int CGroupList::luaDetachChild(CLuaState &ls) { const char *funcName = "detachChild"; CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (!vb) { nlwarning("%s requires a view, group or control", funcName); @@ -1143,7 +1142,7 @@ int CGroupList::luaDetachChild(CLuaState &ls) int CGroupList::luaDelChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CGroupList::delChild", 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (vb) delChild(vb); updateCoords(); return 0; diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 137dcec10..782c1f943 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -25,6 +25,7 @@ #include "view_bitmap.h" #include "action_handler.h" // Just for getAllParams #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/misc/i18n.h" @@ -1692,7 +1693,7 @@ int CGroupSubMenu::luaGetSubMenu(CLuaState &ls) const char *funcName = "getSubMenu"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + CLuaIHMRyzom::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); return 1; } @@ -1703,7 +1704,7 @@ int CGroupSubMenu::luaAddSubMenu(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam())); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + CLuaIHMRyzom::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); return 1; } @@ -1803,11 +1804,11 @@ int CGroupSubMenu::luaSetUserGroupRight(CLuaState &ls) const char *funcName = "setUserGroupRight"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) + if (!(CLuaIHMRyzom::isUIOnStack(ls, 2) || ls.isNil(2))) { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); + CInterfaceElement *el = CLuaIHMRyzom::getUIOnStack(ls, 2); CInterfaceGroup *group = dynamic_cast(el); if (el && !group) { @@ -1823,11 +1824,11 @@ int CGroupSubMenu::luaSetUserGroupLeft(CLuaState &ls) const char *funcName = "setUserGroupLeft"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) + if (!(CLuaIHMRyzom::isUIOnStack(ls, 2) || ls.isNil(2))) { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); + CInterfaceElement *el = CLuaIHMRyzom::getUIOnStack(ls, 2); CInterfaceGroup *group = dynamic_cast(el); if (el && !group) { @@ -1844,7 +1845,7 @@ int CGroupSubMenu::luaGetUserGroupRight(CLuaState &ls) const char *funcName = "getUserGroupRight"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); + CLuaIHMRyzom::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); return 1; } @@ -1858,7 +1859,7 @@ int CGroupSubMenu::luaGetUserGroupLeft(CLuaState &ls) CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1)); if (pIE) { - CLuaIHM::pushUIOnStack(ls, pIE); + CLuaIHMRyzom::pushUIOnStack(ls, pIE); return 1; } else return 0; @@ -2281,7 +2282,7 @@ void CGroupMenu::setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip int CGroupMenu::luaGetRootMenu(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getRootMenu", 0); - CLuaIHM::pushUIOnStack(ls, getRootMenu()); + CLuaIHMRyzom::pushUIOnStack(ls, getRootMenu()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 00cb26a83..dd408b445 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -24,6 +24,7 @@ #include "interface_manager.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" using namespace std; @@ -234,7 +235,7 @@ void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) int CGroupTab::luaAddTab(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CGroupTab::addTab", 1); - CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CCtrlTabButton *tabB = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (tabB) { // don't use addTab to avoid selection of new tab @@ -259,7 +260,7 @@ int CGroupTab::luaAddTabWithOrder(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CCtrlTabButton *tabB = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if (tabB) { // don't use addTab to avoid selection of new tab @@ -394,7 +395,7 @@ int CGroupTab::luaGetTabButton(CLuaState &ls) CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1)); if(tab != NULL) { - CLuaIHM::pushUIOnStack(ls, tab); + CLuaIHMRyzom::pushUIOnStack(ls, tab); return 1; } return 0; @@ -725,7 +726,7 @@ int CGroupTab::luaGetGroup(CLuaState &ls) CInterfaceGroup* group = getGroup((uint) ls.toNumber(1)); if(group != NULL) { - CLuaIHM::pushUIOnStack(ls, group); + CLuaIHMRyzom::pushUIOnStack(ls, group); return 1; } return 0; diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 7c0be8016..9fe98e9c6 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -26,6 +26,7 @@ #include "group_container.h" #include "action_handler.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" @@ -1490,7 +1491,7 @@ int CGroupTree::SNode::luaGetParentTree(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getParentTree", 0); if (ParentTree) { - CLuaIHM::pushUIOnStack(ls, ParentTree); + CLuaIHMRyzom::pushUIOnStack(ls, ParentTree); } else { diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 7edc093ae..85bc0ba0f 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -26,6 +26,7 @@ #include "interface_link.h" #include "nel/misc/xml_auto_ptr.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/misc/mem_stream.h" // @@ -34,29 +35,6 @@ using namespace NLMISC; CStringMapper *_UIStringMapper = NULL; -// ------------------------------------------------------------------------------------------------ -CReflectableRefPtrTarget::~CReflectableRefPtrTarget() -{ - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CLuaState *lua= pIM->getLuaState(); - if(!lua) return; - CLuaStackChecker lsc(lua); - // remove from the lua registry if i'm in - lua->pushLightUserData((void *) this); - lua->getTable(LUA_REGISTRYINDEX); - if (!lua->isNil(-1)) - { - lua->pop(); - lua->pushLightUserData((void *) this); - lua->pushNil(); - lua->setTable(LUA_REGISTRYINDEX); - } - else - { - lua->pop(); - } -} - // ------------------------------------------------------------------------------------------------ CInterfaceElement::~CInterfaceElement() { @@ -1198,7 +1176,7 @@ int CInterfaceElement::luaSetPosRef(CLuaState &ls) int CInterfaceElement::luaSetParentPos(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "setParentPos", 1); - CInterfaceElement *ie = CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *ie = CLuaIHMRyzom::getUIOnStack(ls, 1); if(ie) { setParentPos(ie); diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 0202618ba..963cbb050 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -80,19 +80,6 @@ public: }; -/** Reflectable refcounted object - * NB nico : added this intermediate class so that the binding from lua to the reflection - * system that are found in CLuaIHM can be reused for other objects as well - * NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount' - * because the refcount part is only used for ref pointing in the ui - */ -class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount -{ -public: - virtual ~CReflectableRefPtrTarget(); -}; - - #define DECLARE_UI_CLASS(_class_) \ virtual std::string getClassName() {return #_class_;} \ static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());} diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 1a75cf4cb..f1db4917d 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -25,9 +25,11 @@ #include "group_editbox.h" #include "group_scrolltext.h" #include "lua_ihm.h" +#include "lua_ihm_ryzom.h" #include "nel/misc/stream.h" +#include "lua_manager.h" using namespace std; using namespace NL3D; @@ -445,7 +447,7 @@ void CInterfaceGroup::addGroup (CInterfaceGroup *child, sint eltOrder /*= -1*/) int CInterfaceGroup::luaAddGroup (CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::addTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CInterfaceGroup * group = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if(group) { group->setParent(this); @@ -616,7 +618,7 @@ bool CInterfaceGroup::delGroup (CInterfaceGroup *child, bool dontDelete /* = fal int CInterfaceGroup::luaDelGroup (CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::delTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CInterfaceGroup * group = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); if(group) { delGroup(group); @@ -643,7 +645,7 @@ int CInterfaceGroup::luaGetGroup(CLuaState &ls) { CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size()); } - CLuaIHM::pushUIOnStack(ls, _ChildrenGroups[index]); + CLuaIHMRyzom::pushUIOnStack(ls, _ChildrenGroups[index]); return 1; } @@ -1747,7 +1749,7 @@ void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy) void CInterfaceGroup::pushLUAEnvTable() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CLuaState *lua= pIM->getLuaState(); + CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); if(!_LUAEnvTableCreated) @@ -1782,7 +1784,7 @@ void CInterfaceGroup::deleteLUAEnvTable(bool recurse) if(_LUAEnvTableCreated) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CLuaState *lua= pIM->getLuaState(); + CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); // replace simply the table with Nil, letting LUA Garbage collector do the realease stuff @@ -1866,7 +1868,7 @@ int CInterfaceGroup::luaFind(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, element); + CLuaIHMRyzom::pushUIOnStack(ls, element); } return 1; } @@ -1885,7 +1887,7 @@ CInterfaceElement* CInterfaceGroup::findFromShortId(const std::string &id) int CInterfaceGroup::luaGetEnclosingContainer(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getEnclosingContainer", 0); - CLuaIHM::pushUIOnStack(ls, getEnclosingContainer()); + CLuaIHMRyzom::pushUIOnStack(ls, getEnclosingContainer()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e162df279..d92d59354 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -5887,9 +5887,9 @@ void CInterfaceManager::getLuaValueInfo(std::string &str, sint index) // If its a Userdata, try to display UI info else if(type==LUA_TUSERDATA) { - if(CLuaIHM::isUIOnStack(ls, index)) + if(CLuaIHMRyzom::isUIOnStack(ls, index)) { - CInterfaceElement *ui= CLuaIHM::getUIOnStack(ls, index); + CInterfaceElement *ui= CLuaIHMRyzom::getUIOnStack(ls, index); str+= NLMISC::toString(" (ui=%p)", ui); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 75a33cc29..550a5e867 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -629,8 +629,6 @@ public: // @{ /// Execute a lua script (smallScript for speed optimisation, see lua_helper). return false if parse/execute error (warning/sysinfo displayed) bool executeLuaScript(const std::string &luaScript, bool smallScript= false); - /// Get the lua state (NULL if not inited) - class CLuaState *getLuaState() const {return _LuaState;} /// Reload all LUA scripts inserted through void reloadAllLuaFileScripts(); /// For debug: dump in the sysinfo and nlwarning state of lua. detail range from 0 to 2 (clamped). diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 16232de19..bdf2c7050 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -110,6 +110,7 @@ using namespace NLGUI; #include "lua_ihm.h" #include "lua_ihm_ryzom.h" #include "../r2/editor.h" +#include "lua_manager.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -496,7 +497,7 @@ CInterfaceParser::~CInterfaceParser() { // delete _Pointer; _Pointer = NULL; - delete _LuaState; + //delete _LuaState; _LuaState = NULL; } /** Convert a string into a memstream @@ -4663,7 +4664,9 @@ void CInterfaceParser::initLUA() // create a new LUA environnement nlassert(_LuaState==NULL); - _LuaState= new CLuaState( ClientCfg.LoadLuaDebugger ); + CLuaManager::enableLuaDebugging(); + CLuaManager::getInstance(); + _LuaState= CLuaManager::getInstance().getLuaState(); #ifdef LUA_NEVRAX_VERSION extern ILuaIDEInterface *LuaDebuggerIDE; @@ -4679,8 +4682,8 @@ void CInterfaceParser::initLUA() void CInterfaceParser::uninitLUA() { // Delete all LUA environnement (and hence variables) -// delete _LuaState; - _LuaState= NULL; + // delete _LuaState; + // _LuaState= NULL; // delete all .lua file loaded _LuaFileScripts.clear(); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index c6cf16b37..5ee00ba4d 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -15,7 +15,6 @@ // along with this program. If not, see . -#include "stdpch.h" #include "nel/gui/lua_helper.h" using namespace NLGUI; @@ -62,70 +61,14 @@ using namespace NLGUI; #include "lua_ihm.h" #include "reflect.h" -#include "action_handler.h" -#include "action_handler_tools.h" -#include "interface_manager.h" -#include "interface_group.h" -#include "view_text.h" -#include "game_share/people_pd.h" -#include "group_tree.h" -#include "interface_link.h" -#include "interface_expr.h" -#include "people_interraction.h" #include "nel/misc/algo.h" #include "nel/misc/file.h" #include "nel/misc/i18n.h" #include "nel/misc/time_nl.h" -#include "skill_manager.h" -#include "group_html.h" -#include "../net_manager.h" -#include "../user_entity.h" -#include "sphrase_manager.h" -#include "guild_manager.h" -#include "../client_cfg.h" -#include "../sheet_manager.h" #include "lua_object.h" -#include "game_share/emote_list_parser.h" -#include "game_share/pvp_clan.h" -#include "../weather.h" -#include "../continent_manager.h" -#include "../zone_util.h" -#include "../motion/user_controls.h" -#include "group_html_cs.h" -#include "bonus_malus.h" -#include "group_editbox.h" -#include "../entities.h" -#include "../sheet_manager.h" // for emotes -#include "../global.h" // for emotes -#include "../entity_animation_manager.h" // for emotes -#include "../net_manager.h" // for emotes -#include "../client_chat_manager.h" // for emotes -#include "../login.h" -#include "lua_object.h" -#include "../actions.h" -#include "../bg_downloader_access.h" -#include "../connection.h" -#include "../login_patch.h" - -#include "bot_chat_page_all.h" -#include "bot_chat_page_ring_sessions.h" -#include "nel/georges/u_form_loader.h" -#include "nel/georges/u_form.h" -#include "nel/georges/u_form_elm.h" #include "nel/misc/polygon.h" -#include "game_share/scenario_entry_points.h" -#include "game_share/bg_downloader_msg.h" -#include "game_share/constants.h" -#include "game_share/visual_slot_manager.h" +#include "lua_manager.h" -#ifdef LUA_NEVRAX_VERSION - #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger -#endif - - -#ifdef LUA_NEVRAX_VERSION - extern ILuaIDEInterface *LuaDebuggerIDE; -#endif // *************************************************************************** /* @@ -136,15 +79,6 @@ Compilation is VERY SLOW // *************************************************************************** using namespace NLMISC; -using namespace NLGEORGES; -using namespace R2; - - -extern NLMISC::CLog g_log; -extern CContinentManager ContinentMngr; -extern uint8 PlayerSelectedSlot; -extern CClientChatManager ChatMngr; -extern void addWebIGParams (string &url, bool trustedDomain); // declare ostream << operator for ucstring -> registration of ucstring iin luabind will build a 'tostring' function from it std::ostream &operator<<(std::ostream &str, const ucstring &value) @@ -169,69 +103,6 @@ struct CMiscFunctions }; -/** - * Data structure pushed in lua (a userdata) to access CReflectableRefPtrTarget derived objects - * These includes element of the GUI. - * if holds a pointer to the reflectable object, and - * a cache to its CClassInfo for fast access to exported properties - * \see reflect.h - */ - -// -class CReflectableLuaRef -{ -public: - CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {} - NLMISC::CRefPtr Ptr; - const CClassInfo &getClassInfo() const; - // IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo - const CReflectedProperty *getProp(const char *luaStringPtr) const; -private: - // cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer) - mutable const CClassInfo *_ClassInfo; -}; - -inline const CClassInfo &CReflectableLuaRef::getClassInfo() const -{ - nlassert(Ptr); // class info should not be accessed for a null ptr - if (_ClassInfo) return *_ClassInfo; - _ClassInfo = Ptr->getClassInfo(); - return *_ClassInfo; -} - -const CReflectedProperty *CReflectableLuaRef::getProp(const char *luaStringPtr) const -{ - const CClassInfo &ci = getClassInfo(); - CClassInfo::TLuaStrToPropMap::const_iterator it = ci.LuaStrToProp.find(luaStringPtr); - if (it != ci.LuaStrToProp.end()) - { - return it->second.Prop; - } - // slowly retrieve property, and store in cache - // NB nico : this could also be done at startup... - const CReflectedProperty *prop = CReflectSystem::getProperty(ci.ClassName, luaStringPtr, false); - if (!prop) return NULL; - CLuaIndexedProperty lip; - lip.Id = CLuaString(luaStringPtr); // keep a ref on the lua string to ensure that its pointer always remains valid - lip.Prop = prop; - ci.LuaStrToProp[luaStringPtr] = lip; - return prop; -} - -// *************************************************************************** -static sint32 getTargetSlotNr() -{ - const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); - if (!node) return 0; - if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) - { - return 0; - } - return node->getValue32(); -} - // *************************************************************************** bool CLuaIHM::pop(CLuaState &ls, NLMISC::CRGBA &dest) { @@ -331,118 +202,6 @@ void CLuaIHM::push(CLuaState &ls, const ucstring &value) #endif } -// *************************************************************************** -// *************************************************************************** -// Special Action Handlers for Lua -// *************************************************************************** -// *************************************************************************** - - - -// *************************************************************************** -// Allow also to call script from expression -static DECLARE_INTERFACE_USER_FCT(lua) -{ - if(args.size()!=1 || !args[0].toString()) - { - nlwarning(" requires 1 arg (string=script)"); - return false; - } - - // Retrieve lua state - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CLuaState *state= pIM->getLuaState(); - if(!state) - return false; - CLuaState &ls= *state; - - // *** clear return value - const std::string retId= "__ui_internal_ret_"; - CLuaStackChecker lsc(&ls); - ls.push(retId); - ls.pushNil(); - ls.setTable(LUA_GLOBALSINDEX); - - - // *** execute script - std::string script= args[0].getString(); - // assign return value in retId. - script= retId + "= " + script; - // execute a small script here, because most often exprs are called from xml files => lot of redundant script - pIM->executeLuaScript(script, true); - - - // *** retrieve and convert return value - ls.push(retId); - ls.getTable(LUA_GLOBALSINDEX); - bool ok= false; - sint type= ls.type(); - if (type==LUA_TBOOLEAN) - { - // get and pop - bool val= ls.toBoolean(); - ls.pop(); - // set result - result.setBool(val); - ok= true; - } - else if(type==LUA_TNUMBER) - { - // get and pop - double val= ls.toNumber(); - ls.pop(); - // set double or integer? - if(val==floor(val)) - result.setInteger(sint64(floor(val))); - else - result.setDouble(val); - ok= true; - } - else if(type==LUA_TSTRING) - { - // get and pop - std::string val; - ls.toString(-1, val); - ls.pop(); - // set result - result.setString(val); - ok= true; - } - else if(type==LUA_TUSERDATA) - { - // NB: the value is poped in obj.set() (no need to do ls.pop()); - - // try with ucstring - ucstring ucstrVal; - if (CLuaIHM::pop(ls, ucstrVal)) - { - result.setUCString(ucstrVal); - ok= true; - } - - // try with RGBA - if(!ok) - { - NLMISC::CRGBA rgbaVal; - if (CLuaIHM::pop(ls, rgbaVal)) - { - result.setRGBA(rgbaVal); - ok= true; - } - } - } - else - { - // error (nil for instance) - ls.pop(); - } - - return ok; -} -REGISTER_INTERFACE_USER_FCT("lua", lua) - - - // *************************************************************************** // *************************************************************************** // CInterface To LUA Registry @@ -452,8 +211,7 @@ REGISTER_INTERFACE_USER_FCT("lua", lua) CLuaState * ELuaIHMException::getLuaState() { - CInterfaceManager *im = CInterfaceManager::getInstance(); - return im->getLuaState(); + return CLuaManager::getInstance().getLuaState(); } // *************************************************************************** @@ -539,45 +297,9 @@ void CLuaIHM::registerBasics(CLuaState &ls) .def_readwrite("y", &NLMISC::CVector2f::y) ]; - // MISC ui ctors - struct CUICtor - { - // CGroupTree::SNode - static int SNode(CLuaState &ls) - { - CLuaIHM::checkArgCount(ls, "SNode", 0); - CLuaIHM::pushReflectableOnStack(ls, new CGroupTree::SNode); - return 1; - } - }; - - ls.registerFunc("SNode", CUICtor::SNode); } -// *************************************************************************** -CInterfaceElement *CLuaIHM::getUIRelative(CInterfaceElement *pIE, const std::string &propName) -{ - //H_AUTO(Lua_CLuaIHM_getUIRelative) - if (pIE == NULL) return NULL; - // If the prop is "parent", then return the parent of the ui - if(propName=="parent") - { - return pIE->getParent(); - } - // else try to get a child (if group/exist) - else - { - CInterfaceGroup *group= dynamic_cast(pIE); - if(group) - { - return group->getElement(group->getId()+":"+propName); - } - } - - return NULL; -} - // *************************************************************************** int CLuaIHM::luaMethodCall(lua_State *ls) { @@ -688,71 +410,6 @@ void CLuaIHM::luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflect static CLuaString lstr_Env("Env"); static CLuaString lstr_isNil("isNil"); -// *************************************************************************** -int CLuaIHM::luaUIIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIIndex) - nlassert(ls.getTop()==2); - // get the userdata and key - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - - const char *propName = ls.toString(2); - CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); - // ** try to get the Env Table (interface group only) - if(propName==lstr_isNil) - { - ls.push(pRPT==NULL); - return 1; - } - - // Check the object is not NULL or freed - if(pRPT==NULL) - { - return 0; - } - - // ** try to get the Env Table (interface group only) - if(propName==lstr_Env) - { - // Env can be bound to a CInterfaceGroup only - CInterfaceGroup *group= dynamic_cast(pRPT); - if(group==NULL) - { - ls.pushNil(); - return 1; - } - else - { - group->pushLUAEnvTable(); - return 1; - } - } - - // ** try to get the property - const CReflectedProperty *prop = pRefElm->getProp(propName); - if (prop) - { - luaValueFromReflectedProperty(ls, *pRPT, *prop); - return 1; - } - - // ** try to get a UI relative - CInterfaceElement *uiRelative= getUIRelative(dynamic_cast(pRPT), propName); - if(uiRelative) - { - // push the UI onto the stack - CLuaIHM::pushUIOnStack(ls, uiRelative); - return 1; - } - - - // Fail to find any Attributes or elements - // Yoyo: don't write any message or warning because this may be a feature (if user want to test that something exit in the ui) - ls.pushNil(); - return 1; -} - - // *************************************************************************** void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) { @@ -832,312 +489,6 @@ void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflec } -// *************************************************************************** -int CLuaIHM::luaUINewIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUINewIndex) - nlassert(ls.getTop()==3); - // get the userdata and key - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - nlassert(pRefElm); - CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); - // Check the UI is not NULL or freed - if(pRPT == NULL) - { - return 0; - } - - const char *propName = ls.toString(2); - // ** try to set the Env Table (interface group only) - if(propName == lstr_Env) - { - CInterfaceElement *pIE = dynamic_cast(pRPT); - std::string name ; - if (pIE) - { - name = pIE->getId(); - } - else - { - name = ""; - } - // Exception!!! not allowed - throw ELuaIHMException("You cannot change the Env Table of '%s'", name.c_str()); - } - - - // ** try to set the property - const CReflectedProperty *prop = pRefElm->getProp(propName); - if (prop) - { - luaValueToReflectedProperty(ls, 3, *pRPT, *prop); - return 0; - } - - CInterfaceElement *pIE = dynamic_cast(pRPT); - // ** try to get another UI (child or parent) - CInterfaceElement *uiRelative= getUIRelative(pIE, propName); - if(uiRelative) - { - // Exception!!! not allowed - throw ELuaIHMException("You cannot write into the UI '%s' of '%s'", propName, pIE->getId().c_str()); - } - - // ** Prop Not Found - throw ELuaIHMException("Property '%s' not found in '%s' of type %s", propName, pIE ? pIE->getId().c_str() : "", typeid(*pRPT).name()); - - // Fail to find any Attributes or elements - return 0; -} - -// *************************************************************************** -int CLuaIHM::luaUIEq(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIEq) - nlassert(ls.getTop() == 2); - // read lhs & rhs - // get the userdata and key - CReflectableLuaRef *lhs = (CReflectableLuaRef *) ls.toUserData(1); - CReflectableLuaRef *rhs = (CReflectableLuaRef *) ls.toUserData(2); - nlassert(lhs); - nlassert(rhs); - ls.push(lhs->Ptr == rhs->Ptr); - return 1; -} - - -// *************************************************************************** -int CLuaIHM::luaUIDtor(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIDtor) - nlassert(ls.getTop()==1); - // get the userdata - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - nlassert(pRefElm); - - // call dtor - pRefElm->~CReflectableLuaRef(); - - return 0; -} - -// *************************************************************************** -int CLuaIHM::luaUINext(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUINext) - // Code below allow enumeration of properties of a reflectable object - // From lua standpoint, the object is seen as a table with (key, value) pairs - // If object is a CInterfaceGroup, iteration is also done on sons (groups, controls & view). - - if (ls.getTop() != 2) - { - CLuaIHM::fails(ls, "__next metamethod require 2 arguments (table & key)"); - } - CLuaIHM::check(ls, isReflectableOnStack(ls, 1), "__next : require ui element as first arg"); - CReflectableRefPtrTarget *reflectedObject = getReflectableOnStack(ls, 1); - // To traverse all properties / field of the object, we must be able to determine the next key from a previous key - // (keys are ordered) - // We use the 'TValueType' enum to know which kind of property we are traversing, and an index in this group of properties - // The key which uniquely identify an element / property in the reflectable object - struct CKey - { - enum TValueType - { - VTGroup = 0, // children groups (If the object is a CInterfaceGroup) - VTView, // children views (If the object is a CInterfaceView) - VTCtrl, // children controls (If the object is a CInterfaceCtrl) - VTProp // List of exported proeprties (For all relfectable objects) - }; - TValueType ValueType; - sint Index; - const CClassInfo *ClassInfo; // if ValueType is "VTProp" -> give the class for which property are currently enumerated - // - static int tostring(CLuaState &ls) // '__print' metamathod - { - CLuaIHM::checkArgCount(ls, "reflected object metatable:__print", 1); - CKey key; - key.pop(ls); - switch(key.ValueType) - { - case VTGroup: ls.push(toString("_Group %d", key.Index)); break; - case VTView: ls.push(toString("_View %d", key.Index)); break; - case VTCtrl: ls.push(toString("_Ctrl %d", key.Index)); break; - case VTProp: ls.push(key.ClassInfo->Properties[key.Index].Name); break; - } - return 1; - } - // push the key on the lua stack - void push(CLuaState &ls) - { - void *ud = ls.newUserData(sizeof(*this)); - *(CKey *) ud = *this; - getMetaTable(ls).push(); - ls.setMetaTable(-2); - } - // pop the key from the lua stack - void pop(CLuaState &ls) - { - CLuaStackChecker lsc(&ls, -1); - if (!ls.isUserData(-1)) - { - CLuaIHM::fails(ls, "Can't pop object, not a user data"); - } - // check that metatable is good (it is share between all keys) - ls.getMetaTable(-1); - getMetaTable(ls).push(); - if (!ls.rawEqual(-1, -2)) - { - CLuaIHM::fails(ls, "Bad metatable for reflectable object key"); - } - ls.pop(2); - // retrieve key - *this = *(CKey *) ls.toUserData(-1); - ls.pop(); - } - // get the metatable for a CKey - CLuaObject &getMetaTable(CLuaState &ls) - { - static CLuaObject metatable; - if (!metatable.isValid()) - { - // first build - CLuaStackChecker lsc(&ls); - ls.newTable(); - ls.push("__tostring"); - ls.push(CKey::tostring); - ls.setTable(-3); - metatable.pop(ls); - } - return metatable; - } - }; - // Pop the current key to continue enumeration - CKey key; - if (ls.isNil(2)) - { - // no key -> start of table - key.ValueType = CKey::VTGroup; - key.Index = -1; - } - else - { - key.pop(ls); - } - // - CInterfaceGroup *group = dynamic_cast(reflectedObject); - bool enumerate = true; - while (enumerate) - { - switch(key.ValueType) - { - case CKey::VTGroup: - if (!group || (key.Index + 1) == (sint) group->getGroups().size()) - { - key.Index = -1; - key.ValueType = CKey::VTView; // continue enumeration with views - } - else - { - ++ key.Index; - key.push(ls); - CLuaIHM::pushUIOnStack(ls, group->getGroups()[key.Index]); - return 2; - } - break; - case CKey::VTView: - if (!group || (key.Index + 1) == (sint) group->getViews().size()) - { - key.Index = -1; - key.ValueType = CKey::VTCtrl; // continue enumeration with controls - } - else - { - ++ key.Index; - key.push(ls); - CLuaIHM::pushUIOnStack(ls, group->getViews()[key.Index]); - return 2; - } - break; - case CKey::VTCtrl: - if (!group || (key.Index + 1) == (sint) group->getControls().size()) - { - key.Index = -1; - key.ValueType = CKey::VTProp; // continue enumeration with properties - key.ClassInfo = reflectedObject->getClassInfo(); - } - else - { - ++ key.Index; - key.push(ls); - CLuaIHM::pushUIOnStack(ls, group->getControls()[key.Index]); - return 2; - } - break; - case CKey::VTProp: - if (!key.ClassInfo) - { - enumerate = false; - break; - } - if ((sint) key.ClassInfo->Properties.size() == (key.Index + 1)) - { - key.ClassInfo = key.ClassInfo->ParentClass; // continue enumeration in parent class - key.Index = -1; - } - else - { - ++ key.Index; - key.push(ls); - luaValueFromReflectedProperty(ls, *reflectedObject, key.ClassInfo->Properties[key.Index]); - return 2; - } - break; - default: - nlassert(0); - break; - } - } - ls.pushNil(); - return 0; -} - -// *************************************************************************** -int CLuaIHM::luaClientCfgIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaClientCfgIndex) - CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(ls.toString(2)); - if (!v) return 0; - if (v->size() != 1) - { - // arrays not implemented (would require a second metatable).... - throw ELuaWrappedFunctionException(&ls, "Access to array inside client.cfg not supported."); - } - switch(v->Type) - { - case CConfigFile::CVar::T_REAL: - ls.push((double) v->asDouble()); - return 1; - break; - case CConfigFile::CVar::T_STRING: - ls.push(v->asString()); - return 1; - break; - default: // handle both T_INT && T_BOOL - case CConfigFile::CVar::T_INT: - ls.push((double) v->asInt()); - return 1; - break; - } - return 0; -} - -// *************************************************************************** -int CLuaIHM::luaClientCfgNewIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaClientCfgNewIndex) - throw ELuaWrappedFunctionException(&ls, "Can't write into config file from lua."); -} - // *************************************************************************** void CLuaIHM::createLuaEnumTable(CLuaState &ls, const std::string &str) { @@ -1175,50 +526,6 @@ void CLuaIHM::registerIHM(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_registerIHM) CLuaStackChecker lsc(&ls); - // *** Register the metatable for access to client.cfg (nb nico this may be more general later -> access to any config file ...) - { - ls.pushValue(LUA_GLOBALSINDEX); - CLuaObject globals(ls); - CLuaObject clientCfg = globals.newTable("config"); - CLuaObject mt = globals.newTable("__cfmt"); - nlverify(clientCfg.setMetaTable(mt)); - mt.setValue("__index", luaClientCfgIndex); - mt.setValue("__newindex", luaClientCfgNewIndex); - globals.setNil("__cfmt"); // remove temp metatable - } - - // *** Register the MetaTable for UI userdata - ls.push(IHM_LUA_METATABLE); // "__ui_metatable" - ls.newTable(); // "__ui_metatable" {} - // set the '__index' method - ls.push("__index"); - ls.push(luaUIIndex); - nlassert(ls.isCFunction()); - ls.setTable(-3); // "__ui_metatable" {"__index"= CFunc_luaUIIndex} - // set the '__newindex' method - ls.push("__newindex"); - ls.push(luaUINewIndex); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the '__newindex' method - ls.push("__gc"); - ls.push(luaUIDtor); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the '__eq' method - ls.push("__eq"); - ls.push(luaUIEq); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the custom '__next' method - ls.push("__next"); - ls.push(luaUINext); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set registry - ls.setTable(LUA_REGISTRYINDEX); - - // *** Register a Table for ui env. ls.push(IHM_LUA_ENVTABLE); // "__ui_envtable" ls.newTable(); // "__ui_envtable" {} @@ -1392,28 +699,6 @@ CReflectableRefPtrTarget *CLuaIHM::getReflectableOnStack(CLuaState &ls, sint } -// *************************************************************************** -void CLuaIHM::pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE) -{ - //H_AUTO(Lua_CLuaIHM_pushUIOnStack) - pushReflectableOnStack(ls, pIE); -} - -// *************************************************************************** -bool CLuaIHM::isUIOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_isUIOnStack) - return getUIOnStack(ls, index) != NULL; -} - -// *************************************************************************** -CInterfaceElement *CLuaIHM::getUIOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_getUIOnStack) - return dynamic_cast(getReflectableOnStack(ls, index)); -} - - // *************************************************************************** // *************************************************************************** // LUA IHM Functions @@ -1429,26 +714,6 @@ uint32 CLuaIHM::getLocalTime() } -// *************************************************************************** -static CEntityCL *getTargetEntity() -{ - const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); - if (!node) return NULL; - if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) - { - return NULL; - } - return EntitiesMngr.entity((uint) node->getValue32()); -} - -// *************************************************************************** -static CEntityCL *getSlotEntity(uint slot) -{ - return EntitiesMngr.entity(slot); -} - // *************************************************************************** std::string CLuaIHM::findReplaceAll(const std::string &str, const std::string &search, const std::string &replace) { @@ -1489,78 +754,6 @@ ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, } -// *************************************************************************** -int CLuaIHM::runExprAndPushResult(CLuaState &ls, const std::string &expr) -{ - //H_AUTO(Lua_CLuaIHM_runExprAndPushResult) - // Execute expression - CInterfaceExprValue value; - if (CInterfaceExpr::eval(expr, value, NULL)) - { - switch(value.getType()) - { - case CInterfaceExprValue::Boolean: - ls.push(value.getBool()); - break; - case CInterfaceExprValue::Integer: - ls.push((double)value.getInteger()); - break; - case CInterfaceExprValue::Double: - ls.push(value.getDouble()); - break; - case CInterfaceExprValue::String: - { - ucstring ucstr= value.getUCString(); - // Yoyo: dynamically decide whether must return a string or a ucstring - bool mustUseUCString= false; - for (uint i = 0; i < ucstr.size (); i++) - { - if (ucstr[i] > 255) - { - mustUseUCString= true; - break; - } - } - // push a ucstring? - if(mustUseUCString) - { -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), ucstr); -#else - luabind::object obj(ls.getStatePointer(), ucstr); - obj.pushvalue(); -#endif - } - else - { - ls.push(ucstr.toString()); - } - break; - } - case CInterfaceExprValue::RGBA: - { - CRGBA color = value.getRGBA(); -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), color); -#else - luabind::object obj(ls.getStatePointer(), color); - obj.pushvalue(); -#endif - break; - } - break; - case CInterfaceExprValue::UserType: // Yoyo: don't care UserType... - default: - ls.pushNil(); - break; - } - } - else - ls.pushNil(); - - return 1; -} - // *************************************************************************** void CLuaIHM::fails(CLuaState &ls, const char *format, ...) { @@ -1646,21 +839,6 @@ void CLuaIHM::checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index) } } -// *************************************************************************** -void CLuaIHM::checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index) -{ - //H_AUTO(Lua_CLuaIHM_checkArgTypeUIElement) - nlassert(index > 0); - if (ls.getTop() < (int) index) - { - fails(ls, "%s : argument %d of expected type ui element was not defined", funcName, index); - } - if (!isUIOnStack(ls, index)) - { - fails(ls, "%s : argument %d of expected type ui element has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); - } -} - // *************************************************************************** void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index) { diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.h b/code/ryzom/client/src/interface_v3/lua_ihm.h index 6894cc224..557e984eb 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm.h @@ -74,11 +74,6 @@ class CLuaIHM public: static void registerAll(CLuaState &ls); - // CInterfaceElement management on stack, stored by a CRefPtr. - static void pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE); - static bool isUIOnStack(CLuaState &ls, sint index); - static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index); - /** CReflectableInterfaceElement management on stack, stored by a CRefPtr. * May be called as well for ui element, because they derive from CReflectableRefPtrTarget */ @@ -110,7 +105,6 @@ public: static void check(CLuaState &ls, bool ok, const std::string &failReason); static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType); static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index); - static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index); static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index); /** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack * The various check... function call this function when their test fails @@ -140,16 +134,6 @@ private: static void registerIHM(CLuaState &ls); static void createLuaEnumTable(CLuaState &ls, const std::string &str); - // Functions for the ui metatable - static class CInterfaceElement *getUIRelative(class CInterfaceElement *pIE, const std::string &propName); - static int luaUIIndex(CLuaState &ls); - static int luaUINewIndex(CLuaState &ls); - static int luaUIEq(CLuaState &ls); - static int luaUINext(CLuaState &ls); - static int luaUIDtor(CLuaState &ls); - static int luaClientCfgIndex(CLuaState &ls); - static int luaClientCfgNewIndex(CLuaState &ls); - /// \name Exported Functions // @{ @@ -169,9 +153,6 @@ private: // Function export tools // Function to forward lua call to C++ to a 'lua method' exported from a reflected object static int luaMethodCall(lua_State *ls); - -public: - static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct }; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index cb9ceae2e..b96bcb72d 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -100,6 +100,7 @@ #include "game_share/bg_downloader_msg.h" #include "game_share/constants.h" #include "game_share/visual_slot_manager.h" +#include "lua_manager.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -148,6 +149,109 @@ private: REGISTER_ACTION_HANDLER( CHandlerLUA, "lua"); std::deque > CHandlerLUA::_UICallerStack; +// *************************************************************************** +// Allow also to call script from expression +static DECLARE_INTERFACE_USER_FCT(lua) +{ + if(args.size()!=1 || !args[0].toString()) + { + nlwarning(" requires 1 arg (string=script)"); + return false; + } + + // Retrieve lua state + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + CLuaState *state= CLuaManager::getInstance().getLuaState(); + if(!state) + return false; + CLuaState &ls= *state; + + // *** clear return value + const std::string retId= "__ui_internal_ret_"; + CLuaStackChecker lsc(&ls); + ls.push(retId); + ls.pushNil(); + ls.setTable(LUA_GLOBALSINDEX); + + + // *** execute script + std::string script= args[0].getString(); + // assign return value in retId. + script= retId + "= " + script; + // execute a small script here, because most often exprs are called from xml files => lot of redundant script + pIM->executeLuaScript(script, true); + + + // *** retrieve and convert return value + ls.push(retId); + ls.getTable(LUA_GLOBALSINDEX); + bool ok= false; + sint type= ls.type(); + if (type==LUA_TBOOLEAN) + { + // get and pop + bool val= ls.toBoolean(); + ls.pop(); + // set result + result.setBool(val); + ok= true; + } + else if(type==LUA_TNUMBER) + { + // get and pop + double val= ls.toNumber(); + ls.pop(); + // set double or integer? + if(val==floor(val)) + result.setInteger(sint64(floor(val))); + else + result.setDouble(val); + ok= true; + } + else if(type==LUA_TSTRING) + { + // get and pop + std::string val; + ls.toString(-1, val); + ls.pop(); + // set result + result.setString(val); + ok= true; + } + else if(type==LUA_TUSERDATA) + { + // NB: the value is poped in obj.set() (no need to do ls.pop()); + + // try with ucstring + ucstring ucstrVal; + if (CLuaIHM::pop(ls, ucstrVal)) + { + result.setUCString(ucstrVal); + ok= true; + } + + // try with RGBA + if(!ok) + { + NLMISC::CRGBA rgbaVal; + if (CLuaIHM::pop(ls, rgbaVal)) + { + result.setRGBA(rgbaVal); + ok= true; + } + } + } + else + { + // error (nil for instance) + ls.pop(); + } + + return ok; +} +REGISTER_INTERFACE_USER_FCT("lua", lua) + + CCtrlBase *CHandlerLUA::getUICaller() { if(_UICallerStack.empty()) @@ -169,6 +273,440 @@ CCtrlBase *CHandlerLUA::getUICaller() #define LUABIND_FUNC(__func__) luabind::def(#__func__, &__func__) +// *************************************************************************** +int CLuaIHMRyzom::luaClientCfgIndex(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaClientCfgIndex) + CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(ls.toString(2)); + if (!v) return 0; + if (v->size() != 1) + { + // arrays not implemented (would require a second metatable).... + throw ELuaWrappedFunctionException(&ls, "Access to array inside client.cfg not supported."); + } + switch(v->Type) + { + case CConfigFile::CVar::T_REAL: + ls.push((double) v->asDouble()); + return 1; + break; + case CConfigFile::CVar::T_STRING: + ls.push(v->asString()); + return 1; + break; + default: // handle both T_INT && T_BOOL + case CConfigFile::CVar::T_INT: + ls.push((double) v->asInt()); + return 1; + break; + } + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::luaClientCfgNewIndex(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaClientCfgNewIndex) + throw ELuaWrappedFunctionException(&ls, "Can't write into config file from lua."); +} + +// *************************************************************************** +CInterfaceElement *CLuaIHMRyzom::getUIRelative(CInterfaceElement *pIE, const std::string &propName) +{ + //H_AUTO(Lua_CLuaIHM_getUIRelative) + if (pIE == NULL) return NULL; + // If the prop is "parent", then return the parent of the ui + if(propName=="parent") + { + return pIE->getParent(); + } + // else try to get a child (if group/exist) + else + { + CInterfaceGroup *group= dynamic_cast(pIE); + if(group) + { + return group->getElement(group->getId()+":"+propName); + } + } + + return NULL; +} + +static CLuaString lstr_Env("Env"); +static CLuaString lstr_isNil("isNil"); + +// *************************************************************************** +int CLuaIHMRyzom::luaUIIndex(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaUIIndex) + nlassert(ls.getTop()==2); + // get the userdata and key + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + + const char *propName = ls.toString(2); + CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); + // ** try to get the Env Table (interface group only) + if(propName==lstr_isNil) + { + ls.push(pRPT==NULL); + return 1; + } + + // Check the object is not NULL or freed + if(pRPT==NULL) + { + return 0; + } + + // ** try to get the Env Table (interface group only) + if(propName==lstr_Env) + { + // Env can be bound to a CInterfaceGroup only + CInterfaceGroup *group= dynamic_cast(pRPT); + if(group==NULL) + { + ls.pushNil(); + return 1; + } + else + { + group->pushLUAEnvTable(); + return 1; + } + } + + // ** try to get the property + const CReflectedProperty *prop = pRefElm->getProp(propName); + if (prop) + { + CLuaIHM::luaValueFromReflectedProperty(ls, *pRPT, *prop); + return 1; + } + + // ** try to get a UI relative + CInterfaceElement *uiRelative= getUIRelative(dynamic_cast(pRPT), propName); + if(uiRelative) + { + // push the UI onto the stack + pushUIOnStack(ls, uiRelative); + return 1; + } + + + // Fail to find any Attributes or elements + // Yoyo: don't write any message or warning because this may be a feature (if user want to test that something exit in the ui) + ls.pushNil(); + return 1; +} + +// *************************************************************************** +int CLuaIHMRyzom::luaUINewIndex(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaUINewIndex) + nlassert(ls.getTop()==3); + // get the userdata and key + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + nlassert(pRefElm); + CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); + // Check the UI is not NULL or freed + if(pRPT == NULL) + { + return 0; + } + + const char *propName = ls.toString(2); + // ** try to set the Env Table (interface group only) + if(propName == lstr_Env) + { + CInterfaceElement *pIE = dynamic_cast(pRPT); + std::string name ; + if (pIE) + { + name = pIE->getId(); + } + else + { + name = ""; + } + // Exception!!! not allowed + throw ELuaIHMException("You cannot change the Env Table of '%s'", name.c_str()); + } + + + // ** try to set the property + const CReflectedProperty *prop = pRefElm->getProp(propName); + if (prop) + { + CLuaIHM::luaValueToReflectedProperty(ls, 3, *pRPT, *prop); + return 0; + } + + CInterfaceElement *pIE = dynamic_cast(pRPT); + // ** try to get another UI (child or parent) + CInterfaceElement *uiRelative= getUIRelative(pIE, propName); + if(uiRelative) + { + // Exception!!! not allowed + throw ELuaIHMException("You cannot write into the UI '%s' of '%s'", propName, pIE->getId().c_str()); + } + + // ** Prop Not Found + throw ELuaIHMException("Property '%s' not found in '%s' of type %s", propName, pIE ? pIE->getId().c_str() : "", typeid(*pRPT).name()); + + // Fail to find any Attributes or elements + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::luaUIEq(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaUIEq) + nlassert(ls.getTop() == 2); + // read lhs & rhs + // get the userdata and key + CReflectableLuaRef *lhs = (CReflectableLuaRef *) ls.toUserData(1); + CReflectableLuaRef *rhs = (CReflectableLuaRef *) ls.toUserData(2); + nlassert(lhs); + nlassert(rhs); + ls.push(lhs->Ptr == rhs->Ptr); + return 1; +} + + +// *************************************************************************** +int CLuaIHMRyzom::luaUIDtor(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaUIDtor) + nlassert(ls.getTop()==1); + // get the userdata + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + nlassert(pRefElm); + + // call dtor + pRefElm->~CReflectableLuaRef(); + + return 0; +} + +// *************************************************************************** +int CLuaIHMRyzom::luaUINext(CLuaState &ls) +{ + //H_AUTO(Lua_CLuaIHM_luaUINext) + // Code below allow enumeration of properties of a reflectable object + // From lua standpoint, the object is seen as a table with (key, value) pairs + // If object is a CInterfaceGroup, iteration is also done on sons (groups, controls & view). + + if (ls.getTop() != 2) + { + CLuaIHM::fails(ls, "__next metamethod require 2 arguments (table & key)"); + } + CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "__next : require ui element as first arg"); + CReflectableRefPtrTarget *reflectedObject = CLuaIHM::getReflectableOnStack(ls, 1); + // To traverse all properties / field of the object, we must be able to determine the next key from a previous key + // (keys are ordered) + // We use the 'TValueType' enum to know which kind of property we are traversing, and an index in this group of properties + // The key which uniquely identify an element / property in the reflectable object + struct CKey + { + enum TValueType + { + VTGroup = 0, // children groups (If the object is a CInterfaceGroup) + VTView, // children views (If the object is a CInterfaceView) + VTCtrl, // children controls (If the object is a CInterfaceCtrl) + VTProp // List of exported proeprties (For all relfectable objects) + }; + TValueType ValueType; + sint Index; + const CClassInfo *ClassInfo; // if ValueType is "VTProp" -> give the class for which property are currently enumerated + // + static int tostring(CLuaState &ls) // '__print' metamathod + { + CLuaIHM::checkArgCount(ls, "reflected object metatable:__print", 1); + CKey key; + key.pop(ls); + switch(key.ValueType) + { + case VTGroup: ls.push(toString("_Group %d", key.Index)); break; + case VTView: ls.push(toString("_View %d", key.Index)); break; + case VTCtrl: ls.push(toString("_Ctrl %d", key.Index)); break; + case VTProp: ls.push(key.ClassInfo->Properties[key.Index].Name); break; + } + return 1; + } + // push the key on the lua stack + void push(CLuaState &ls) + { + void *ud = ls.newUserData(sizeof(*this)); + *(CKey *) ud = *this; + getMetaTable(ls).push(); + ls.setMetaTable(-2); + } + // pop the key from the lua stack + void pop(CLuaState &ls) + { + CLuaStackChecker lsc(&ls, -1); + if (!ls.isUserData(-1)) + { + CLuaIHM::fails(ls, "Can't pop object, not a user data"); + } + // check that metatable is good (it is share between all keys) + ls.getMetaTable(-1); + getMetaTable(ls).push(); + if (!ls.rawEqual(-1, -2)) + { + CLuaIHM::fails(ls, "Bad metatable for reflectable object key"); + } + ls.pop(2); + // retrieve key + *this = *(CKey *) ls.toUserData(-1); + ls.pop(); + } + // get the metatable for a CKey + CLuaObject &getMetaTable(CLuaState &ls) + { + static CLuaObject metatable; + if (!metatable.isValid()) + { + // first build + CLuaStackChecker lsc(&ls); + ls.newTable(); + ls.push("__tostring"); + ls.push(CKey::tostring); + ls.setTable(-3); + metatable.pop(ls); + } + return metatable; + } + }; + // Pop the current key to continue enumeration + CKey key; + if (ls.isNil(2)) + { + // no key -> start of table + key.ValueType = CKey::VTGroup; + key.Index = -1; + } + else + { + key.pop(ls); + } + // + CInterfaceGroup *group = dynamic_cast(reflectedObject); + bool enumerate = true; + while (enumerate) + { + switch(key.ValueType) + { + case CKey::VTGroup: + if (!group || (key.Index + 1) == (sint) group->getGroups().size()) + { + key.Index = -1; + key.ValueType = CKey::VTView; // continue enumeration with views + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getGroups()[key.Index]); + return 2; + } + break; + case CKey::VTView: + if (!group || (key.Index + 1) == (sint) group->getViews().size()) + { + key.Index = -1; + key.ValueType = CKey::VTCtrl; // continue enumeration with controls + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getViews()[key.Index]); + return 2; + } + break; + case CKey::VTCtrl: + if (!group || (key.Index + 1) == (sint) group->getControls().size()) + { + key.Index = -1; + key.ValueType = CKey::VTProp; // continue enumeration with properties + key.ClassInfo = reflectedObject->getClassInfo(); + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getControls()[key.Index]); + return 2; + } + break; + case CKey::VTProp: + if (!key.ClassInfo) + { + enumerate = false; + break; + } + if ((sint) key.ClassInfo->Properties.size() == (key.Index + 1)) + { + key.ClassInfo = key.ClassInfo->ParentClass; // continue enumeration in parent class + key.Index = -1; + } + else + { + ++ key.Index; + key.push(ls); + CLuaIHM::luaValueFromReflectedProperty(ls, *reflectedObject, key.ClassInfo->Properties[key.Index]); + return 2; + } + break; + default: + nlassert(0); + break; + } + } + ls.pushNil(); + return 0; +} + +// *************************************************************************** +void CLuaIHMRyzom::pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE) +{ + //H_AUTO(Lua_CLuaIHM_pushUIOnStack) + CLuaIHM::pushReflectableOnStack(ls, pIE); +} + +// *************************************************************************** +bool CLuaIHMRyzom::isUIOnStack(CLuaState &ls, sint index) +{ + //H_AUTO(Lua_CLuaIHM_isUIOnStack) + return getUIOnStack(ls, index) != NULL; +} + +// *************************************************************************** +CInterfaceElement *CLuaIHMRyzom::getUIOnStack(CLuaState &ls, sint index) +{ + //H_AUTO(Lua_CLuaIHM_getUIOnStack) + return dynamic_cast(CLuaIHM::getReflectableOnStack(ls, index)); +} + +// *************************************************************************** +void CLuaIHMRyzom::checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index) +{ + //H_AUTO(Lua_CLuaIHM_checkArgTypeUIElement) + nlassert(index > 0); + if (ls.getTop() < (int) index) + { + CLuaIHM::fails(ls, "%s : argument %d of expected type ui element was not defined", funcName, index); + } + if (!isUIOnStack(ls, index)) + { + CLuaIHM::fails(ls, "%s : argument %d of expected type ui element has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); + } +} + + + // *************************************************************************** void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str) { @@ -193,6 +731,62 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) { CLuaStackChecker lsc( &ls ); + // MISC ui ctors + struct CUICtor + { + // CGroupTree::SNode + static int SNode(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "SNode", 0); + CLuaIHM::pushReflectableOnStack(ls, new CGroupTree::SNode); + return 1; + } + }; + + ls.registerFunc("SNode", CUICtor::SNode); + + // *** Register the metatable for access to client.cfg (nb nico this may be more general later -> access to any config file ...) + ls.pushValue(LUA_GLOBALSINDEX); + CLuaObject globals(ls); + CLuaObject clientCfg = globals.newTable("config"); + CLuaObject mt = globals.newTable("__cfmt"); + nlverify(clientCfg.setMetaTable(mt)); + mt.setValue("__index", luaClientCfgIndex); + mt.setValue("__newindex", luaClientCfgNewIndex); + globals.setNil("__cfmt"); // remove temp metatable + + // *** Register the MetaTable for UI userdata + ls.push(IHM_LUA_METATABLE); // "__ui_metatable" + ls.newTable(); // "__ui_metatable" {} + // set the '__index' method + ls.push("__index"); + ls.push(luaUIIndex); + nlassert(ls.isCFunction()); + ls.setTable(-3); // "__ui_metatable" {"__index"= CFunc_luaUIIndex} + // set the '__newindex' method + ls.push("__newindex"); + ls.push(luaUINewIndex); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the '__newindex' method + ls.push("__gc"); + ls.push(luaUIDtor); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the '__eq' method + ls.push("__eq"); + ls.push(luaUIEq); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the custom '__next' method + ls.push("__next"); + ls.push(luaUINext); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set registry + ls.setTable(LUA_REGISTRYINDEX); + + ls.registerFunc( "getUI", getUI ); ls.registerFunc("setOnDraw", setOnDraw); ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); @@ -438,7 +1032,7 @@ int CLuaIHMRyzom::getUI(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, pIE); + pushUIOnStack(ls, pIE); } return 1; } @@ -449,8 +1043,8 @@ int CLuaIHMRyzom::setCaptureKeyboard(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) const char *funcName = "setCaptureKeyboard"; CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); - CCtrlBase *ctrl = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); + checkArgTypeUIElement(ls, funcName, 1); + CCtrlBase *ctrl = dynamic_cast( getUIOnStack(ls, 1)); if (!ctrl) { CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); @@ -480,11 +1074,11 @@ int CLuaIHMRyzom::setOnDraw(CLuaState &ls) // params: CInterfaceGroup*, "script". // return: none CLuaIHM::checkArgCount(ls, "setOnDraw", 2); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); std::string script; ls.toString(2, script); @@ -507,12 +1101,12 @@ int CLuaIHMRyzom::addOnDbChange(CLuaState &ls) // params: CInterfaceGroup*, "dblist", "script". // return: none CLuaIHM::checkArgCount(ls, "addOnDbChange", 3); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); CLuaIHM::check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); std::string dbList, script; ls.toString(2, dbList); ls.toString(3, script); @@ -537,11 +1131,11 @@ int CLuaIHMRyzom::removeOnDbChange(CLuaState &ls) // params: CInterfaceGroup*, "dbList" // return: none CLuaIHM::checkArgCount(ls, "removeOnDbChange", 2); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); std::string dbList; ls.toString(2, dbList); @@ -565,12 +1159,12 @@ int CLuaIHMRyzom::runAH(CLuaState &ls) // params: CInterfaceElement *, "ah", "params". // return: none CLuaIHM::checkArgCount(ls, "runAH", 3); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); + CLuaIHM::check(ls, isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); CLuaIHM::check(ls, ls.isString(2), "runAH() requires a string in param 2"); CLuaIHM::check(ls, ls.isString(3), "runAH() requires a string in param 3"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); std::string ah, params; ls.toString(2, ah); ls.toString(3, params); @@ -606,7 +1200,7 @@ int CLuaIHMRyzom::runExpr(CLuaState &ls) ls.toString(1, expr); // run expression and push result - return CLuaIHM::runExprAndPushResult(ls, expr); + return runExprAndPushResult(ls, expr); } // *************************************************************************** @@ -654,7 +1248,7 @@ int CLuaIHMRyzom::runFct(CLuaState &ls) // run expression and push result - return CLuaIHM::runExprAndPushResult(ls, expr); + return runExprAndPushResult(ls, expr); } // *************************************************************************** @@ -780,10 +1374,10 @@ int CLuaIHMRyzom::deleteUI(CLuaState &ls) // params: CInterfaceElement * // return: none CLuaIHM::checkArgCount(ls, "deleteUI", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); if(!pIE) return 0; @@ -848,10 +1442,10 @@ int CLuaIHMRyzom::dumpUI(CLuaState &ls) // params: CInterfaceElement * // return: none CLuaIHM::checkArgCount(ls, "dumpUI", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); if(!pIE) debugInfo("UI: NULL"); else @@ -904,7 +1498,7 @@ int CLuaIHMRyzom::setTopWindow(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_setTopWindow) const char *funcName = "setTopWindow"; CLuaIHM::checkArgCount(ls, funcName, 1); - CInterfaceGroup *wnd = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + CInterfaceGroup *wnd = dynamic_cast( getUIOnStack(ls, 1)); if (!wnd) { CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); @@ -1030,8 +1624,8 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CLuaIHM::checkArgCount(ls, "setTextFormatTaged", 2); // *** check and retrieve param 1 - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); + CInterfaceElement *pIE= getUIOnStack(ls, 1); // *** check and retrieve param 2. must be a string or a ucstring ucstring text; @@ -1392,10 +1986,10 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) const char *funcName = "enableModalWindow"; CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); std::string modalId = ls.toString(2); // convert to id @@ -1612,10 +2206,10 @@ int CLuaIHMRyzom::disableContextHelpForControl(CLuaState &ls) // params: CCtrlBase* // return: none CLuaIHM::checkArgCount(ls, "disableContextHelpForControl", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); // go CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -1815,7 +2409,7 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, pIE); + pushUIOnStack(ls, pIE); } return 1; } @@ -1833,7 +2427,7 @@ int CLuaIHMRyzom::getCurrentWindowUnder(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, pIE); + pushUIOnStack(ls, pIE); } return 1; } @@ -1847,10 +2441,10 @@ int CLuaIHMRyzom::getUIId(CLuaState &ls) // params: CInterfaceElement* // return: "ui:interface:...". (empty if error) CLuaIHM::checkArgCount(ls, "getUIId", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); // convert to id if(pIE) @@ -1870,10 +2464,10 @@ int CLuaIHMRyzom::getIndexInDB(CLuaState &ls) // params: CDBCtrlSheet* // return: index in DB of a dbctrlsheet (empty if error) CLuaIHM::checkArgCount(ls, "getIndexInDB", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); + CLuaIHM::check(ls, isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + CInterfaceElement *pIE= getUIOnStack(ls, 1); CDBCtrlSheet *pCS= dynamic_cast(pIE); // get the index in db @@ -1919,7 +2513,7 @@ int CLuaIHMRyzom::createGroupInstance(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, result); + pushUIOnStack(ls, result); } return 1; } @@ -1966,7 +2560,7 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls) if (pRoot) pRoot->addGroup(result); result->setActive(true); - CLuaIHM::pushUIOnStack(ls, result); + pushUIOnStack(ls, result); } return 1; } @@ -2005,7 +2599,7 @@ int CLuaIHMRyzom::createUIElement(CLuaState &ls) } else { - CLuaIHM::pushUIOnStack(ls, result); + pushUIOnStack(ls, result); } return 1; } @@ -2256,7 +2850,7 @@ void CLuaIHMRyzom::debugInfo(const std::string &cstDbg) if (ClientCfg.LuaDebugInfoGotoButtonEnabled) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); + lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer(); lua_Debug luaDbg; if(lua_getstack (ls, 1, &luaDbg)) { @@ -2305,7 +2899,7 @@ void CLuaIHMRyzom::dumpCallStack(int startStackLevel) { lua_Debug dbg; CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); + lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer(); int stackLevel = startStackLevel; rawDebugInfo("Call stack : "); rawDebugInfo("-------------"); @@ -2328,7 +2922,7 @@ void CLuaIHMRyzom::getCallStackAsString(int startStackLevel /*=0*/,std::string & result.clear(); lua_Debug dbg; CInterfaceManager *pIM= CInterfaceManager::getInstance(); - lua_State *ls = pIM->getLuaState()->getStatePointer(); + lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer(); int stackLevel = startStackLevel; result += "Call stack : \n"; result += "-------------"; @@ -3269,3 +3863,75 @@ std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint lin } return ""; } + +// *************************************************************************** +int CLuaIHMRyzom::runExprAndPushResult(CLuaState &ls, const std::string &expr) +{ + //H_AUTO(Lua_CLuaIHM_runExprAndPushResult) + // Execute expression + CInterfaceExprValue value; + if (CInterfaceExpr::eval(expr, value, NULL)) + { + switch(value.getType()) + { + case CInterfaceExprValue::Boolean: + ls.push(value.getBool()); + break; + case CInterfaceExprValue::Integer: + ls.push((double)value.getInteger()); + break; + case CInterfaceExprValue::Double: + ls.push(value.getDouble()); + break; + case CInterfaceExprValue::String: + { + ucstring ucstr= value.getUCString(); + // Yoyo: dynamically decide whether must return a string or a ucstring + bool mustUseUCString= false; + for (uint i = 0; i < ucstr.size (); i++) + { + if (ucstr[i] > 255) + { + mustUseUCString= true; + break; + } + } + // push a ucstring? + if(mustUseUCString) + { +#if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), ucstr); +#else + luabind::object obj(ls.getStatePointer(), ucstr); + obj.pushvalue(); +#endif + } + else + { + ls.push(ucstr.toString()); + } + break; + } + case CInterfaceExprValue::RGBA: + { + CRGBA color = value.getRGBA(); +#if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), color); +#else + luabind::object obj(ls.getStatePointer(), color); + obj.pushvalue(); +#endif + break; + } + break; + case CInterfaceExprValue::UserType: // Yoyo: don't care UserType... + default: + ls.pushNil(); + break; + } + } + else + ls.pushNil(); + + return 1; +} diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 200adbab6..3c046a38d 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -11,6 +11,25 @@ public: private: static void createLuaEnumTable(CLuaState &ls, const std::string &str); + static int luaClientCfgIndex(CLuaState &ls); + static int luaClientCfgNewIndex(CLuaState &ls); + + // Functions for the ui metatable + static class CInterfaceElement *getUIRelative(class CInterfaceElement *pIE, const std::string &propName); + static int luaUIIndex(CLuaState &ls); + static int luaUINewIndex(CLuaState &ls); + static int luaUIEq(CLuaState &ls); + static int luaUINext(CLuaState &ls); + static int luaUIDtor(CLuaState &ls); + + // CInterfaceElement management on stack, stored by a CRefPtr. +public: + static void pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE); + static bool isUIOnStack(CLuaState &ls, sint index); + static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index); + static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index); + +private: static int getUI(CLuaState &ls); // params: "ui:interface:...". return: CInterfaceElement* (nil if error), an additionnal boolean parameter // LUA exported Functions with standard lua (because use ui object, use variable param number, or return dynamic-typed object) @@ -251,6 +270,8 @@ public: // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else // a, empty tag is returned static std::string createGotoFileButtonTag(const char *fileName, uint line); + + static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct }; #endif diff --git a/code/ryzom/client/src/interface_v3/lua_manager.cpp b/code/ryzom/client/src/interface_v3/lua_manager.cpp new file mode 100644 index 000000000..ccfeb147a --- /dev/null +++ b/code/ryzom/client/src/interface_v3/lua_manager.cpp @@ -0,0 +1,34 @@ +// Ryzom - MMORPG Framework +// 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 "lua_manager.h" +#include "nel/gui/lua_helper.h" + +bool CLuaManager::debugLua = false; +CLuaManager* CLuaManager::instance = NULL; + +CLuaManager::CLuaManager() +{ + luaState = new NLGUI::CLuaState( debugLua ); +} + +CLuaManager::~CLuaManager() +{ + luaState = NULL; +} + + diff --git a/code/ryzom/client/src/interface_v3/lua_manager.h b/code/ryzom/client/src/interface_v3/lua_manager.h new file mode 100644 index 000000000..246e7bbd6 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/lua_manager.h @@ -0,0 +1,57 @@ +// Ryzom - MMORPG Framework +// 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 LUA_MANAGER_H +#define LUA_MANAGER_H + +#include "nel/misc/smart_ptr.h" + +namespace NLGUI +{ + class CLuaState; +} + +/// Provides a single global access point to the Lua state, and related stuff. :( +class CLuaManager +{ +public: + ~CLuaManager(); + + static CLuaManager& getInstance() + { + if( instance == NULL ) + { + instance = new CLuaManager(); + } + return *instance; + } + + /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. + static void enableLuaDebugging(){ debugLua = true; } + + NLGUI::CLuaState* getLuaState() const{ return luaState; } + +private: + CLuaManager(); + + static CLuaManager *instance; + static bool debugLua; + + NLMISC::CSmartPtr< NLGUI::CLuaState > luaState; +}; + + +#endif diff --git a/code/ryzom/client/src/interface_v3/lua_object.cpp b/code/ryzom/client/src/interface_v3/lua_object.cpp index 209d7ba0c..109fce0a2 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.cpp +++ b/code/ryzom/client/src/interface_v3/lua_object.cpp @@ -17,7 +17,7 @@ //#include "stdpch.h" #include "lua_object.h" #include "lua_ihm.h" -#include "lua_ihm_ryzom.h" +//#include "lua_ihm_ryzom.h" #include "nel/gui/lua_helper.h" using namespace NLGUI; // @@ -617,7 +617,7 @@ void CLuaObject::dump(uint maxDepth /*= 20*/, std::set *alreadySee } catch(const std::exception &e) { - CLuaIHMRyzom::dumpCallStack(); + //CLuaIHMRyzom::dumpCallStack(); nlwarning(e.what()); } } diff --git a/code/ryzom/client/src/interface_v3/reflect.cpp b/code/ryzom/client/src/interface_v3/reflect.cpp index 17476ca52..a99d26243 100644 --- a/code/ryzom/client/src/interface_v3/reflect.cpp +++ b/code/ryzom/client/src/interface_v3/reflect.cpp @@ -15,9 +15,6 @@ // along with this program. If not, see . - - -#include "stdpch.h" #include "reflect.h" // Yoyo: Act like a singleton, else registerClass may crash. @@ -132,4 +129,63 @@ const CReflectedProperty *CReflectable::getReflectedProperty(const std::string & } +#include "lua_manager.h" +CReflectableRefPtrTarget::~CReflectableRefPtrTarget() +{ + CLuaState *lua= CLuaManager::getInstance().getLuaState(); + if(!lua) + return; + CLuaStackChecker lsc(lua); + // remove from the lua registry if i'm in + lua->pushLightUserData((void *) this); + lua->getTable(LUA_REGISTRYINDEX); + if (!lua->isNil(-1)) + { + lua->pop(); + lua->pushLightUserData((void *) this); + lua->pushNil(); + lua->setTable(LUA_REGISTRYINDEX); + } + else + { + lua->pop(); + } +} + +/** + * Data structure pushed in lua (a userdata) to access CReflectableRefPtrTarget derived objects + * These includes element of the GUI. + * if holds a pointer to the reflectable object, and + * a cache to its CClassInfo for fast access to exported properties + * \see reflect.h + */ + +// + +inline const CClassInfo &CReflectableLuaRef::getClassInfo() const +{ + nlassert(Ptr); // class info should not be accessed for a null ptr + if (_ClassInfo) return *_ClassInfo; + _ClassInfo = Ptr->getClassInfo(); + return *_ClassInfo; +} + +const CReflectedProperty *CReflectableLuaRef::getProp(const char *luaStringPtr) const +{ + const CClassInfo &ci = getClassInfo(); + CClassInfo::TLuaStrToPropMap::const_iterator it = ci.LuaStrToProp.find(luaStringPtr); + if (it != ci.LuaStrToProp.end()) + { + return it->second.Prop; + } + // slowly retrieve property, and store in cache + // NB nico : this could also be done at startup... + const CReflectedProperty *prop = CReflectSystem::getProperty(ci.ClassName, luaStringPtr, false); + if (!prop) return NULL; + CLuaIndexedProperty lip; + lip.Id = CLuaString(luaStringPtr); // keep a ref on the lua string to ensure that its pointer always remains valid + lip.Prop = prop; + ci.LuaStrToProp[luaStringPtr] = lip; + return prop; +} diff --git a/code/ryzom/client/src/interface_v3/reflect.h b/code/ryzom/client/src/interface_v3/reflect.h index 5dbdbe554..6fbb8097f 100644 --- a/code/ryzom/client/src/interface_v3/reflect.h +++ b/code/ryzom/client/src/interface_v3/reflect.h @@ -340,10 +340,31 @@ private: +/** Reflectable refcounted object + * NB nico : added this intermediate class so that the binding from lua to the reflection + * system that are found in CLuaIHM can be reused for other objects as well + * NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount' + * because the refcount part is only used for ref pointing in the ui + */ +class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount +{ +public: + virtual ~CReflectableRefPtrTarget(); +}; - - +class CReflectableLuaRef +{ +public: + CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {} + NLMISC::CRefPtr Ptr; + const CClassInfo &getClassInfo() const; + // IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo + const CReflectedProperty *getProp(const char *luaStringPtr) const; +private: + // cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer) + mutable const CClassInfo *_ClassInfo; +}; #endif diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 635e2476a..6ec4b99f4 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -112,6 +112,7 @@ #include "connection.h" #include "landscape_poly_drawer.h" #include "interface_v3/lua_ihm.h" +#include "interface_v3/lua_ihm_ryzom.h" #include "far_tp.h" #include "session_browser_impl.h" #include "bg_downloader_access.h" @@ -144,6 +145,8 @@ #include "interface_v3/bot_chat_manager.h" #include "string_manager_client.h" +#include "interface_v3/lua_manager.h" + /////////// // USING // @@ -1514,7 +1517,7 @@ bool mainLoop() R2::getEditor().waitScenario(); } - CSessionBrowserImpl::getInstance().init(CInterfaceManager::getInstance()->getLuaState()); + CSessionBrowserImpl::getInstance().init(CLuaManager::getInstance().getLuaState()); } CInterfaceManager::getInstance()->executeLuaScript("game:onMainLoopBegin()"); @@ -2977,7 +2980,7 @@ bool mainLoop() } // end of main loop CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getLuaState()) + if (CLuaManager::getInstance().getLuaState()) { CInterfaceManager::getInstance()->executeLuaScript("game:onMainLoopEnd()"); } @@ -3228,11 +3231,10 @@ class CHandlerDebugUiDumpElementUnderMouse : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { if (HighlightedDebugUI == NULL) return; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CLuaState *lua = pIM->getLuaState(); + CLuaState *lua = CLuaManager::getInstance().getLuaState(); if (!lua) return; CLuaStackRestorer lsr(lua, 0); - CLuaIHM::pushUIOnStack(*lua, HighlightedDebugUI); + CLuaIHMRyzom::pushUIOnStack(*lua, HighlightedDebugUI); lua->pushValue(LUA_GLOBALSINDEX); CLuaObject env(*lua); env["inspect"].callNoThrow(1, 0); @@ -3403,9 +3405,9 @@ void displayDebug() line-= 2 * lineStep; // Lua stuffs CInterfaceManager *pIM = CInterfaceManager::getInstance(); - TextContext->printfAt(0.0f, line, "Lua mem (kb) : %d / %d", pIM->getLuaState()->getGCCount(), pIM->getLuaState()->getGCThreshold()); + TextContext->printfAt(0.0f, line, "Lua mem (kb) : %d / %d", CLuaManager::getInstance().getLuaState()->getGCCount(), CLuaManager::getInstance().getLuaState()->getGCThreshold()); line-= lineStep; - TextContext->printfAt(0.0f, line, "Lua stack size = %d", pIM->getLuaState()->getTop()); + TextContext->printfAt(0.0f, line, "Lua stack size = %d", CLuaManager::getInstance().getLuaState()->getTop()); line-= lineStep; #endif diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index f2a6119e6..f6c43b2f7 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -113,6 +113,7 @@ using namespace NLGUI; #include "../session_browser_impl.h" #include "../far_tp.h" +#include "../interface_v3/lua_manager.h" using namespace NLMISC; @@ -587,7 +588,7 @@ CLuaState &CEditor::getLua() { //H_AUTO(R2_CEditor_getLua) CHECK_EDITOR - CLuaState *ls = getUI().getLuaState(); + CLuaState *ls = CLuaManager::getInstance().getLuaState(); nlassert(ls); return *ls; } @@ -3953,7 +3954,7 @@ void CEditor::release() } // clear the environment - if (getUI().getLuaState()) + if (CLuaManager::getInstance().getLuaState()) { getLua().push(R2_LUA_PATH); getLua().pushNil(); diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 3695ec1ac..e63dfa260 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -90,6 +90,7 @@ #include "faction_war_manager.h" #include "interface_v3/interface_ddx.h" #include "bg_downloader_access.h" +#include "interface_v3/lua_manager.h" /////////// @@ -633,6 +634,8 @@ void release() CInterfaceExpr::release(); CPdrTokenRegistry::releaseInstance(); NLNET::IModuleManager::releaseInstance(); + delete &CLuaManager::getInstance(); + From 731d1ced46f0e5157ecc6b8d31b83f9263e42d3b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 23 May 2012 04:13:58 +0200 Subject: [PATCH 029/339] CHANGED: #1471 Moved the previously refactored code to the NELGUI library. --- .../interface_v3 => nel/include/nel/gui}/lua_ihm.h | 1 + .../include/nel/gui}/lua_manager.h | 0 .../include/nel/gui}/lua_object.h | 0 .../interface_v3 => nel/include/nel/gui}/reflect.h | 2 +- .../src/interface_v3 => nel/src/gui}/lua_ihm.cpp | 14 ++++++++++---- .../interface_v3 => nel/src/gui}/lua_manager.cpp | 2 +- .../interface_v3 => nel/src/gui}/lua_object.cpp | 4 ++-- .../src/interface_v3 => nel/src/gui}/reflect.cpp | 4 ++-- code/ryzom/client/src/commands.cpp | 6 +++--- code/ryzom/client/src/debug_client.cpp | 2 +- code/ryzom/client/src/decal_anim.cpp | 4 ++-- code/ryzom/client/src/init_main_loop.cpp | 2 +- .../client/src/interface_v3/ctrl_base_button.cpp | 2 +- code/ryzom/client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../client/src/interface_v3/ctrl_text_button.cpp | 2 +- .../ryzom/client/src/interface_v3/dbctrl_sheet.cpp | 4 ++-- code/ryzom/client/src/interface_v3/dbctrl_sheet.h | 2 +- .../client/src/interface_v3/dbgroup_combo_box.cpp | 4 ++-- .../client/src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../ryzom/client/src/interface_v3/group_header.cpp | 2 +- code/ryzom/client/src/interface_v3/group_html.cpp | 2 +- code/ryzom/client/src/interface_v3/group_list.cpp | 2 +- code/ryzom/client/src/interface_v3/group_menu.cpp | 2 +- code/ryzom/client/src/interface_v3/group_tab.cpp | 2 +- code/ryzom/client/src/interface_v3/group_tree.cpp | 2 +- .../client/src/interface_v3/interface_3d_scene.cpp | 2 +- .../client/src/interface_v3/interface_element.cpp | 2 +- .../client/src/interface_v3/interface_element.h | 2 +- .../client/src/interface_v3/interface_group.cpp | 4 ++-- .../client/src/interface_v3/interface_link.cpp | 2 +- .../client/src/interface_v3/interface_manager.cpp | 2 +- .../client/src/interface_v3/interface_parser.cpp | 4 ++-- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 12 ++++++------ code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h | 2 +- .../interface_v3/register_interface_elements.cpp | 2 +- .../client/src/interface_v3/sphrase_manager.cpp | 2 +- code/ryzom/client/src/interface_v3/view_text.cpp | 2 +- code/ryzom/client/src/main_loop.cpp | 4 ++-- code/ryzom/client/src/r2/config_var.h | 2 +- code/ryzom/client/src/r2/displayer_base.cpp | 2 +- code/ryzom/client/src/r2/displayer_lua.cpp | 2 +- code/ryzom/client/src/r2/displayer_lua.h | 2 +- code/ryzom/client/src/r2/displayer_visual.cpp | 2 +- .../client/src/r2/displayer_visual_entity.cpp | 2 +- code/ryzom/client/src/r2/displayer_visual_entity.h | 2 +- code/ryzom/client/src/r2/dmc/action_historic.cpp | 2 +- code/ryzom/client/src/r2/dmc/com_lua_module.cpp | 4 ++-- code/ryzom/client/src/r2/editor.cpp | 8 ++++---- code/ryzom/client/src/r2/editor.h | 2 +- .../client/src/r2/entity_custom_select_box.cpp | 2 +- .../ryzom/client/src/r2/entity_custom_select_box.h | 2 +- code/ryzom/client/src/r2/instance.cpp | 2 +- code/ryzom/client/src/r2/instance.h | 2 +- code/ryzom/client/src/r2/lua_event_forwarder.cpp | 2 +- code/ryzom/client/src/r2/object_factory_client.cpp | 2 +- code/ryzom/client/src/r2/object_factory_client.h | 2 +- code/ryzom/client/src/r2/palette_node.h | 2 +- code/ryzom/client/src/r2/tool.cpp | 2 +- code/ryzom/client/src/r2/tool_choose_pos_lua.h | 2 +- code/ryzom/client/src/r2/tool_create_entity.cpp | 2 +- code/ryzom/client/src/r2/tool_pick.cpp | 2 +- code/ryzom/client/src/release.cpp | 2 +- code/ryzom/client/src/session_browser_impl.cpp | 4 ++-- 64 files changed, 91 insertions(+), 84 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/lua_ihm.h (97%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/lua_manager.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/lua_object.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/reflect.h (97%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/lua_ihm.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/lua_manager.cpp (93%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/lua_object.cpp (96%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/reflect.cpp (96%) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h similarity index 97% rename from code/ryzom/client/src/interface_v3/lua_ihm.h rename to code/nel/include/nel/gui/lua_ihm.h index 557e984eb..8eecb2da5 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -26,6 +26,7 @@ namespace NLMISC { class CPolygon2D; class CVector2f; + class CRGBA; } class CReflectable; diff --git a/code/ryzom/client/src/interface_v3/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h similarity index 100% rename from code/ryzom/client/src/interface_v3/lua_manager.h rename to code/nel/include/nel/gui/lua_manager.h diff --git a/code/ryzom/client/src/interface_v3/lua_object.h b/code/nel/include/nel/gui/lua_object.h similarity index 100% rename from code/ryzom/client/src/interface_v3/lua_object.h rename to code/nel/include/nel/gui/lua_object.h diff --git a/code/ryzom/client/src/interface_v3/reflect.h b/code/nel/include/nel/gui/reflect.h similarity index 97% rename from code/ryzom/client/src/interface_v3/reflect.h rename to code/nel/include/nel/gui/reflect.h index 6fbb8097f..64dbb5e2e 100644 --- a/code/ryzom/client/src/interface_v3/reflect.h +++ b/code/nel/include/nel/gui/reflect.h @@ -21,7 +21,7 @@ #define CL_REFLECT_H #include "nel/misc/rgba.h" -#include "lua_object.h" +#include "nel/gui/lua_object.h" // #include diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/lua_ihm.cpp rename to code/nel/src/gui/lua_ihm.cpp index 5ee00ba4d..7ec02ee8a 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -26,6 +26,10 @@ using namespace NLGUI; #undef assert #endif +#ifdef NL_OS_WINDOWS +#include +#endif + // Warning: cannot use namespace std, when using luabind #ifdef NL_OS_WINDOWS # ifndef NL_EXTENDED_FOR_SCOPE @@ -59,15 +63,17 @@ using namespace NLGUI; #endif -#include "lua_ihm.h" -#include "reflect.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/reflect.h" #include "nel/misc/algo.h" #include "nel/misc/file.h" #include "nel/misc/i18n.h" #include "nel/misc/time_nl.h" -#include "lua_object.h" +#include "nel/misc/path.h" +#include "nel/misc/sstring.h" +#include "nel/gui/lua_object.h" #include "nel/misc/polygon.h" -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp similarity index 93% rename from code/ryzom/client/src/interface_v3/lua_manager.cpp rename to code/nel/src/gui/lua_manager.cpp index ccfeb147a..f7606ec2b 100644 --- a/code/ryzom/client/src/interface_v3/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" #include "nel/gui/lua_helper.h" bool CLuaManager::debugLua = false; diff --git a/code/ryzom/client/src/interface_v3/lua_object.cpp b/code/nel/src/gui/lua_object.cpp similarity index 96% rename from code/ryzom/client/src/interface_v3/lua_object.cpp rename to code/nel/src/gui/lua_object.cpp index 109fce0a2..432e3c607 100644 --- a/code/ryzom/client/src/interface_v3/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -15,8 +15,8 @@ // along with this program. If not, see . //#include "stdpch.h" -#include "lua_object.h" -#include "lua_ihm.h" +#include "nel/gui/lua_object.h" +#include "nel/gui/lua_ihm.h" //#include "lua_ihm_ryzom.h" #include "nel/gui/lua_helper.h" using namespace NLGUI; diff --git a/code/ryzom/client/src/interface_v3/reflect.cpp b/code/nel/src/gui/reflect.cpp similarity index 96% rename from code/ryzom/client/src/interface_v3/reflect.cpp rename to code/nel/src/gui/reflect.cpp index a99d26243..078fa3ef6 100644 --- a/code/ryzom/client/src/interface_v3/reflect.cpp +++ b/code/nel/src/gui/reflect.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . -#include "reflect.h" +#include "nel/gui/reflect.h" // Yoyo: Act like a singleton, else registerClass may crash. CReflectSystem::TClassMap *CReflectSystem::_ClassMap= NULL; @@ -129,7 +129,7 @@ const CReflectedProperty *CReflectable::getReflectedProperty(const std::string & } -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" CReflectableRefPtrTarget::~CReflectableRefPtrTarget() { diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 3f0855f87..a97b3e33c 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -92,14 +92,14 @@ #include "weather.h" #include "forage_source_cl.h" #include "connection.h" -#include "interface_v3/lua_object.h" -#include "interface_v3/lua_ihm.h" +#include "nel/gui/lua_object.h" +#include "nel/gui/lua_ihm.h" #include "interface_v3/lua_ihm_ryzom.h" #include "init.h" #include "interface_v3/people_interraction.h" #include "far_tp.h" #include "zone_util.h" -#include "interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" // diff --git a/code/ryzom/client/src/debug_client.cpp b/code/ryzom/client/src/debug_client.cpp index c989a09f5..ff05c57cc 100644 --- a/code/ryzom/client/src/debug_client.cpp +++ b/code/ryzom/client/src/debug_client.cpp @@ -45,7 +45,7 @@ using namespace NLGUI; #include "character_cl.h" #include "r2/editor.h" #include "r2/dmc/client_edition_module.h" -#include "interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" /////////// // USING // diff --git a/code/ryzom/client/src/decal_anim.cpp b/code/ryzom/client/src/decal_anim.cpp index 3e3b43172..3cafb48a7 100644 --- a/code/ryzom/client/src/decal_anim.cpp +++ b/code/ryzom/client/src/decal_anim.cpp @@ -18,8 +18,8 @@ // #include "decal_anim.h" #include "decal.h" -#include "interface_v3/lua_ihm.h" -#include "interface_v3/lua_object.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/lua_object.h" // #include "nel/misc/vector_2f.h" #include "nel/misc/algo.h" diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index fafb7ef34..9b85367c3 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -104,7 +104,7 @@ #include "landscape_poly_drawer.h" #include "session_browser_impl.h" -#include "interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" // ProgressBar steps in init main loop diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index 045e9cf5c..233f362ae 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -23,7 +23,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "../time_client.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index f9abe1f3a..9b313ef75 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -22,7 +22,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "group_menu.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 17e713992..9014ebdc8 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -26,7 +26,7 @@ #include "view_text.h" #include "view_text_id.h" #include "group_container.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 06f16e379..e48178f77 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -44,13 +44,13 @@ #include "sphrase_manager.h" #include "../client_sheets/sphrase_sheet.h" #include "nel/misc/xml_auto_ptr.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "game_share/bot_chat_types.h" #include "../r2/editor.h" -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" extern CSheetManager SheetMngr; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index f904e34a8..7b6021415 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -23,7 +23,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/smart_ptr.h" // client -#include "reflect.h" +#include "nel/gui/reflect.h" #include "ctrl_base.h" #include "interface_expr.h" #include "action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index cbf6da945..3ccc65b7c 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -23,9 +23,9 @@ #include "interface_manager.h" #include "ctrl_button.h" #include "action_handler.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 3d76b1c80..8ea72a0df 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -28,7 +28,7 @@ #include "group_editbox.h" #include "view_text_formated.h" #include "view_text_id.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "group_list.h" #include "ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 373eccb1c..a493e3abe 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -28,7 +28,7 @@ #include "dbctrl_sheet.h" #include "group_container.h" #include "../time_client.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index eb8121ac3..93f418a65 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "group_container.h" #include "group_header.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index c8a54f602..82a8d3828 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -43,7 +43,7 @@ extern "C" #include "view_bitmap.h" #include "../actions.h" #include "dbgroup_combo_box.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../time_client.h" #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 792958295..91c245851 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -25,7 +25,7 @@ #include "view_bitmap.h" #include "view_text_id.h" #include "group_container.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 782c1f943..2aaac86c6 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -24,7 +24,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "view_bitmap.h" #include "action_handler.h" // Just for getAllParams -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index dd408b445..38a971890 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -23,7 +23,7 @@ #include "../time_client.h" #include "interface_manager.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 9fe98e9c6..6eb9159e3 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -25,7 +25,7 @@ #include "view_text.h" #include "group_container.h" #include "action_handler.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 2d654a7ba..52186b823 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -32,7 +32,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" // ---------------------------------------------------------------------------- using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 85bc0ba0f..47a11c3c3 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -25,7 +25,7 @@ #include "../misc.h" #include "interface_link.h" #include "nel/misc/xml_auto_ptr.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "nel/misc/mem_stream.h" // diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 963cbb050..27d6e4656 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -23,7 +23,7 @@ #include "nel/misc/string_mapper.h" #include "nel/misc/smart_ptr.h" #include "interface_property.h" -#include "reflect.h" +#include "nel/gui/reflect.h" // ---------------------------------------------------------------------------- class CInterfaceGroup; diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index f1db4917d..24fd256f3 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -24,12 +24,12 @@ #include "group_container.h" #include "group_editbox.h" #include "group_scrolltext.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "nel/misc/stream.h" -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" using namespace std; using namespace NL3D; diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index e8c2db540..582736412 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -23,7 +23,7 @@ #include "interface_element.h" #include "interface_manager.h" #include "interface_expr_node.h" -#include "reflect.h" +#include "nel/gui/reflect.h" #include "nel/misc/cdb_branch.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index d92d59354..1ad33bdb4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -112,7 +112,7 @@ namespace NLGUI extern void luaDebuggerMainLoop(); } using namespace NLGUI; -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "add_on_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index bdf2c7050..f2534eaab 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -107,10 +107,10 @@ #include "../commands.h" #include "nel/gui/lua_helper.h" using namespace NLGUI; -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" #include "../r2/editor.h" -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index b96bcb72d..73ae6a813 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -41,10 +41,10 @@ #include "lua_ihm_ryzom.h" #include "interface_manager.h" #include "nel/gui/lua_helper.h" -#include "lua_object.h" +#include "nel/gui/lua_object.h" -#include "lua_ihm.h" -#include "reflect.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/reflect.h" #include "action_handler.h" #include "action_handler_tools.h" #include "interface_manager.h" @@ -67,7 +67,7 @@ #include "guild_manager.h" #include "../client_cfg.h" #include "../sheet_manager.h" -#include "lua_object.h" +#include "nel/gui/lua_object.h" #include "game_share/emote_list_parser.h" #include "game_share/pvp_clan.h" #include "../weather.h" @@ -84,7 +84,7 @@ #include "../net_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes #include "../login.h" -#include "lua_object.h" +#include "nel/gui/lua_object.h" #include "../actions.h" #include "../bg_downloader_access.h" #include "../connection.h" @@ -100,7 +100,7 @@ #include "game_share/bg_downloader_msg.h" #include "game_share/constants.h" #include "game_share/visual_slot_manager.h" -#include "lua_manager.h" +#include "nel/gui/lua_manager.h" #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 3c046a38d..ba9089186 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -1,7 +1,7 @@ #ifndef LUA_IHM_RYZOM_H #define LUA_IHM_RYZOM_H -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" class CLuaIHMRyzom { diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index d7134f5b5..e763f40ee 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -38,7 +38,7 @@ #include "dbgroup_list_sheet.h" #include "group_editbox.h" #include "group_tree.h" -#include "reflect.h" +#include "nel/gui/reflect.h" #include "dbview_bar.h" #include "dbview_bar3.h" #include "group_list.h" diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index dc12a391f..5fb3244d8 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -35,7 +35,7 @@ #include "macrocmd_manager.h" #include "game_share/rolemaster_flags.h" #include "game_share/people.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index e05349985..969691ac1 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -27,7 +27,7 @@ #include "ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" -#include "lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" using namespace std; diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 6ec4b99f4..d3c8023a4 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -111,7 +111,7 @@ #include "camera_recorder.h" #include "connection.h" #include "landscape_poly_drawer.h" -#include "interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "interface_v3/lua_ihm_ryzom.h" #include "far_tp.h" #include "session_browser_impl.h" @@ -145,7 +145,7 @@ #include "interface_v3/bot_chat_manager.h" #include "string_manager_client.h" -#include "interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" /////////// diff --git a/code/ryzom/client/src/r2/config_var.h b/code/ryzom/client/src/r2/config_var.h index 674c38816..a93f9bc27 100644 --- a/code/ryzom/client/src/r2/config_var.h +++ b/code/ryzom/client/src/r2/config_var.h @@ -17,7 +17,7 @@ #ifndef R2_CONFIG_VAR_H #define R2_CONFIG_VAR_H -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include "editor.h" namespace R2 diff --git a/code/ryzom/client/src/r2/displayer_base.cpp b/code/ryzom/client/src/r2/displayer_base.cpp index a149972de..941081169 100644 --- a/code/ryzom/client/src/r2/displayer_base.cpp +++ b/code/ryzom/client/src/r2/displayer_base.cpp @@ -20,7 +20,7 @@ // #include "game_share/object.h" // -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../interface_v3/interface_element.h" namespace R2 diff --git a/code/ryzom/client/src/r2/displayer_lua.cpp b/code/ryzom/client/src/r2/displayer_lua.cpp index f73960f3a..1fa9c639a 100644 --- a/code/ryzom/client/src/r2/displayer_lua.cpp +++ b/code/ryzom/client/src/r2/displayer_lua.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "displayer_lua.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../interface_v3/lua_ihm_ryzom.h" #include "editor.h" diff --git a/code/ryzom/client/src/r2/displayer_lua.h b/code/ryzom/client/src/r2/displayer_lua.h index 6cfb2ac64..55b276afe 100644 --- a/code/ryzom/client/src/r2/displayer_lua.h +++ b/code/ryzom/client/src/r2/displayer_lua.h @@ -18,7 +18,7 @@ #define R2_DISPLAYER_LUA_H #include "displayer_base.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include "lua_event_forwarder.h" namespace R2 diff --git a/code/ryzom/client/src/r2/displayer_visual.cpp b/code/ryzom/client/src/r2/displayer_visual.cpp index d0f2a0d21..d46607f55 100644 --- a/code/ryzom/client/src/r2/displayer_visual.cpp +++ b/code/ryzom/client/src/r2/displayer_visual.cpp @@ -25,7 +25,7 @@ #include "nel/misc/vector_2f.h" // #include "../time_client.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../global.h" // #include "../interface_v3/interface_manager.h" diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.cpp b/code/ryzom/client/src/r2/displayer_visual_entity.cpp index 7a27f1c11..63a0d029b 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -50,7 +50,7 @@ #include "../interface_v3/interface_3d_scene.h" #include "../interface_v3/character_3d.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../pacs_client.h" #include "../time_client.h" // diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.h b/code/ryzom/client/src/r2/displayer_visual_entity.h index 4a9fe164e..26f475184 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.h +++ b/code/ryzom/client/src/r2/displayer_visual_entity.h @@ -20,7 +20,7 @@ #include "displayer_visual.h" #include "instance.h" #include "../decal.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include "instance_map_deco.h" class CEntityCL; diff --git a/code/ryzom/client/src/r2/dmc/action_historic.cpp b/code/ryzom/client/src/r2/dmc/action_historic.cpp index 05ed9fdd4..16d85c2d7 100644 --- a/code/ryzom/client/src/r2/dmc/action_historic.cpp +++ b/code/ryzom/client/src/r2/dmc/action_historic.cpp @@ -19,7 +19,7 @@ #include "property_accessor.h" #include "../object_factory_client.h" #include "../editor.h" -#include "../../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" namespace R2 { diff --git a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp index 7c94d7560..e64d4a8db 100644 --- a/code/ryzom/client/src/r2/dmc/com_lua_module.cpp +++ b/code/ryzom/client/src/r2/dmc/com_lua_module.cpp @@ -36,7 +36,7 @@ #include "../object_factory_client.h" #include "../editor.h" #include "../../net_manager.h" -#include "../../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../../interface_v3/lua_ihm_ryzom.h" #include "game_share/object.h" @@ -51,7 +51,7 @@ #include "nel/gui/lua_helper.h" using namespace NLGUI; -#include "../../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../../entities.h" diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index f6c43b2f7..5dc606010 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -58,16 +58,16 @@ using namespace NLGUI; #include "nel/gui/event_descriptor.h" #include "../interface_v3/group_tree.h" #include "../client_cfg.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../interface_v3/lua_ihm_ryzom.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include "../global.h" #include "../connection.h" #include "../main_loop.h" #include "../interface_v3/people_interraction.h" #include "../time_client.h" #include "../pacs_client.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../actions.h" #include "../actions_client.h" #include "object_factory_client.h" @@ -113,7 +113,7 @@ using namespace NLGUI; #include "../session_browser_impl.h" #include "../far_tp.h" -#include "../interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h index 1c793b3d5..6219715b2 100644 --- a/code/ryzom/client/src/r2/editor.h +++ b/code/ryzom/client/src/r2/editor.h @@ -17,7 +17,7 @@ #ifndef R2_EDITOR_H #define R2_EDITOR_H -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include "instance.h" #include "tool.h" #include "../decal.h" diff --git a/code/ryzom/client/src/r2/entity_custom_select_box.cpp b/code/ryzom/client/src/r2/entity_custom_select_box.cpp index ea2bd21f8..3c70120d7 100644 --- a/code/ryzom/client/src/r2/entity_custom_select_box.cpp +++ b/code/ryzom/client/src/r2/entity_custom_select_box.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" // #include "entity_custom_select_box.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" // #include "nel/misc/vector.h" diff --git a/code/ryzom/client/src/r2/entity_custom_select_box.h b/code/ryzom/client/src/r2/entity_custom_select_box.h index 0ff3357c3..f16d6f5f8 100644 --- a/code/ryzom/client/src/r2/entity_custom_select_box.h +++ b/code/ryzom/client/src/r2/entity_custom_select_box.h @@ -18,7 +18,7 @@ #define R2_ENTITY_CUSTOM_SELECT_BOX_H #include "nel/misc/aabbox.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" #include class CLuaObject; diff --git a/code/ryzom/client/src/r2/instance.cpp b/code/ryzom/client/src/r2/instance.cpp index 00d32e750..af4b2a58e 100644 --- a/code/ryzom/client/src/r2/instance.cpp +++ b/code/ryzom/client/src/r2/instance.cpp @@ -25,7 +25,7 @@ // #include "../entities.h" #include "../interface_v3/interface_manager.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../interface_v3/lua_ihm_ryzom.h" // #include "displayer_visual_entity.h" diff --git a/code/ryzom/client/src/r2/instance.h b/code/ryzom/client/src/r2/instance.h index 8825c6946..cc71b28ae 100644 --- a/code/ryzom/client/src/r2/instance.h +++ b/code/ryzom/client/src/r2/instance.h @@ -19,7 +19,7 @@ #include "nel/misc/smart_ptr.h" // -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" // #include "game_share/object.h" #include "displayer_base.h" diff --git a/code/ryzom/client/src/r2/lua_event_forwarder.cpp b/code/ryzom/client/src/r2/lua_event_forwarder.cpp index 004ea9430..7f9b06d1a 100644 --- a/code/ryzom/client/src/r2/lua_event_forwarder.cpp +++ b/code/ryzom/client/src/r2/lua_event_forwarder.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "lua_event_forwarder.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" namespace R2 diff --git a/code/ryzom/client/src/r2/object_factory_client.cpp b/code/ryzom/client/src/r2/object_factory_client.cpp index 81d4c085d..4a63796de 100644 --- a/code/ryzom/client/src/r2/object_factory_client.cpp +++ b/code/ryzom/client/src/r2/object_factory_client.cpp @@ -18,7 +18,7 @@ #include "object_factory_client.h" #include "editor.h" #include "instance.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "../interface_v3/lua_ihm_ryzom.h" namespace R2 diff --git a/code/ryzom/client/src/r2/object_factory_client.h b/code/ryzom/client/src/r2/object_factory_client.h index eee5635b7..e5ac9989d 100644 --- a/code/ryzom/client/src/r2/object_factory_client.h +++ b/code/ryzom/client/src/r2/object_factory_client.h @@ -19,7 +19,7 @@ #include "game_share/object.h" #include "editor.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" namespace R2 { diff --git a/code/ryzom/client/src/r2/palette_node.h b/code/ryzom/client/src/r2/palette_node.h index 772797469..c4e41fb2e 100644 --- a/code/ryzom/client/src/r2/palette_node.h +++ b/code/ryzom/client/src/r2/palette_node.h @@ -21,7 +21,7 @@ #if 0 //#include "interface_user_data.h" #include "group_tree.h" -#include "lua_object.h" +#include "nel/gui/lua_object.h" // #include "nel/misc/smart_ptr.h" diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index a97296590..ead70db66 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -30,7 +30,7 @@ #include "../time_client.h" #include "displayer_visual.h" #include "../interface_v3/group_map.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" // #include "nel/pacs/u_global_position.h" #include "nel/pacs/u_global_retriever.h" diff --git a/code/ryzom/client/src/r2/tool_choose_pos_lua.h b/code/ryzom/client/src/r2/tool_choose_pos_lua.h index 8e21c716e..697eb34e6 100644 --- a/code/ryzom/client/src/r2/tool_choose_pos_lua.h +++ b/code/ryzom/client/src/r2/tool_choose_pos_lua.h @@ -19,7 +19,7 @@ #include "tool_choose_pos.h" #include "nel/misc/vector.h" -#include "../interface_v3/lua_object.h" +#include "nel/gui/lua_object.h" class CEntity; class CLuaObject; diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index 73b55a0d7..44f79d0fe 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -27,7 +27,7 @@ #include "../entity_cl.h" #include "../player_r2_cl.h" #include "../sheet_manager.h" -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" #include "nel/misc/cdb_leaf.h" #include "../interface_v3/interface_manager.h" #include "dmc/palette.h" diff --git a/code/ryzom/client/src/r2/tool_pick.cpp b/code/ryzom/client/src/r2/tool_pick.cpp index 3f81fc672..d629b6b9a 100644 --- a/code/ryzom/client/src/r2/tool_pick.cpp +++ b/code/ryzom/client/src/r2/tool_pick.cpp @@ -19,7 +19,7 @@ #include "tool_pick.h" #include "instance.h" // -#include "../interface_v3/lua_ihm.h" +#include "nel/gui/lua_ihm.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index e63dfa260..018cc964a 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -90,7 +90,7 @@ #include "faction_war_manager.h" #include "interface_v3/interface_ddx.h" #include "bg_downloader_access.h" -#include "interface_v3/lua_manager.h" +#include "nel/gui/lua_manager.h" /////////// diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index c5ddb8f47..7828ed52a 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -17,8 +17,8 @@ #include "stdpch.h" #include "session_browser_impl.h" -#include "interface_v3/lua_object.h" -#include "interface_v3/lua_ihm.h" +#include "nel/gui/lua_object.h" +#include "nel/gui/lua_ihm.h" #include "connection.h" #include "net_manager.h" #include "interface_v3/interface_manager.h" From c817c68e83b8608027076ec0f241df9a85a3d28d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 23 May 2012 19:40:41 +0200 Subject: [PATCH 030/339] CHANGED: #1471 Moved the stuff I moved to NELGUI library, under the NLGUI namespace. --- code/nel/include/nel/gui/lua_ihm.h | 204 +-- code/nel/include/nel/gui/lua_manager.h | 60 +- code/nel/include/nel/gui/lua_object.h | 516 +++--- code/nel/include/nel/gui/reflect.h | 659 ++++--- code/nel/src/gui/lua_ihm.cpp | 1611 +++++++++-------- code/nel/src/gui/lua_manager.cpp | 27 +- code/nel/src/gui/lua_object.cpp | 1157 ++++++------ code/nel/src/gui/reflect.cpp | 285 +-- code/ryzom/client/src/decal_anim.h | 8 +- .../src/interface_v3/interface_element.h | 2 + .../client/src/interface_v3/interface_link.h | 10 +- .../client/src/interface_v3/lua_ihm_ryzom.h | 4 +- code/ryzom/client/src/r2/displayer_base.h | 6 +- .../client/src/r2/entity_custom_select_box.h | 7 +- .../ryzom/client/src/r2/lua_event_forwarder.h | 4 +- code/ryzom/client/src/r2/prim_render.h | 6 +- code/ryzom/client/src/r2/tool.h | 3 +- code/ryzom/client/src/r2/tool_choose_pos.h | 6 +- .../ryzom/client/src/r2/tool_choose_pos_lua.h | 5 +- code/ryzom/client/src/r2/tool_create_entity.h | 6 +- code/ryzom/client/src/r2/tool_draw_prim.h | 6 +- 21 files changed, 2318 insertions(+), 2274 deletions(-) diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index 8eecb2da5..bd7b5627a 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -19,8 +19,9 @@ #include "nel/misc/types_nl.h" #include "nel/gui/lua_helper.h" -using namespace NLGUI; +#define IHM_LUA_METATABLE "__ui_metatable" +#define IHM_LUA_ENVTABLE "__ui_envtable" namespace NLMISC { @@ -29,133 +30,122 @@ namespace NLMISC class CRGBA; } -class CReflectable; -class CReflectedProperty; - -// *************************************************************************** -/* Use this Exception for all LUA Error (eg: scripted passes bad number of paramters). - * Does not herit from Exception because avoid nlinfo, because sent twice (catch then resent) - * This is special to lua and IHM since it works with CLuaStackChecker, and also append to the error msg - * the FileName/LineNumber - */ -class ELuaIHMException : public ELuaWrappedFunctionException +namespace NLGUI { -private: - static CLuaState *getLuaState(); -public: - ELuaIHMException() : ELuaWrappedFunctionException(getLuaState()) + + class CReflectable; + class CReflectedProperty; + + // *************************************************************************** + /* Use this Exception for all LUA Error (eg: scripted passes bad number of paramters). + * Does not herit from Exception because avoid nlinfo, because sent twice (catch then resent) + * This is special to lua and IHM since it works with CLuaStackChecker, and also append to the error msg + * the FileName/LineNumber + */ + class ELuaIHMException : public ELuaWrappedFunctionException { - } - ELuaIHMException(const std::string &reason) : ELuaWrappedFunctionException(getLuaState(), reason) + private: + static CLuaState *getLuaState(); + public: + ELuaIHMException() : ELuaWrappedFunctionException(getLuaState()) + { + } + ELuaIHMException(const std::string &reason) : ELuaWrappedFunctionException(getLuaState(), reason) + { + } + ELuaIHMException(const char *format, ...) : ELuaWrappedFunctionException(getLuaState()) + { + std::string reason; + NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); + init(getLuaState(), reason); + } + }; + + // *************************************************************************** + /** + * Define Functions to export from C to LUA + * \author Lionel Berenguier + * \author Nevrax France + * \date 2004 + */ + class CLuaIHM { - } - ELuaIHMException(const char *format, ...) : ELuaWrappedFunctionException(getLuaState()) - { - std::string reason; - NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); - init(getLuaState(), reason); - } -}; + public: + static void registerAll(CLuaState &ls); + + /** CReflectableInterfaceElement management on stack, stored by a CRefPtr. + * May be called as well for ui element, because they derive from CReflectableRefPtrTarget + */ + static void pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT); + static bool isReflectableOnStack(CLuaState &ls, sint index); + static CReflectableRefPtrTarget *getReflectableOnStack(CLuaState &ls, sint index); -// *************************************************************************** -#define IHM_LUA_METATABLE "__ui_metatable" -#define IHM_LUA_ENVTABLE "__ui_envtable" + // ucstring + static bool pop(CLuaState &ls, ucstring &dest); + static void push(CLuaState &ls, const ucstring &value); + static bool isUCStringOnStack(CLuaState &ls, sint index); + static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest); -// *************************************************************************** -/** - * Define Functions to export from C to LUA - * \author Lionel Berenguier - * \author Nevrax France - * \date 2004 - */ -class CLuaIHM -{ -public: - static void registerAll(CLuaState &ls); + // RGBA + static bool pop(CLuaState &ls, NLMISC::CRGBA &dest); - /** CReflectableInterfaceElement management on stack, stored by a CRefPtr. - * May be called as well for ui element, because they derive from CReflectableRefPtrTarget - */ - static void pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT); - static bool isReflectableOnStack(CLuaState &ls, sint index); - static CReflectableRefPtrTarget *getReflectableOnStack(CLuaState &ls, sint index); + // CVector2f + static bool pop(CLuaState &ls, NLMISC::CVector2f &dest); + // helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail) + static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest); - // ucstring - static bool pop(CLuaState &ls, ucstring &dest); - static void push(CLuaState &ls, const ucstring &value); - static bool isUCStringOnStack(CLuaState &ls, sint index); - static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest); + // argument checkin helpers + static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required + static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required + static void checkArgMax(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at most the one required + static void check(CLuaState &ls, bool ok, const std::string &failReason); + static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType); + static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index); + static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index); + /** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack + * The various check... function call this function when their test fails + */ + static void fails(CLuaState &ls, const char *format, ...); + // pop a sint32 from a lua stack, throw an exception on fail + static bool popSINT32(CLuaState &ls, sint32 & dest); + bool popString(CLuaState &ls, std::string & dest); - // RGBA - static bool pop(CLuaState &ls, NLMISC::CRGBA &dest); + /** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object + * (throws on error) + */ + static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException); - // CVector2f - static bool pop(CLuaState &ls, NLMISC::CVector2f &dest); - - // helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail) - static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest); - - // argument checkin helpers - static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required - static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required - static void checkArgMax(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at most the one required - static void check(CLuaState &ls, bool ok, const std::string &failReason); - static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType); - static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index); - static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index); - /** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack - * The various check... function call this function when their test fails - */ - static void fails(CLuaState &ls, const char *format, ...); - - // pop a sint32 from a lua stack, throw an exception on fail - static bool popSINT32(CLuaState &ls, sint32 & dest); - bool popString(CLuaState &ls, std::string & dest); - - /** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object - * (throws on error) - */ - static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException); - - // push a reflected property on the stack - // NB : no check is done that 'property' is part of the class info of 'reflectedObject' - static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property); + // push a reflected property on the stack + // NB : no check is done that 'property' is part of the class info of 'reflectedObject' + static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property); -private: + private: + static void registerBasics(CLuaState &ls); + static void registerIHM(CLuaState &ls); + static void createLuaEnumTable(CLuaState &ls, const std::string &str); + //////////////////////////////////////////// Exported functions ////////////////////////////////////////////////////// + static uint32 getLocalTime(); + static double getPreciseLocalTime(); + static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace); + static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace); + static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace); + static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace); + static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace); - static void registerBasics(CLuaState &ls); - static void registerIHM(CLuaState &ls); - static void createLuaEnumTable(CLuaState &ls, const std::string &str); + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// \name Exported Functions - // @{ - - // LUA exported Functions with luabind - static uint32 getLocalTime(); - static double getPreciseLocalTime(); - - static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace); - static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace); - // just for ease of use - static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace); - static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace); - static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace); - - // @} - - // Function export tools - // Function to forward lua call to C++ to a 'lua method' exported from a reflected object - static int luaMethodCall(lua_State *ls); -}; + static int luaMethodCall(lua_State *ls); + }; +} #endif // NL_LUA_IHM_H diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h index 246e7bbd6..def6ab472 100644 --- a/code/nel/include/nel/gui/lua_manager.h +++ b/code/nel/include/nel/gui/lua_manager.h @@ -22,36 +22,36 @@ namespace NLGUI { class CLuaState; + + /// Provides a single global access point to the Lua state, and related stuff. :( + class CLuaManager + { + public: + ~CLuaManager(); + + static CLuaManager& getInstance() + { + if( instance == NULL ) + { + instance = new CLuaManager(); + } + return *instance; + } + + /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. + static void enableLuaDebugging(){ debugLua = true; } + + NLGUI::CLuaState* getLuaState() const{ return luaState; } + + private: + CLuaManager(); + + static CLuaManager *instance; + static bool debugLua; + + NLMISC::CSmartPtr< NLGUI::CLuaState > luaState; + }; + } -/// Provides a single global access point to the Lua state, and related stuff. :( -class CLuaManager -{ -public: - ~CLuaManager(); - - static CLuaManager& getInstance() - { - if( instance == NULL ) - { - instance = new CLuaManager(); - } - return *instance; - } - - /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup. - static void enableLuaDebugging(){ debugLua = true; } - - NLGUI::CLuaState* getLuaState() const{ return luaState; } - -private: - CLuaManager(); - - static CLuaManager *instance; - static bool debugLua; - - NLMISC::CSmartPtr< NLGUI::CLuaState > luaState; -}; - - #endif diff --git a/code/nel/include/nel/gui/lua_object.h b/code/nel/include/nel/gui/lua_object.h index 7e2d19370..d188018ee 100644 --- a/code/nel/include/nel/gui/lua_object.h +++ b/code/nel/include/nel/gui/lua_object.h @@ -20,282 +20,284 @@ #include "nel/misc/smart_ptr.h" #include "nel/misc/rgba.h" -// #include "nel/gui/lua_helper.h" -using namespace NLGUI; - - -class CLuaEnumeration; - -/** - * Wrapper to a lua value - * - * Useful to navigate through lua tables without having to deal with the stack. - * - * The following types are tracked by reference : - * - lua table - * - lua user data - * - lua functions - * - * The following types are kept by value : - * - * - lua numbers - * - lua strings ? - * - lua boolean - * - lua light user datas - * - lua 'pointers' - * - * Each reference object has an id giving its path in order to track bugs more easily - */ -class CLuaObject +namespace NLGUI { -public: - CLuaObject() {} - ~CLuaObject(); - // Build this object by popping it from the given lua state - CLuaObject(CLuaState &state, const char *id =""); - CLuaObject(CLuaState &state, const std::string &id); - // Build this object from another object - CLuaObject(const CLuaObject &other); - // Copy refrence to another lua object - CLuaObject &operator=(const CLuaObject &other); - // Get id for that object - const std::string &getId() const { return _Id; } - // Set id for that object - void setId(const std::string &id) { _Id = id; } - // See if the obj - bool isValid() const; - // Pop a new value for this lua object from the top of the stack. The stack must not be empty - void pop(CLuaState &luaState, const char *id =""); - // Push the object that is being referenced on the stack - // An assertion is raised if 'pop' hasn't been called or - // if the lua state has been destroyed - void push() const; - // Get the lua state in which the object resides. - CLuaState *getLuaState() const; - // Release the object. 'pop' must be called to make the object valid again - void release(); - // type queries - int type() const; - const char *getTypename() const; - bool isNil() const; - bool isNumber() const; - bool isBoolean() const; - bool isString() const; - bool isFunction() const; - bool isCFunction() const; - bool isTable() const; - bool isUserData() const; - bool isLightUserData() const; - bool isRGBA() const; - // equality - bool rawEqual(const CLuaObject &other) const; - // conversions (no throw) : the actual value of object is not modified!! - NLMISC::CRGBA toRGBA() const; // default to black if not a crgba - bool toBoolean() const; - lua_Number toNumber() const; - std::string toString() const; - lua_CFunction toCFunction() const; - void *toUserData() const; - const void *toPointer() const; - // implicit conversions (no throw) - operator bool() const; - operator float() const; - operator double() const; - operator std::string() const; - /** create a sub table for this object, with a string as a key - * This object must be a table or an exception if thrown - */ - CLuaObject newTable(const char *tableName) throw(ELuaNotATable); + class CLuaEnumeration; - /** Set a value in a table. - * If this object is not a table then an exception is thrown - * NB : value should came from the same lua environment - * \TODO other type of keys + /** + * Wrapper to a lua value + * + * Useful to navigate through lua tables without having to deal with the stack. + * + * The following types are tracked by reference : + * - lua table + * - lua user data + * - lua functions + * + * The following types are kept by value : + * + * - lua numbers + * - lua strings ? + * - lua boolean + * - lua light user datas + * - lua 'pointers' + * + * Each reference object has an id giving its path in order to track bugs more easily */ - void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable); - void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setValue(const char *key, const std::string &value) throw(ELuaNotATable); - void setValue(const char *key, const char *value) throw(ELuaNotATable); - void setValue(const char *key, bool value) throw(ELuaNotATable); - void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable); - void setValue(const char *key, double value) throw(ELuaNotATable); - void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } - void setNil(const char *key) throw(ELuaNotATable); - void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); } - /** Erase a value in a table by its key. - * If this object is not a table then an exception is thrown. - * \TODO other type of keys - */ - void eraseValue(const char *key) throw(ELuaNotATable); - void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); } - // test is this object is enumerable - bool isEnumerable() const; - // Enumeration of a table. If the object is not a table, an exception is thrown. - CLuaEnumeration enumerate() throw(ELuaNotATable); - // retrieve metatable of an object (or nil if object has no metatable) - CLuaObject getMetaTable() const; - // set metatable for this object - bool setMetaTable(CLuaObject &metatable); - /** Access to a sub element of a table (no throw). - * if the element is not a table, then 'nil' is returned - * TODO nico : add other key types if needed - * TODO nico : version that takes destination object as a reference in its parameter to avoid an object copy - */ - CLuaObject operator[](double key) const; - CLuaObject operator[](const char *key) const; - CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); } - /** Checked access to a sub element of a table. An exception is thrown is the element is not a table. - */ - CLuaObject at(const char *key) const throw (ELuaNotATable); - CLuaObject at(const std::string &key) const { return at(key.c_str()); } - - // Test is that table has the given key. The object must be a table or an exception is thrown - bool hasKey(const char *key) const; - - /** debug : recursively get value (useful for table) - * \param maxDepth (0 for no limit) - * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered) - */ - std::string toStringRecurse(uint depth = 0, uint maxDepth = 20, std::set *alreadySeen = NULL) const; - - /** dump the value in the log (includes tables) - * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered) - */ - void dump(uint maxDepth = 20, std::set *alreadySeen = NULL) const; - // concatenate identifiers, adding a dot between them if necessary. If right is a number then brackets are added - static std::string concatId(const std::string &left, const std::string &right); - // If this object is a function, then call it and return true on success - bool callNoThrow(int numArgs, int numRet); - // Call a method of this table by name (no throw version) - bool callMethodByNameNoThrow(const char *name, int numArgs, int numRet); -private: - NLMISC::CRefPtr _LuaState; - std::string _Id; -}; - - -/** enumeration of the content of a lua table - * - * Example of use : - * - *\code - CLuaObject table; - table.pop(luaState); // retrieve table from the top of a lua stack - CLuaEnumeration enueration = table.enumerate(); - while (enumeration.hasNext()) + class CLuaObject { - nlinfo('key = %s", enumeration.nextKey().toString().c_str()); - nlinfo('value = %s", enumeration.nextValue().toString().c_str()); - enumeration.next(); + public: + CLuaObject() {} + ~CLuaObject(); + // Build this object by popping it from the given lua state + CLuaObject(CLuaState &state, const char *id =""); + CLuaObject(CLuaState &state, const std::string &id); + // Build this object from another object + CLuaObject(const CLuaObject &other); + // Copy refrence to another lua object + CLuaObject &operator=(const CLuaObject &other); + // Get id for that object + const std::string &getId() const { return _Id; } + // Set id for that object + void setId(const std::string &id) { _Id = id; } + // See if the obj + bool isValid() const; + // Pop a new value for this lua object from the top of the stack. The stack must not be empty + void pop(CLuaState &luaState, const char *id =""); + // Push the object that is being referenced on the stack + // An assertion is raised if 'pop' hasn't been called or + // if the lua state has been destroyed + void push() const; + // Get the lua state in which the object resides. + CLuaState *getLuaState() const; + // Release the object. 'pop' must be called to make the object valid again + void release(); + // type queries + int type() const; + const char *getTypename() const; + bool isNil() const; + bool isNumber() const; + bool isBoolean() const; + bool isString() const; + bool isFunction() const; + bool isCFunction() const; + bool isTable() const; + bool isUserData() const; + bool isLightUserData() const; + bool isRGBA() const; + // equality + bool rawEqual(const CLuaObject &other) const; + // conversions (no throw) : the actual value of object is not modified!! + NLMISC::CRGBA toRGBA() const; // default to black if not a crgba + bool toBoolean() const; + lua_Number toNumber() const; + std::string toString() const; + lua_CFunction toCFunction() const; + void *toUserData() const; + const void *toPointer() const; + // implicit conversions (no throw) + operator bool() const; + operator float() const; + operator double() const; + operator std::string() const; + /** create a sub table for this object, with a string as a key + * This object must be a table or an exception if thrown + */ + CLuaObject newTable(const char *tableName) throw(ELuaNotATable); + + + /** Set a value in a table. + * If this object is not a table then an exception is thrown + * NB : value should came from the same lua environment + * \TODO other type of keys + */ + void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable); + void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } + void setValue(const char *key, const std::string &value) throw(ELuaNotATable); + void setValue(const char *key, const char *value) throw(ELuaNotATable); + void setValue(const char *key, bool value) throw(ELuaNotATable); + void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable); + void setValue(const char *key, double value) throw(ELuaNotATable); + void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); } + void setNil(const char *key) throw(ELuaNotATable); + void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); } + /** Erase a value in a table by its key. + * If this object is not a table then an exception is thrown. + * \TODO other type of keys + */ + void eraseValue(const char *key) throw(ELuaNotATable); + void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); } + // test is this object is enumerable + bool isEnumerable() const; + // Enumeration of a table. If the object is not a table, an exception is thrown. + CLuaEnumeration enumerate() throw(ELuaNotATable); + // retrieve metatable of an object (or nil if object has no metatable) + CLuaObject getMetaTable() const; + // set metatable for this object + bool setMetaTable(CLuaObject &metatable); + /** Access to a sub element of a table (no throw). + * if the element is not a table, then 'nil' is returned + * TODO nico : add other key types if needed + * TODO nico : version that takes destination object as a reference in its parameter to avoid an object copy + */ + CLuaObject operator[](double key) const; + CLuaObject operator[](const char *key) const; + CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); } + /** Checked access to a sub element of a table. An exception is thrown is the element is not a table. + */ + CLuaObject at(const char *key) const throw (ELuaNotATable); + CLuaObject at(const std::string &key) const { return at(key.c_str()); } + + // Test is that table has the given key. The object must be a table or an exception is thrown + bool hasKey(const char *key) const; + + /** debug : recursively get value (useful for table) + * \param maxDepth (0 for no limit) + * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered) + */ + std::string toStringRecurse(uint depth = 0, uint maxDepth = 20, std::set *alreadySeen = NULL) const; + + /** dump the value in the log (includes tables) + * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered) + */ + void dump(uint maxDepth = 20, std::set *alreadySeen = NULL) const; + // concatenate identifiers, adding a dot between them if necessary. If right is a number then brackets are added + static std::string concatId(const std::string &left, const std::string &right); + // If this object is a function, then call it and return true on success + bool callNoThrow(int numArgs, int numRet); + // Call a method of this table by name (no throw version) + bool callMethodByNameNoThrow(const char *name, int numArgs, int numRet); + private: + NLMISC::CRefPtr _LuaState; + std::string _Id; }; - \endcode - * - * There is a macro called 'ENUM_LUA_TABLE' to automate that process. - * Previous code would then be written as follow : - * - * - *\code - CLuaObject table; - table.pop(luaState); // retrieve table from the top of a lua stack - ENUM_LUA_TABLE(table, enumeration); + + + /** enumeration of the content of a lua table + * + * Example of use : + * + *\code + CLuaObject table; + table.pop(luaState); // retrieve table from the top of a lua stack + CLuaEnumeration enueration = table.enumerate(); + while (enumeration.hasNext()) + { + nlinfo('key = %s", enumeration.nextKey().toString().c_str()); + nlinfo('value = %s", enumeration.nextValue().toString().c_str()); + enumeration.next(); + }; + \endcode + * + * There is a macro called 'ENUM_LUA_TABLE' to automate that process. + * Previous code would then be written as follow : + * + * + *\code + CLuaObject table; + table.pop(luaState); // retrieve table from the top of a lua stack + ENUM_LUA_TABLE(table, enumeration); + { + nlinfo('key = %s", enumeration.nextKey().toString().c_str()); + nlinfo('value = %s", enumeration.nextValue().toString().c_str()); + }; + \endcode + * + */ + class CLuaEnumeration { - nlinfo('key = %s", enumeration.nextKey().toString().c_str()); - nlinfo('value = %s", enumeration.nextValue().toString().c_str()); + public: + // is there a next key,value pair in the table + bool hasNext() { return _HasNext; } + // Return next key. Assertion if 'hasNext' is false + const CLuaObject &nextKey() const; + // Return next value. Assertion if 'hasNext' is false + CLuaObject &nextValue(); + // Go to the next value. Assertion if there's no such value + void next(); + private: + friend class CLuaObject; + // current value & key + CLuaObject _Table; + CLuaObject _Key; + CLuaObject _Value; + CLuaObject _NextFunction; // pointer to the global 'next' function + bool _HasNext; + // construction from a table on the stack + CLuaEnumeration(CLuaObject &table); }; - \endcode - * - */ -class CLuaEnumeration -{ -public: - // is there a next key,value pair in the table - bool hasNext() { return _HasNext; } - // Return next key. Assertion if 'hasNext' is false - const CLuaObject &nextKey() const; - // Return next value. Assertion if 'hasNext' is false - CLuaObject &nextValue(); - // Go to the next value. Assertion if there's no such value - void next(); -private: - friend class CLuaObject; - // current value & key - CLuaObject _Table; - CLuaObject _Key; - CLuaObject _Value; - CLuaObject _NextFunction; // pointer to the global 'next' function - bool _HasNext; - // construction from a table on the stack - CLuaEnumeration(CLuaObject &table); -}; -/** macro to ease lua table enumeration - * \param object A CLuaObject which must be a table, and on which enumeration is done. An exception will be thrown as 'CLuaObject::enumerate' is - * called if this is not the case - * \param enumerator The enumerator object - */ -#define ENUM_LUA_TABLE(object, enumerator) for(CLuaEnumeration enumerator = (object).enumerate(); enumerator.hasNext(); enumerator.next()) + /** macro to ease lua table enumeration + * \param object A CLuaObject which must be a table, and on which enumeration is done. An exception will be thrown as 'CLuaObject::enumerate' is + * called if this is not the case + * \param enumerator The enumerator object + */ + #define ENUM_LUA_TABLE(object, enumerator) for(CLuaEnumeration enumerator = (object).enumerate(); enumerator.hasNext(); enumerator.next()) -//opitmized lua string for fast comparison -class CLuaString -{ -public: - explicit CLuaString(const char *value = "") + //opitmized lua string for fast comparison + class CLuaString { - nlassert( value != NULL ); - _Str = value; + public: + explicit CLuaString(const char *value = "") + { + nlassert( value != NULL ); + _Str = value; + } + const std::string& getStr() const{ return _Str; } + private: + std::string _Str; + mutable CLuaState::TRefPtr _LuaState; // ref ptr so that statics get rebuilt on lua restart + mutable CLuaObject _InLua; + }; + + inline bool operator==(const char* lh, const CLuaString& rh) + { + return std::string(lh) == rh.getStr(); } - const std::string& getStr() const{ return _Str; } -private: - std::string _Str; - mutable CLuaState::TRefPtr _LuaState; // ref ptr so that statics get rebuilt on lua restart - mutable CLuaObject _InLua; -}; -inline bool operator==(const char* lh, const CLuaString& rh) -{ - return std::string(lh) == rh.getStr(); + inline bool operator==( const CLuaString& lh, const CLuaString& rh) + { + return lh.getStr() == rh.getStr(); + } + + inline bool operator==(const CLuaString& lh, const char* rh) + { + return std::string(rh) == lh.getStr(); + } + + inline bool operator==( const CLuaString& lh, const std::string& rh) + { + return lh.getStr() == rh; + } + + inline bool operator==(const std::string& lh, const CLuaString& rh) + { + return lh == rh.getStr(); + } + + class CLuaHashMapTraits + { + public: + static const size_t bucket_size = 4; + static const size_t min_buckets = 8; + CLuaHashMapTraits() + {} + + // hasher for lua string -> they are unique pointers for each string, so just hash a pointer instead of a string... + size_t operator()(const char *value) const { return ((size_t) value) >> 3; } + + // equality for lua string for hash_map -> they are unique pointer -> compare pointers instead of string content + bool operator()(const char *lhs, const char *rhs) const { return lhs < rhs; } + }; + + } -inline bool operator==( const CLuaString& lh, const CLuaString& rh) -{ - return lh.getStr() == rh.getStr(); -} - -inline bool operator==(const CLuaString& lh, const char* rh) -{ - return std::string(rh) == lh.getStr(); -} - -inline bool operator==( const CLuaString& lh, const std::string& rh) -{ - return lh.getStr() == rh; -} - -inline bool operator==(const std::string& lh, const CLuaString& rh) -{ - return lh == rh.getStr(); -} - -class CLuaHashMapTraits -{ -public: - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - CLuaHashMapTraits() - {} - - // hasher for lua string -> they are unique pointers for each string, so just hash a pointer instead of a string... - size_t operator()(const char *value) const { return ((size_t) value) >> 3; } - - // equality for lua string for hash_map -> they are unique pointer -> compare pointers instead of string content - bool operator()(const char *lhs, const char *rhs) const { return lhs < rhs; } -}; - #endif diff --git a/code/nel/include/nel/gui/reflect.h b/code/nel/include/nel/gui/reflect.h index 64dbb5e2e..435c74799 100644 --- a/code/nel/include/nel/gui/reflect.h +++ b/code/nel/include/nel/gui/reflect.h @@ -14,358 +14,355 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - #ifndef CL_REFLECT_H #define CL_REFLECT_H #include "nel/misc/rgba.h" #include "nel/gui/lua_object.h" -// #include -class CReflectable; namespace NLGUI { + class CReflectable; class CLuaState; -} -struct CClassInfo; + struct CClassInfo; -/** A property of a reflectable object - * NB: multiple inheritance not supported - */ -class CReflectedProperty -{ -public: - enum TType { Boolean = 0, - SInt32, - UInt32, - Float, - String, - UCString, - RGBA, - LuaMethod - }; // other types will be added when needed - // define some pointer-to-member types - typedef bool (CReflectable::* TGetBool) () const; - typedef sint32 (CReflectable::* TGetSInt32) () const; - typedef uint32 (CReflectable::* TGetUInt32) () const; - typedef float (CReflectable::* TGetFloat) () const; - typedef std::string (CReflectable::* TGetString) () const; - typedef ucstring (CReflectable::* TGetUCString) () const; - typedef NLMISC::CRGBA (CReflectable::* TGetRGBA) () const; - // - typedef void (CReflectable::* TSetBool) (bool); - typedef void (CReflectable::* TSetSInt32) (sint32); - typedef void (CReflectable::* TSetUInt32) (uint32); - typedef void (CReflectable::* TSetFloat) (float); - typedef void (CReflectable::* TSetString) (const std::string &); - typedef void (CReflectable::* TSetUCString) (const ucstring &); - typedef void (CReflectable::* TSetRGBA) (NLMISC::CRGBA col); - // - typedef int (CReflectable:: *TLuaMethod) (CLuaState &luaState); - -public: - TType Type; - // In each union we have method pointers to retrieve / set the data of the desired type (as told in 'Type') - union - { - TGetBool GetBool; - TGetSInt32 GetSInt32; - TGetUInt32 GetUInt32; - TGetFloat GetFloat; - TGetString GetString; - TGetUCString GetUCString; - TGetRGBA GetRGBA; - TLuaMethod GetLuaMethod; // lua method can only be obtained, not written ... - } GetMethod; - union - { - TSetBool SetBool; - TSetSInt32 SetSInt32; - TSetUInt32 SetUInt32; - TSetFloat SetFloat; - TSetString SetString; - TSetUCString SetUCString; - TSetRGBA SetRGBA; - } SetMethod; - // name of the property - std::string Name; - mutable CLuaObject LuaMethodRef; // cache pointer to function call if type == LuaMethod - const CClassInfo *ParentClass; // filled when 'registerClass' is called -}; - -// a vector of reflected properties -typedef std::vector TReflectedProperties; - - -struct CClassInfo; - -/** Base class for a reflectable object - * NB: multiple inheritance not supported - */ -class CReflectable -{ -public: - virtual ~CReflectable() {} - virtual const char *getReflectedClassName() const { return "CReflectable"; } - virtual const char *getRflectedParentClassName() const { return ""; } - - /** When registering classes, the reflect system will call this function on each class - * to know which properties they exports. - * To defines which properties are exported use the REFLECT_EXPORT_** macros. - * By doing so, a new 'getReflectedProperties' function will be defined + /** A property of a reflectable object + * NB: multiple inheritance not supported */ - static void getReflectedProperties(TReflectedProperties &/* props */) + class CReflectedProperty { + public: + enum TType { Boolean = 0, + SInt32, + UInt32, + Float, + String, + UCString, + RGBA, + LuaMethod + }; // other types will be added when needed + // define some pointer-to-member types + typedef bool (CReflectable::* TGetBool) () const; + typedef sint32 (CReflectable::* TGetSInt32) () const; + typedef uint32 (CReflectable::* TGetUInt32) () const; + typedef float (CReflectable::* TGetFloat) () const; + typedef std::string (CReflectable::* TGetString) () const; + typedef ucstring (CReflectable::* TGetUCString) () const; + typedef NLMISC::CRGBA (CReflectable::* TGetRGBA) () const; + // + typedef void (CReflectable::* TSetBool) (bool); + typedef void (CReflectable::* TSetSInt32) (sint32); + typedef void (CReflectable::* TSetUInt32) (uint32); + typedef void (CReflectable::* TSetFloat) (float); + typedef void (CReflectable::* TSetString) (const std::string &); + typedef void (CReflectable::* TSetUCString) (const ucstring &); + typedef void (CReflectable::* TSetRGBA) (NLMISC::CRGBA col); + // + typedef int (CReflectable:: *TLuaMethod) (CLuaState &luaState); + + public: + TType Type; + // In each union we have method pointers to retrieve / set the data of the desired type (as told in 'Type') + union + { + TGetBool GetBool; + TGetSInt32 GetSInt32; + TGetUInt32 GetUInt32; + TGetFloat GetFloat; + TGetString GetString; + TGetUCString GetUCString; + TGetRGBA GetRGBA; + TLuaMethod GetLuaMethod; // lua method can only be obtained, not written ... + } GetMethod; + union + { + TSetBool SetBool; + TSetSInt32 SetSInt32; + TSetUInt32 SetUInt32; + TSetFloat SetFloat; + TSetString SetString; + TSetUCString SetUCString; + TSetRGBA SetRGBA; + } SetMethod; + // name of the property + std::string Name; + mutable CLuaObject LuaMethodRef; // cache pointer to function call if type == LuaMethod + const CClassInfo *ParentClass; // filled when 'registerClass' is called + }; + + // a vector of reflected properties + typedef std::vector TReflectedProperties; + + + struct CClassInfo; + + /** Base class for a reflectable object + * NB: multiple inheritance not supported + */ + class CReflectable + { + public: + virtual ~CReflectable() {} + virtual const char *getReflectedClassName() const { return "CReflectable"; } + virtual const char *getRflectedParentClassName() const { return ""; } + + /** When registering classes, the reflect system will call this function on each class + * to know which properties they exports. + * To defines which properties are exported use the REFLECT_EXPORT_** macros. + * By doing so, a new 'getReflectedProperties' function will be defined + */ + static void getReflectedProperties(TReflectedProperties &/* props */) + { + } + // get class infos for this reflectable object + const CClassInfo *getClassInfo(); + + /** get a property from this object by name + * TODO nico : optimized version for lua string (found in CLuaIHM) would maybe fit better here ... + */ + const CReflectedProperty *getReflectedProperty(const std::string &propertyName, bool dspWarning= true) const; + }; + + struct CLuaIndexedProperty + { + const CReflectedProperty *Prop; + CLuaString Id; // must keep id here, so that we are sure the string is not gc in lua and its pointer remains valid + }; + + + struct CClassInfo + { + TReflectedProperties Properties; // the properties exported by this class + const CClassInfo *ParentClass; // pointer to infos of the parent class, or NULL if it is a root class + std::string ClassName; + /** For lua speedup (used by CLuaIHM) : because lua string are unique, we can use them to access property directly. + */ + typedef CHashMap TLuaStrToPropMap; + mutable TLuaStrToPropMap LuaStrToProp; + }; + + /** Simple reflection system. + * Used by the GUI and some other objects. + * It is used to export some properties so that we can easily manipulate them in the GUI scripts (either lua or with CInterfaceExpr). + * NB: multiple inheritance not supported + * + * Example of use : a class exporting a boolean + * + * class CTestClass : public CReflectable + * { + * public: + * void setValue(bool value) { _Value = value; } + * bool getValue() const { return _Value; } + * \\ export the bool value + * REFLECT_EXPORT_START(CTestClass, CReflectable) + * REFLECT_BOOL("myValue", setValue, getValue) + * REFLECT_EXPORT_END + * private: + * bool _Value; + * }; + * + * The class must then be registered with : + * + * REGISTER_REFLECTABLE_CLASS(CTestClass, CReflectable) + * + * NB: It should be registered after its parents + * + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CReflectSystem + { + public: + + typedef std::map TClassMap; + + public: + // release memory + static void release(); + + /** register a class and its properties + * NB : class should be registered after their parent have been, or an assertion will be raised + */ + static void registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties); + + // retrieve a property of a reflectable class, or NULL if unknown + static const CReflectedProperty *getProperty(const std::string &className, const std::string &propertyName, bool dspWarning= true); + + // get the list of class for debug or read purpose (NULL if no register has been called) + static const TClassMap *getClassMap() {return _ClassMap;} + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + private: + static TClassMap *_ClassMap; // each class and its infos + }; + + + /** Helper macros to export properties of a reflectable class + */ + + /** Start a declaration of a reflectable class exports + * Should be placed inside the class + */ + #define REFLECT_EXPORT_START(className, parentName) \ + virtual const char *getReflectedClassName() const { return #className; } \ + virtual const char *getReflectedParentClassName() const { return #parentName; } \ + static void getReflectedProperties(TReflectedProperties &props) \ + { \ + typedef className A; \ + typedef bool (className::* TGetBoola) () const; \ + typedef sint32 (className::* TGetSInt32a) () const; \ + typedef uint32 (className::* TGetUInt32a) () const; \ + typedef float (className::* TGetFloata) () const; \ + typedef std::string (className::* TGetStringa) () const; \ + typedef ucstring (className::* TGetUCStringa) () const; \ + typedef NLMISC::CRGBA (className::* TGetRGBAa) () const; \ + typedef void (className::* TSetBoola) (bool); \ + typedef void (className::* TSetSInt32a) (sint32); \ + typedef void (className::* TSetUInt32a) (uint32); \ + typedef void (className::* TSetFloata) (float); \ + typedef void (className::* TSetStringa) (const std::string &); \ + typedef void (className::* TSetUCStringa) (const ucstring &); \ + typedef void (className::* TSetRGBAa) (NLMISC::CRGBA col); \ + typedef int (className:: *TLuaMethoda) (CLuaState &luaState); \ + nlunreferenced(props); + + + // export a boolean value, by giving the name of the get and the set method + #define REFLECT_BOOL(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::Boolean; \ + prop.GetMethod.GetBool = (CReflectedProperty::TGetBool) (TGetBoola) &A::getMethod; \ + prop.SetMethod.SetBool = (CReflectedProperty::TSetBool) (TSetBoola) &A::setMethod; \ + props.push_back(prop); \ } - // get class infos for this reflectable object - const CClassInfo *getClassInfo(); - /** get a property from this object by name - * TODO nico : optimized version for lua string (found in CLuaIHM) would maybe fit better here ... + // export a sint32 value, by giving the name of the get and the set method + #define REFLECT_SINT32(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::SInt32; \ + prop.GetMethod.GetSInt32 = (CReflectedProperty::TGetSInt32) (TGetSInt32a) &A::getMethod; \ + prop.SetMethod.SetSInt32 = (CReflectedProperty::TSetSInt32) (TSetSInt32a) &A::setMethod; \ + props.push_back(prop); \ + } + + // export a sint32 value, by giving the name of the get and the set method + #define REFLECT_UINT32(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::UInt32; \ + prop.GetMethod.GetUInt32 = (CReflectedProperty::TGetUInt32) (TGetUInt32a) &A::getMethod; \ + prop.SetMethod.SetUInt32 = (CReflectedProperty::TSetUInt32) (TSetUInt32a) &A::setMethod; \ + props.push_back(prop); \ + } + + // export a float value, by giving the name of the get and the set method + #define REFLECT_FLOAT(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::Float; \ + prop.GetMethod.GetFloat = (CReflectedProperty::TGetFloat) (TGetFloata) &A::getMethod; \ + prop.SetMethod.SetFloat = (CReflectedProperty::TSetFloat) (TSetFloata) &A::setMethod; \ + props.push_back(prop); \ + } + + // export a string value, by giving the name of the get and the set method + #define REFLECT_STRING(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::String; \ + prop.GetMethod.GetString = (CReflectedProperty::TGetString) (TGetStringa) &A::getMethod; \ + prop.SetMethod.SetString = (CReflectedProperty::TSetString) (TSetStringa) &A::setMethod; \ + props.push_back(prop); \ + } + + // export a unicode string value, by giving the name of the get and the set method + #define REFLECT_UCSTRING(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::UCString; \ + prop.GetMethod.GetUCString = (CReflectedProperty::TGetUCString) (TGetUCStringa) &A::getMethod; \ + prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) (TSetUCStringa) &A::setMethod; \ + props.push_back(prop); \ + } + + + // export a color value, by giving the name of the get and the set method + #define REFLECT_RGBA(exportName, getMethod, setMethod) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::RGBA; \ + prop.GetMethod.GetRGBA = (CReflectedProperty::TGetRGBA) (TGetRGBAa) &A::getMethod; \ + prop.SetMethod.SetRGBA = (CReflectedProperty::TSetRGBA) (TSetRGBAa) &A::setMethod; \ + props.push_back(prop); \ + } + + // export a lua method + #define REFLECT_LUA_METHOD(exportName, method) \ + { \ + CReflectedProperty prop; \ + prop.Name = exportName; \ + prop.Type = CReflectedProperty::LuaMethod; \ + prop.GetMethod.GetLuaMethod = (CReflectedProperty::TLuaMethod) (TLuaMethoda) &A::method; \ + props.push_back(prop); \ + } + + + + // ends an export declaration + #define REFLECT_EXPORT_END } + + + // This macro registers a reflectable class to the manager + #define REGISTER_REFLECTABLE_CLASS(className, parentName) \ + { \ + TReflectedProperties props; \ + className::getReflectedProperties(props); \ + CReflectSystem::registerClass(#className, #parentName, props); \ + } + + + + /** Reflectable refcounted object + * NB nico : added this intermediate class so that the binding from lua to the reflection + * system that are found in CLuaIHM can be reused for other objects as well + * NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount' + * because the refcount part is only used for ref pointing in the ui */ - const CReflectedProperty *getReflectedProperty(const std::string &propertyName, bool dspWarning= true) const; -}; - -struct CLuaIndexedProperty -{ - const CReflectedProperty *Prop; - CLuaString Id; // must keep id here, so that we are sure the string is not gc in lua and its pointer remains valid -}; + class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount + { + public: + virtual ~CReflectableRefPtrTarget(); + }; -struct CClassInfo -{ - TReflectedProperties Properties; // the properties exported by this class - const CClassInfo *ParentClass; // pointer to infos of the parent class, or NULL if it is a root class - std::string ClassName; - /** For lua speedup (used by CLuaIHM) : because lua string are unique, we can use them to access property directly. - */ - typedef CHashMap TLuaStrToPropMap; - mutable TLuaStrToPropMap LuaStrToProp; -}; - -/** Simple reflection system. - * Used by the GUI and some other objects. - * It is used to export some properties so that we can easily manipulate them in the GUI scripts (either lua or with CInterfaceExpr). - * NB: multiple inheritance not supported - * - * Example of use : a class exporting a boolean - * - * class CTestClass : public CReflectable - * { - * public: - * void setValue(bool value) { _Value = value; } - * bool getValue() const { return _Value; } - * \\ export the bool value - * REFLECT_EXPORT_START(CTestClass, CReflectable) - * REFLECT_BOOL("myValue", setValue, getValue) - * REFLECT_EXPORT_END - * private: - * bool _Value; - * }; - * - * The class must then be registered with : - * - * REGISTER_REFLECTABLE_CLASS(CTestClass, CReflectable) - * - * NB: It should be registered after its parents - * - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CReflectSystem -{ -public: - - typedef std::map TClassMap; - -public: - // release memory - static void release(); - - /** register a class and its properties - * NB : class should be registered after their parent have been, or an assertion will be raised - */ - static void registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties); - - // retrieve a property of a reflectable class, or NULL if unknown - static const CReflectedProperty *getProperty(const std::string &className, const std::string &propertyName, bool dspWarning= true); - - // get the list of class for debug or read purpose (NULL if no register has been called) - static const TClassMap *getClassMap() {return _ClassMap;} - -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -private: - static TClassMap *_ClassMap; // each class and its infos -}; + class CReflectableLuaRef + { + public: + CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {} + NLMISC::CRefPtr Ptr; + const CClassInfo &getClassInfo() const; + // IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo + const CReflectedProperty *getProp(const char *luaStringPtr) const; + private: + // cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer) + mutable const CClassInfo *_ClassInfo; + }; -/** Helper macros to export properties of a reflectable class - */ - -/** Start a declaration of a reflectable class exports - * Should be placed inside the class - */ -#define REFLECT_EXPORT_START(className, parentName) \ - virtual const char *getReflectedClassName() const { return #className; } \ - virtual const char *getReflectedParentClassName() const { return #parentName; } \ - static void getReflectedProperties(TReflectedProperties &props) \ - { \ - typedef className A; \ - typedef bool (className::* TGetBoola) () const; \ - typedef sint32 (className::* TGetSInt32a) () const; \ - typedef uint32 (className::* TGetUInt32a) () const; \ - typedef float (className::* TGetFloata) () const; \ - typedef std::string (className::* TGetStringa) () const; \ - typedef ucstring (className::* TGetUCStringa) () const; \ - typedef NLMISC::CRGBA (className::* TGetRGBAa) () const; \ - typedef void (className::* TSetBoola) (bool); \ - typedef void (className::* TSetSInt32a) (sint32); \ - typedef void (className::* TSetUInt32a) (uint32); \ - typedef void (className::* TSetFloata) (float); \ - typedef void (className::* TSetStringa) (const std::string &); \ - typedef void (className::* TSetUCStringa) (const ucstring &); \ - typedef void (className::* TSetRGBAa) (NLMISC::CRGBA col); \ - typedef int (className:: *TLuaMethoda) (CLuaState &luaState); \ - nlunreferenced(props); - - -// export a boolean value, by giving the name of the get and the set method -#define REFLECT_BOOL(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::Boolean; \ - prop.GetMethod.GetBool = (CReflectedProperty::TGetBool) (TGetBoola) &A::getMethod; \ - prop.SetMethod.SetBool = (CReflectedProperty::TSetBool) (TSetBoola) &A::setMethod; \ - props.push_back(prop); \ } -// export a sint32 value, by giving the name of the get and the set method -#define REFLECT_SINT32(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::SInt32; \ - prop.GetMethod.GetSInt32 = (CReflectedProperty::TGetSInt32) (TGetSInt32a) &A::getMethod; \ - prop.SetMethod.SetSInt32 = (CReflectedProperty::TSetSInt32) (TSetSInt32a) &A::setMethod; \ - props.push_back(prop); \ -} - -// export a sint32 value, by giving the name of the get and the set method -#define REFLECT_UINT32(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::UInt32; \ - prop.GetMethod.GetUInt32 = (CReflectedProperty::TGetUInt32) (TGetUInt32a) &A::getMethod; \ - prop.SetMethod.SetUInt32 = (CReflectedProperty::TSetUInt32) (TSetUInt32a) &A::setMethod; \ - props.push_back(prop); \ -} - -// export a float value, by giving the name of the get and the set method -#define REFLECT_FLOAT(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::Float; \ - prop.GetMethod.GetFloat = (CReflectedProperty::TGetFloat) (TGetFloata) &A::getMethod; \ - prop.SetMethod.SetFloat = (CReflectedProperty::TSetFloat) (TSetFloata) &A::setMethod; \ - props.push_back(prop); \ -} - -// export a string value, by giving the name of the get and the set method -#define REFLECT_STRING(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::String; \ - prop.GetMethod.GetString = (CReflectedProperty::TGetString) (TGetStringa) &A::getMethod; \ - prop.SetMethod.SetString = (CReflectedProperty::TSetString) (TSetStringa) &A::setMethod; \ - props.push_back(prop); \ -} - -// export a unicode string value, by giving the name of the get and the set method -#define REFLECT_UCSTRING(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::UCString; \ - prop.GetMethod.GetUCString = (CReflectedProperty::TGetUCString) (TGetUCStringa) &A::getMethod; \ - prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) (TSetUCStringa) &A::setMethod; \ - props.push_back(prop); \ -} - - -// export a color value, by giving the name of the get and the set method -#define REFLECT_RGBA(exportName, getMethod, setMethod) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::RGBA; \ - prop.GetMethod.GetRGBA = (CReflectedProperty::TGetRGBA) (TGetRGBAa) &A::getMethod; \ - prop.SetMethod.SetRGBA = (CReflectedProperty::TSetRGBA) (TSetRGBAa) &A::setMethod; \ - props.push_back(prop); \ -} - -// export a lua method -#define REFLECT_LUA_METHOD(exportName, method) \ -{ \ - CReflectedProperty prop; \ - prop.Name = exportName; \ - prop.Type = CReflectedProperty::LuaMethod; \ - prop.GetMethod.GetLuaMethod = (CReflectedProperty::TLuaMethod) (TLuaMethoda) &A::method; \ - props.push_back(prop); \ -} - - - -// ends an export declaration -#define REFLECT_EXPORT_END } - - -// This macro registers a reflectable class to the manager -#define REGISTER_REFLECTABLE_CLASS(className, parentName) \ -{ \ - TReflectedProperties props; \ - className::getReflectedProperties(props); \ - CReflectSystem::registerClass(#className, #parentName, props); \ -} - - - -/** Reflectable refcounted object - * NB nico : added this intermediate class so that the binding from lua to the reflection - * system that are found in CLuaIHM can be reused for other objects as well - * NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount' - * because the refcount part is only used for ref pointing in the ui - */ -class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount -{ -public: - virtual ~CReflectableRefPtrTarget(); -}; - - -class CReflectableLuaRef -{ -public: - CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {} - NLMISC::CRefPtr Ptr; - const CClassInfo &getClassInfo() const; - // IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo - const CReflectedProperty *getProp(const char *luaStringPtr) const; -private: - // cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer) - mutable const CClassInfo *_ClassInfo; -}; - - #endif diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 7ec02ee8a..8cd1ea463 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -16,7 +16,6 @@ #include "nel/gui/lua_helper.h" -using namespace NLGUI; #include @@ -92,840 +91,848 @@ std::ostream &operator<<(std::ostream &str, const ucstring &value) return str << value.toString(); } -struct CMiscFunctions +namespace NLGUI { - static std::string fileLookup(const std::string &fileName) + + struct CMiscFunctions { - return NLMISC::CPath::lookup(fileName, false); - } - static void shellExecute(const char *operation, const char *fileName, const char *parameters) - { - #if !FINAL_VERSION - #ifdef NL_OS_WINDOWS - ShellExecute(NULL, operation, fileName, parameters, NULL, SW_SHOWDEFAULT); + static std::string fileLookup(const std::string &fileName) + { + return NLMISC::CPath::lookup(fileName, false); + } + static void shellExecute(const char *operation, const char *fileName, const char *parameters) + { + #if !FINAL_VERSION + #ifdef NL_OS_WINDOWS + ShellExecute(NULL, operation, fileName, parameters, NULL, SW_SHOWDEFAULT); + #endif #endif + } + }; + + + // *************************************************************************** + bool CLuaIHM::pop(CLuaState &ls, NLMISC::CRGBA &dest) + { + //H_AUTO(Lua_CLuaIHM_pop) + try + { + if (ls.isNil(-1)) return false; + #if LUABIND_VERSION > 600 + luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); + ls.pop(); + #else + luabind::object obj(ls.getStatePointer()); + obj.set(); + #endif + dest = luabind::object_cast(obj); + } + catch(const luabind::cast_failed &) + { + return false; + } + return true; + } + + // *************************************************************************** + bool CLuaIHM::pop(CLuaState &ls,NLMISC::CVector2f &dest) + { + //H_AUTO(Lua_CLuaIHM_pop) + try + { + if (ls.isNil(-1)) return false; + #if LUABIND_VERSION > 600 + luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); + ls.pop(); + #else + luabind::object obj(ls.getStatePointer()); + obj.set(); + #endif + dest = luabind::object_cast(obj); + } + catch(const luabind::cast_failed &) + { + return false; + } + return true; + } + + // *************************************************************************** + bool CLuaIHM::pop(CLuaState &ls, ucstring &dest) + { + //H_AUTO(Lua_CLuaIHM_pop) + try + { + if (ls.isNil(-1)) return false; + #if LUABIND_VERSION > 600 + luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); + ls.pop(); + #else + luabind::object obj(ls.getStatePointer()); + obj.set(); + #endif + dest = luabind::object_cast(obj); + } + catch(const luabind::cast_failed &) + { + return false; + } + return true; + } + + // *************************************************************************** + bool CLuaIHM::isUCStringOnStack(CLuaState &ls, sint index) + { + //H_AUTO(Lua_CLuaIHM_isUCStringOnStack) + ls.pushValue(index); + ucstring dummy; + return pop(ls, dummy); + } + + // *************************************************************************** + bool CLuaIHM::getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest) + { + //H_AUTO(Lua_CLuaIHM_getUCStringOnStack) + ls.pushValue(index); + return pop(ls, dest); + } + + + // *************************************************************************** + void CLuaIHM::push(CLuaState &ls, const ucstring &value) + { + //H_AUTO(Lua_CLuaIHM_push) + #if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), value); + #else + luabind::object obj(ls.getStatePointer(), value); + obj.pushvalue(); #endif } -}; + + // *************************************************************************** + // *************************************************************************** + // CInterface To LUA Registry + // *************************************************************************** + // *************************************************************************** -// *************************************************************************** -bool CLuaIHM::pop(CLuaState &ls, NLMISC::CRGBA &dest) -{ - //H_AUTO(Lua_CLuaIHM_pop) - try + CLuaState * ELuaIHMException::getLuaState() { - if (ls.isNil(-1)) return false; -#if LUABIND_VERSION > 600 - luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); - ls.pop(); -#else - luabind::object obj(ls.getStatePointer()); - obj.set(); -#endif - dest = luabind::object_cast(obj); + return CLuaManager::getInstance().getLuaState(); } - catch(const luabind::cast_failed &) - { - return false; - } - return true; -} - -// *************************************************************************** -bool CLuaIHM::pop(CLuaState &ls,NLMISC::CVector2f &dest) -{ - //H_AUTO(Lua_CLuaIHM_pop) - try - { - if (ls.isNil(-1)) return false; -#if LUABIND_VERSION > 600 - luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); - ls.pop(); -#else - luabind::object obj(ls.getStatePointer()); - obj.set(); -#endif - dest = luabind::object_cast(obj); - } - catch(const luabind::cast_failed &) - { - return false; - } - return true; -} - -// *************************************************************************** -bool CLuaIHM::pop(CLuaState &ls, ucstring &dest) -{ - //H_AUTO(Lua_CLuaIHM_pop) - try - { - if (ls.isNil(-1)) return false; -#if LUABIND_VERSION > 600 - luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); - ls.pop(); -#else - luabind::object obj(ls.getStatePointer()); - obj.set(); -#endif - dest = luabind::object_cast(obj); - } - catch(const luabind::cast_failed &) - { - return false; - } - return true; -} - -// *************************************************************************** -bool CLuaIHM::isUCStringOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_isUCStringOnStack) - ls.pushValue(index); - ucstring dummy; - return pop(ls, dummy); -} - -// *************************************************************************** -bool CLuaIHM::getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest) -{ - //H_AUTO(Lua_CLuaIHM_getUCStringOnStack) - ls.pushValue(index); - return pop(ls, dest); -} - - -// *************************************************************************** -void CLuaIHM::push(CLuaState &ls, const ucstring &value) -{ - //H_AUTO(Lua_CLuaIHM_push) -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), value); -#else - luabind::object obj(ls.getStatePointer(), value); - obj.pushvalue(); -#endif -} - -// *************************************************************************** -// *************************************************************************** -// CInterface To LUA Registry -// *************************************************************************** -// *************************************************************************** - - -CLuaState * ELuaIHMException::getLuaState() -{ - return CLuaManager::getInstance().getLuaState(); -} - -// *************************************************************************** -#define LUA_REGISTER_BASIC(_type_) \ -luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \ -_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ -{ \ - return (_type_)lua_tonumber(L, index); \ -} \ -int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ -{ \ - if (lua_isnumber(L, index)) return 0; else return -1; \ -} \ -void convert_cpp_to_lua(lua_State* L, const _type_& v) \ -{ \ - lua_pushnumber(L, (double)v); \ -} - -// Basic LUA types -namespace luabind -{ - namespace converters - { - LUA_REGISTER_BASIC(sint8) - LUA_REGISTER_BASIC(uint8) - LUA_REGISTER_BASIC(sint16) - LUA_REGISTER_BASIC(uint16) - LUA_REGISTER_BASIC(sint32) - LUA_REGISTER_BASIC(uint32) -// LUA_REGISTER_BASIC(sint) -// LUA_REGISTER_BASIC(uint) - } -} - -// *************************************************************************** -void CLuaIHM::registerBasics(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_registerBasics) - using namespace luabind; - lua_State *L= ls.getStatePointer(); - - // RGBA - module(L) - [ - class_("CRGBA") - .def(constructor<>()) - .def(constructor()) - .def(constructor()) - .def(constructor()) - .def_readwrite("R", &NLMISC::CRGBA::R) - .def_readwrite("G", &NLMISC::CRGBA::G) - .def_readwrite("B", &NLMISC::CRGBA::B) - .def_readwrite("A", &NLMISC::CRGBA::A) - ]; - - // ucstring - module(L) - [ - class_("ucstring") - .def(constructor<>()) - .def(constructor()) - .def(constructor()) - .def(const_self + other()) - .def(other() + const_self) - // NB nico : luabind crash not solved here -> use concatUCString as a replacement -// .def(const_self + other()) - .def(const_self < other()) - .def(const_self == other()) - .def("toUtf8", &ucstring::toUtf8) - .def("fromUtf8", &ucstring::fromUtf8) - .def("substr", &ucstring::luabind_substr) - .def(luabind::tostring(const_self)) // __string metamethod - .def("toString", (std::string(ucstring::*)()const)&ucstring::toString) - //.def(self + other()) - ]; - - // CVector2f - module(L) - [ - class_("CVector2f") - .def(constructor()) - .def_readwrite("x", &NLMISC::CVector2f::x) - .def_readwrite("y", &NLMISC::CVector2f::y) - ]; } + // *************************************************************************** + #define LUA_REGISTER_BASIC(_type_) \ + luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \ + _type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ + { \ + return (_type_)lua_tonumber(L, index); \ + } \ + int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ + { \ + if (lua_isnumber(L, index)) return 0; else return -1; \ + } \ + void convert_cpp_to_lua(lua_State* L, const _type_& v) \ + { \ + lua_pushnumber(L, (double)v); \ + } -// *************************************************************************** -int CLuaIHM::luaMethodCall(lua_State *ls) -{ - //H_AUTO(Lua_CLuaIHM_luaMethodCall) - nlassert(ls); - const CReflectedProperty *prop = (const CReflectedProperty *) lua_touserdata(ls, lua_upvalueindex(1)); - CLuaState *state = (CLuaState *) lua_touserdata(ls, lua_upvalueindex(2)); - nlassert(prop); - nlassert(prop->Type == CReflectedProperty::LuaMethod); - nlassert(state); - if (state->empty()) + // Basic LUA types + namespace luabind { - state->push(NLMISC::toString("Error while calling lua method %s:%s : no 'self' reference provided, did you you function call '.' instead of method call ':' ?", - prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) - ); - lua_error(ls); - } - // because this is a method, first parameter is the 'this' - CReflectableRefPtrTarget *pRPT = getReflectableOnStack(*state, 1); - if (pRPT == NULL) - { - state->push(NLMISC::toString("Error while calling lua method %s:%s : 'self' pointer is nil or of bad type, can't make the call.", - prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) - ); - lua_error(ls); - } - // - state->remove(1); // remove 'self' reference from parameters stack - // - sint numResults = 0; - sint initialStackSize = state->getTop(); - try - { - // call the actual method - numResults = (pRPT->*(prop->GetMethod.GetLuaMethod))(*state); - } - catch(const std::exception &e) - { - // restore stack to its initial size - state->setTop(initialStackSize); - lua_pushstring(ls, e.what()); - // TODO : see if this is safe to call lua error there" ... (it does a long jump) - lua_error(ls); - } - return numResults; -} - -// *************************************************************************** -void CLuaIHM::luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property) -{ - //H_AUTO(Lua_CLuaIHM_luaValueFromReflectedProperty) - switch(property.Type) - { - case CReflectedProperty::Boolean: - ls.push( (reflectedObject.*(property.GetMethod.GetBool))() ); - break; - case CReflectedProperty::SInt32: - ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetSInt32))() ); - break; - case CReflectedProperty::Float: - ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() ); - break; - case CReflectedProperty::String: - ls.push( (reflectedObject.*(property.GetMethod.GetString))() ); - break; - case CReflectedProperty::UCString: + namespace converters { - ucstring str = (reflectedObject.*(property.GetMethod.GetUCString))(); -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), str); -#else - luabind::object obj(ls.getStatePointer(), str); - obj.pushvalue(); -#endif + LUA_REGISTER_BASIC(sint8) + LUA_REGISTER_BASIC(uint8) + LUA_REGISTER_BASIC(sint16) + LUA_REGISTER_BASIC(uint16) + LUA_REGISTER_BASIC(sint32) + LUA_REGISTER_BASIC(uint32) + // LUA_REGISTER_BASIC(sint) + // LUA_REGISTER_BASIC(uint) } - break; - case CReflectedProperty::RGBA: - { - CRGBA color = (reflectedObject.*(property.GetMethod.GetRGBA))(); -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), color); -#else - luabind::object obj(ls.getStatePointer(), color); - obj.pushvalue(); -#endif - } - break; - case CReflectedProperty::LuaMethod: - { - // must create a closure that will forward the call to the real method - if (!property.LuaMethodRef.isValid()) - { - ls.pushLightUserData((void *) &property); - ls.pushLightUserData((void *) &ls); - ls.pushCClosure(luaMethodCall, 2); - property.LuaMethodRef.pop(ls); - } - nlassert(property.LuaMethodRef.getLuaState() == &ls); // only one single lua state supported for now - property.LuaMethodRef.push(); - } - break; - default: - nlstop; - break; } -} -static CLuaString lstr_Env("Env"); -static CLuaString lstr_isNil("isNil"); - -// *************************************************************************** -void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) +namespace NLGUI { - //H_AUTO(Lua_property_throw) - if(ls.isNil(stackIndex)) - throw ELuaIHMException("Trying to set nil to UI property '%s'", property.Name.c_str()); - switch(property.Type) + + // *************************************************************************** + void CLuaIHM::registerBasics(CLuaState &ls) { - case CReflectedProperty::Boolean: + //H_AUTO(Lua_CLuaIHM_registerBasics) + using namespace luabind; + lua_State *L= ls.getStatePointer(); + + // RGBA + module(L) + [ + class_("CRGBA") + .def(constructor<>()) + .def(constructor()) + .def(constructor()) + .def(constructor()) + .def_readwrite("R", &NLMISC::CRGBA::R) + .def_readwrite("G", &NLMISC::CRGBA::G) + .def_readwrite("B", &NLMISC::CRGBA::B) + .def_readwrite("A", &NLMISC::CRGBA::A) + ]; + + // ucstring + module(L) + [ + class_("ucstring") + .def(constructor<>()) + .def(constructor()) + .def(constructor()) + .def(const_self + other()) + .def(other() + const_self) + // NB nico : luabind crash not solved here -> use concatUCString as a replacement + // .def(const_self + other()) + .def(const_self < other()) + .def(const_self == other()) + .def("toUtf8", &ucstring::toUtf8) + .def("fromUtf8", &ucstring::fromUtf8) + .def("substr", &ucstring::luabind_substr) + .def(luabind::tostring(const_self)) // __string metamethod + .def("toString", (std::string(ucstring::*)()const)&ucstring::toString) + //.def(self + other()) + ]; + + // CVector2f + module(L) + [ + class_("CVector2f") + .def(constructor()) + .def_readwrite("x", &NLMISC::CVector2f::x) + .def_readwrite("y", &NLMISC::CVector2f::y) + ]; + + } + + + // *************************************************************************** + int CLuaIHM::luaMethodCall(lua_State *ls) + { + //H_AUTO(Lua_CLuaIHM_luaMethodCall) + nlassert(ls); + const CReflectedProperty *prop = (const CReflectedProperty *) lua_touserdata(ls, lua_upvalueindex(1)); + CLuaState *state = (CLuaState *) lua_touserdata(ls, lua_upvalueindex(2)); + nlassert(prop); + nlassert(prop->Type == CReflectedProperty::LuaMethod); + nlassert(state); + if (state->empty()) + { + state->push(NLMISC::toString("Error while calling lua method %s:%s : no 'self' reference provided, did you you function call '.' instead of method call ':' ?", + prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) + ); + lua_error(ls); + } + // because this is a method, first parameter is the 'this' + CReflectableRefPtrTarget *pRPT = getReflectableOnStack(*state, 1); + if (pRPT == NULL) + { + state->push(NLMISC::toString("Error while calling lua method %s:%s : 'self' pointer is nil or of bad type, can't make the call.", + prop->ParentClass->ClassName.c_str(), prop->Name.c_str()) + ); + lua_error(ls); + } + // + state->remove(1); // remove 'self' reference from parameters stack + // + sint numResults = 0; + sint initialStackSize = state->getTop(); + try + { + // call the actual method + numResults = (pRPT->*(prop->GetMethod.GetLuaMethod))(*state); + } + catch(const std::exception &e) + { + // restore stack to its initial size + state->setTop(initialStackSize); + lua_pushstring(ls, e.what()); + // TODO : see if this is safe to call lua error there" ... (it does a long jump) + lua_error(ls); + } + return numResults; + } + + // *************************************************************************** + void CLuaIHM::luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property) + { + //H_AUTO(Lua_CLuaIHM_luaValueFromReflectedProperty) + switch(property.Type) + { + case CReflectedProperty::Boolean: + ls.push( (reflectedObject.*(property.GetMethod.GetBool))() ); + break; + case CReflectedProperty::SInt32: + ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetSInt32))() ); + break; + case CReflectedProperty::Float: + ls.push( (lua_Number)(reflectedObject.*(property.GetMethod.GetFloat))() ); + break; + case CReflectedProperty::String: + ls.push( (reflectedObject.*(property.GetMethod.GetString))() ); + break; + case CReflectedProperty::UCString: { - bool val= ls.toBoolean(stackIndex); - (target.*(property.SetMethod.SetBool))(val); - return; + ucstring str = (reflectedObject.*(property.GetMethod.GetUCString))(); + #if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), str); + #else + luabind::object obj(ls.getStatePointer(), str); + obj.pushvalue(); + #endif } - case CReflectedProperty::SInt32: + break; + case CReflectedProperty::RGBA: { - sint32 val= (sint32)ls.toNumber(stackIndex); - (target.*(property.SetMethod.SetSInt32))(val); - return; + CRGBA color = (reflectedObject.*(property.GetMethod.GetRGBA))(); + #if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), color); + #else + luabind::object obj(ls.getStatePointer(), color); + obj.pushvalue(); + #endif } - case CReflectedProperty::UInt32: + break; + case CReflectedProperty::LuaMethod: { - uint32 val= (uint32)ls.toNumber(stackIndex); - (target.*(property.SetMethod.SetUInt32))(val); - return; - } - case CReflectedProperty::Float: - { - float val= (float)ls.toNumber(stackIndex); - (target.*(property.SetMethod.SetFloat))(val); - return; - } - case CReflectedProperty::String: - { - std::string val; - ls.toString(stackIndex, val); - (target.*(property.SetMethod.SetString))(val); - return; - } - case CReflectedProperty::UCString: - { - ucstring val; - // Additionaly return of CInterfaceExpr may be std::string... test std string too - if(ls.isString() || ls.isNumber()) + // must create a closure that will forward the call to the real method + if (!property.LuaMethodRef.isValid()) { - std::string str; - ls.toString(stackIndex, str); - val= str; + ls.pushLightUserData((void *) &property); + ls.pushLightUserData((void *) &ls); + ls.pushCClosure(luaMethodCall, 2); + property.LuaMethodRef.pop(ls); } - else + nlassert(property.LuaMethodRef.getLuaState() == &ls); // only one single lua state supported for now + property.LuaMethodRef.push(); + } + break; + default: + nlstop; + break; + } + } + + static CLuaString lstr_Env("Env"); + static CLuaString lstr_isNil("isNil"); + + // *************************************************************************** + void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) + { + //H_AUTO(Lua_property_throw) + if(ls.isNil(stackIndex)) + throw ELuaIHMException("Trying to set nil to UI property '%s'", property.Name.c_str()); + switch(property.Type) + { + case CReflectedProperty::Boolean: { - // else this should be a ucstring - if (!pop(ls, val)) + bool val= ls.toBoolean(stackIndex); + (target.*(property.SetMethod.SetBool))(val); + return; + } + case CReflectedProperty::SInt32: + { + sint32 val= (sint32)ls.toNumber(stackIndex); + (target.*(property.SetMethod.SetSInt32))(val); + return; + } + case CReflectedProperty::UInt32: + { + uint32 val= (uint32)ls.toNumber(stackIndex); + (target.*(property.SetMethod.SetUInt32))(val); + return; + } + case CReflectedProperty::Float: + { + float val= (float)ls.toNumber(stackIndex); + (target.*(property.SetMethod.SetFloat))(val); + return; + } + case CReflectedProperty::String: + { + std::string val; + ls.toString(stackIndex, val); + (target.*(property.SetMethod.SetString))(val); + return; + } + case CReflectedProperty::UCString: + { + ucstring val; + // Additionaly return of CInterfaceExpr may be std::string... test std string too + if(ls.isString() || ls.isNumber()) { - throw ELuaIHMException("You must set a string, number or ucstring to UI property '%s'", property.Name.c_str()); + std::string str; + ls.toString(stackIndex, str); + val= str; } + else + { + // else this should be a ucstring + if (!pop(ls, val)) + { + throw ELuaIHMException("You must set a string, number or ucstring to UI property '%s'", property.Name.c_str()); + } + } + (target.*(property.SetMethod.SetUCString))(val); + return; } - (target.*(property.SetMethod.SetUCString))(val); - return; - } - case CReflectedProperty::RGBA: - { - CRGBA color; - if (pop(ls, color)) + case CReflectedProperty::RGBA: { - (target.*(property.SetMethod.SetRGBA))(color); + CRGBA color; + if (pop(ls, color)) + { + (target.*(property.SetMethod.SetRGBA))(color); + } + else + { + throw ELuaIHMException("You must set a CRGBA to UI property '%s'", property.Name.c_str()); + } + return; } - else - { - throw ELuaIHMException("You must set a CRGBA to UI property '%s'", property.Name.c_str()); - } - return; - } - default: - nlstop; - } -} - - -// *************************************************************************** -void CLuaIHM::createLuaEnumTable(CLuaState &ls, const std::string &str) -{ - //H_AUTO(Lua_CLuaIHM_createLuaEnumTable) - std::string path = "", script, p; - CSString s = str; - // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') - p = s.splitTo('.', true); - while (p.size() > 0) - { - if (path == "") - path = p; - else - path += "." + p; - script = "if (" + path + " == nil) then " + path + " = {}; end"; - ls.executeScript(script); - p = s.splitTo('.', true); - } -} - -#define LUABIND_ENUM(__enum__, __name__, __num__, __toStringFunc__) \ - createLuaEnumTable(ls, __name__); \ - for (uint e=0 ; e<__num__ ; e++) \ - { \ - std::string str = __toStringFunc__((__enum__)e); \ - std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \ - ls.executeScript(temp); \ - } \ - -// *************************************************************************** -#define LUABIND_FUNC(__func__) luabind::def(#__func__, &__func__) - -void CLuaIHM::registerIHM(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_registerIHM) - CLuaStackChecker lsc(&ls); - - // *** Register a Table for ui env. - ls.push(IHM_LUA_ENVTABLE); // "__ui_envtable" - ls.newTable(); // "__ui_envtable" {} - ls.setTable(LUA_REGISTRYINDEX); - - - // *** Register Functions - - // Through LUABind API - lua_State *L= ls.getStatePointer(); - - luabind::module(L) - [ - luabind::def("findReplaceAll", (std::string(*)(const std::string &, const std::string &, const std::string &)) &findReplaceAll), - luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const ucstring &)) &findReplaceAll), - luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const std::string &)) &findReplaceAll), - luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const std::string &)) &findReplaceAll), - luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const ucstring &)) &findReplaceAll), - - #if !FINAL_VERSION - LUABIND_FUNC(openDoc), - LUABIND_FUNC(launchProgram), - #endif - - luabind::def("fileLookup", CMiscFunctions::fileLookup), - luabind::def("shellExecute", CMiscFunctions::shellExecute) - ]; - - // inside i18n table - luabind::module(L, "i18n") - [ - luabind::def("get", &CI18N::get), - luabind::def("hasTranslation", &CI18N::hasTranslation) - ]; - // inside 'nlfile' table - luabind::module(L, "nlfile") - [ - luabind::def("getFilename", NLMISC::CFile::getFilename), - luabind::def("getExtension", NLMISC::CFile::getExtension), - luabind::def("getFilenameWithoutExtension", NLMISC::CFile::getFilenameWithoutExtension) - ]; - // inside 'nltime' table - luabind::module(L, "nltime") - [ - luabind::def("getPreciseLocalTime", getPreciseLocalTime), - luabind::def("getSecondsSince1970", NLMISC::CTime::getSecondsSince1970), - luabind::def("getLocalTime", getLocalTime) // NB : use CLuaIHM::getLocalTime instead of NLMISC::CTime::getLocalTime, because the NLMISC - // version returns a uint64, which can't be casted into lua numbers (doubles ...) - ]; -} - - -// *************************************************************************** -double CLuaIHM::getPreciseLocalTime() -{ - //H_AUTO(Lua_CLuaIHM_getPreciseLocalTime) - // don't export these 2 function to lua directly here, because all uint64 can't be represented with lua 'numbers' - return NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime()); -} - -// *************************************************************************** -void CLuaIHM::registerAll(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_registerAll) - registerBasics(ls); - registerIHM(ls); -} - - - -//#define CHECK_REFLECTABLE_MT - - -// *************************************************************************** -void CLuaIHM::pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT) -{ - //H_AUTO(Lua_CLuaIHM_pushReflectableOnStack) - nlassert(pRPT); - CLuaStackChecker lsc(&ls, 1); - - if (!pRPT) - { - ls.pushNil(); - return; - } - - //ls.dumpStack(); - /** if there's already a ref ptr for this object in the registry, then use it, - * else create a new one to avoid costly allocations - */ - ls.pushLightUserData(pRPT); - ls.getTable(LUA_REGISTRYINDEX); - //ls.dumpStack(); - if (ls.isNil()) - { - ls.pop(1); - //ls.dumpStack(); - // allocate the user data where to put the ref ptr - void *ptr= ls.newUserData(sizeof(CReflectableLuaRef)); - nlassert(ptr); - //ls.dumpStack(); - // initialize it, and copy the given element - new (ptr) CReflectableLuaRef(pRPT); - // Assign to this user data the __ui_metatable - //ls.dumpStack(); - ls.push(IHM_LUA_METATABLE); // userdata "__ui_metatable" - //ls.dumpStack(); - ls.getTable(LUA_REGISTRYINDEX); // userdata __ui_metatable - //ls.dumpStack(); - nlverify(ls.setMetaTable(-2)); // userdata - //ls.dumpStack(); - - // cache in registry - ls.pushLightUserData(pRPT); - ls.pushValue(-2); // copy for table insertion - //ls.dumpStack(); - ls.setTable(LUA_REGISTRYINDEX); - //ls.dumpStack(); - } - - // Check that the metatable is correct -#ifdef CHECK_REFLECTABLE_MT - nlverify(ls.getMetaTable(-1)); // userdata __ui_metatable - ls.push("__index"); - ls.getTable(-2); - ls.push("__newindex"); - ls.getTable(-3); - ls.push("__gc"); - ls.getTable(-4); - nlassert(ls.isCFunction(-1)); - nlassert(ls.isCFunction(-2)); - nlassert(ls.isCFunction(-3)); - ls.pop(4); -#endif - //ls.dumpStack(); -} - -// *************************************************************************** -bool CLuaIHM::isReflectableOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_isReflectableOnStack) - CLuaStackChecker lsc(&ls); - - if(!ls.isUserData(index)) - return false; - // verify that it is a UI with its metatable - if(!ls.getMetaTable(index)) // ??? object_metatable - return false; - ls.push(IHM_LUA_METATABLE); // ??? object_metatable "__ui_metatable" - ls.getTable(LUA_REGISTRYINDEX); // ??? object_metatable __ui_metatable - // equal test - bool ok= ls.rawEqual(-2, -1); - // Also must not be nil (maybe nil in case of LuaIHM still not registered) - ok= ok && !ls.isNil(-1); - ls.pop(); - ls.pop(); - - return ok; -} - -// *************************************************************************** -CReflectableRefPtrTarget *CLuaIHM::getReflectableOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_getReflectableOnStack) - if(!isReflectableOnStack(ls, index)) - return NULL; - - CReflectableLuaRef *p= (CReflectableLuaRef *) ls.toUserData(index); - nlassert(p->Ptr); - return p->Ptr; -} - - -// *************************************************************************** -// *************************************************************************** -// LUA IHM Functions -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -uint32 CLuaIHM::getLocalTime() -{ - //H_AUTO(Lua_CLuaIHM_getLocalTime) - return (uint32) NLMISC::CTime::getLocalTime(); -} - - -// *************************************************************************** -std::string CLuaIHM::findReplaceAll(const std::string &str, const std::string &search, const std::string &replace) -{ - //H_AUTO(Lua_CLuaIHM_findReplaceAll) - std::string ret= str; - while(strFindReplace(ret, search, replace)); - return ret; -} - -// *************************************************************************** -ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace) -{ - //H_AUTO(Lua_CLuaIHM_findReplaceAll) - ucstring ret= str; - while(strFindReplace(ret, search, replace)); - return ret; -} - -// *************************************************************************** -ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace) -{ - //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); -} - -// *************************************************************************** -ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace) -{ - //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); -} - -// *************************************************************************** -ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace) -{ - //H_AUTO(Lua_CLuaIHM_findReplaceAll) - return findReplaceAll(str, ucstring(search), ucstring(replace)); -} - - -// *************************************************************************** -void CLuaIHM::fails(CLuaState &ls, const char *format, ...) -{ - //H_AUTO(Lua_CLuaIHM_fails) - std::string reason; - NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); - std::string stack; - ls.getStackAsString(stack); - // use a std::exception, to avoid Nel Exception warning - throw ELuaIHMException("%s. Lua stack = \n %s", reason.c_str(), stack.c_str()); -} - - -// *************************************************************************** -void CLuaIHM::checkArgCount(CLuaState &ls, const char* funcName, uint nArgs) -{ - //H_AUTO(Lua_CLuaIHM_checkArgCount) - if(ls.getTop()!=(sint)nArgs) - { - fails(ls, "%s() need exactly %d arguments (tips : check between method & function call)", funcName, nArgs); - } -} - -// *************************************************************************** -void CLuaIHM::checkArgMin(CLuaState &ls, const char* funcName, uint nArgs) -{ - //H_AUTO(Lua_CLuaIHM_checkArgMin) - if(ls.getTop()<(sint)nArgs) - { - fails(ls, "%s() need at least %d arguments (tips : check between method & function call)", funcName, nArgs); - } -} - -// *************************************************************************** -void CLuaIHM::checkArgMax(CLuaState &ls,const char* funcName,uint nArgs) -{ - //H_AUTO(Lua_CLuaIHM_checkArgMax) - if(ls.getTop()>(sint)nArgs) - { - fails(ls, "%s() need at most %d arguments.", funcName, nArgs); - } -} - -// *************************************************************************** -void CLuaIHM::check(CLuaState &ls, bool ok, const std::string &failReason) -{ - //H_AUTO(Lua_CLuaIHM_check) - if(!ok) - { - fails(ls, failReason.c_str()); - } -} - -// *************************************************************************** -void CLuaIHM::checkArgType(CLuaState &ls, const char *funcName, uint index, int argType) -{ - //H_AUTO(Lua_CLuaIHM_checkArgType) - nlassert(index > 0); - if (ls.getTop() < (int) index) - { - fails(ls, "%s : argument %d of expected type %s was not defined", funcName, index, ls.getTypename(argType)); - } - if (ls.type(index) != argType) - { - fails(ls, "%s : argument %d of expected type %s has bad type : %s", funcName, index, ls.getTypename(argType), ls.getTypename(ls.type(index)), ls.type(index)); - } -} - -// *************************************************************************** -void CLuaIHM::checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index) -{ - //H_AUTO(Lua_CLuaIHM_checkArgTypeRGBA) - nlassert(index > 0); - if (ls.getTop() < (int) index) - { - fails(ls, "%s : argument %d of expected type RGBA was not defined", funcName, index); - } - ls.pushValue(index); - CRGBA dummy; - if (!pop(ls, dummy)) - { - fails(ls, "%s : argument %d of expected type RGBA has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); - } -} - -// *************************************************************************** -void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index) -{ - //H_AUTO(Lua_CLuaIHM_checkArgTypeUCString) - nlassert(index > 0); - if (ls.getTop() < (int) index) - { - fails(ls, "%s : argument %d of expected type ucstring was not defined", funcName, index); - } - ls.pushValue(index); - ucstring dummy; - if (!pop(ls, dummy)) - { - fails(ls, "%s : argument %d of expected type ucstring has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); - } -} - - - -// *************************************************************************** -bool CLuaIHM::popString(CLuaState &ls, std::string & dest) -{ - //H_AUTO(Lua_CLuaIHM_popString) - try - { -#if LUABIND_VERSION > 600 - luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); - ls.pop(); -#else - luabind::object obj(ls.getStatePointer()); - obj.set(); -#endif - dest = luabind::object_cast(obj); - } - catch(const luabind::cast_failed &) - { - return false; - } - return true; -} - -// *************************************************************************** -bool CLuaIHM::popSINT32(CLuaState &ls, sint32 & dest) -{ - //H_AUTO(Lua_CLuaIHM_popSINT32) - try - { -#if LUABIND_VERSION > 600 - luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); - ls.pop(); -#else - luabind::object obj(ls.getStatePointer()); - obj.set(); -#endif - dest = luabind::object_cast(obj); - } - catch(const luabind::cast_failed &) - { - return false; - } - return true; -} - -// *************************************************************************** -void CLuaIHM::getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest) -{ - //H_AUTO(Lua_CLuaIHM_getPoly2DOnStack) - ls.pushValue(index); - CLuaObject poly; - poly.pop(ls); - dest.Vertices.clear(); - ENUM_LUA_TABLE(poly, it) - { - it.nextValue().push(); - NLMISC::CVector2f pos; - if (!pop(ls, pos)) - { - fails(ls, "2D polygon expects CVector2f for poly coordinates"); + default: + nlstop; } - dest.Vertices.push_back(pos); } + + + // *************************************************************************** + void CLuaIHM::createLuaEnumTable(CLuaState &ls, const std::string &str) + { + //H_AUTO(Lua_CLuaIHM_createLuaEnumTable) + std::string path = "", script, p; + CSString s = str; + // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') + p = s.splitTo('.', true); + while (p.size() > 0) + { + if (path == "") + path = p; + else + path += "." + p; + script = "if (" + path + " == nil) then " + path + " = {}; end"; + ls.executeScript(script); + p = s.splitTo('.', true); + } + } + + #define LUABIND_ENUM(__enum__, __name__, __num__, __toStringFunc__) \ + createLuaEnumTable(ls, __name__); \ + for (uint e=0 ; e<__num__ ; e++) \ + { \ + std::string str = __toStringFunc__((__enum__)e); \ + std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \ + ls.executeScript(temp); \ + } \ + + // *************************************************************************** + #define LUABIND_FUNC(__func__) luabind::def(#__func__, &__func__) + + void CLuaIHM::registerIHM(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_registerIHM) + CLuaStackChecker lsc(&ls); + + // *** Register a Table for ui env. + ls.push(IHM_LUA_ENVTABLE); // "__ui_envtable" + ls.newTable(); // "__ui_envtable" {} + ls.setTable(LUA_REGISTRYINDEX); + + + // *** Register Functions + + // Through LUABind API + lua_State *L= ls.getStatePointer(); + + luabind::module(L) + [ + luabind::def("findReplaceAll", (std::string(*)(const std::string &, const std::string &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const ucstring &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const ucstring &)) &findReplaceAll), + + #if !FINAL_VERSION + LUABIND_FUNC(openDoc), + LUABIND_FUNC(launchProgram), + #endif + + luabind::def("fileLookup", CMiscFunctions::fileLookup), + luabind::def("shellExecute", CMiscFunctions::shellExecute) + ]; + + // inside i18n table + luabind::module(L, "i18n") + [ + luabind::def("get", &CI18N::get), + luabind::def("hasTranslation", &CI18N::hasTranslation) + ]; + // inside 'nlfile' table + luabind::module(L, "nlfile") + [ + luabind::def("getFilename", NLMISC::CFile::getFilename), + luabind::def("getExtension", NLMISC::CFile::getExtension), + luabind::def("getFilenameWithoutExtension", NLMISC::CFile::getFilenameWithoutExtension) + ]; + // inside 'nltime' table + luabind::module(L, "nltime") + [ + luabind::def("getPreciseLocalTime", getPreciseLocalTime), + luabind::def("getSecondsSince1970", NLMISC::CTime::getSecondsSince1970), + luabind::def("getLocalTime", getLocalTime) // NB : use CLuaIHM::getLocalTime instead of NLMISC::CTime::getLocalTime, because the NLMISC + // version returns a uint64, which can't be casted into lua numbers (doubles ...) + ]; + } + + + // *************************************************************************** + double CLuaIHM::getPreciseLocalTime() + { + //H_AUTO(Lua_CLuaIHM_getPreciseLocalTime) + // don't export these 2 function to lua directly here, because all uint64 can't be represented with lua 'numbers' + return NLMISC::CTime::ticksToSecond(NLMISC::CTime::getPerformanceTime()); + } + + // *************************************************************************** + void CLuaIHM::registerAll(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_registerAll) + registerBasics(ls); + registerIHM(ls); + } + + + + //#define CHECK_REFLECTABLE_MT + + + // *************************************************************************** + void CLuaIHM::pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT) + { + //H_AUTO(Lua_CLuaIHM_pushReflectableOnStack) + nlassert(pRPT); + CLuaStackChecker lsc(&ls, 1); + + if (!pRPT) + { + ls.pushNil(); + return; + } + + //ls.dumpStack(); + /** if there's already a ref ptr for this object in the registry, then use it, + * else create a new one to avoid costly allocations + */ + ls.pushLightUserData(pRPT); + ls.getTable(LUA_REGISTRYINDEX); + //ls.dumpStack(); + if (ls.isNil()) + { + ls.pop(1); + //ls.dumpStack(); + // allocate the user data where to put the ref ptr + void *ptr= ls.newUserData(sizeof(CReflectableLuaRef)); + nlassert(ptr); + //ls.dumpStack(); + // initialize it, and copy the given element + new (ptr) CReflectableLuaRef(pRPT); + // Assign to this user data the __ui_metatable + //ls.dumpStack(); + ls.push(IHM_LUA_METATABLE); // userdata "__ui_metatable" + //ls.dumpStack(); + ls.getTable(LUA_REGISTRYINDEX); // userdata __ui_metatable + //ls.dumpStack(); + nlverify(ls.setMetaTable(-2)); // userdata + //ls.dumpStack(); + + // cache in registry + ls.pushLightUserData(pRPT); + ls.pushValue(-2); // copy for table insertion + //ls.dumpStack(); + ls.setTable(LUA_REGISTRYINDEX); + //ls.dumpStack(); + } + + // Check that the metatable is correct + #ifdef CHECK_REFLECTABLE_MT + nlverify(ls.getMetaTable(-1)); // userdata __ui_metatable + ls.push("__index"); + ls.getTable(-2); + ls.push("__newindex"); + ls.getTable(-3); + ls.push("__gc"); + ls.getTable(-4); + nlassert(ls.isCFunction(-1)); + nlassert(ls.isCFunction(-2)); + nlassert(ls.isCFunction(-3)); + ls.pop(4); + #endif + //ls.dumpStack(); + } + + // *************************************************************************** + bool CLuaIHM::isReflectableOnStack(CLuaState &ls, sint index) + { + //H_AUTO(Lua_CLuaIHM_isReflectableOnStack) + CLuaStackChecker lsc(&ls); + + if(!ls.isUserData(index)) + return false; + // verify that it is a UI with its metatable + if(!ls.getMetaTable(index)) // ??? object_metatable + return false; + ls.push(IHM_LUA_METATABLE); // ??? object_metatable "__ui_metatable" + ls.getTable(LUA_REGISTRYINDEX); // ??? object_metatable __ui_metatable + // equal test + bool ok= ls.rawEqual(-2, -1); + // Also must not be nil (maybe nil in case of LuaIHM still not registered) + ok= ok && !ls.isNil(-1); + ls.pop(); + ls.pop(); + + return ok; + } + + // *************************************************************************** + CReflectableRefPtrTarget *CLuaIHM::getReflectableOnStack(CLuaState &ls, sint index) + { + //H_AUTO(Lua_CLuaIHM_getReflectableOnStack) + if(!isReflectableOnStack(ls, index)) + return NULL; + + CReflectableLuaRef *p= (CReflectableLuaRef *) ls.toUserData(index); + nlassert(p->Ptr); + return p->Ptr; + } + + + // *************************************************************************** + // *************************************************************************** + // LUA IHM Functions + // *************************************************************************** + // *************************************************************************** + + + // *************************************************************************** + uint32 CLuaIHM::getLocalTime() + { + //H_AUTO(Lua_CLuaIHM_getLocalTime) + return (uint32) NLMISC::CTime::getLocalTime(); + } + + + // *************************************************************************** + std::string CLuaIHM::findReplaceAll(const std::string &str, const std::string &search, const std::string &replace) + { + //H_AUTO(Lua_CLuaIHM_findReplaceAll) + std::string ret= str; + while(strFindReplace(ret, search, replace)); + return ret; + } + + // *************************************************************************** + ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace) + { + //H_AUTO(Lua_CLuaIHM_findReplaceAll) + ucstring ret= str; + while(strFindReplace(ret, search, replace)); + return ret; + } + + // *************************************************************************** + ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace) + { + //H_AUTO(Lua_CLuaIHM_findReplaceAll) + return findReplaceAll(str, ucstring(search), ucstring(replace)); + } + + // *************************************************************************** + ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace) + { + //H_AUTO(Lua_CLuaIHM_findReplaceAll) + return findReplaceAll(str, ucstring(search), ucstring(replace)); + } + + // *************************************************************************** + ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace) + { + //H_AUTO(Lua_CLuaIHM_findReplaceAll) + return findReplaceAll(str, ucstring(search), ucstring(replace)); + } + + + // *************************************************************************** + void CLuaIHM::fails(CLuaState &ls, const char *format, ...) + { + //H_AUTO(Lua_CLuaIHM_fails) + std::string reason; + NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize); + std::string stack; + ls.getStackAsString(stack); + // use a std::exception, to avoid Nel Exception warning + throw ELuaIHMException("%s. Lua stack = \n %s", reason.c_str(), stack.c_str()); + } + + + // *************************************************************************** + void CLuaIHM::checkArgCount(CLuaState &ls, const char* funcName, uint nArgs) + { + //H_AUTO(Lua_CLuaIHM_checkArgCount) + if(ls.getTop()!=(sint)nArgs) + { + fails(ls, "%s() need exactly %d arguments (tips : check between method & function call)", funcName, nArgs); + } + } + + // *************************************************************************** + void CLuaIHM::checkArgMin(CLuaState &ls, const char* funcName, uint nArgs) + { + //H_AUTO(Lua_CLuaIHM_checkArgMin) + if(ls.getTop()<(sint)nArgs) + { + fails(ls, "%s() need at least %d arguments (tips : check between method & function call)", funcName, nArgs); + } + } + + // *************************************************************************** + void CLuaIHM::checkArgMax(CLuaState &ls,const char* funcName,uint nArgs) + { + //H_AUTO(Lua_CLuaIHM_checkArgMax) + if(ls.getTop()>(sint)nArgs) + { + fails(ls, "%s() need at most %d arguments.", funcName, nArgs); + } + } + + // *************************************************************************** + void CLuaIHM::check(CLuaState &ls, bool ok, const std::string &failReason) + { + //H_AUTO(Lua_CLuaIHM_check) + if(!ok) + { + fails(ls, failReason.c_str()); + } + } + + // *************************************************************************** + void CLuaIHM::checkArgType(CLuaState &ls, const char *funcName, uint index, int argType) + { + //H_AUTO(Lua_CLuaIHM_checkArgType) + nlassert(index > 0); + if (ls.getTop() < (int) index) + { + fails(ls, "%s : argument %d of expected type %s was not defined", funcName, index, ls.getTypename(argType)); + } + if (ls.type(index) != argType) + { + fails(ls, "%s : argument %d of expected type %s has bad type : %s", funcName, index, ls.getTypename(argType), ls.getTypename(ls.type(index)), ls.type(index)); + } + } + + // *************************************************************************** + void CLuaIHM::checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index) + { + //H_AUTO(Lua_CLuaIHM_checkArgTypeRGBA) + nlassert(index > 0); + if (ls.getTop() < (int) index) + { + fails(ls, "%s : argument %d of expected type RGBA was not defined", funcName, index); + } + ls.pushValue(index); + CRGBA dummy; + if (!pop(ls, dummy)) + { + fails(ls, "%s : argument %d of expected type RGBA has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); + } + } + + // *************************************************************************** + void CLuaIHM::checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index) + { + //H_AUTO(Lua_CLuaIHM_checkArgTypeUCString) + nlassert(index > 0); + if (ls.getTop() < (int) index) + { + fails(ls, "%s : argument %d of expected type ucstring was not defined", funcName, index); + } + ls.pushValue(index); + ucstring dummy; + if (!pop(ls, dummy)) + { + fails(ls, "%s : argument %d of expected type ucstring has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); + } + } + + + + // *************************************************************************** + bool CLuaIHM::popString(CLuaState &ls, std::string & dest) + { + //H_AUTO(Lua_CLuaIHM_popString) + try + { + #if LUABIND_VERSION > 600 + luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); + ls.pop(); + #else + luabind::object obj(ls.getStatePointer()); + obj.set(); + #endif + dest = luabind::object_cast(obj); + } + catch(const luabind::cast_failed &) + { + return false; + } + return true; + } + + // *************************************************************************** + bool CLuaIHM::popSINT32(CLuaState &ls, sint32 & dest) + { + //H_AUTO(Lua_CLuaIHM_popSINT32) + try + { + #if LUABIND_VERSION > 600 + luabind::object obj(luabind::from_stack(ls.getStatePointer(), -1)); + ls.pop(); + #else + luabind::object obj(ls.getStatePointer()); + obj.set(); + #endif + dest = luabind::object_cast(obj); + } + catch(const luabind::cast_failed &) + { + return false; + } + return true; + } + + // *************************************************************************** + void CLuaIHM::getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest) + { + //H_AUTO(Lua_CLuaIHM_getPoly2DOnStack) + ls.pushValue(index); + CLuaObject poly; + poly.pop(ls); + dest.Vertices.clear(); + ENUM_LUA_TABLE(poly, it) + { + it.nextValue().push(); + NLMISC::CVector2f pos; + if (!pop(ls, pos)) + { + fails(ls, "2D polygon expects CVector2f for poly coordinates"); + } + dest.Vertices.push_back(pos); + } + } + } - - diff --git a/code/nel/src/gui/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp index f7606ec2b..5e9ef7761 100644 --- a/code/nel/src/gui/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -18,17 +18,22 @@ #include "nel/gui/lua_manager.h" #include "nel/gui/lua_helper.h" -bool CLuaManager::debugLua = false; -CLuaManager* CLuaManager::instance = NULL; - -CLuaManager::CLuaManager() +namespace NLGUI { - luaState = new NLGUI::CLuaState( debugLua ); + + bool CLuaManager::debugLua = false; + CLuaManager* CLuaManager::instance = NULL; + + CLuaManager::CLuaManager() + { + luaState = new NLGUI::CLuaState( debugLua ); + } + + CLuaManager::~CLuaManager() + { + luaState = NULL; + } + + } -CLuaManager::~CLuaManager() -{ - luaState = NULL; -} - - diff --git a/code/nel/src/gui/lua_object.cpp b/code/nel/src/gui/lua_object.cpp index 432e3c607..b11705f5b 100644 --- a/code/nel/src/gui/lua_object.cpp +++ b/code/nel/src/gui/lua_object.cpp @@ -14,643 +14,638 @@ // 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/lua_object.h" #include "nel/gui/lua_ihm.h" -//#include "lua_ihm_ryzom.h" #include "nel/gui/lua_helper.h" -using namespace NLGUI; -// -//#include "interface_manager.h" -//////////////// -// CLuaObject // -//////////////// - -// ************************************************* -CLuaObject::CLuaObject(CLuaState &state, const char *id) +namespace NLGUI { - pop(state, id); -} -// ************************************************* -CLuaObject::CLuaObject(CLuaState &state, const std::string &id) -{ - pop(state, id.c_str()); -} - - -// ************************************************* -bool CLuaObject::isValid() const -{ - return getLuaState() != NULL; -} - -// ************************************************* -CLuaState *CLuaObject::getLuaState() const -{ - return _LuaState; -} - -// ************************************************* -CLuaObject::CLuaObject(const CLuaObject &other) -{ - if (other.isValid()) + // ************************************************* + CLuaObject::CLuaObject(CLuaState &state, const char *id) { + pop(state, id); + } + + // ************************************************* + CLuaObject::CLuaObject(CLuaState &state, const std::string &id) + { + pop(state, id.c_str()); + } + + + // ************************************************* + bool CLuaObject::isValid() const + { + return getLuaState() != NULL; + } + + // ************************************************* + CLuaState *CLuaObject::getLuaState() const + { + return _LuaState; + } + + // ************************************************* + CLuaObject::CLuaObject(const CLuaObject &other) + { + if (other.isValid()) + { + other.push(); + nlassert(other.getLuaState()); + pop(*other.getLuaState()); + _Id = other._Id; + } + // else ... copy of an invalid CLuaObject( is an invalid CLuaObject + } + + // ************************************************* + CLuaObject &CLuaObject::operator=(const CLuaObject &other) + { + if (!other.isValid()) + { + release(); + return *this; + } other.push(); - nlassert(other.getLuaState()); pop(*other.getLuaState()); _Id = other._Id; - } - // else ... copy of an invalid CLuaObject( is an invalid CLuaObject -} - -// ************************************************* -CLuaObject &CLuaObject::operator=(const CLuaObject &other) -{ - if (!other.isValid()) - { - release(); return *this; } - other.push(); - pop(*other.getLuaState()); - _Id = other._Id; - return *this; -} -// ************************************************* -bool CLuaObject::rawEqual(const CLuaObject &other) const -{ - nlassert(other.getLuaState() == getLuaState()); - push(); - other.push(); - bool equal = other.getLuaState()->rawEqual(-1, -2); - getLuaState()->pop(2); - return equal; -} - -// ************************************************* -CLuaObject::~CLuaObject() -{ - release(); -} - -// ************************************************* -void CLuaObject::release() -{ - if (_LuaState) + // ************************************************* + bool CLuaObject::rawEqual(const CLuaObject &other) const { - CLuaStackChecker lsc(_LuaState); + nlassert(other.getLuaState() == getLuaState()); + push(); + other.push(); + bool equal = other.getLuaState()->rawEqual(-1, -2); + getLuaState()->pop(2); + return equal; + } + + // ************************************************* + CLuaObject::~CLuaObject() + { + release(); + } + + // ************************************************* + void CLuaObject::release() + { + if (_LuaState) + { + CLuaStackChecker lsc(_LuaState); + _LuaState->pushLightUserData((void *) this); + _LuaState->pushNil(); + _LuaState->setTable(LUA_REGISTRYINDEX); + _LuaState = NULL; + } + } + + // ************************************************* + void CLuaObject::pop(CLuaState &luaState, const char *id) + { + release(); + nlassert(luaState.getTop() >= 1); + { + CLuaStackChecker lsc(&luaState); + luaState.pushLightUserData((void *) this); + luaState.pushValue(-2); // copy original object + luaState.setTable(LUA_REGISTRYINDEX); + } + luaState.pop(); + _LuaState = &luaState; + _Id = id; + } + + // ************************************************* + void CLuaObject::push() const + { + nlassert(isValid()); _LuaState->pushLightUserData((void *) this); - _LuaState->pushNil(); - _LuaState->setTable(LUA_REGISTRYINDEX); - _LuaState = NULL; + _LuaState->getTable(LUA_REGISTRYINDEX); } -} -// ************************************************* -void CLuaObject::pop(CLuaState &luaState, const char *id) -{ - release(); - nlassert(luaState.getTop() >= 1); + // ************************************************* + int CLuaObject::type() const { - CLuaStackChecker lsc(&luaState); - luaState.pushLightUserData((void *) this); - luaState.pushValue(-2); // copy original object - luaState.setTable(LUA_REGISTRYINDEX); + push(); + int type = _LuaState->type(); + _LuaState->pop(); + return type; } - luaState.pop(); - _LuaState = &luaState; - _Id = id; -} -// ************************************************* -void CLuaObject::push() const -{ - nlassert(isValid()); - _LuaState->pushLightUserData((void *) this); - _LuaState->getTable(LUA_REGISTRYINDEX); -} - -// ************************************************* -int CLuaObject::type() const -{ - push(); - int type = _LuaState->type(); - _LuaState->pop(); - return type; -} - -// ************************************************* -const char *CLuaObject::getTypename() const -{ - push(); - const char *typeName = _LuaState->getTypename(-1); - _LuaState->pop(); - return typeName; -} - -// ************************************************* -bool CLuaObject::isNil() const { push(); bool result = _LuaState->isNil(); _LuaState->pop(); return result; } -bool CLuaObject::isNumber() const { push(); bool result = _LuaState->isNumber(); _LuaState->pop(); return result; } -bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; } -bool CLuaObject::isString() const { push(); bool result = _LuaState->isString(); _LuaState->pop(); return result; } -bool CLuaObject::isFunction() const { push(); bool result = _LuaState->isFunction(); _LuaState->pop(); return result; } -bool CLuaObject::isCFunction() const { push(); bool result = _LuaState->isCFunction(); _LuaState->pop(); return result; } -bool CLuaObject::isTable() const { push(); bool result = _LuaState->isTable(); _LuaState->pop(); return result; } -bool CLuaObject::isUserData() const { push(); bool result = _LuaState->isUserData(); _LuaState->pop(); return result; } -bool CLuaObject::isLightUserData() const { push(); bool result = _LuaState->isLightUserData(); _LuaState->pop(); return result; } -bool CLuaObject::isRGBA() const -{ - if (!isUserData()) return false; - push(); - NLMISC::CRGBA dummy; - return CLuaIHM::pop(*_LuaState, dummy); -} - -// ************************************************* -bool CLuaObject::toBoolean() const { push(); bool result = _LuaState->toBoolean(); _LuaState->pop(); return result; } -lua_Number CLuaObject::toNumber() const { push(); lua_Number result = _LuaState->toNumber(); _LuaState->pop(); return result; } -std::string CLuaObject::toString() const -{ - push(); - const char *str = _LuaState->toString(); - std::string result = str ? str : ""; - _LuaState->pop(); - return result; -} -lua_CFunction CLuaObject::toCFunction() const { push(); lua_CFunction result = _LuaState->toCFunction(); _LuaState->pop(); return result; } -void *CLuaObject::toUserData() const { push(); void *result = _LuaState->toUserData(); _LuaState->pop(); return result; } -const void *CLuaObject::toPointer() const { push(); const void *result = _LuaState->toPointer(); _LuaState->pop(); return result; } -NLMISC::CRGBA CLuaObject::toRGBA() const -{ - NLMISC::CRGBA result; - push(); - if (CLuaIHM::pop(*_LuaState, result)) + // ************************************************* + const char *CLuaObject::getTypename() const { + push(); + const char *typeName = _LuaState->getTypename(-1); + _LuaState->pop(); + return typeName; + } + + // ************************************************* + bool CLuaObject::isNil() const { push(); bool result = _LuaState->isNil(); _LuaState->pop(); return result; } + bool CLuaObject::isNumber() const { push(); bool result = _LuaState->isNumber(); _LuaState->pop(); return result; } + bool CLuaObject::isBoolean() const { push(); bool result = _LuaState->isBoolean(); _LuaState->pop(); return result; } + bool CLuaObject::isString() const { push(); bool result = _LuaState->isString(); _LuaState->pop(); return result; } + bool CLuaObject::isFunction() const { push(); bool result = _LuaState->isFunction(); _LuaState->pop(); return result; } + bool CLuaObject::isCFunction() const { push(); bool result = _LuaState->isCFunction(); _LuaState->pop(); return result; } + bool CLuaObject::isTable() const { push(); bool result = _LuaState->isTable(); _LuaState->pop(); return result; } + bool CLuaObject::isUserData() const { push(); bool result = _LuaState->isUserData(); _LuaState->pop(); return result; } + bool CLuaObject::isLightUserData() const { push(); bool result = _LuaState->isLightUserData(); _LuaState->pop(); return result; } + bool CLuaObject::isRGBA() const + { + if (!isUserData()) return false; + push(); + NLMISC::CRGBA dummy; + return CLuaIHM::pop(*_LuaState, dummy); + } + + // ************************************************* + bool CLuaObject::toBoolean() const { push(); bool result = _LuaState->toBoolean(); _LuaState->pop(); return result; } + lua_Number CLuaObject::toNumber() const { push(); lua_Number result = _LuaState->toNumber(); _LuaState->pop(); return result; } + std::string CLuaObject::toString() const + { + push(); + const char *str = _LuaState->toString(); + std::string result = str ? str : ""; + _LuaState->pop(); return result; } - return NLMISC::CRGBA::Black; -} - -// ************************************************* -CLuaObject::operator bool() const { return toBoolean(); } -CLuaObject::operator float() const { return (float) toNumber(); } -CLuaObject::operator double() const { return (double) toNumber(); } -CLuaObject::operator std::string() const { return toString(); } - - -// ************************************************* -bool CLuaObject::isEnumerable() const -{ - if (isTable()) return true; - CLuaStackRestorer lsr(_LuaState, _LuaState->getTop()); - push(); - if (_LuaState->getMetaTable(-1)) + lua_CFunction CLuaObject::toCFunction() const { push(); lua_CFunction result = _LuaState->toCFunction(); _LuaState->pop(); return result; } + void *CLuaObject::toUserData() const { push(); void *result = _LuaState->toUserData(); _LuaState->pop(); return result; } + const void *CLuaObject::toPointer() const { push(); const void *result = _LuaState->toPointer(); _LuaState->pop(); return result; } + NLMISC::CRGBA CLuaObject::toRGBA() const { - _LuaState->remove(-2); - _LuaState->push("__next"); - _LuaState->getTable(-2); - return _LuaState->isFunction(); + NLMISC::CRGBA result; + push(); + if (CLuaIHM::pop(*_LuaState, result)) + { + return result; + } + return NLMISC::CRGBA::Black; } - return false; -} -// ************************************************* -CLuaEnumeration CLuaObject::enumerate() throw(ELuaNotATable) -{ - if (!isEnumerable()) - { - throw ELuaNotATable(NLMISC::toString("Called CLuaObject::enumerate on an object that has no enumeration (not a table or no '__next' method in the metatable). Object is '%s' with type '%s'", getId().c_str(), getTypename()).c_str()); - } - return CLuaEnumeration(*this); -} - -// ************************************************* -CLuaObject CLuaObject::operator[](const char *key) const -{ - nlassert(key); - nlassert(isValid()); - if (!isEnumerable()) - { - _LuaState->pushNil(); - CLuaObject result(*_LuaState); - return result; - } - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->getTable(-2); - CLuaObject subObject(*_LuaState, concatId(getId(), key)); - _LuaState->pop(); // pop the sub object - return subObject; -} - -// ************************************************* -CLuaObject CLuaObject::operator[](double key) const -{ - nlassert(isValid()); - if (!isEnumerable()) - { - _LuaState->pushNil(); - CLuaObject result(*_LuaState); - return result; - } - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->getTable(-2); - CLuaObject subObject(*_LuaState, concatId(getId(), NLMISC::toString(key))); - _LuaState->pop(); // pop the sub object - return subObject; -} - -// ************************************************* -CLuaObject CLuaObject::at(const char *key) const throw(ELuaNotATable) -{ - if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Can't get key '%s' in object '%s' because type is '%s', it is not a table.", key, getId().c_str(), getTypename()).c_str()); - return operator[](key); -} - -// ************************************************* -bool CLuaObject::hasKey(const char *key) const -{ - if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Trying to access key '%s' on object '%s' of type %s.", key, getId().c_str(), getTypename()).c_str()); - CLuaObject value = operator[](key); - return (!value.isNil()); -} - -// ************************************************* -CLuaObject CLuaObject::newTable(const char *tableName) throw(ELuaNotATable) -{ - nlassert(tableName); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to create a subtable '%s' on object '%s' of type %s (not a table).", tableName, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(tableName); - _LuaState->newTable(); - _LuaState->setTable(-3); - _LuaState->pop(); - return at(tableName); //\TODO nico double copy here ... -} - -// ************************************************* -void CLuaObject::setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable) -{ - nlassert(key); - nlassert(isValid()); - nlassert(value.isValid()); - nlassert(getLuaState() == value.getLuaState()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - value.push(); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::setNil(const char *key) throw(ELuaNotATable) -{ - nlassert(key); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value 'nil' at key %s on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->pushNil(); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::setValue(const char *key, const char *value) throw(ELuaNotATable) -{ - nlassert(value); - nlassert(key); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->push(value); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::setValue(const char *key, const std::string &value) throw(ELuaNotATable) -{ - setValue(key, value.c_str()); -} - -// ************************************************* -void CLuaObject::setValue(const char *key, bool value) throw(ELuaNotATable) -{ - nlassert(key); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' at key %s on object '%s' of type %s (not a table).", value ? "true" : "false", key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->push(value); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable) -{ - nlassert(key); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a function value '%p' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->push(value); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::setValue(const char *key, double value) throw(ELuaNotATable) -{ - nlassert(key); - nlassert(isValid()); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%lf' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->push(value); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -void CLuaObject::eraseValue(const char *key) throw(ELuaNotATable) -{ - nlassert(isValid()); - nlassert(key); - if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to erase a value with key '%s' on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); - CLuaStackChecker lsc(_LuaState); - push(); - _LuaState->push(key); - _LuaState->pushNil(); - _LuaState->setTable(-3); - _LuaState->pop(); -} - -// ************************************************* -bool CLuaObject::callNoThrow(int numArgs, int numRet) -{ - nlassert(isValid()); - if (!isFunction()) - { - nlwarning("Calling a non function object (id = %s, type = %s)", getId().c_str(), getTypename()); - _LuaState->pop(numArgs); - return false; - } - // TMP TMP - static volatile bool dumpFunction = false; - if (dumpFunction) + // ************************************************* + CLuaObject::operator bool() const { return toBoolean(); } + CLuaObject::operator float() const { return (float) toNumber(); } + CLuaObject::operator double() const { return (double) toNumber(); } + CLuaObject::operator std::string() const { return toString(); } + + + // ************************************************* + bool CLuaObject::isEnumerable() const { + if (isTable()) return true; CLuaStackRestorer lsr(_LuaState, _LuaState->getTop()); push(); - lua_Debug ar; - lua_getinfo (_LuaState->getStatePointer(), ">lS", &ar); - nlwarning((std::string(ar.what) + ", at line " + NLMISC::toString(ar.linedefined) + " in " + std::string(ar.source)).c_str()); + if (_LuaState->getMetaTable(-1)) + { + _LuaState->remove(-2); + _LuaState->push("__next"); + _LuaState->getTable(-2); + return _LuaState->isFunction(); + } + return false; } - push(); - _LuaState->insert(-1 - numArgs); // put the function before its arguments - int result = _LuaState->pcall(numArgs, numRet); - switch (result) - { - case LUA_ERRRUN: - case LUA_ERRMEM: - case LUA_ERRERR: - nlwarning(_LuaState->toString(-1)); - _LuaState->pop(); - return false; - break; - case 0: - return true; - break; - default: - nlassert(0); - break; - } - return false; -} -// ************************************************* -bool CLuaObject::callMethodByNameNoThrow(const char *name, int numArgs, int numRet) -{ - nlassert(isValid()); - int initialStackSize = _LuaState->getTop(); - if (!isTable() && !isUserData()) + // ************************************************* + CLuaEnumeration CLuaObject::enumerate() throw(ELuaNotATable) { - nlwarning("Can't call method : object is not a table (id = %s)", getId().c_str()); + if (!isEnumerable()) + { + throw ELuaNotATable(NLMISC::toString("Called CLuaObject::enumerate on an object that has no enumeration (not a table or no '__next' method in the metatable). Object is '%s' with type '%s'", getId().c_str(), getTypename()).c_str()); + } + return CLuaEnumeration(*this); + } + + // ************************************************* + CLuaObject CLuaObject::operator[](const char *key) const + { + nlassert(key); + nlassert(isValid()); + if (!isEnumerable()) + { + _LuaState->pushNil(); + CLuaObject result(*_LuaState); + return result; + } + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->getTable(-2); + CLuaObject subObject(*_LuaState, concatId(getId(), key)); + _LuaState->pop(); // pop the sub object + return subObject; + } + + // ************************************************* + CLuaObject CLuaObject::operator[](double key) const + { + nlassert(isValid()); + if (!isEnumerable()) + { + _LuaState->pushNil(); + CLuaObject result(*_LuaState); + return result; + } + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->getTable(-2); + CLuaObject subObject(*_LuaState, concatId(getId(), NLMISC::toString(key))); + _LuaState->pop(); // pop the sub object + return subObject; + } + + // ************************************************* + CLuaObject CLuaObject::at(const char *key) const throw(ELuaNotATable) + { + if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Can't get key '%s' in object '%s' because type is '%s', it is not a table.", key, getId().c_str(), getTypename()).c_str()); + return operator[](key); + } + + // ************************************************* + bool CLuaObject::hasKey(const char *key) const + { + if (!isEnumerable()) throw ELuaNotATable(NLMISC::toString("Trying to access key '%s' on object '%s' of type %s.", key, getId().c_str(), getTypename()).c_str()); + CLuaObject value = operator[](key); + return (!value.isNil()); + } + + // ************************************************* + CLuaObject CLuaObject::newTable(const char *tableName) throw(ELuaNotATable) + { + nlassert(tableName); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to create a subtable '%s' on object '%s' of type %s (not a table).", tableName, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(tableName); + _LuaState->newTable(); + _LuaState->setTable(-3); + _LuaState->pop(); + return at(tableName); //\TODO nico double copy here ... + } + + // ************************************************* + void CLuaObject::setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable) + { + nlassert(key); + nlassert(isValid()); + nlassert(value.isValid()); + nlassert(getLuaState() == value.getLuaState()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + value.push(); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::setNil(const char *key) throw(ELuaNotATable) + { + nlassert(key); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value 'nil' at key %s on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->pushNil(); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::setValue(const char *key, const char *value) throw(ELuaNotATable) + { + nlassert(value); + nlassert(key); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->push(value); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::setValue(const char *key, const std::string &value) throw(ELuaNotATable) + { + setValue(key, value.c_str()); + } + + // ************************************************* + void CLuaObject::setValue(const char *key, bool value) throw(ELuaNotATable) + { + nlassert(key); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%s' at key %s on object '%s' of type %s (not a table).", value ? "true" : "false", key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->push(value); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable) + { + nlassert(key); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a function value '%p' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->push(value); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::setValue(const char *key, double value) throw(ELuaNotATable) + { + nlassert(key); + nlassert(isValid()); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to set a value '%lf' at key %s on object '%s' of type %s (not a table).", value, key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->push(value); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + void CLuaObject::eraseValue(const char *key) throw(ELuaNotATable) + { + nlassert(isValid()); + nlassert(key); + if (!isTable()) throw ELuaNotATable(NLMISC::toString("Trying to erase a value with key '%s' on object '%s' of type %s (not a table).", key, getId().c_str(), getTypename())); + CLuaStackChecker lsc(_LuaState); + push(); + _LuaState->push(key); + _LuaState->pushNil(); + _LuaState->setTable(-3); + _LuaState->pop(); + } + + // ************************************************* + bool CLuaObject::callNoThrow(int numArgs, int numRet) + { + nlassert(isValid()); + if (!isFunction()) + { + nlwarning("Calling a non function object (id = %s, type = %s)", getId().c_str(), getTypename()); + _LuaState->pop(numArgs); + return false; + } + // TMP TMP + static volatile bool dumpFunction = false; + if (dumpFunction) + { + CLuaStackRestorer lsr(_LuaState, _LuaState->getTop()); + push(); + lua_Debug ar; + lua_getinfo (_LuaState->getStatePointer(), ">lS", &ar); + nlwarning((std::string(ar.what) + ", at line " + NLMISC::toString(ar.linedefined) + " in " + std::string(ar.source)).c_str()); + } + push(); + _LuaState->insert(-1 - numArgs); // put the function before its arguments + int result = _LuaState->pcall(numArgs, numRet); + switch (result) + { + case LUA_ERRRUN: + case LUA_ERRMEM: + case LUA_ERRERR: + nlwarning(_LuaState->toString(-1)); + _LuaState->pop(); + return false; + break; + case 0: + return true; + break; + default: + nlassert(0); + break; + } + return false; + } + + // ************************************************* + bool CLuaObject::callMethodByNameNoThrow(const char *name, int numArgs, int numRet) + { + nlassert(isValid()); + int initialStackSize = _LuaState->getTop(); + if (!isTable() && !isUserData()) + { + nlwarning("Can't call method : object is not a table (id = %s)", getId().c_str()); + _LuaState->setTop(std::max(0, initialStackSize - numArgs)); + return false; + } + CLuaObject method = (*this)[name]; + push(); // the 'self' parameter + _LuaState->insert(-1 - numArgs); // put 'self' before the arguments + if (method.callNoThrow(numArgs + 1, numRet)) + { + return true; + } _LuaState->setTop(std::max(0, initialStackSize - numArgs)); return false; } - CLuaObject method = (*this)[name]; - push(); // the 'self' parameter - _LuaState->insert(-1 - numArgs); // put 'self' before the arguments - if (method.callNoThrow(numArgs + 1, numRet)) - { - return true; - } - _LuaState->setTop(std::max(0, initialStackSize - numArgs)); - return false; -} -///////////////////// -// CLuaEnumeration // -///////////////////// + ///////////////////// + // CLuaEnumeration // + ///////////////////// -// ************************************************* -CLuaEnumeration::CLuaEnumeration(CLuaObject &table) -{ - nlassert(table.isEnumerable()); - CLuaState *luaState = table.getLuaState(); - CLuaStackChecker lsc(luaState); - // get pointer to the 'next' function - luaState->pushValue(LUA_GLOBALSINDEX); - _NextFunction = CLuaObject(*luaState)["next"]; - // - nlassert(luaState); - table.push(); - luaState->pushNil(); - _HasNext = false; - if (_NextFunction.callNoThrow(2, 2)) + // ************************************************* + CLuaEnumeration::CLuaEnumeration(CLuaObject &table) { - _Value.pop(*luaState); - _Key.pop(*luaState); - _HasNext = !_Key.isNil(); - _Value.setId(CLuaObject::concatId(table.getId(), _Key.toString())); - _Table = table; + nlassert(table.isEnumerable()); + CLuaState *luaState = table.getLuaState(); + CLuaStackChecker lsc(luaState); + // get pointer to the 'next' function + luaState->pushValue(LUA_GLOBALSINDEX); + _NextFunction = CLuaObject(*luaState)["next"]; + // + nlassert(luaState); + table.push(); + luaState->pushNil(); + _HasNext = false; + if (_NextFunction.callNoThrow(2, 2)) + { + _Value.pop(*luaState); + _Key.pop(*luaState); + _HasNext = !_Key.isNil(); + _Value.setId(CLuaObject::concatId(table.getId(), _Key.toString())); + _Table = table; + } + } -} - -// ************************************************* -const CLuaObject &CLuaEnumeration::nextKey() const -{ - nlassert(_HasNext); - return _Key; -} - -// ************************************************* -CLuaObject &CLuaEnumeration::nextValue() -{ - nlassert(_HasNext); - return _Value; -} - -// ************************************************* -CLuaObject CLuaObject::getMetaTable() const -{ - nlassert(isValid()); - CLuaStackChecker lsc(_LuaState); - push(); - if (_LuaState->getMetaTable(-1)) + // ************************************************* + const CLuaObject &CLuaEnumeration::nextKey() const { - _LuaState->remove(-2); + nlassert(_HasNext); + return _Key; + } + + // ************************************************* + CLuaObject &CLuaEnumeration::nextValue() + { + nlassert(_HasNext); + return _Value; + } + + // ************************************************* + CLuaObject CLuaObject::getMetaTable() const + { + nlassert(isValid()); + CLuaStackChecker lsc(_LuaState); + push(); + if (_LuaState->getMetaTable(-1)) + { + _LuaState->remove(-2); + return CLuaObject(*_LuaState); + } + _LuaState->pop(); + _LuaState->pushNil(); return CLuaObject(*_LuaState); } - _LuaState->pop(); - _LuaState->pushNil(); - return CLuaObject(*_LuaState); -} -// ************************************************* -bool CLuaObject::setMetaTable(CLuaObject &metatable) -{ - nlassert(isValid()); - nlassert(metatable.isValid()); - nlassert(this->getLuaState() == metatable.getLuaState()); - CLuaStackChecker lsc(_LuaState); - push(); - metatable.push(); - bool ok = _LuaState->setMetaTable(-2); - _LuaState->pop(1); - return ok; -} - -// ************************************************* -std::string CLuaObject::toStringRecurse(uint depth /*=0*/, uint maxDepth /*= 20*/, std::set *alreadySeen /*= NULL */) const -{ - if (maxDepth != 0 && depth > maxDepth) return ""; - const uint INDENT_NUM_BLANK = 2; - std::string indentStr(depth * INDENT_NUM_BLANK, ' '); - nlassert(_LuaState); - if (isEnumerable()) // is enumeration possible on that object ? + // ************************************************* + bool CLuaObject::setMetaTable(CLuaObject &metatable) { - std::string result; - if (alreadySeen) + nlassert(isValid()); + nlassert(metatable.isValid()); + nlassert(this->getLuaState() == metatable.getLuaState()); + CLuaStackChecker lsc(_LuaState); + push(); + metatable.push(); + bool ok = _LuaState->setMetaTable(-2); + _LuaState->pop(1); + return ok; + } + + // ************************************************* + std::string CLuaObject::toStringRecurse(uint depth /*=0*/, uint maxDepth /*= 20*/, std::set *alreadySeen /*= NULL */) const + { + if (maxDepth != 0 && depth > maxDepth) return ""; + const uint INDENT_NUM_BLANK = 2; + std::string indentStr(depth * INDENT_NUM_BLANK, ' '); + nlassert(_LuaState); + if (isEnumerable()) // is enumeration possible on that object ? { - if (alreadySeen->count(toPointer())) // avoid cyclic graph (infinite recursion else) + std::string result; + if (alreadySeen) { - result += indentStr +""; - return result; + if (alreadySeen->count(toPointer())) // avoid cyclic graph (infinite recursion else) + { + result += indentStr +""; + return result; + } + alreadySeen->insert(toPointer()); } - alreadySeen->insert(toPointer()); + result += indentStr + "{\n"; + CLuaObject *table = const_cast(this); + uint numElem = 0; + ENUM_LUA_TABLE(*table, it) + { + //nlwarning("entering table %s", it.nextKey().toString().c_str()); + result += std::string((depth + 1) * INDENT_NUM_BLANK, ' ') + it.nextKey().toString() + " = "; + if (it.nextValue().isEnumerable()) + { + result += "\n" + it.nextValue().toStringRecurse(depth + 1, maxDepth, alreadySeen); + } + else + { + result += it.nextValue().toStringRecurse(); + } + result += ",\n"; + ++ numElem; + if (numElem > 4000) + { + throw NLMISC::Exception("possible infinite loop, aborting enumeration"); + } + } + result += indentStr + "}"; + return result; } - result += indentStr + "{\n"; - CLuaObject *table = const_cast(this); - uint numElem = 0; - ENUM_LUA_TABLE(*table, it) + else if (isNil()) { - //nlwarning("entering table %s", it.nextKey().toString().c_str()); - result += std::string((depth + 1) * INDENT_NUM_BLANK, ' ') + it.nextKey().toString() + " = "; - if (it.nextValue().isEnumerable()) - { - result += "\n" + it.nextValue().toStringRecurse(depth + 1, maxDepth, alreadySeen); - } - else - { - result += it.nextValue().toStringRecurse(); - } - result += ",\n"; - ++ numElem; - if (numElem > 4000) - { - throw NLMISC::Exception("possible infinite loop, aborting enumeration"); - } + return (indentStr + "nil").c_str(); } - result += indentStr + "}"; - return result; - } - else if (isNil()) - { - return (indentStr + "nil").c_str(); - } - else if (isString()) - { - return (indentStr + "\"" + toString() + "\"").c_str(); - } - else if (isFunction()) - { - return (indentStr + "").c_str(); - } - else - { - return ((indentStr + toString()).c_str()); - } -} - -// ************************************************* -void CLuaObject::dump(uint maxDepth /*= 20*/, std::set *alreadySeen /*= NULL */) const -{ - try - { - std::string str = toStringRecurse(0, maxDepth, alreadySeen); - std::vector res; - NLMISC::explode(str, std::string("\n"), res); - for(uint k = 0; k < res.size(); ++k) + else if (isString()) { - NLMISC::InfoLog->forceDisplayRaw((res[k] + "\n") .c_str()); + return (indentStr + "\"" + toString() + "\"").c_str(); + } + else if (isFunction()) + { + return (indentStr + "").c_str(); + } + else + { + return ((indentStr + toString()).c_str()); } } - catch(const std::exception &e) - { - //CLuaIHMRyzom::dumpCallStack(); - nlwarning(e.what()); - } -} -// ************************************************* -std::string CLuaObject::concatId(const std::string &left,const std::string &right) -{ - if (!right.empty() && isdigit(right[0])) + // ************************************************* + void CLuaObject::dump(uint maxDepth /*= 20*/, std::set *alreadySeen /*= NULL */) const { - if (left.empty()) return "[" + right + "]"; - return left + "[" + right + "]"; + try + { + std::string str = toStringRecurse(0, maxDepth, alreadySeen); + std::vector res; + NLMISC::explode(str, std::string("\n"), res); + for(uint k = 0; k < res.size(); ++k) + { + NLMISC::InfoLog->forceDisplayRaw((res[k] + "\n") .c_str()); + } + } + catch(const std::exception &e) + { + //CLuaIHMRyzom::dumpCallStack(); + nlwarning(e.what()); + } + } + + // ************************************************* + std::string CLuaObject::concatId(const std::string &left,const std::string &right) + { + if (!right.empty() && isdigit(right[0])) + { + if (left.empty()) return "[" + right + "]"; + return left + "[" + right + "]"; + } + if (left.empty()) return right; + return left + "." + right; + + } + + // ************************************************* + void CLuaEnumeration::next() + { + nlassert(_HasNext); + CLuaState *luaState = _Table.getLuaState(); + nlassert(luaState); + CLuaStackChecker lsc(luaState); + _Table.push(); + _Key.push(); + _HasNext = false; + if (_NextFunction.callNoThrow(2, 2)) + { + _Value.pop(*luaState); + _Key.pop(*luaState); + _HasNext = !_Key.isNil(); + _Value.setId(_Table.getId() + "." + _Key.toString()); + } } - if (left.empty()) return right; - return left + "." + right; } - -// ************************************************* -void CLuaEnumeration::next() -{ - nlassert(_HasNext); - CLuaState *luaState = _Table.getLuaState(); - nlassert(luaState); - CLuaStackChecker lsc(luaState); - _Table.push(); - _Key.push(); - _HasNext = false; - if (_NextFunction.callNoThrow(2, 2)) - { - _Value.pop(*luaState); - _Key.pop(*luaState); - _HasNext = !_Key.isNil(); - _Value.setId(_Table.getId() + "." + _Key.toString()); - } -} - diff --git a/code/nel/src/gui/reflect.cpp b/code/nel/src/gui/reflect.cpp index 078fa3ef6..5058ba232 100644 --- a/code/nel/src/gui/reflect.cpp +++ b/code/nel/src/gui/reflect.cpp @@ -17,175 +17,182 @@ #include "nel/gui/reflect.h" -// Yoyo: Act like a singleton, else registerClass may crash. -CReflectSystem::TClassMap *CReflectSystem::_ClassMap= NULL; - -// hack to register the root class at startup -static const struct CRootReflectableClassRegister +namespace NLGUI { - CRootReflectableClassRegister() + // Yoyo: Act like a singleton, else registerClass may crash. + CReflectSystem::TClassMap *CReflectSystem::_ClassMap= NULL; + + // hack to register the root class at startup + static const struct CRootReflectableClassRegister { - TReflectedProperties props; - CReflectSystem::registerClass("CReflectable", "", props); - } -} _RootReflectableClassRegisterInstance; + CRootReflectableClassRegister() + { + TReflectedProperties props; + CReflectSystem::registerClass("CReflectable", "", props); + } + } _RootReflectableClassRegisterInstance; -//=================================================================================== -// release memory -void CReflectSystem::release() -{ - delete _ClassMap; - _ClassMap = NULL; -} + //=================================================================================== + // release memory + void CReflectSystem::release() + { + delete _ClassMap; + _ClassMap = NULL; + } -//=================================================================================== -void CReflectSystem::registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties) -{ - if(!_ClassMap) _ClassMap= new TClassMap; + //=================================================================================== + void CReflectSystem::registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties) + { + if(!_ClassMap) _ClassMap= new TClassMap; - TClassMap::const_iterator it = _ClassMap->find(className); - if (it != _ClassMap->end()) - { - nlerror("CReflectSystem::registerClass : Class registered twice : %s!", className.c_str()); + TClassMap::const_iterator it = _ClassMap->find(className); + if (it != _ClassMap->end()) + { + nlerror("CReflectSystem::registerClass : Class registered twice : %s!", className.c_str()); + } + CClassInfo &ci = (*_ClassMap)[className]; + ci.Properties = properties; + ci.ClassName = className; + for(uint k = 0; k < ci.Properties.size(); ++k) + { + ci.Properties[k].ParentClass = &ci; + } + if (parentName.empty()) + { + ci.ParentClass = NULL; + } + else + { + it = _ClassMap->find(parentName); + if (it == _ClassMap->end()) + { + nlerror("CReflectSystem::registerClass : Parent class %s not found", parentName.c_str()); + } + ci.ParentClass = &(it->second); + } } - CClassInfo &ci = (*_ClassMap)[className]; - ci.Properties = properties; - ci.ClassName = className; - for(uint k = 0; k < ci.Properties.size(); ++k) + + //=================================================================================== + const CReflectedProperty *CReflectSystem::getProperty(const std::string &className, const std::string &propertyName, bool dspWarning) { - ci.Properties[k].ParentClass = &ci; - } - if (parentName.empty()) - { - ci.ParentClass = NULL; - } - else - { - it = _ClassMap->find(parentName); + if(!_ClassMap) _ClassMap= new TClassMap; + + TClassMap::const_iterator it = _ClassMap->find(className); if (it == _ClassMap->end()) { - nlerror("CReflectSystem::registerClass : Parent class %s not found", parentName.c_str()); + nlwarning("CReflectSystem::getProperty : Unkwown class : %s", className.c_str()); + return NULL; } - ci.ParentClass = &(it->second); - } -} - -//=================================================================================== -const CReflectedProperty *CReflectSystem::getProperty(const std::string &className, const std::string &propertyName, bool dspWarning) -{ - if(!_ClassMap) _ClassMap= new TClassMap; - - TClassMap::const_iterator it = _ClassMap->find(className); - if (it == _ClassMap->end()) - { - nlwarning("CReflectSystem::getProperty : Unkwown class : %s", className.c_str()); - return NULL; - } - const CClassInfo *ci = &it->second; - while (ci) - { - // Linear search should suffice for now - for(uint k = 0; k < ci->Properties.size(); ++k) + const CClassInfo *ci = &it->second; + while (ci) { - if (ci->Properties[k].Name == propertyName) + // Linear search should suffice for now + for(uint k = 0; k < ci->Properties.size(); ++k) { - return &(ci->Properties[k]); + if (ci->Properties[k].Name == propertyName) + { + return &(ci->Properties[k]); + } } + // search in parent + ci = ci->ParentClass; } - // search in parent - ci = ci->ParentClass; - } - //\ TODO nico : possible optimization : instead of going up in the parents when - // searching for a property, it would be simpler to concatenate properties - // from parent class at registration. - // All that would be left at the end would be a hash_map of properties ... + //\ TODO nico : possible optimization : instead of going up in the parents when + // searching for a property, it would be simpler to concatenate properties + // from parent class at registration. + // All that would be left at the end would be a hash_map of properties ... - if(dspWarning) - nlwarning("CReflectSystem::getProperty : %s is not a property of class : %s", propertyName.c_str(), className.c_str()); - return NULL; -} - - -//=================================================================================== -const CClassInfo *CReflectable::getClassInfo() -{ - if (!CReflectSystem::getClassMap()) return NULL; - // TODO nico : a possible optimization would be to use the address of the static function - // 'getReflectedProperties' as a key into the CClassInfo map. This pointer uniquely identify - // classes that export properties - CReflectSystem::TClassMap::const_iterator it = CReflectSystem::getClassMap()->find(this->getReflectedClassName()); - if (it == CReflectSystem::getClassMap()->end()) - { + if(dspWarning) + nlwarning("CReflectSystem::getProperty : %s is not a property of class : %s", propertyName.c_str(), className.c_str()); return NULL; } - return &(it->second); -} -//=================================================================================== -const CReflectedProperty *CReflectable::getReflectedProperty(const std::string &propertyName, bool dspWarning) const -{ - return CReflectSystem::getProperty(this->getReflectedClassName(), propertyName, dspWarning); -} + //=================================================================================== + const CClassInfo *CReflectable::getClassInfo() + { + if (!CReflectSystem::getClassMap()) return NULL; + // TODO nico : a possible optimization would be to use the address of the static function + // 'getReflectedProperties' as a key into the CClassInfo map. This pointer uniquely identify + // classes that export properties + CReflectSystem::TClassMap::const_iterator it = CReflectSystem::getClassMap()->find(this->getReflectedClassName()); + if (it == CReflectSystem::getClassMap()->end()) + { + return NULL; + } + return &(it->second); + } + + //=================================================================================== + const CReflectedProperty *CReflectable::getReflectedProperty(const std::string &propertyName, bool dspWarning) const + { + return CReflectSystem::getProperty(this->getReflectedClassName(), propertyName, dspWarning); + } + +} #include "nel/gui/lua_manager.h" -CReflectableRefPtrTarget::~CReflectableRefPtrTarget() +namespace NLGUI { - CLuaState *lua= CLuaManager::getInstance().getLuaState(); - if(!lua) - return; - CLuaStackChecker lsc(lua); - // remove from the lua registry if i'm in - lua->pushLightUserData((void *) this); - lua->getTable(LUA_REGISTRYINDEX); - if (!lua->isNil(-1)) + CReflectableRefPtrTarget::~CReflectableRefPtrTarget() { - lua->pop(); + CLuaState *lua= CLuaManager::getInstance().getLuaState(); + if(!lua) + return; + CLuaStackChecker lsc(lua); + // remove from the lua registry if i'm in lua->pushLightUserData((void *) this); - lua->pushNil(); - lua->setTable(LUA_REGISTRYINDEX); + lua->getTable(LUA_REGISTRYINDEX); + if (!lua->isNil(-1)) + { + lua->pop(); + lua->pushLightUserData((void *) this); + lua->pushNil(); + lua->setTable(LUA_REGISTRYINDEX); + } + else + { + lua->pop(); + } } - else + + /** + * Data structure pushed in lua (a userdata) to access CReflectableRefPtrTarget derived objects + * These includes element of the GUI. + * if holds a pointer to the reflectable object, and + * a cache to its CClassInfo for fast access to exported properties + * \see reflect.h + */ + + // + + inline const CClassInfo &CReflectableLuaRef::getClassInfo() const { - lua->pop(); + nlassert(Ptr); // class info should not be accessed for a null ptr + if (_ClassInfo) return *_ClassInfo; + _ClassInfo = Ptr->getClassInfo(); + return *_ClassInfo; } -} -/** - * Data structure pushed in lua (a userdata) to access CReflectableRefPtrTarget derived objects - * These includes element of the GUI. - * if holds a pointer to the reflectable object, and - * a cache to its CClassInfo for fast access to exported properties - * \see reflect.h - */ - -// - -inline const CClassInfo &CReflectableLuaRef::getClassInfo() const -{ - nlassert(Ptr); // class info should not be accessed for a null ptr - if (_ClassInfo) return *_ClassInfo; - _ClassInfo = Ptr->getClassInfo(); - return *_ClassInfo; -} - -const CReflectedProperty *CReflectableLuaRef::getProp(const char *luaStringPtr) const -{ - const CClassInfo &ci = getClassInfo(); - CClassInfo::TLuaStrToPropMap::const_iterator it = ci.LuaStrToProp.find(luaStringPtr); - if (it != ci.LuaStrToProp.end()) + const CReflectedProperty *CReflectableLuaRef::getProp(const char *luaStringPtr) const { - return it->second.Prop; + const CClassInfo &ci = getClassInfo(); + CClassInfo::TLuaStrToPropMap::const_iterator it = ci.LuaStrToProp.find(luaStringPtr); + if (it != ci.LuaStrToProp.end()) + { + return it->second.Prop; + } + // slowly retrieve property, and store in cache + // NB nico : this could also be done at startup... + const CReflectedProperty *prop = CReflectSystem::getProperty(ci.ClassName, luaStringPtr, false); + if (!prop) return NULL; + CLuaIndexedProperty lip; + lip.Id = CLuaString(luaStringPtr); // keep a ref on the lua string to ensure that its pointer always remains valid + lip.Prop = prop; + ci.LuaStrToProp[luaStringPtr] = lip; + return prop; } - // slowly retrieve property, and store in cache - // NB nico : this could also be done at startup... - const CReflectedProperty *prop = CReflectSystem::getProperty(ci.ClassName, luaStringPtr, false); - if (!prop) return NULL; - CLuaIndexedProperty lip; - lip.Id = CLuaString(luaStringPtr); // keep a ref on the lua string to ensure that its pointer always remains valid - lip.Prop = prop; - ci.LuaStrToProp[luaStringPtr] = lip; - return prop; + } diff --git a/code/ryzom/client/src/decal_anim.h b/code/ryzom/client/src/decal_anim.h index 9dde03b9e..50ae61d66 100644 --- a/code/ryzom/client/src/decal_anim.h +++ b/code/ryzom/client/src/decal_anim.h @@ -23,7 +23,13 @@ namespace NLMISC class CVector2f; } -class CLuaObject; +namespace NLGUI +{ + class CLuaObject; +} + +using namespace NLGUI; + class CDecal; // TODO nico : this would fit nicely in the particle system animation system (would be more flexible) diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 27d6e4656..3b5a878cb 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -25,6 +25,8 @@ #include "interface_property.h" #include "nel/gui/reflect.h" +using namespace NLGUI; + // ---------------------------------------------------------------------------- class CInterfaceGroup; diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/ryzom/client/src/interface_v3/interface_link.h index c83ef5034..ae88849dd 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.h +++ b/code/ryzom/client/src/interface_v3/interface_link.h @@ -22,12 +22,20 @@ #include "nel/misc/cdb_branch.h" #include "nel/misc/cdb_branch_observing_handler.h" +namespace NLGUI +{ + class CReflectedProperty; +} + + class CInterfaceElement; -class CReflectedProperty; class CInterfaceExprValue; class CInterfaceGroup; class CInterfaceExprNode; +using namespace NLGUI; + + /** A link in an interface. * A link is an object that can read one or several values from the database, that can evaluate an expression * on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index ba9089186..71fe3f398 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -3,10 +3,12 @@ #include "nel/gui/lua_ihm.h" +using namespace NLGUI; + class CLuaIHMRyzom { public: - static void RegisterRyzomFunctions( NLGUI::CLuaState &ls ); + static void RegisterRyzomFunctions( CLuaState &ls ); private: static void createLuaEnumTable(CLuaState &ls, const std::string &str); diff --git a/code/ryzom/client/src/r2/displayer_base.h b/code/ryzom/client/src/r2/displayer_base.h index 26e61e0d7..40f077af2 100644 --- a/code/ryzom/client/src/r2/displayer_base.h +++ b/code/ryzom/client/src/r2/displayer_base.h @@ -21,8 +21,10 @@ #include "nel/misc/class_registry.h" #include "../interface_v3/interface_element.h" -class CLuaObject; - +namespace NLGUI +{ + class CLuaObject; +} namespace R2 { diff --git a/code/ryzom/client/src/r2/entity_custom_select_box.h b/code/ryzom/client/src/r2/entity_custom_select_box.h index f16d6f5f8..5bd923806 100644 --- a/code/ryzom/client/src/r2/entity_custom_select_box.h +++ b/code/ryzom/client/src/r2/entity_custom_select_box.h @@ -21,7 +21,12 @@ #include "nel/gui/lua_object.h" #include -class CLuaObject; +namespace NLGUI +{ + class CLuaObject; +} + +using namespace NLGUI; namespace R2 { diff --git a/code/ryzom/client/src/r2/lua_event_forwarder.h b/code/ryzom/client/src/r2/lua_event_forwarder.h index bd16cd57c..41343b127 100644 --- a/code/ryzom/client/src/r2/lua_event_forwarder.h +++ b/code/ryzom/client/src/r2/lua_event_forwarder.h @@ -20,8 +20,10 @@ namespace NLGUI { class CLuaState; + class CLuaString; } -class CLuaString; + +using namespace NLGUI; namespace R2 { diff --git a/code/ryzom/client/src/r2/prim_render.h b/code/ryzom/client/src/r2/prim_render.h index 025da5862..bab97d5f6 100644 --- a/code/ryzom/client/src/r2/prim_render.h +++ b/code/ryzom/client/src/r2/prim_render.h @@ -24,8 +24,12 @@ #include "../interface_v3/group_map.h" +namespace NLGUI +{ + class CLuaObject; +} + class CEntityCL; -class CLuaObject; class CCtrlPolygon; namespace R2 diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index 4e5613c55..e10e5002e 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -29,8 +29,9 @@ class CInterfaceManager; namespace NLGUI { class CEventDescriptor; + class CLuaObject; } -class CLuaObject; + class CGroupMap; namespace NLMISC diff --git a/code/ryzom/client/src/r2/tool_choose_pos.h b/code/ryzom/client/src/r2/tool_choose_pos.h index 9eddb3fd6..98940a8b9 100644 --- a/code/ryzom/client/src/r2/tool_choose_pos.h +++ b/code/ryzom/client/src/r2/tool_choose_pos.h @@ -25,8 +25,10 @@ class CEntity; class CEntityCL; -class CLuaObject; - +namespace NLGUI +{ + class CLuaObject; +} namespace R2 { diff --git a/code/ryzom/client/src/r2/tool_choose_pos_lua.h b/code/ryzom/client/src/r2/tool_choose_pos_lua.h index 697eb34e6..867cb98b4 100644 --- a/code/ryzom/client/src/r2/tool_choose_pos_lua.h +++ b/code/ryzom/client/src/r2/tool_choose_pos_lua.h @@ -22,8 +22,11 @@ #include "nel/gui/lua_object.h" class CEntity; -class CLuaObject; +namespace NLGUI +{ + class CLuaObject; +} namespace R2 { diff --git a/code/ryzom/client/src/r2/tool_create_entity.h b/code/ryzom/client/src/r2/tool_create_entity.h index f906bc5e3..c80475b55 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.h +++ b/code/ryzom/client/src/r2/tool_create_entity.h @@ -25,8 +25,10 @@ #include "displayer_visual_entity.h" class CEntity; -class CLuaObject; - +namespace NLGUI +{ + class CLuaObject; +} namespace R2 { diff --git a/code/ryzom/client/src/r2/tool_draw_prim.h b/code/ryzom/client/src/r2/tool_draw_prim.h index fd85bd498..32f5f682e 100644 --- a/code/ryzom/client/src/r2/tool_draw_prim.h +++ b/code/ryzom/client/src/r2/tool_draw_prim.h @@ -25,8 +25,10 @@ class CEntity; -class CLuaObject; - +namespace NLGUI +{ + class CLuaObject; +} namespace R2 { From bb9101ae9fbbbdeec0594dfcd8c2eda126115e2c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 24 May 2012 00:55:50 +0200 Subject: [PATCH 031/339] ADDED: #1471 added a global db manager for the GUI library, also added support for resizeing the CDB bank handler. --- code/nel/include/nel/gui/db_manager.h | 47 +++++++++++++++++ code/nel/include/nel/misc/cdb_bank_handler.h | 6 +++ code/nel/include/nel/misc/cdb_manager.h | 6 +++ code/nel/src/gui/db_manager.cpp | 53 ++++++++++++++++++++ code/nel/src/misc/cdb_bank_handler.cpp | 12 +++++ code/nel/src/misc/cdb_manager.cpp | 5 ++ 6 files changed, 129 insertions(+) create mode 100644 code/nel/include/nel/gui/db_manager.h create mode 100644 code/nel/src/gui/db_manager.cpp diff --git a/code/nel/include/nel/gui/db_manager.h b/code/nel/include/nel/gui/db_manager.h new file mode 100644 index 000000000..38e75a755 --- /dev/null +++ b/code/nel/include/nel/gui/db_manager.h @@ -0,0 +1,47 @@ +// Ryzom - MMORPG Framework +// 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 DBMANAGER_H +#define DBMANAGER_H + +#include "nel/misc/cdb_manager.h" + +namespace NLGUI +{ + + class CDBManager : public NLMISC::CCDBManager + { + public: + static CDBManager* getInstance(); + static void release(); + + NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true ); + void delDbProp( const std::string &name ); + sint32 getDbValue32( const std::string &name ); + NLMISC::CCDBNodeBranch* getDB() const; + + private: + CDBManager(); + ~CDBManager(); + + static CDBManager *instance; + + }; + +} + +#endif diff --git a/code/nel/include/nel/misc/cdb_bank_handler.h b/code/nel/include/nel/misc/cdb_bank_handler.h index 102026f4d..3a225c1cb 100644 --- a/code/nel/include/nel/misc/cdb_bank_handler.h +++ b/code/nel/include/nel/misc/cdb_bank_handler.h @@ -113,6 +113,12 @@ public: */ uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; } + /** + @brief Resizes the bank holders. WARNING: Resets data contained. + @param newSize - The new maximum number of banks. + */ + void resize( uint newSize ); + private: /// Mapping from server database index to client database index (first-level nodes) std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping; diff --git a/code/nel/include/nel/misc/cdb_manager.h b/code/nel/include/nel/misc/cdb_manager.h index de6ccd20f..af4914b9a 100644 --- a/code/nel/include/nel/misc/cdb_manager.h +++ b/code/nel/include/nel/misc/cdb_manager.h @@ -171,6 +171,12 @@ namespace NLMISC{ */ void resetBank( uint gc, uint bank ); + + /** + @brief Resizes the bank holders. WARNING: Resets data contained. + @param newSize - The new maximum number of banks. + */ + void resizeBanks( uint newSize ); protected: CCDBBankHandler bankHandler; diff --git a/code/nel/src/gui/db_manager.cpp b/code/nel/src/gui/db_manager.cpp new file mode 100644 index 000000000..293bd2aae --- /dev/null +++ b/code/nel/src/gui/db_manager.cpp @@ -0,0 +1,53 @@ +#include "nel/gui/db_manager.h" + +namespace NLGUI +{ + CDBManager* CDBManager::instance = NULL; + + CDBManager::CDBManager() : + NLMISC::CCDBManager( "ROOT", 0 ) + { + } + + CDBManager::~CDBManager() + { + } + + CDBManager* CDBManager::getInstance() + { + if( instance == NULL ) + instance = new CDBManager(); + return instance; + } + + void CDBManager::release() + { + nlassert( instance != NULL ); + delete instance; + instance = NULL; + } + + NLMISC::CCDBNodeLeaf* CDBManager::getDbProp( const std::string &name, bool create ) + { + return getDbLeaf( name, create ); + } + + void CDBManager::delDbProp( const std::string &name ) + { + delDbNode( name ); + } + + sint32 CDBManager::getDbValue32( const std::string &name ) + { + NLMISC::CCDBNodeLeaf *node = getDbProp( name, false ); + if( node != NULL ) + return node->getValue32(); + else + return 0; + } + + NLMISC::CCDBNodeBranch* CDBManager::getDB() const + { + return _Database; + } +} \ No newline at end of file diff --git a/code/nel/src/misc/cdb_bank_handler.cpp b/code/nel/src/misc/cdb_bank_handler.cpp index f090ece4c..48a832611 100644 --- a/code/nel/src/misc/cdb_bank_handler.cpp +++ b/code/nel/src/misc/cdb_bank_handler.cpp @@ -91,6 +91,18 @@ _FirstLevelIdBitsByBank( maxbanks ) _FirstLevelIdBitsByBank[ bank ] = idb; } } + + void CCDBBankHandler::resize( uint newSize ) + { + reset(); + + _CDBBankNames.clear(); + _CDBBankToUnifiedIndexMapping.clear(); + _FirstLevelIdBitsByBank.clear(); + + _CDBBankToUnifiedIndexMapping.reserve( newSize ); + _FirstLevelIdBitsByBank.reserve( newSize ); + } } diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp index 8fc8a6897..e9b6e7283 100644 --- a/code/nel/src/misc/cdb_manager.cpp +++ b/code/nel/src/misc/cdb_manager.cpp @@ -146,4 +146,9 @@ namespace NLMISC{ _Database->resetNode( gc, bankHandler.getUIDForBank( bank ) ); } + void CCDBManager::resizeBanks( uint newSize ) + { + bankHandler.resize( newSize ); + } + } From dc6c1db2cd1ac806aebb25f7c136a158ff9cbba3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 24 May 2012 05:02:24 +0200 Subject: [PATCH 032/339] CHANGED: #1471 instead of CInterfaceManager, the new global db manager will be used. --- code/ryzom/client/src/cdb_synchronised.cpp | 2 +- code/ryzom/client/src/character_cl.cpp | 18 +- code/ryzom/client/src/client_chat_manager.cpp | 12 +- code/ryzom/client/src/commands.cpp | 122 +-- code/ryzom/client/src/connection.cpp | 68 +- code/ryzom/client/src/cursor_functions.cpp | 16 +- code/ryzom/client/src/debug_client.cpp | 12 +- code/ryzom/client/src/entities.cpp | 10 +- code/ryzom/client/src/entity_cl.cpp | 74 +- code/ryzom/client/src/far_tp.cpp | 4 +- code/ryzom/client/src/game_context_menu.cpp | 28 +- code/ryzom/client/src/ground_fx_manager.cpp | 14 +- code/ryzom/client/src/init_main_loop.cpp | 18 +- .../src/interface_v3/action_handler.cpp | 24 +- .../src/interface_v3/action_handler_game.cpp | 138 ++-- .../src/interface_v3/action_handler_help.cpp | 68 +- .../src/interface_v3/action_handler_item.cpp | 30 +- .../src/interface_v3/action_handler_move.cpp | 2 +- .../interface_v3/action_handler_outpost.cpp | 58 +- .../interface_v3/action_handler_phrase.cpp | 16 +- .../src/interface_v3/action_handler_ui.cpp | 20 +- .../src/interface_v3/action_phrase_faber.cpp | 76 +- .../interface_v3/animal_position_state.cpp | 10 +- .../client/src/interface_v3/bar_manager.cpp | 46 +- .../bot_chat_page_create_guild.cpp | 2 +- .../bot_chat_page_dynamic_mission.cpp | 24 +- .../interface_v3/bot_chat_page_mission.cpp | 64 +- .../bot_chat_page_mission_end.cpp | 4 +- .../src/interface_v3/bot_chat_page_news.cpp | 2 +- .../bot_chat_page_player_gift.cpp | 6 +- .../src/interface_v3/bot_chat_page_trade.cpp | 710 +++++++++--------- .../client/src/interface_v3/character_3d.cpp | 4 +- .../client/src/interface_v3/chat_filter.cpp | 6 +- .../src/interface_v3/chat_text_manager.cpp | 8 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../src/interface_v3/ctrl_base_button.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 14 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 26 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 6 +- .../dbgroup_list_sheet_bonus_malus.cpp | 2 +- .../dbgroup_list_sheet_mission.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 6 +- .../dbgroup_list_sheet_text_share.cpp | 16 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 22 +- .../client/src/interface_v3/dbview_bar.cpp | 6 +- .../src/interface_v3/encyclopedia_manager.cpp | 8 +- .../client/src/interface_v3/group_compas.cpp | 26 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../src/interface_v3/group_html_forum.cpp | 2 +- .../src/interface_v3/group_html_mail.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 6 +- .../interface_v3/group_in_scene_bubble.cpp | 10 +- .../interface_v3/group_in_scene_user_info.cpp | 44 +- .../client/src/interface_v3/group_map.cpp | 112 +-- .../group_phrase_skill_filter.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 4 +- .../client/src/interface_v3/guild_manager.cpp | 88 +-- .../src/interface_v3/interface_config.cpp | 6 +- .../client/src/interface_v3/interface_ddx.cpp | 24 +- .../src/interface_v3/interface_element.cpp | 16 +- .../src/interface_v3/interface_expr.cpp | 16 +- .../interface_v3/interface_expr_user_fct.cpp | 6 +- .../interface_expr_user_fct_game.cpp | 2 +- .../interface_expr_user_fct_items.cpp | 18 +- .../src/interface_v3/interface_link.cpp | 7 +- .../src/interface_v3/interface_manager.cpp | 161 ++-- .../src/interface_v3/interface_manager.h | 41 +- .../src/interface_v3/interface_observer.h | 10 +- .../src/interface_v3/interface_property.cpp | 48 +- .../src/interface_v3/inventory_manager.cpp | 164 ++-- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 32 +- .../client/src/interface_v3/macrocmd_key.cpp | 84 +-- .../src/interface_v3/macrocmd_manager.cpp | 6 +- .../client/src/interface_v3/obs_huge_list.cpp | 188 ++--- .../src/interface_v3/people_interraction.cpp | 42 +- .../client/src/interface_v3/player_trade.cpp | 2 +- .../src/interface_v3/sbrick_manager.cpp | 6 +- .../client/src/interface_v3/skill_manager.cpp | 28 +- .../src/interface_v3/sphrase_manager.cpp | 76 +- .../client/src/interface_v3/view_radar.cpp | 4 +- .../client/src/interface_v3/view_text_id.cpp | 2 +- code/ryzom/client/src/login.cpp | 72 +- code/ryzom/client/src/main_loop.cpp | 14 +- code/ryzom/client/src/misc.cpp | 8 +- .../ryzom/client/src/motion/user_controls.cpp | 2 +- code/ryzom/client/src/net_manager.cpp | 50 +- code/ryzom/client/src/outpost_manager.cpp | 10 +- code/ryzom/client/src/player_cl.cpp | 8 +- code/ryzom/client/src/player_r2_cl.cpp | 8 +- code/ryzom/client/src/progress.cpp | 2 +- .../client/src/r2/displayer_visual_entity.cpp | 14 +- .../src/r2/dmc/client_edition_module.cpp | 10 +- code/ryzom/client/src/r2/editor.cpp | 36 +- code/ryzom/client/src/r2/tool.cpp | 2 +- .../client/src/r2/tool_create_entity.cpp | 8 +- code/ryzom/client/src/release.cpp | 5 +- code/ryzom/client/src/time_client.cpp | 10 +- code/ryzom/client/src/user_entity.cpp | 106 +-- code/ryzom/client/src/weather.cpp | 6 +- 99 files changed, 1706 insertions(+), 1780 deletions(-) diff --git a/code/ryzom/client/src/cdb_synchronised.cpp b/code/ryzom/client/src/cdb_synchronised.cpp index 2a161d295..415024b17 100644 --- a/code/ryzom/client/src/cdb_synchronised.cpp +++ b/code/ryzom/client/src/cdb_synchronised.cpp @@ -319,7 +319,7 @@ void CCDBSynchronised::writeInitInProgressIntoUIDB() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pIM) - pIM->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")->setValueBool(_InitInProgress); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CDB_INIT_IN_PROGRESS")->setValueBool(_InitInProgress); else nlwarning("InterfaceManager not created"); } diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 259461b6e..55f1af798 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -8387,7 +8387,7 @@ ADD_METHOD(void CCharacterCL::displayDebug(float x, float &y, float lineStep)) / TextContext->printfAt(x, y, "Mount: %3u(Theoretical: %3u) Rider: %3u(Theoretical: %3u)", mount(), _TheoreticalMount, rider(), _TheoreticalRider); y += lineStep; // VPA - sint64 prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); if(isPlayer() || isUser()) { SPropVisualA visualA = *(SPropVisualA *)(&prop); @@ -8403,7 +8403,7 @@ ADD_METHOD(void CCharacterCL::displayDebug(float x, float &y, float lineStep)) / TextContext->printfAt(x, y, "VPA: %"NL_I64"X", prop); y += lineStep; // VPB - prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); if(isPlayer() || isUser()) { SPropVisualB visualB = *(SPropVisualB *)(&prop); @@ -8415,7 +8415,7 @@ ADD_METHOD(void CCharacterCL::displayDebug(float x, float &y, float lineStep)) / TextContext->printfAt(x, y, "VPB: %"NL_I64"X", prop); y += lineStep; // VPC - prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); + prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); if(isPlayer() || isUser()) { SPropVisualC visualC = *(SPropVisualC *)(&prop); @@ -8547,7 +8547,7 @@ void CCharacterCL::load() // virtual _LookRdy = false; // Visual properties A _HeadIdx = CEntityCL::BadIndex; - sint64 prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); updateVisualPropertyVpa(0, prop); } }// load // @@ -9798,11 +9798,11 @@ NLMISC_COMMAND(weapon, "change the weapon in hand", " ") CInterfaceManager *im = CInterfaceManager::getInstance(); uint slot; fromString(args[0], slot); - CCDBNodeLeaf *propA = im->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); + CCDBNodeLeaf *propA = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); if (!propA) return false; sint64 valueA = propA->getValue64(); - CCDBNodeLeaf *propB = im->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPB), false); + CCDBNodeLeaf *propB = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPB), false); if (!propB) return false; sint64 valueB = propB->getValue64(); @@ -9869,7 +9869,7 @@ NLMISC_COMMAND(advantageFX, "turn on / off the advantage fx for an item in hand" fromString(args[0], slot); /* - CCDBNodeLeaf *prop = im->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); if (!prop) return false; sint64 value = prop->getValue64(); uint hand; @@ -9917,11 +9917,11 @@ NLMISC_COMMAND(trailLength, "set length of trail for one weapon in hand", "getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); + CCDBNodeLeaf *propA = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPA), false); if (!propA) return false; sint64 valueA = propA->getValue64(); - CCDBNodeLeaf *propB = im->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPB), false); + CCDBNodeLeaf *propB = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", (int) slot, (int) PROPERTY_VPB), false); if (!propB) return false; sint64 valueB = propB->getValue64(); diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 59b72cedb..f62b02323 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -286,7 +286,7 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam ) if (isChatTeam) { - if (CInterfaceManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool()) + if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool()) msgType = "STRING:CHAT_TEAM"; else return; // don't display team chat message if there is no team chat @@ -1058,8 +1058,8 @@ void CClientChatManager::initInGame() _DynamicChannelIdLeaf[i]= NULL; _DynamicChannelIdCache[i]= DynamicChannelEmptyId; // get - CCDBNodeLeaf *name= pIM->getDbProp(toString("SERVER:DYN_CHAT:CHANNEL%d:NAME", i), false); - CCDBNodeLeaf *id= pIM->getDbProp(toString("SERVER:DYN_CHAT:CHANNEL%d:ID", i), false); + CCDBNodeLeaf *name= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:DYN_CHAT:CHANNEL%d:NAME", i), false); + CCDBNodeLeaf *id= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:DYN_CHAT:CHANNEL%d:ID", i), false); if(name && id) { _DynamicChannelNameLeaf[i]= name; @@ -1247,8 +1247,8 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne CInterfaceGroup *pEditBox = dynamic_cast(pCGW->getContainer()->getGroup("content:ebw")); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const bool teamActive = pIM->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool(); - const bool guildActive = pIM->getDbProp("SERVER:GUILD:NAME")->getValueBool(); + const bool teamActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool(); + const bool guildActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValueBool(); if (m == CChatGroup::team && ! teamActive) m = PeopleInterraction.TheUserChat.Filter.getTargetGroup(); @@ -1409,7 +1409,7 @@ class CHandlerSwapChatMode : public IActionHandler CInterfaceManager *pIM= CInterfaceManager::getInstance(); bool updateCapture= getParam(sParams, "update_capture")=="1"; - CCDBNodeLeaf *node= pIM->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB", false); if(node) { // if "chatmode" is active diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index a97b3e33c..70d435f6f 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -1175,7 +1175,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") } // Set the property. - CCDBNodeLeaf *node= pIM->getDbProp(args[0], false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(args[0], false); if(node) node->setValue64(value); else @@ -1186,7 +1186,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") } else if (size == 1) { - CCDBNodeLeaf *node= pIM->getDbProp(args[0], false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(args[0], false); if(node) { sint64 prop = node->getValue64(); @@ -1646,7 +1646,7 @@ NLMISC_COMMAND(forgetAll, "forget all bricks", "") for (uint i = 0;i<20;i++) { sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); - CCDBNodeLeaf * node= CInterfaceManager::getInstance()->getDbProp(buf); + CCDBNodeLeaf * node= NLGUI::CDBManager::getInstance()->getDbProp(buf); node->setValue64(0); } return true; @@ -2027,24 +2027,24 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n sint64 *prop = 0; CCDBNodeLeaf *node = 0; // Set The property 'CLFECOMMON::PROPERTY_POSITION'. - node = IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSX), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSX), false); if(node) { sint64 x = (sint64)(entityPos.x*1000.0); sint64 y = (sint64)(entityPos.y*1000.0); sint64 z = (sint64)(entityPos.z*1000.0); node->setValue64(x); - node = IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSY), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSY), false); if(node) { node->setValue64(y); - node = IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSZ), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSZ), false); if(node) node->setValue64(z); } } // Set The property 'PROPERTY_ORIENTATION'. - node = IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); if(node) { float dir = (float)atan2(UserEntity->front().y, UserEntity->front().x); @@ -2052,7 +2052,7 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n node->setValue64(*prop); } // Set Mode - node = IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); if(node) { MBEHAV::EMode m = MBEHAV::NORMAL; @@ -2075,11 +2075,11 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n visualC.PropertySubData.BreastSize = 7; // Set The Database prop = (sint64 *)&visualB; - IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); prop = (sint64 *)&visualC; - IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); prop = (sint64 *)&visualA; - IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); // Apply Changes. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); } @@ -2091,7 +2091,7 @@ NLMISC_COMMAND(entity, "Create an entity on the user or just remove it if Form n barVal+= 32; barVal<<= 7; barVal+= 10; barVal<<= 7; barVal+= 127; - IM->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_BARS))->setValue64(barVal); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_BARS))->setValue64(barVal); EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_BARS); // must also update position, else don't work EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_POSITION); @@ -2948,9 +2948,9 @@ NLMISC_COMMAND(paintTarget, "Modify the target color", const string propNameA = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPC); - vA.PropertyA = CInterfaceManager::getInstance()->getDbProp(propNameA)->getValue64(); - vB.PropertyB = CInterfaceManager::getInstance()->getDbProp(propNameB)->getValue64(); - vC.PropertyC = CInterfaceManager::getInstance()->getDbProp(propNameC)->getValue64(); + vA.PropertyA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA)->getValue64(); + vB.PropertyB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB)->getValue64(); + vC.PropertyC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC)->getValue64(); // Get the visual item index uint value; @@ -2964,9 +2964,9 @@ NLMISC_COMMAND(paintTarget, "Modify the target color", vB.PropertySubData.FeetColor = value; // Set the database. - CInterfaceManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); - CInterfaceManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); - CInterfaceManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); + NLGUI::CDBManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); + NLGUI::CDBManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); + NLGUI::CDBManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); @@ -3049,9 +3049,9 @@ NLMISC_COMMAND(vP, "Modify the Visual Property", const string propNameA = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPC); - vA.PropertyA = CInterfaceManager::getInstance()->getDbProp(propNameA)->getValue64(); - vB.PropertyB = CInterfaceManager::getInstance()->getDbProp(propNameB)->getValue64(); - vC.PropertyC = CInterfaceManager::getInstance()->getDbProp(propNameC)->getValue64(); + vA.PropertyA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA)->getValue64(); + vB.PropertyB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB)->getValue64(); + vC.PropertyC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC)->getValue64(); // Get the visual item index uint value; fromString(args[2], value); @@ -3180,9 +3180,9 @@ NLMISC_COMMAND(vP, "Modify the Visual Property", } // Set the database. - CInterfaceManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); - CInterfaceManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); - CInterfaceManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); + NLGUI::CDBManager::getInstance()->getDbProp(propNameA)->setValue64((sint64)vA.PropertyA); + NLGUI::CDBManager::getInstance()->getDbProp(propNameB)->setValue64((sint64)vB.PropertyB); + NLGUI::CDBManager::getInstance()->getDbProp(propNameC)->setValue64((sint64)vC.PropertyC); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); @@ -3214,7 +3214,7 @@ NLMISC_COMMAND(altLook, "Modify the Alternative Look Property", const string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_VPA); // Get the old value (not useful since we change the whole property). SAltLookProp altLookProp; - altLookProp.Summary = CInterfaceManager::getInstance()->getDbProp(propName)->getValue64(); + altLookProp.Summary = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); uint32 colorTop, colorBot, weaponRightHand, weaponLeftHand, seed, colorHair, hat; fromString(args[1], colorTop); fromString(args[2], colorBot); @@ -3250,7 +3250,7 @@ NLMISC_COMMAND(altLook, "Modify the Alternative Look Property", } // Set the database. - CInterfaceManager::getInstance()->getDbProp(propName)->setValue64((sint64)altLookProp.Summary); + NLGUI::CDBManager::getInstance()->getDbProp(propName)->setValue64((sint64)altLookProp.Summary); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); @@ -3385,12 +3385,12 @@ NLMISC_COMMAND(testMount, "Set the entity to mount"," ") // Set the database. string propName = toString("SERVER:Entities:E%d:P%d", mount, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); - CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(slot); + NLGUI::CDBManager::getInstance()->getDbProp(propName)->setValue64(slot); // Force to update properties. EntitiesMngr.updateVisualProperty(0, mount, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); // Set the database. propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); - CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(mount); + NLGUI::CDBManager::getInstance()->getDbProp(propName)->setValue64(mount); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); return true; @@ -3416,7 +3416,7 @@ NLMISC_COMMAND(mount, "Set the entity to mount"," []") // Set the database. string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); - CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(mount); + NLGUI::CDBManager::getInstance()->getDbProp(propName)->setValue64(mount); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_ENTITY_MOUNTED_ID); @@ -3444,7 +3444,7 @@ NLMISC_COMMAND(rider, "Set the rider"," []") // Set the database. string propName = toString("SERVER:Entities:E%d:P%d", slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); - CInterfaceManager::getInstance()->getDbProp(propName)->setValue64(rider); + NLGUI::CDBManager::getInstance()->getDbProp(propName)->setValue64(rider); // Force to update properties. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_RIDER_ENTITY_ID); @@ -3474,7 +3474,7 @@ NLMISC_COMMAND(learnAllBrick, "learn all bricks (only in local mode)", "") uint i=0; for(;;) { - CCDBNodeLeaf * node= pIM->getDbProp(toString("SERVER:BRICK_FAMILY:%d:BRICKS", i), false); + CCDBNodeLeaf * node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:BRICK_FAMILY:%d:BRICKS", i), false); if(node) node->setValue64(SINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)); else @@ -3617,7 +3617,7 @@ NLMISC_COMMAND(money, "To earn Money (only in local mode)"," [getDbProp("SERVER:INVENTORY:MONEY")->setValue64(money); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:MONEY")->setValue64(money); return true; /* sint32 a = 0; @@ -3646,10 +3646,10 @@ NLMISC_COMMAND(money, "To earn Money (only in local mode)"," [getDefine("money_2"); string bs = im->getDefine("money_3"); string vbs = im->getDefine("money_4"); - im->getDbProp(ls + ":QUANTITY")->setValue32(a); - im->getDbProp(ms + ":QUANTITY")->setValue32(b); - im->getDbProp(bs + ":QUANTITY")->setValue32(c); - im->getDbProp(vbs + ":QUANTITY")->setValue32(d); + NLGUI::CDBManager::getInstance()->getDbProp(ls + ":QUANTITY")->setValue32(a); + NLGUI::CDBManager::getInstance()->getDbProp(ms + ":QUANTITY")->setValue32(b); + NLGUI::CDBManager::getInstance()->getDbProp(bs + ":QUANTITY")->setValue32(c); + NLGUI::CDBManager::getInstance()->getDbProp(vbs + ":QUANTITY")->setValue32(d); return true; */ } @@ -3874,7 +3874,7 @@ NLMISC_COMMAND(displayInventoryCounter, "display the Inventory counter to compar CInterfaceManager *pIM= CInterfaceManager::getInstance(); - uint srvVal= pIM->getDbProp("SERVER:INVENTORY:COUNTER")->getValue32(); + uint srvVal= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:COUNTER")->getValue32(); uint locVal= pIM->getLocalSyncActionCounter() ; srvVal&= pIM->getLocalSyncActionCounterMask(); locVal&= pIM->getLocalSyncActionCounterMask(); @@ -3893,7 +3893,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") CSPhraseManager *pPM= CSPhraseManager::getInstance(); // next - uint srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); + uint srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); uint locVal= pPM->getPhraseNextExecuteCounter() ; srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; @@ -3901,7 +3901,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "") pIM->displaySystemInfo(ucstring( "NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); // cycle - srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); + srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); locVal= pPM->getPhraseCycleExecuteCounter() ; srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; @@ -4404,7 +4404,7 @@ NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name") if (args.size() != 1) return false; CInterfaceManager *pIM= CInterfaceManager::getInstance(); uint skillId= (uint) SKILLS::toSkill(args[0]); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); if(node) { pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); @@ -4418,7 +4418,7 @@ NLMISC_COMMAND(setSkillValue, "set a skill value by its name", "skill_name value if (args.size() != 2) return false; CInterfaceManager *pIM= CInterfaceManager::getInstance(); uint skillId= (uint) SKILLS::toSkill(args[0]); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); if(node) { sint32 value; @@ -4434,7 +4434,7 @@ NLMISC_COMMAND(getBaseSkillValue, "get a baseskill value by its name", "skill_na if (args.size() != 1) return false; CInterfaceManager *pIM= CInterfaceManager::getInstance(); uint skillId= (uint) SKILLS::toSkill(args[0]); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); if(node) { pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); @@ -4448,7 +4448,7 @@ NLMISC_COMMAND(setBaseSkillValue, "set a baseskill value by its name", "skill_na if (args.size() != 2) return false; CInterfaceManager *pIM= CInterfaceManager::getInstance(); uint skillId= (uint) SKILLS::toSkill(args[0]); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); if(node) { sint32 value; @@ -4468,10 +4468,10 @@ NLMISC_COMMAND(setAllSkillValue, "set all Skill and baseskill to the given value for(uint i=0;igetDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", i), false); if(node) node->setValue32(value); - node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", i), false); if(node) node->setValue32(value); } @@ -4597,7 +4597,7 @@ NLMISC_COMMAND(vprop, "Flush the Visual Property (local only). you must write to sint64 val= 0; fromString(args[2], val); CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:Entities:E%d:P%d", slot, propId), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:Entities:E%d:P%d", slot, propId), false); if(node) node->setValue64(val); } @@ -4765,10 +4765,10 @@ NLMISC_COMMAND(fillAllInfoVersion, "", "") CInterfaceManager *pIM= CInterfaceManager::getInstance(); for(i=0;igetDbProp(toString("SERVER:EXCHANGE:GIVE:%d:INFO_VERSION", i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:EXCHANGE:GIVE:%d:INFO_VERSION", i), false); if(node) node->setValue32(ver); - node= pIM->getDbProp(toString("SERVER:EXCHANGE:RECEIVE:%d:INFO_VERSION", i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:EXCHANGE:RECEIVE:%d:INFO_VERSION", i), false); if(node) node->setValue32(ver); } @@ -4796,7 +4796,7 @@ NLMISC_COMMAND(fullFillInventory, "", "dbstring sheetName") // read db dest CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeBranch *nb= pIM->getDbBranch(args[0]); + CCDBNodeBranch *nb= NLGUI::CDBManager::getInstance()->getDbBranch(args[0]); if(!nb) return false; @@ -4804,14 +4804,14 @@ NLMISC_COMMAND(fullFillInventory, "", "dbstring sheetName") for(uint i=0;igetDbProp(args[0]+":"+toString(i)+":SHEET", false); + nl= NLGUI::CDBManager::getInstance()->getDbProp(args[0]+":"+toString(i)+":SHEET", false); if(nl) { nl->setValue64(value); - nl= pIM->getDbProp(args[0]+":"+toString(i)+":QUALITY", false); + nl= NLGUI::CDBManager::getInstance()->getDbProp(args[0]+":"+toString(i)+":QUALITY", false); if(nl) nl->setValue64(i); - nl= pIM->getDbProp(args[0]+":"+toString(i)+":PREREQUISIT_VALID", false); + nl= NLGUI::CDBManager::getInstance()->getDbProp(args[0]+":"+toString(i)+":PREREQUISIT_VALID", false); if(nl) nl->setValue64(1); } @@ -4835,7 +4835,7 @@ NLMISC_COMMAND(fillAllItemPreReq, "", "dbstring value") for(;;) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(toString("%s:%d:PREREQUISIT_VALID", dbBase.c_str(), index), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:PREREQUISIT_VALID", dbBase.c_str(), index), false); if(!node) break; node->setValue32(value); @@ -5628,13 +5628,13 @@ NLMISC_COMMAND(setMission, "locally set a mission text for test", "= 30) return false; if (index < 15) { - im->getDbProp(toString("SERVER:MISSIONS:%d:TITLE", (int) index))->setValue32(strID); - im->getDbProp(toString("SERVER:MISSIONS:%d:FINISHED", (int) index))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:MISSIONS:%d:TITLE", (int) index))->setValue32(strID); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:MISSIONS:%d:FINISHED", (int) index))->setValue32(0); } else { - im->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:TITLE", (int) index - 15))->setValue32(strID); - im->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:FINISHED", (int) index - 15))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:TITLE", (int) index - 15))->setValue32(strID); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:FINISHED", (int) index - 15))->setValue32(0); } setDynString(strID++, args[1]); return true; @@ -5647,11 +5647,11 @@ static bool setMissionStep(uint missionIndex, uint stepIndex, uint32 strID) if (stepIndex >= 20) return false; if (missionIndex < 15) { - im->getDbProp(toString("SERVER:MISSIONS:%d:GOALS:%d:TEXT", (int) missionIndex, (int) stepIndex))->setValue32(strID); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:MISSIONS:%d:GOALS:%d:TEXT", (int) missionIndex, (int) stepIndex))->setValue32(strID); } else { - im->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:GOALS:%d:TEXT", (int) (missionIndex - 15), (int) stepIndex))->setValue32(strID); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:GOALS:%d:TEXT", (int) (missionIndex - 15), (int) stepIndex))->setValue32(strID); } return true; } @@ -5696,11 +5696,11 @@ static bool debugSetMissionState(uint index, sint32 /* state */) CInterfaceManager *im = CInterfaceManager::getInstance(); if (index < 15) { - im->getDbProp(toString("SERVER:MISSIONS:%d:TITLE", (int) index))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:MISSIONS:%d:TITLE", (int) index))->setValue32(0); } else { - im->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:TITLE", (int) index - 15))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GROUP:MISSIONS:%d:TITLE", (int) index - 15))->setValue32(0); } return true; } diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index b7f3c1c97..03b63e232 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -247,7 +247,7 @@ REGISTER_ACTION_HANDLER (CAHOnReloadTestPage, "on_reload_test_page"); void initWebBrowser() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - //pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); + //NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // start the browser CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); @@ -389,9 +389,9 @@ bool connection (const string &cookie, const string &fsaddr) }*/ pIM->activateMasterGroup ("ui:outgame", true); - pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP + NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Active inputs Actions.enable(true); @@ -410,7 +410,7 @@ bool connection (const string &cookie, const string &fsaddr) SetMouseSpeed (ClientCfg.CursorSpeed); SetMouseAcceleration (ClientCfg.CursorAcceleration); - pIM->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot); PlayerSelectedSlot = ClientCfg.SelectedSlot; } @@ -447,7 +447,7 @@ bool connection (const string &cookie, const string &fsaddr) { if (ClientCfg.SelectCharacter == -1) { - pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select + NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select } } InterfaceState = globalMenu(); @@ -553,9 +553,9 @@ bool reconnection() TInterfaceState InterfaceState = GLOBAL_MENU; pIM->activateMasterGroup ("ui:outgame", true); - pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Active inputs Actions.enable(true); @@ -571,7 +571,7 @@ bool reconnection() SetMouseCursor (); SetMouseSpeed (ClientCfg.CursorSpeed); SetMouseAcceleration (ClientCfg.CursorAcceleration); - pIM->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(ClientCfg.SelectedSlot); PlayerSelectedSlot = ClientCfg.SelectedSlot; } @@ -588,7 +588,7 @@ bool reconnection() { if (ClientCfg.SelectCharacter == -1) { - pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select + NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(0); // 0 == select } InterfaceState = globalMenu(); } @@ -972,7 +972,7 @@ TInterfaceState globalMenu() // SKIP INTRO : Write to the database if we have to skip the intro and write we want to skip further intro to client cfg if (ClientCfg.SkipIntro) { - CCDBNodeLeaf *pNL = pIM->getDbProp("UI:TEMP:SKIP_INTRO", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SKIP_INTRO", false); if (pNL != NULL) pNL->setValue64(1); } @@ -993,9 +993,9 @@ TInterfaceState globalMenu() pIM->uninitOutGame(); pIM->initOutGame(); pIM->activateMasterGroup ("ui:outgame", true); - pIM->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP + NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); pIM->getElementFromId("ui:outgame:charsel")->setActive(false); pIM->getElementFromId("ui:outgame:charsel")->setActive(true); // Active inputs @@ -1034,7 +1034,7 @@ TInterfaceState globalMenu() } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // check if we can send another dated block if (NetMngr.getCurrentServerTick() != serverTick) @@ -1061,7 +1061,7 @@ TInterfaceState globalMenu() pIM->updateFrameEvents(); pIM->updateFrameViews(NULL); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Movie shooter globalMenuMovieShooter(); @@ -1122,15 +1122,15 @@ TInterfaceState globalMenu() WaitServerAnswer = false; if (ClientCfg.SelectCharacter == -1) { - CCDBNodeLeaf *pNL = pIM->getDbProp("UI:SERVER_RECEIVED_CHARS", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SERVER_RECEIVED_CHARS", false); if (pNL != NULL) { pNL->setValue64 (1); // Send impulse to interface observers IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); pNL->setValue64 (0); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } } else @@ -1178,7 +1178,7 @@ TInterfaceState globalMenu() if (ClientCfg.SelectCharacter == -1) { CCDBNodeLeaf *pNL; - pNL = pIM->getDbProp(CharNameValidDBLink,false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(CharNameValidDBLink,false); if (pNL != NULL) { if (CharNameValid) @@ -1187,15 +1187,15 @@ TInterfaceState globalMenu() pNL->setValue64(0); } - pNL = pIM->getDbProp("UI:SERVER_RECEIVED_VALID", false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SERVER_RECEIVED_VALID", false); if (pNL != NULL) { pNL->setValue64 (1); // Send impulse to interface observers IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); pNL->setValue64 (0); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } } } @@ -1222,7 +1222,7 @@ TInterfaceState globalMenu() if (NetMngr.getConnectionState() == CNetManager::Disconnect) { // Display the connection failure screen - CCDBNodeLeaf *pNL = pIM->getDbProp("UI:CURRENT_SCREEN", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:CURRENT_SCREEN", false); if (pNL != NULL) pNL->setValue64 (nScreenServerCrashed); @@ -1691,22 +1691,22 @@ public: CreateCharMsg.Slot = (uint8)result.getInteger(); - pIM->getDbProp("UI:SELECTED_SLOT")->setValue32(PlayerSelectedSlot); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_SLOT")->setValue32(PlayerSelectedSlot); } // Setup the new career string sCaracBasePath = getParam (Params, "caracs"); - CreateCharMsg.NbPointFighter = (uint8)pIM->getDbProp(sCaracBasePath+"FIGHT")->getValue32(); - CreateCharMsg.NbPointCaster = (uint8)pIM->getDbProp(sCaracBasePath+"MAGIC")->getValue32(); - CreateCharMsg.NbPointCrafter = (uint8)pIM->getDbProp(sCaracBasePath+"CRAFT")->getValue32(); - CreateCharMsg.NbPointHarvester = (uint8)pIM->getDbProp(sCaracBasePath+"FORAGE")->getValue32(); + CreateCharMsg.NbPointFighter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"FIGHT")->getValue32(); + CreateCharMsg.NbPointCaster = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"MAGIC")->getValue32(); + CreateCharMsg.NbPointCrafter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"CRAFT")->getValue32(); + CreateCharMsg.NbPointHarvester = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sCaracBasePath+"FORAGE")->getValue32(); // Setup starting point string sLocationPath = getParam(Params, "loc"); { CreateCharMsg.StartPoint = RYZOM_STARTING_POINT::borea; - CCDBNodeLeaf *pNL = pIM->getDbProp (sLocationPath, false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp (sLocationPath, false); if (pNL != NULL) CreateCharMsg.StartPoint = (RYZOM_STARTING_POINT::TStartPoint)(pNL->getValue64()); else @@ -1865,7 +1865,7 @@ public: string sDBSlot = getParam(Params, "dbslot"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - uint8 nSelectedSlot = (uint8)pIM->getDbProp(sDBSlot,false)->getValue32(); + uint8 nSelectedSlot = (uint8)NLGUI::CDBManager::getInstance()->getDbProp(sDBSlot,false)->getValue32(); if (nSelectedSlot > CharacterSummaries.size()) return; @@ -1927,7 +1927,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (sName.empty()) { - pIM->getDbProp(sDBLink,false)->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(sDBLink,false)->setValue32(0); return; } @@ -2648,7 +2648,7 @@ class CAHScenarioControl : public IActionHandler { bool team = !(R2::getEditor().isInitialized()); if(team) - team = (pIM->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0; + team = (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0; groupTeam->setActive(team); } } @@ -2921,7 +2921,7 @@ class CAHHideCharsFilters : public IActionHandler result = scenarioWnd->findFromShortId(string("invite_team")); if(result) { - bool team = (pIM->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0; + bool team = (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:TEAM_MEMBER")->getValue8())!=0; team = (team && !(R2::getEditor().isInitialized()) && lookingForPlayers); result->setActive(team); } @@ -3223,7 +3223,7 @@ class CAHLoadScenario : public IActionHandler if(R2::getEditor().getAccessMode() != R2::CEditor::AccessDM) { - bool noob = pIM->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool(); + bool noob = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool(); if (FreeTrial && noob && (nevraxScenario != "1" || trialAllowed != "1")) { CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); @@ -3319,7 +3319,7 @@ class CAHLoadScenario : public IActionHandler { for (uint i = 0 ; i < 8 ; ++i) { - uint32 val = pIM->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); + uint32 val = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); if(val!=0) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 2ced655c9..312dd589e 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -149,7 +149,7 @@ static bool testMissionOption(sint32 priorityWanted) for(uint k = 0; k < NUM_MISSION_OPTIONS; ++k) { std::string nodeName = toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PRIORITY", (int) k); - CCDBNodeLeaf *pNL = pIM->getDbProp(nodeName, false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(nodeName, false); if(pNL) { sint32 priority = pNL->getValue32(); @@ -159,7 +159,7 @@ static bool testMissionOption(sint32 priorityWanted) if(priorityWanted != 2 || textID==0) { nodeName = toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k); - pNL = pIM->getDbProp(nodeName, false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(nodeName, false); if(pNL && pNL->getValue32()) { textID = pNL->getValue32(); @@ -206,7 +206,7 @@ static bool testMissionRing() for(uint i=0;igetDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", i), false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", i), false); if(pNL && pNL->getValue32()) { uint32 textID = pNL->getValue32(); @@ -273,7 +273,7 @@ void checkUnderCursor() entity= EntitiesMngr.getEntityUnderPos(cursX, cursY, ClientCfg.SelectionDist, isPlayerUnderCursor); // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = IM->getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! @@ -308,7 +308,7 @@ void checkUnderCursor() float dist = (float)(entity->pos() - UserEntity->pos()).norm()-entity->box().getRadius(); // Entity Slot under the cursor. SlotUnderCursor = entity->slot(); - uint32 availablePrograms = (uint32)IM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32(); + uint32 availablePrograms = (uint32)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32(); bool entityAttackable = (availablePrograms&(1<properties().attackable(); if (ClientCfg.R2EDEnabled) { @@ -427,7 +427,7 @@ void checkUnderCursor() else if(availablePrograms & (1 << BOTCHATTYPE::WebPageFlag)) { // get the web page title textID - CCDBNodeLeaf *pNL = IM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); if(pNL && pNL->getValue32()) { uint32 textID = pNL->getValue32(); @@ -446,7 +446,7 @@ void checkUnderCursor() else if(availablePrograms & (1 << BOTCHATTYPE::OutpostFlag)) { // get the outpost sheet - CCDBNodeLeaf *pNL = IM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST", false); if(pNL && pNL->getValue32()) { // get the outpost name @@ -790,7 +790,7 @@ void contextTalk(bool rightClick, bool dblClick) if(IM == 0) return; // Get Entity Program - uint32 availablePrograms = (uint32)IM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32(); + uint32 availablePrograms = (uint32)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32(); // Static Mission if(availablePrograms & (1 << BOTCHATTYPE::ChooseMissionFlag)) UserEntity->moveTo(SlotUnderCursor, 2.0, CUserEntity::StaticMission); diff --git a/code/ryzom/client/src/debug_client.cpp b/code/ryzom/client/src/debug_client.cpp index ff05c57cc..e86b54825 100644 --- a/code/ryzom/client/src/debug_client.cpp +++ b/code/ryzom/client/src/debug_client.cpp @@ -584,22 +584,22 @@ void displayNetDebug () TextContext->printfAt(1.f, line, "Local Counter: %d", val); line += lineStep; // Inventory Counter - val= pIM->getDbProp("SERVER:INVENTORY:COUNTER")->getValue32(); + val= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:COUNTER")->getValue32(); val&= pIM->getLocalSyncActionCounterMask(); TextContext->printfAt(1.f, line, "INVENTORY:COUNTER: %d", val); line += lineStep; // Exchange Counter - val= pIM->getDbProp("SERVER:EXCHANGE:COUNTER")->getValue32(); + val= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:EXCHANGE:COUNTER")->getValue32(); val&= pIM->getLocalSyncActionCounterMask(); TextContext->printfAt(1.f, line, "EXCHANGE:COUNTER: %d", val); line += lineStep; // Programme Counter - val= pIM->getDbProp("SERVER:TARGET:CONTEXT_MENU:COUNTER")->getValue32(); + val= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_MENU:COUNTER")->getValue32(); val&= pIM->getLocalSyncActionCounterMask(); TextContext->printfAt(1.f, line, "TARGET:CONTEXT_MENU:COUNTER: %d", val); line += lineStep; // User Counter - val= pIM->getDbProp("SERVER:USER:COUNTER")->getValue32(); + val= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:COUNTER")->getValue32(); val&= pIM->getLocalSyncActionCounterMask(); TextContext->printfAt(1.f, line, "USER:COUNTER: %d", val); line += lineStep; @@ -608,14 +608,14 @@ void displayNetDebug () // SPhrase Execution Synchronisation Counter CSPhraseManager *pPM= CSPhraseManager::getInstance(); // Next action - uint srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); + uint srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); uint locVal= pPM->getPhraseNextExecuteCounter() ; srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; TextContext->printfAt(1.f, line, "NextAction (loc/srv): %d/%d", locVal, srvVal); line += lineStep; // CycleAction - srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); + srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); locVal= pPM->getPhraseCycleExecuteCounter(); srvVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK; diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index fcf5d3f08..37bd0293c 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -433,21 +433,21 @@ void CEntityManager::initialize(uint nbMaxEntity) for (i=0; iaddDBObserver(&MissionTargetObserver, "SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE"); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&MissionTargetObserver, ICDBNode::CTextId( "SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE" ) ); } // Add an Observer to the Team database for (i=0; iaddDBObserver(&TeamUIDObserver, toString(TEAM_DB_PATH ":%d:UID", i)); - pIM->addDBObserver(&TeamPresentObserver, toString(TEAM_DB_PATH ":%d:NAME", i)); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamUIDObserver, ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:UID", i) ) ); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&TeamPresentObserver, ICDBNode::CTextId( toString(TEAM_DB_PATH ":%d:NAME", i) )); } // Add an Observer to the Animal database for (i=0; iaddDBObserver(&AnimalUIDObserver, toString("SERVER:PACK_ANIMAL:BEAST%d:UID",i)); - pIM->addDBObserver(&AnimalStatusObserver, toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i)); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalUIDObserver, ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:UID",i) )); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&AnimalStatusObserver, ICDBNode::CTextId( toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i) )); } }// initialize // diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index 7cefa69d7..690bb12da 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -2423,33 +2423,33 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CEntityCL::_EntitiesColor[CEntityCL::User] = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:USER")->getValueRGBA(); - CEntityCL::_EntitiesColor[CEntityCL::Player] = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:PLAYER")->getValueRGBA(); - CEntityCL::_EntitiesColor[CEntityCL::NPC] = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:NPC")->getValueRGBA(); - CEntityCL::_EntitiesColor[CEntityCL::Fauna] = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:FAUNA")->getValueRGBA(); - CEntityCL::_EntitiesColor[CEntityCL::ForageSource] = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:SOURCE")->getValueRGBA(); - CEntityCL::_DeadColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:DEAD")->getValueRGBA(); - CEntityCL::_TargetColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:TARGET")->getValueRGBA(); - CEntityCL::_GroupColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:GROUP")->getValueRGBA(); - CEntityCL::_GuildColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:GUILD")->getValueRGBA(); - CEntityCL::_UserMountColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:MOUNT")->getValueRGBA(); - CEntityCL::_UserPackAnimalColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:BEAST")->getValueRGBA(); - CEntityCL::_PvpEnemyColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:PVPENEMY")->getValueRGBA(); - CEntityCL::_PvpAllyColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:PVPALLY")->getValueRGBA(); - CEntityCL::_PvpAllyInTeamColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:PVPALLYINTEAM")->getValueRGBA(); - CEntityCL::_PvpNeutralColor = pIM->getDbProp("UI:SAVE:ENTITY:COLORS:PVPNEUTRAL")->getValueRGBA(); + CEntityCL::_EntitiesColor[CEntityCL::User] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:USER")->getValueRGBA(); + CEntityCL::_EntitiesColor[CEntityCL::Player] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:PLAYER")->getValueRGBA(); + CEntityCL::_EntitiesColor[CEntityCL::NPC] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:NPC")->getValueRGBA(); + CEntityCL::_EntitiesColor[CEntityCL::Fauna] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:FAUNA")->getValueRGBA(); + CEntityCL::_EntitiesColor[CEntityCL::ForageSource] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:SOURCE")->getValueRGBA(); + CEntityCL::_DeadColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:DEAD")->getValueRGBA(); + CEntityCL::_TargetColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:TARGET")->getValueRGBA(); + CEntityCL::_GroupColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:GROUP")->getValueRGBA(); + CEntityCL::_GuildColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:GUILD")->getValueRGBA(); + CEntityCL::_UserMountColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:MOUNT")->getValueRGBA(); + CEntityCL::_UserPackAnimalColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:BEAST")->getValueRGBA(); + CEntityCL::_PvpEnemyColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:PVPENEMY")->getValueRGBA(); + CEntityCL::_PvpAllyColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:PVPALLY")->getValueRGBA(); + CEntityCL::_PvpAllyInTeamColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:PVPALLYINTEAM")->getValueRGBA(); + CEntityCL::_PvpNeutralColor = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:COLORS:PVPNEUTRAL")->getValueRGBA(); // don't save these colors in .icfg because players can't change them - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::SGM - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:SGM")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::GM - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:GM")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::VG - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:VG")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::SG - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:SG")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::G - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:G")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::SGM - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:SGM")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::GM - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:GM")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::VG - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:VG")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::SG - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:SG")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::G - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:G")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::CM - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:CM")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::EM - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:EM")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::EG - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:EG")->getValueRGBA(); - CEntityCL::_GMTitleColor[ CHARACTER_TITLE::OBSERVER - CHARACTER_TITLE::BeginGmTitle ] = pIM->getDbProp("UI:INTERFACE:ENTITY:COLORS:OBSERVER")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::CM - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:CM")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::EM - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:EM")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::EG - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:EG")->getValueRGBA(); + CEntityCL::_GMTitleColor[ CHARACTER_TITLE::OBSERVER - CHARACTER_TITLE::BeginGmTitle ] = NLGUI::CDBManager::getInstance()->getDbProp("UI:INTERFACE:ENTITY:COLORS:OBSERVER")->getValueRGBA(); } }; REGISTER_ACTION_HANDLER (CUpdateEntitiesColor, "update_entities_color"); @@ -2631,7 +2631,7 @@ void CEntityCL::updateMissionTarget() for (j=0; jgetDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(i)+":TARGET"+toString(j)+":TITLE", false); if (prop) { _MissionTarget = _NameId == (uint32)prop->getValue32(); @@ -2733,7 +2733,7 @@ CCDBNodeLeaf *CEntityCL::getOpacityDBNode() if (!_OpacityMinNodeLeaf) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - _OpacityMinNodeLeaf = pIM->getDbProp("UI:SAVE:USER_CHAR_OPA_MIN", false); + _OpacityMinNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_OPA_MIN", false); } return _OpacityMinNodeLeaf; } @@ -2831,8 +2831,8 @@ void CEntityCL::updateIsInTeam () for (uint i=0; igetDbProp(toString(TEAM_DB_PATH ":%d:UID", i), false); - CCDBNodeLeaf *presentProp = pIM->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:UID", i), false); + CCDBNodeLeaf *presentProp = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", i), false); // If same Entity uid than the one in the Database, ok the entity is in the Player TEAM!! if (uidProp && uidProp->getValue32() == (sint32)dataSetId() && presentProp && presentProp->getValueBool() ) @@ -2861,9 +2861,9 @@ void CEntityCL::updateIsUserAnimal () for (uint i=0; igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *statusProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); - CCDBNodeLeaf *typeProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); + CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); + CCDBNodeLeaf *typeProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); // I must have the same Id, and the animal entry must be ok. if(uidProp && statusProp && typeProp && uidProp->getValue32() == (sint32)dataSetId() && ANIMAL_STATUS::isSpawned((ANIMAL_STATUS::EAnimalStatus)(statusProp->getValue32()) )) @@ -2893,8 +2893,8 @@ ANIMAL_STATUS::EAnimalStatus CEntityCL::getPackAnimalStatus() const for (uint i=0; igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *statusProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); + CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); // I must have the same Id, and the animal entry must be ok. if(uidProp && statusProp && uidProp->getValue32() == (sint32)dataSetId()) return (ANIMAL_STATUS::EAnimalStatus)(statusProp->getValue32()); @@ -2915,8 +2915,8 @@ bool CEntityCL::getPackAnimalIndexInDB(sint &dbIndex) const for (uint i=0; igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *statusProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); + CCDBNodeLeaf *statusProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", i), false); // I must have the same Id, and the animal entry must be ok. if(uidProp && statusProp && uidProp->getValue32() == (sint32)dataSetId()) { @@ -3026,7 +3026,7 @@ void CEntityCL::updateVisiblePostPos(const NLMISC::TTime &/* currentTimeInMs */, bool bShowReticle = true; - CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE"); + CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_RETICLE"); if (node) { bShowReticle = node->getValueBool(); @@ -3142,7 +3142,7 @@ void CEntityCL::updateVisiblePostPos(const NLMISC::TTime &/* currentTimeInMs */, // Colorize the selection depending of the level of the creature { CRGBA col = CRGBA(0,0,0); - uint8 nForce = CInterfaceManager::getInstance()->getDbProp("SERVER:TARGET:FORCE_RATIO")->getValue8(); + uint8 nForce = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:FORCE_RATIO")->getValue8(); _SelectionFX.setUserParam(0, 0.1f*nForce + 0.1f); } } diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index caa31a305..a7e4ebb94 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -1268,7 +1268,7 @@ void CFarTP::sendReady() // Update Network. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Be nice to the system nlSleep(100); } @@ -1407,7 +1407,7 @@ void CFarTP::farTPmainLoop() // Update Network. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // TODO: resend in case the last datagram sent was lost? // // check if we can send another dated block diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index b6e77dc20..292158262 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -82,7 +82,7 @@ void CGameContextMenu::init(const std::string &srcMenuId) CInterfaceManager *pIM= CInterfaceManager::getInstance(); _GroupMenu = dynamic_cast(pIM->getWindowFromId ("ui:interface:" + menuId + "")); - _ContextVal = pIM->getDbProp("SERVER:TARGET:CONTEXT_VAL", false); + _ContextVal = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_VAL", false); if(_GroupMenu == NULL) { @@ -93,7 +93,7 @@ void CGameContextMenu::init(const std::string &srcMenuId) _GroupMilkoPad = "ui:interface:milko_pad"; if(_GroupMilkoPad != NULL) { - _MilkoAttackDisengage = pIM->getDbProp("UI:VARIABLES:MK_ATTACK", false); + _MilkoAttackDisengage = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_ATTACK", false); _MilkoAttDisBut1 = "ui:interface:milko_pad:content:mode1:mode1_content:milko_actions:action5"; _MilkoAttDisBut2 = "ui:interface:milko_pad:content:mode2:action5"; } @@ -109,13 +109,13 @@ void CGameContextMenu::init(const std::string &srcMenuId) } // Some DB links - _AvailablePrograms = pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES"); - _ServerTeamPresent = pIM->getDbProp(TEAM_DB_PATH ":0:PRESENT", false); - _ServerInDuel = pIM->getDbProp("SERVER:USER:IN_DUEL", false); - _ServerInPvpChallenge = pIM->getDbProp("SERVER:USER:IN_PVP_CHALLENGE", false); - _WebPageTitle = pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); - _OutpostSheet = pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST", false); - _OutpostRightToBannish = pIM->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); + _AvailablePrograms = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES"); + _ServerTeamPresent = NLGUI::CDBManager::getInstance()->getDbProp(TEAM_DB_PATH ":0:PRESENT", false); + _ServerInDuel = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IN_DUEL", false); + _ServerInPvpChallenge = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IN_PVP_CHALLENGE", false); + _WebPageTitle = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); + _OutpostSheet = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST", false); + _OutpostRightToBannish = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); // Some text Menu @@ -146,14 +146,14 @@ void CGameContextMenu::init(const std::string &srcMenuId) // Mission DB and Text link for(uint k = 0; k < NUM_MISSION_OPTIONS; ++k) { - _MissionOption[k] = pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); + _MissionOption[k] = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); _TextMission[k] = toString(("ui:interface:" + menuId + ":mo%d").c_str(), (int) k); } // Mission Ring DB and Text link for(uint k = 0; k < BOTCHATTYPE::MaxR2MissionEntryDatabase; ++k) { - _MissionRing[k]= pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", k), false); + _MissionRing[k]= NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", k), false); _TextMissionRing[k] = toString(("ui:interface:" + menuId + ":mr%d").c_str(), (int) k); } @@ -569,7 +569,7 @@ void CGameContextMenu::update() if(ok) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:GCM_BEAST_SELECTED", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:GCM_BEAST_SELECTED", false); // beast_order AH start with 1 (0 for ALL beasts) if(node) node->setValue32(animalIndex+1); @@ -960,10 +960,10 @@ bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index, // Get animal status and type CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", index), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", index), false); if(!node) return false; ANIMAL_STATUS::EAnimalStatus status= (ANIMAL_STATUS::EAnimalStatus)node->getValue32(); - node= pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", index), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", index), false); if(!node) return false; ANIMAL_TYPE::EAnimalType anitype= (ANIMAL_TYPE::EAnimalType)node->getValue32(); diff --git a/code/ryzom/client/src/ground_fx_manager.cpp b/code/ryzom/client/src/ground_fx_manager.cpp index 2d3ce3810..4bfe7201b 100644 --- a/code/ryzom/client/src/ground_fx_manager.cpp +++ b/code/ryzom/client/src/ground_fx_manager.cpp @@ -919,7 +919,7 @@ NLMISC_COMMAND(gfxAdd, "gfxAdd", "<>") CInterfaceManager *IM = CInterfaceManager::getInstance(); // Set Position - node = IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSX), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSX), false); NLMISC::CVectorD pos; pos = UserEntity->pos() + 2.f * UserEntity->front(); if(node) @@ -928,11 +928,11 @@ NLMISC_COMMAND(gfxAdd, "gfxAdd", "<>") sint64 y = (sint64)(pos.y * 1000.0); sint64 z = (sint64)(pos.z * 1000.0); node->setValue64(x); - node = IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSY), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSY), false); if(node) { node->setValue64(y); - node = IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSZ), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSZ), false); if(node) { node->setValue64(z); @@ -944,7 +944,7 @@ NLMISC_COMMAND(gfxAdd, "gfxAdd", "<>") entity->front(UserEntity->front()); entity->dir(UserEntity->front()); // Set Mode - node = IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_MODE), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_MODE), false); if(node) { MBEHAV::EMode m = MBEHAV::NORMAL; @@ -967,11 +967,11 @@ NLMISC_COMMAND(gfxAdd, "gfxAdd", "<>") visualC.PropertySubData.BreastSize = 7; // Set The Database prop = (sint64 *)&visualB; - IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); prop = (sint64 *)&visualC; - IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); prop = (sint64 *)&visualA; - IM->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+NLMISC::toString("%d", slot)+":P"+NLMISC::toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); // Apply Changes. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); } diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 9b85367c3..caa765af5 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -317,7 +317,7 @@ inline void waitForNetworkMessage(bool &var) // Update network. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Send dummy info NetMngr.send(); // Do not take all the CPU. @@ -475,9 +475,9 @@ void initMainLoop() IngameDbMngr.init(CPath::lookup("database.xml"), ProgressBar); ICDBNode::CTextId textId("SERVER"); - if( pIM->getDB()->getNode(textId, false) ) - pIM->getDB()->removeNode(textId); - pIM->getDB()->attachChild(IngameDbMngr.getNodePtr(),"SERVER"); + if( NLGUI::CDBManager::getInstance()->getDB()->getNode(textId, false) ) + NLGUI::CDBManager::getInstance()->getDB()->removeNode(textId); + NLGUI::CDBManager::getInstance()->getDB()->attachChild(IngameDbMngr.getNodePtr(),"SERVER"); // Set the database NetMngr.setDataBase (IngameDbMngr.getNodePtr()); @@ -497,8 +497,8 @@ void initMainLoop() // Add the LOCAL branch ICDBNode::CTextId textId("LOCAL"); - if( pIM->getDB()->getNode(textId, false) ) - pIM->getDB()->removeNode(textId); + if( NLGUI::CDBManager::getInstance()->getDB()->getNode(textId, false) ) + NLGUI::CDBManager::getInstance()->getDB()->removeNode(textId); pIM->createLocalBranch(CPath::lookup("local_database.xml"), ProgressBar); initLast = initCurrent; @@ -1219,7 +1219,7 @@ void initMainLoop() // Update Network. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } // Set the LastGameCycle @@ -1488,7 +1488,7 @@ void initWelcomeWindow() CInterfaceGroup* welcomeWnd = dynamic_cast(pIM->getElementFromId("ui:interface:welcome_info")); if(welcomeWnd) { - bool welcomeDbProp = pIM->getDbProp("UI:SAVE:WELCOME")->getValueBool(); + bool welcomeDbProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:WELCOME")->getValueBool(); CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance(); welcomeWnd->setActive((sb.CurrentJoinMode!=CFarTP::LaunchEditor) && welcomeDbProp); } @@ -1502,7 +1502,7 @@ void initHardwareCursor(bool secondCall) CSessionBrowserImpl &sb = CSessionBrowserImpl::getInstance(); string nodeName = "UI:SAVE:HARDWARE_CURSOR"; - CCDBNodeLeaf * node= pIM->getDbProp(nodeName); + CCDBNodeLeaf * node= NLGUI::CDBManager::getInstance()->getDbProp(nodeName); if(node) { diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index 242543531..323bdd3a5 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -324,8 +324,8 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dbdst = getParam (Params, "dbdst"); string dbsrc = getParam (Params, "dbsrc"); - CCDBNodeBranch *pNBdst = pIM->getDbBranch(dbdst); - CCDBNodeBranch *pNBsrc = pIM->getDbBranch(dbsrc); + CCDBNodeBranch *pNBdst = NLGUI::CDBManager::getInstance()->getDbBranch(dbdst); + CCDBNodeBranch *pNBsrc = NLGUI::CDBManager::getInstance()->getDbBranch(dbsrc); // Branch copy @@ -494,21 +494,21 @@ class CAHActiveMenu : public IActionHandler // update GC_POPUP flag if (gc) { - im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64((gc->isPopuped() || gc->getLayerSetup() == 0) ? 1 : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64((gc->isPopuped() || gc->getLayerSetup() == 0) ? 1 : 0); } else { - im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(0); } // update GC_HAS_HELP flag if(gc && !gc->getHelpPage().empty()) { - im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(1); } else { - im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(0); } // open the menu @@ -691,10 +691,10 @@ public: AlphaChooserTarget = gc; if (!_AlphaObserversAdded) { - _UiVariableBGAlpha = im->getDbProp("UI:VARIABLES:ALPHA_BG"); - _UiVariableContentAlpha = im->getDbProp("UI:VARIABLES:ALPHA_CONTENT"); - _UiVariableRolloverAlphaBG = im->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG"); - _UiVariableRolloverAlphaContent = im->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT"); + _UiVariableBGAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_BG"); + _UiVariableContentAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_CONTENT"); + _UiVariableRolloverAlphaBG = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG"); + _UiVariableRolloverAlphaContent = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT"); ICDBNode::CTextId textIdBGAlpha, textIdContentAlpha, textIdRolloverAlphaBG, textIdRolloverAlphaContent; _UiVariableBGAlpha->addObserver(&_BgAlphaObs, textIdBGAlpha); _UiVariableContentAlpha->addObserver(&_ContentAlphaObs, textIdContentAlpha); @@ -724,7 +724,7 @@ public: OldRolloverAlphaContent = gc->getRolloverAlphaContent(); OldUseGlobalAlpha = gc->isUsingGlobalAlpha(); // Enable 'use global alpha' button - im->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1); // show the modal box im->enableModalWindow(gc, "ui:interface:define_ui_transparency"); @@ -785,7 +785,7 @@ class CAHUseGlobalAlphaSettings : public IActionHandler { AlphaChooserTarget->setUseGlobalAlpha(!AlphaChooserTarget->isUsingGlobalAlpha()); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1); } } }; diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 49c6f613b..1e91de65b 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -130,7 +130,7 @@ static bool playerKnowSkill( SKILLS::ESkills e) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string sPath = "SERVER:CHARACTER_INFO:SKILLS:" + toStringEnum( e ) + ":SKILL"; - CCDBNodeLeaf *pNL = pIM->getDbProp(sPath,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath,false); if ((pNL != NULL) && (pNL->getValue64() > 0)) return true; else @@ -501,7 +501,7 @@ public: CInterfaceManager *im = CInterfaceManager::getInstance(); // get flags std::string playerGiftNeededDbPath = toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", intId); - CCDBNodeLeaf *playerGiftNeeded = im->getDbProp(playerGiftNeededDbPath, false); + CCDBNodeLeaf *playerGiftNeeded = NLGUI::CDBManager::getInstance()->getDbProp(playerGiftNeededDbPath, false); if (!playerGiftNeeded) return; // //CBotChatManager::getInstance()->setChosenMissionFlags((uint) missionFlags->getValue8()); @@ -528,7 +528,7 @@ public: { CInterfaceManager *im = CInterfaceManager::getInstance(); // if there is only a single page available for missions, go to that page directly - CCDBNodeLeaf *progs = im->getDbProp("SERVER:TARGET:PROGRAMMES", false); + CCDBNodeLeaf *progs = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:PROGRAMMES", false); if (!progs) { nlwarning(" can't retrieve programs."); @@ -742,11 +742,11 @@ static void chooseSheath (ITEMFAMILY::EItemFamily eIF, string sAllSkills) { // Choose right sheath CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNLwrite = pIM->getDbProp(pIM->getDefine("ui_set_active")); - CCDBNodeLeaf *pNLread = pIM->getDbProp(pIM->getDefine("set_nb")); + CCDBNodeLeaf *pNLwrite = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("ui_set_active")); + CCDBNodeLeaf *pNLread = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_nb")); sint32 nNbSheath = (sint32)pNLread->getValue64(); if (nNbSheath == 0) return; - pNLread = pIM->getDbProp(pIM->getDefine("set_active")); + pNLread = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_active")); sint32 nActiveSheath = (sint32)pNLread->getValue64(); bool bFound = false; for (sint32 i = 0; i < ((nNbSheath/2)+1); ++i) @@ -763,7 +763,7 @@ static void chooseSheath (ITEMFAMILY::EItemFamily eIF, string sAllSkills) string sPath; sPath = pIM->getDefine("set_base") + ":" + NLMISC::toString(nSheathToTest) + ":" + pIM->getDefine("set_r") + ":SHEET"; - pNLread = pIM->getDbProp(sPath); + pNLread = NLGUI::CDBManager::getInstance()->getDbProp(sPath); sint32 sheetid = (sint32)pNLread->getValue64(); CItemSheet *pIS = dynamic_cast(SheetMngr.get(CSheetId(sheetid))); if (pIS != NULL) @@ -1019,8 +1019,8 @@ public: // Look through Database the index of the mount selected for (uint32 i = 0; i < MAX_INVENTORY_ANIMAL; i++) { - CCDBNodeLeaf *uidProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); - CCDBNodeLeaf *typeProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); + CCDBNodeLeaf *typeProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:TYPE", i), false); if ((uidProp != NULL) && (uidProp->getValue32() == (sint32)sel->dataSetId()) && (typeProp != NULL) && (typeProp->getValue32() == ANIMAL_TYPE::Mount)) { @@ -1102,7 +1102,7 @@ public: CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get ID - CCDBNodeLeaf *dbMissionId = pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:ID", idInDb), false); + CCDBNodeLeaf *dbMissionId = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:ID", idInDb), false); if (!dbMissionId) return; uint32 missionId= dbMissionId->getValue32(); @@ -1335,7 +1335,7 @@ class CSelectItemSheet : public IActionHandler { #define SKILL_PATH "SERVER:CHARACTER_INFO:SKILLS:" string path = toString(SKILL_PATH "%d:SKILL", (int) rs); - CCDBNodeLeaf *nl = im->getDbProp(path,false); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(path,false); if (nl) { if (nl->getValue32() == 0) @@ -1421,18 +1421,18 @@ class CSetPriceInDB : public IActionHandler { CSeeds money; money.setTotal(price.getInteger()); - im->getDbProp(ls)->setValue64(money.getLS()); - im->getDbProp(ms)->setValue64(money.getMS()); - im->getDbProp(bs)->setValue64(money.getBS()); - im->getDbProp(vbs)->setValue64(money.getVBS()); + NLGUI::CDBManager::getInstance()->getDbProp(ls)->setValue64(money.getLS()); + NLGUI::CDBManager::getInstance()->getDbProp(ms)->setValue64(money.getMS()); + NLGUI::CDBManager::getInstance()->getDbProp(bs)->setValue64(money.getBS()); + NLGUI::CDBManager::getInstance()->getDbProp(vbs)->setValue64(money.getVBS()); } else { // undefined price - im->getDbProp(ls)->setValue64(-1); - im->getDbProp(ms)->setValue64(-1); - im->getDbProp(bs)->setValue64(-1); - im->getDbProp(vbs)->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp(ls)->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp(ms)->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp(bs)->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp(vbs)->setValue64(-1); } } }; @@ -1553,7 +1553,7 @@ public: CViewTextMenu *pUnseat = dynamic_cast(pMenu->getView("unseat")); // Get the animal Selected. 0 for Alls, 1,2,3,4,5 for each pack animal - CCDBNodeLeaf *node= pIM->getDbProp("UI:BEAST_SELECTED", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:BEAST_SELECTED", false); if(!node) return; sint selected= node->getValue32(); @@ -1566,7 +1566,7 @@ public: { // Get the entity if it is in vision CEntityCL* selectedAnimalInVision = NULL; - CCDBNodeLeaf *uidProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", i), false); if ( uidProp ) { CLFECOMMON::TClientDataSetIndex datasetIndex = uidProp->getValue32(); @@ -1582,7 +1582,7 @@ public: { // Get the entity if it is in vision CEntityCL* selectedAnimalInVision = NULL; - CCDBNodeLeaf *uidProp = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", selected-1), false); + CCDBNodeLeaf *uidProp = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", selected-1), false); if ( uidProp ) { CLFECOMMON::TClientDataSetIndex datasetIndex = uidProp->getValue32(); @@ -1624,7 +1624,7 @@ class CHandlerAnimalTarget : public IActionHandler if(animalIndex>=1 && animalIndex<=MAX_INVENTORY_ANIMAL) { - CCDBNodeLeaf *prop = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", animalIndex-1), false); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:UID", animalIndex-1), false); if(prop) entityUid= prop->getValue32(); } @@ -2022,7 +2022,7 @@ class CActionHandlerSetTargetName : public IActionHandler if (nSlot > -1) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// uint32 nDBid = pIM->getDbProp("SERVER:Entities:E"+toString(nSlot)+":P6")->getValue32(); +// uint32 nDBid = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString(nSlot)+":P6")->getValue32(); uint32 nDBid = 0; if (nSlot < sint32(EntitiesMngr.entities().size()) && EntitiesMngr.entities()[nSlot] != NULL) { @@ -2102,7 +2102,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler if ( pE->isPlayer() ) { // Player => deduce RegionForce & ForceLevel from the database - CCDBNodeLeaf *pDbTargetUid = pIM->getDbProp( pIM->getDefine("target_uid") ); + CCDBNodeLeaf *pDbTargetUid = NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("target_uid") ); if ( ! pDbTargetUid ) return; // Hide the target level if the USER is not in PVP FACTION @@ -2120,7 +2120,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler return; } - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("target_player_level") ); if ( ! pDbPlayerLevel ) return; sint nLevel = pDbPlayerLevel->getValue32(); @@ -2217,7 +2217,7 @@ class CAHUpdateCurrentMode : public IActionHandler string sValue = getParam(Params,"value"); string sDBLink = getParam(Params,"dblink"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNL = pIM->getDbProp(sDBLink, false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sDBLink, false); if (pNL == NULL) return; CInterfaceExprValue eVal; @@ -2267,7 +2267,7 @@ class CAHUpdateCurrentMode : public IActionHandler bool bFound = false; while (!bFound) { - CCDBNodeLeaf *pIntFlags = pIM->getDbProp("SERVER:INTERFACES:FLAGS", false); + CCDBNodeLeaf *pIntFlags = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INTERFACES:FLAGS", false); if (pIntFlags == NULL) return; sint64 nIntFlags = pIntFlags->getValue64(); @@ -2634,13 +2634,13 @@ class CAHTargetTeammateShortcut : public IActionHandler return; // Index is the database index (serverIndex() not used for team list) - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:NAME", indexInTeam ), false ); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:NAME", indexInTeam ), false ); if ( ! pNL ) return; if ( pNL->getValueBool() ) { // There is a character corresponding to this index - pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:UID", indexInTeam ), false ); + pNL = NLGUI::CDBManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:UID", indexInTeam ), false ); if ( ! pNL ) return; CLFECOMMON::TClientDataSetIndex compressedIndex = pNL->getValue32(); @@ -2740,7 +2740,7 @@ public: const string procNames[MAX_NUM_MODES] = { "tb_setexp", "tb_setinfo", "tb_setlab", "tb_setkeys" }; const string dbNames[MAX_NUM_MODES] = { "", "UI:SAVE:CURRENT_INFO_MODE", "UI:SAVE:CURRENT_LAB_MODE", "UI:SAVE:CURRENT_KEY_MODE" }; string sValue; - CCDBNodeLeaf *pNL = pIM->getDbProp(dbNames[desktop], false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(dbNames[desktop], false); if (pNL != NULL) sValue = NLMISC::toString((sint32)pNL->getValue64()); vector vecStr; @@ -2930,9 +2930,9 @@ public: pCB->addText(ucstring(stringModeList[j])); } // -1 is important to indicate we set this value in edit mode - pIM->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(-1); - pIM->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(-1); - pIM->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(nFoundMode); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(nFoundMode); CCtrlBaseButton *pBut = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); if (pBut) @@ -2965,8 +2965,8 @@ public: else texMode= NormalTextureMode; // -1 is important to indicate we set this value in edit mode - pIM->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->setValue32(-1); - pIM->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->setValue32(texMode); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->setValue32(texMode); // **** Init Screen Aspect Ratio // Init the combo box, according to the value @@ -2977,17 +2977,17 @@ public: BkupScreenAspectRatio= ClientCfg.ScreenAspectRatio; // -1 is here to force var change - pIM->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(-1); // detect with an epsilon to avoid float precision problems if(fabs(ClientCfg.ScreenAspectRatio - 1.33333f)<=0.00001f) - pIM->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(0); // 4/3 + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(0); // 4/3 else if(fabs(ClientCfg.ScreenAspectRatio - 1.77777f)<=0.00001f) - pIM->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(1); // 16/9 + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(1); // 16/9 else if(ClientCfg.ScreenAspectRatio == 0.f) - pIM->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(3); // Auto + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(3); // Auto else - pIM->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(2); // Custom + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:SCREEN_RATIO_MODE" )->setValue32(2); // Custom } // **** Init Language : look in game_config.lua @@ -3004,8 +3004,8 @@ class CHandlerGameConfigMode : public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint oldVideoMode= pIM->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getOldValue32(); - sint nVideModeNb = pIM->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getValue32(); + sint oldVideoMode= NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getOldValue32(); + sint nVideModeNb = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getValue32(); if (nVideModeNb == -1) return; CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); @@ -3053,7 +3053,7 @@ class CHandlerGameConfigMode : public IActionHandler for (j = 0; j < (sint)stringFreqList.size(); j++) pCB->addText(ucstring(stringFreqList[j]) + " Hz"); } - pIM->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); // **** dirt the apply button of the DDX // don't do it at init! @@ -3075,8 +3075,8 @@ class CHandlerGameConfigLanguage : public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint old = pIM->getDbProp( GAME_CONFIG_LANGUAGE )->getOldValue32(); - sint newOne = pIM->getDbProp( GAME_CONFIG_LANGUAGE )->getValue32(); + sint old = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_LANGUAGE )->getOldValue32(); + sint newOne = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_LANGUAGE )->getValue32(); if ((old != -1) && (newOne != -1)) { // Set the new language @@ -3100,8 +3100,8 @@ class CHandlerGameConfigFreq : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - sint oldFreq= pIM->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getOldValue32(); - sint newFreq= pIM->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getValue32(); + sint oldFreq= NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getOldValue32(); + sint newFreq= NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getValue32(); // dirt the apply button of the DDX. // don't do it at init! @@ -3123,8 +3123,8 @@ public: virtual void execute(CCtrlBase * /* pCalller */, const string &/* Params */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - sint oldTMode= pIM->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getOldValue32(); - sint newTMode= pIM->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getValue32(); + sint oldTMode= NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getOldValue32(); + sint newTMode= NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getValue32(); // dirt the apply button of the DDX // don't do it at init! @@ -3193,10 +3193,10 @@ class CHandlerGameConfigApply : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); // **** Apply the video mode - sint nVideModeNb = pIM->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getValue32(); + sint nVideModeNb = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getValue32(); if (nVideModeNb != -1) { - sint nVideoFreqNb = pIM->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getValue32(); + sint nVideoFreqNb = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->getValue32(); if (nVideoFreqNb != -1) { // Get W, H @@ -3281,7 +3281,7 @@ class CHandlerGameConfigApply : public IActionHandler bool requestReboot = false; // **** Apply the texture mode - sint nTexMode = pIM->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getValue32(); + sint nTexMode = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_TEXTURE_MODE_DB )->getValue32(); if (nTexMode>=0 && nTexMode<=HighTextureMode) { if ((ClientCfg.DivideTextureSizeBy2 != (nTexMode==LowTextureMode)) || @@ -3303,7 +3303,7 @@ class CHandlerGameConfigApply : public IActionHandler // only if not in "work" language mode (else strange requestReboot) if(ClientCfg.LanguageCode!="wk") { - sint newOne = pIM->getDbProp( GAME_CONFIG_LANGUAGE )->getValue32(); + sint newOne = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_LANGUAGE )->getValue32(); //string newVal = (newOne==2)?"de":(newOne==1)?"fr":"en"; string newVal = convertLanguageIntToLanguageCode(newOne); if (ClientCfg.LanguageCode != newVal) @@ -3315,7 +3315,7 @@ class CHandlerGameConfigApply : public IActionHandler } // Apply the NPC icon display mode - CNPCIconCache::getInstance().setEnabled(!ClientCfg.R2EDEnabled && pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool()); + CNPCIconCache::getInstance().setEnabled(!ClientCfg.R2EDEnabled && NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool()); // Request a reboot if (requestReboot) @@ -3358,8 +3358,8 @@ class CHandlerGameConfigChangeScreenRatioMode : public IActionHandler CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get the current mode - sint oldMode= pIM->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getOldValue32(); - sint mode= pIM->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getValue32(); + sint oldMode= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getOldValue32(); + sint mode= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getValue32(); if(mode<0 || mode>3) return; @@ -3417,7 +3417,7 @@ class CHandlerGameConfigChangeScreenRatioCustom : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - sint mode= pIM->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getValue32(); + sint mode= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SCREEN_RATIO_MODE")->getValue32(); if (mode != 2) return; CGroupEditBox *eb= dynamic_cast(pIM->getElementFromDefine("game_config_screen_ratio_eb")); if(eb) @@ -3457,7 +3457,7 @@ class CHandlerGameMissionAbandon : public IActionHandler uint8 nMissionNb; fromString(Params, nMissionNb); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); if (pNL != NULL) pNL->setValue64(0); sendMsgToServer("JOURNAL:MISSION_ABANDON", nMissionNb); @@ -3474,7 +3474,7 @@ class CHandlerGameGroupMissionAbandon : public IActionHandler uint8 nMissionNb; fromString(Params, nMissionNb); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); if (pNL != NULL) pNL->setValue64(0); sendMsgToServer("JOURNAL:GROUP_MISSION_ABANDON", nMissionNb); @@ -3679,10 +3679,10 @@ static void fillPlayerBarText(ucstring &str, const string &dbScore, SCORES::TSco sint val= 0; sint maxVal= 0; // Get from local database cause written from CBarManager, from a fast impulse - node= pIM->getDbProp("UI:VARIABLES:USER:" + dbScore, false); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:" + dbScore, false); if(node) val= node->getValue32(); // less accurate/speed Max transferred by DB - node= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SCORES%d:", score), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SCORES%d:", score), false); if(node) maxVal= node->getValue32(); val= max(val, 0); maxVal= max(maxVal, 0); @@ -3777,7 +3777,7 @@ public: // Get the Max value sint32 maxVal= 0; - CCDBNodeLeaf *node= pIM->getDbProp(dbMax, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbMax, false); if(node) maxVal= node->getValue32(); @@ -3804,9 +3804,9 @@ uint32 getMissionTitle(sint32 nSelected) if (nSelected < 0) return 0; else if (nSelected < nNbMission) - return pIM->getDbProp("SERVER:MISSIONS:"+toString(nSelected)+":TITLE")->getValue32(); + return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:MISSIONS:"+toString(nSelected)+":TITLE")->getValue32(); else if (nSelected < (nNbMission+nNbGroupMission)) - return pIM->getDbProp("SERVER:GROUP:MISSIONS:"+toString(nSelected-nNbMission)+":TITLE")->getValue32(); + return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:MISSIONS:"+toString(nSelected-nNbMission)+":TITLE")->getValue32(); return 0; } @@ -3842,7 +3842,7 @@ public: void execute(CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint32 nSelected = pIM->getDbProp("UI:SAVE:MISSION_SELECTED")->getValue32(); + sint32 nSelected = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:MISSION_SELECTED")->getValue32(); sint32 nNbMission, nNbGroupMission; fromString(pIM->getDefine("ipj_nb_mission"), nNbMission); @@ -3884,7 +3884,7 @@ public: } } // No mission at all found so there is no mission in the journal - pIM->getDbProp("UI:SAVE:MISSION_SELECTED")->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:MISSION_SELECTED")->setValue32(-1); } } }; @@ -3996,7 +3996,7 @@ public: uint8 nMissionNb; fromString(sParams, nMissionNb); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:MISSION_WAKE_BUTTON",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION_WAKE_BUTTON",false); if (pNL != NULL) pNL->setValue64(0); sendMsgToServer("MISSION:WAKE", nMissionNb); @@ -4014,7 +4014,7 @@ public: uint8 nMissionNb; fromString(sParams, nMissionNb); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:MISSION_WAKE_BUTTON",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION_WAKE_BUTTON",false); if (pNL != NULL) pNL->setValue64(0); sendMsgToServer("MISSION:GROUP_WAKE", nMissionNb); diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 0d2ec32a6..ccb220e1f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -182,7 +182,7 @@ void CInterfaceHelp::initWindows() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = pIM->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -205,7 +205,7 @@ void CInterfaceHelp::release() // add observers for the update of phrase help texts (depends of weight of equipped weapons) for (uint i = 0; i < MAX_HANDINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNodeLeaf = pIM->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp(std::string(LOCAL_INVENTORY) + ":HAND:" + toString(i), false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -1243,7 +1243,7 @@ static void setupSkillToTradeHelp(CSheetHelpSetup &setup) // for (uint job = 0; job < 8; ++job) // { // std::string dbPath = toString("CHARACTER_INFO:CAREER%d:JOB%d:JOB_CAP", (int) career, (int) job); -// uint level = (uint) im->getDbProp(dbPath)->getValue32(); +// uint level = (uint) NLGUI::CDBManager::getInstance()->getDbProp(dbPath)->getValue32(); // if (level != 0) // has the player this job ? // { // // check if level in this job is enough to get the skills @@ -1437,7 +1437,7 @@ void getMagicProtection(CDBCtrlSheet *item, ucstring &itemText) { // Mul item quality by a constant uint maxAbsorb= item->getQuality(); - CCDBNodeLeaf *nodeFactor= pIM->getDbProp(pIM->getDefine("player_protect_absorbfactor"), false); + CCDBNodeLeaf *nodeFactor= NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("player_protect_absorbfactor"), false); if(nodeFactor) maxAbsorb= maxAbsorb*nodeFactor->getValue32()/100; @@ -1510,7 +1510,7 @@ void getWeightText(CDBCtrlSheet *item, const CItemSheet*pIS, ucstring &itemText) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *pWG = pIM->getDbProp(item->getSheet()+":WEIGHT",false); + CCDBNodeLeaf *pWG = NLGUI::CDBManager::getInstance()->getDbProp(item->getSheet()+":WEIGHT",false); if(pWG) { // must mul weight by quantity @@ -2338,7 +2338,7 @@ void setupItemPreview(CSheetHelpSetup &setup, CItemSheet *pIS) nlassert(pIS); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeBranch *dbBranch = pIM->getDbBranch( setup.SrcSheet->getSheet() ); + CCDBNodeBranch *dbBranch = NLGUI::CDBManager::getInstance()->getDbBranch( setup.SrcSheet->getSheet() ); CInterfaceElement *elt = setup.HelpWindow->getElement(setup.HelpWindow->getId()+setup.PrefixForExtra+INFO_ITEM_PREVIEW); @@ -2353,7 +2353,7 @@ void setupItemPreview(CSheetHelpSetup &setup, CItemSheet *pIS) } static sint32 helpWidth = setup.HelpWindow->getW(); - bool scene_inactive = ! pIM->getDbProp("UI:SAVE:SHOW_3D_ITEM_PREVIEW")->getValueBool(); + bool scene_inactive = ! NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:SHOW_3D_ITEM_PREVIEW")->getValueBool(); if (scene_inactive || (pIS->Family != ITEMFAMILY::ARMOR && pIS->Family != ITEMFAMILY::MELEE_WEAPON && @@ -2818,20 +2818,20 @@ void fillOutpostBuildingListItem(const std::vector &mps, IList uint i; for(i=0;igetDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i)); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i)); if(node) node->setValue32(mps[i].asInt()); - node= pIM->getDbProp(toString("%s:%d:QUALITY", branchBase.c_str(), i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:QUALITY", branchBase.c_str(), i), false); if(node) node->setValue32(qualityLevel); - node= pIM->getDbProp(toString("%s:%d:PREREQUISIT_VALID", branchBase.c_str(), i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:PREREQUISIT_VALID", branchBase.c_str(), i), false); if(node) node->setValue32(1); } // Reset other to 0. for(;;i++) { - CCDBNodeLeaf *node= pIM->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i), false); if(node) node->setValue32(0); else @@ -2918,7 +2918,7 @@ static bool getAuraDisabledState(CDBCtrlSheet *cs) // Get the DISABLED DBprop string db= cs->getSheet() + ":DISABLED"; - CCDBNodeLeaf *node= pIM->getDbProp(db, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(db, false); return node && node->getValue32()!=0; } @@ -2932,7 +2932,7 @@ static sint getBonusMalusSpecialTT(CDBCtrlSheet *cs) // Get the SPECIAL_TOOLTIP DBprop string db= cs->getSheet() + ":SPECIAL_TOOLTIP"; - return pIM->getDbValue32 (db); + return NLGUI::CDBManager::getInstance()->getDbValue32 (db); } @@ -3111,12 +3111,12 @@ void fillSabrinaPhraseListBrick(const CSPhraseCom &phrase, IListSheetBase *listB uint i; for(i=0;igetDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i)); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i)); if(node) node->setValue32(phrase.Bricks[i].asInt()); // For requirements bricks, update the LOCKED state - node= pIM->getDbProp(toString("%s:%d:LOCKED", branchBase.c_str(), i)); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:LOCKED", branchBase.c_str(), i)); if(node) { if(pBM->isBrickKnown(phrase.Bricks[i])) @@ -3129,7 +3129,7 @@ void fillSabrinaPhraseListBrick(const CSPhraseCom &phrase, IListSheetBase *listB // Reset other to 0. for(;;i++) { - CCDBNodeLeaf *node= pIM->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:SHEET", branchBase.c_str(), i), false); if(node) node->setValue32(0); else @@ -3469,73 +3469,73 @@ void setConsoModSuccessTooltip( CDBCtrlSheet *cs ) if( CSheetId(cs->getSheetId()).toString() == "mod_melee_success.sbrick" ) { ustr = CI18N::get("uittModMeleeSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_range_success.sbrick" ) { ustr = CI18N::get("uittModRangeSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_craft_success.sbrick" ) { ustr = CI18N::get("uittModCraftSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:CRAFT", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:CRAFT", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_defense_success.sbrick" ) { ustr = CI18N::get("uittModDefenseSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:DODGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:DODGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_dodge_success.sbrick" ) { ustr = CI18N::get("uittModDodgeSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:DODGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:DODGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_parry_success.sbrick" ) { ustr = CI18N::get("uittModParrySuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:PARRY", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:PARRY", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_forage_success.sbrick" ) { ustr = CI18N::get("uittModForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::common_ecosystem)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::common_ecosystem)+":FORAGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_desert_forage_success.sbrick" ) { ustr = CI18N::get("uittModDesertForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::desert)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::desert)+":FORAGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_forest_forage_success.sbrick" ) { ustr = CI18N::get("uittModForestForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::forest)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::forest)+":FORAGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_lacustre_forage_success.sbrick" ) { ustr = CI18N::get("uittModLacustreForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::lacustre)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::lacustre)+":FORAGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_jungle_forage_success.sbrick" ) { ustr = CI18N::get("uittModJungleForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::jungle)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::jungle)+":FORAGE", false); } else if( CSheetId(cs->getSheetId()).toString() == "mod_primary_root_forage_success.sbrick" ) { ustr = CI18N::get("uittModPrimaryRootForageSuccess"); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::primary_root)+":FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:"+toString((uint8)ECOSYSTEM::primary_root)+":FORAGE", false); } if( nodeSM ) @@ -3577,7 +3577,7 @@ public: pIM->setContextHelpText(CI18N::get("uittPvpOutpostInRound")); else if(specialTTId==BONUS_MALUS::DeathPenalty) { - CCDBNodeLeaf * node = pIM->getDbProp("SERVER:USER:DEATH_XP_MALUS", false); + CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEATH_XP_MALUS", false); if( node ) { ucstring txt = CI18N::get("uittDeathPenalty"); @@ -3619,7 +3619,7 @@ public: } ucstring txt; - CCDBNodeLeaf *node = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:NAME", index)); if (node && CStringManagerClient::instance()->getDynString(node->getValue32(), txt)) { pIM->setContextHelpText(CEntityCL::removeTitleFromName(txt)); @@ -3636,13 +3636,13 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Find the mount's db leaf - CCDBNodeBranch *animalsNode = safe_cast(pIM->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); + CCDBNodeBranch *animalsNode = safe_cast(NLGUI::CDBManager::getInstance()->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); BOMB_IF( ! animalsNode, "! animalsNode", return; ); sint32 minTimeRemaining = -1; uint nbAnimals = (uint)animalsNode->getNbNodes(); for ( uint i=0; i!=nbAnimals; ++i ) { - CCDBNodeLeaf *statusNode = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d", i) + ":STATUS", false); + CCDBNodeLeaf *statusNode = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d", i) + ":STATUS", false); if (statusNode && ANIMAL_STATUS::isDead((ANIMAL_STATUS::EAnimalStatus)statusNode->getValue32()) ) { ICDBNode *beastNode = animalsNode->getNode( i ); @@ -3884,7 +3884,7 @@ public: string prefix= getParam(Params, "prefix"); CInterfaceGroup *wnd= dynamic_cast(pIM->getElementFromId(wndStr)); - CCDBNodeLeaf *node= pIM->getDbProp(dbitem); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbitem); // common method for info and botchat if(wnd && node) @@ -3959,7 +3959,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pVal = pIM->getDbProp("UI:SAVE:MK_MODE", false); + CCDBNodeLeaf *pVal = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:MK_MODE", false); if(pVal) { sint32 mode = pVal->getValue32() + 1; diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index ce5e49307..d15f910cf 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -458,7 +458,7 @@ static void sendSwapItemMsg(const CDBCtrlSheet *pCSSrc, const CDBCtrlSheet *pCSD if ((srcInvId == (uint16)INVENTORIES::guild) || (dstInvId == (uint16)INVENTORIES::guild)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - nGuildSessionCounter = pIM->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); + nGuildSessionCounter = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); } out.serial(nGuildSessionCounter); // always serial to use the fixed-sized msg.xml scheme @@ -496,7 +496,7 @@ static void displayQuantityPopup(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCt pCSSrc->copyAspect(&destSheet); // init the editbox ctrl. init cur default to max - pIM->getDbProp("UI:VARIABLES:STACK_SELECTED:CUR_QUANTITY")->setValue32(availableStack); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:STACK_SELECTED:CUR_QUANTITY")->setValue32(availableStack); editBox->setInputStringAsInt(availableStack); // enable the modal @@ -592,7 +592,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet PlayerTrade.putItemInExchange(src, dest, quantitySrc); // user changed the proposal => reset the local ACCEPTED db - pIM->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server sendExchangeAddToServer((uint16)src->getIndexInDB(), (uint8)dest->getIndexInDB(), (uint16)quantitySrc); @@ -612,7 +612,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet PlayerTrade.restoreItem(exchangeSlot); // user changed the proposal => reset the local ACCEPTED db - pIM->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server CBitMemStream out; @@ -702,7 +702,7 @@ static void validateStackItem(CDBCtrlSheet *pCSSrc, CDBCtrlSheet *pCSDst, sint32 PlayerTrade.putItemInExchange(pCSSrc, pCSDst, val); // user changed the proposal => reset the local ACCEPTED db - pIM->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // send msg to server sendExchangeAddToServer((uint16)pCSSrc->getIndexInDB(), (uint8)pCSDst->getIndexInDB(), (uint16)val); @@ -808,7 +808,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the value to drop - sint32 val= pIM->getDbProp("UI:VARIABLES:STACK_SELECTED:CUR_QUANTITY")->getValue32(); + sint32 val= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:STACK_SELECTED:CUR_QUANTITY")->getValue32(); CDBCtrlSheet *pCSSrc = CurrentStackSrc; CDBCtrlSheet *pCSDst = CurrentStackDst; CurrentStackSrc= NULL; @@ -1120,7 +1120,7 @@ public: { PlayerTrade.restoreAllItems(); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp("LOCAL:EXCHANGE:BEGUN")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:BEGUN")->setValue32(0); if (!ClientCfg.Local) { @@ -1157,7 +1157,7 @@ public: } // user changed the proposal => reset the local ACCEPTED db CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // Send the msg CBitMemStream out; @@ -1317,10 +1317,10 @@ class CHandlerActiveSheath : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the user interface value. - uint8 activeSheath = (uint8)pIM->getDbProp( pIM->getDefine("ui_set_active") )->getValue32(); + uint8 activeSheath = (uint8)NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("ui_set_active") )->getValue32(); // Write to the Local Database. - pIM->getDbProp( "LOCAL:INVENTORY:ACTIVE_SHEATH" )->setValue32(activeSheath); + NLGUI::CDBManager::getInstance()->getDbProp( "LOCAL:INVENTORY:ACTIVE_SHEATH" )->setValue32(activeSheath); // Send to server if(!ClientCfg.Local) @@ -1355,10 +1355,10 @@ class CHandlerReceiveActiveSheath : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the user interface value. - uint8 activeSheath = (uint8)pIM->getDbProp( "LOCAL:INVENTORY:ACTIVE_SHEATH" )->getValue32(); + uint8 activeSheath = (uint8)NLGUI::CDBManager::getInstance()->getDbProp( "LOCAL:INVENTORY:ACTIVE_SHEATH" )->getValue32(); // Write to the Local Database. - pIM->getDbProp( pIM->getDefine("ui_set_active") )->setValue32(activeSheath); + NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("ui_set_active") )->setValue32(activeSheath); } }; REGISTER_ACTION_HANDLER( CHandlerReceiveActiveSheath, "receive_active_sheath" ); @@ -1933,7 +1933,7 @@ class CHandlerItemMenuCheck : public IActionHandler if(valid) { pEquip->setGrayed( - pIM->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_FABER")->getValueBool() && + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_FABER")->getValueBool() && pIS->Family!=ITEMFAMILY::ARMOR && pIS->Family!=ITEMFAMILY::JEWELRY ); @@ -1943,8 +1943,8 @@ class CHandlerItemMenuCheck : public IActionHandler //Item Text Edition if (pItemTextEdition != NULL && pItemTextDisplay != NULL) { - pItemTextEdition->setGrayed(pIM->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_EDIT_CUSTOM")->getValueBool()); - pItemTextDisplay->setGrayed(pIM->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_EDIT_CUSTOM")->getValueBool()); + pItemTextEdition->setGrayed(NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_EDIT_CUSTOM")->getValueBool()); + pItemTextDisplay->setGrayed(NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ISACTIVE:PHRASE_EDIT_CUSTOM")->getValueBool()); } if (pCS->getGrayed()) diff --git a/code/ryzom/client/src/interface_v3/action_handler_move.cpp b/code/ryzom/client/src/interface_v3/action_handler_move.cpp index de3c8d304..2d52c0d14 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -430,7 +430,7 @@ class CAHToggleDodgeParry : public IActionHandler ucstring msg; // 0 - dodge mode // 1 - parry mode - if (pIM->getDbProp("SERVER:DEFENSE:DEFENSE_MODE")->getValue32() == 0) + if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DEFENSE:DEFENSE_MODE")->getValue32() == 0) { sendMsgToServer("COMBAT:PARRY"); msg = CI18N::get("msgUserModeParry"); diff --git a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp index 8d8aaec9d..02c34e921 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -44,7 +44,7 @@ using namespace NLMISC; uint8 getOutpostSelection() { uint8 nOutpost = 0; - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SELECTION",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SELECTION",false); if (pNL != NULL) nOutpost = (uint8)pNL->getValue32(); return nOutpost; @@ -54,7 +54,7 @@ uint32 getOutpostSheet() { uint32 sheet= 0; uint8 outpostSel= getOutpostSelection(); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel),false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel),false); if (pNL != NULL) sheet = pNL->getValue32(); return sheet; @@ -70,7 +70,7 @@ public: CInterfaceManager *pIM= CInterfaceManager::getInstance(); // set confirm dialog flag - pIM->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(true); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(true); // Ask if ok before. pIM->validMessageBox(CInterfaceManager::QuestionIconMsg, CI18N::get("uiQConfirmGiveupOutpost"), @@ -88,7 +88,7 @@ public: uint32 sheet= 0; uint8 outpostSel; fromString(sParams, outpostSel); - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel),false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GUILD:OUTPOST:O%d:SHEET", outpostSel),false); if (pNL == NULL) return; sheet = pNL->getValue32(); @@ -98,7 +98,7 @@ public: // reset confirm dialog flag CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false); } }; REGISTER_ACTION_HANDLER(COutpostDoGiveup, "outpost_do_giveup"); @@ -110,7 +110,7 @@ public: { // reset confirm dialog flag CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:CONFIRM_DEL_OUTPOST")->setValueBool(false); } }; REGISTER_ACTION_HANDLER(COutpostCancelGiveup, "outpost_cancel_giveup"); @@ -125,7 +125,7 @@ public: CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get Squad slot Destination selected - uint8 nSquadSlot = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); + uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); // get Squad Id to buy selected string sLine = getParam(sParams, "line"); @@ -156,7 +156,7 @@ public: CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get Squad slot Destination selected - uint8 nSquadSlot = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); + uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); // send msg sendMsgToServer("OUTPOST:REMOVE_SQUAD", getOutpostSheet(), nSquadSlot); @@ -174,7 +174,7 @@ public: CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get Squad slot Destination selected - uint8 nSquadSlot = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); + uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); // send msg sendMsgToServer("OUTPOST:INSERT_SQUAD", getOutpostSheet(), nSquadSlot); @@ -192,12 +192,12 @@ uint8 getOutpostSquadSpawnIndex() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get Squad slot - uint8 nSquadSlot = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); + uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); // So we can get the spawn index stored in the DB string sDBPath = "SERVER:GUILD:OUTPOST:O" + toString(getOutpostSelection()) + ":SQUADS:T"; sDBPath += toString(nSquadSlot) + ":SPAWN"; - return pIM->getDbProp(sDBPath)->getValue8(); + return NLGUI::CDBManager::getInstance()->getDbProp(sDBPath)->getValue8(); } // *************************************************************************** @@ -222,8 +222,8 @@ public: uint32 i; for (i = 0; i < OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE; ++i) { - sint32 x = pIM->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32(); - sint32 y = pIM->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32(); + sint32 x = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32(); + sint32 y = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32(); if ((x != 0) || (y != 0)) { if (!bInit) @@ -289,8 +289,8 @@ public: m.NeedToReset = true; for (i = 0; i < OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE; ++i) { - sint32 x = pIM->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32(); - sint32 y = pIM->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32(); + sint32 x = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32(); + sint32 y = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32(); if ((x != 0) || (y != 0)) { CRespawnPointsMsg::SRespawnPoint pt; @@ -326,7 +326,7 @@ public: if (nSpawnIndex != nSpawnSelected) { // get Squad slot - uint8 nSquadSlot = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); + uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8(); sendMsgToServer("OUTPOST:SET_SQUAD_SPAWN", getOutpostSheet(), nSquadSlot, nSpawnSelected); } @@ -354,7 +354,7 @@ static sint localToGmt(sint hour) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); if(node) hour-= node->getValue32(); hour+= 48; @@ -366,7 +366,7 @@ static sint gmtToLocal(sint hour) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); if(node) hour+= node->getValue32(); hour+= 48; @@ -405,7 +405,7 @@ public: fromString(sParams, attPeriod); // Store in local DB (in LOCAL for consistency) - CCDBNodeLeaf *node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); if(node) node->setValue32(localToGmt(attPeriod)); @@ -425,13 +425,13 @@ public: // read current outpost sheet uint32 outpostSheet= 0; - CCDBNodeLeaf *node= pIM->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false); if(node) outpostSheet= node->getValue32(); // read wanted GMT attack period uint8 wantedAttHour= 0; - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); if(node) wantedAttHour= (uint8)node->getValue32(); @@ -451,19 +451,19 @@ public: // read current outpost sheet uint32 outpostSheet= 0; - CCDBNodeLeaf *node= pIM->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:OUTPOST_SELECTED:SHEET", false); if(node) outpostSheet= node->getValue32(); // read wanted GMT attack period uint8 wantedAttHour= 0; - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ATTACK_PERIOD", false); if(node) wantedAttHour= (uint8)node->getValue32(); // read result Att Period Time (NB: for final server check: ensure that the user will get what it sees) uint32 startAttackTime= 0; - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT", false); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT", false); if(node) startAttackTime= node->getValue32(); @@ -497,9 +497,9 @@ public: // Copy SERVER DB to Local selection uint32 outpostSheet= 0; - CCDBNodeLeaf *node= pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST"); if(node) outpostSheet= node->getValue32(); - node= pIM->getDbProp("UI:TEMP:OUTPOST:BOT_SELECTION"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:BOT_SELECTION"); if(node) node->setValue32(outpostSheet); // Send a msg to server @@ -633,7 +633,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbBan = pIM->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); + CCDBNodeLeaf *dbBan = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); // Re-Test if can ban the selection bool okForBanPlayer= false; @@ -656,7 +656,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbBan = pIM->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); + CCDBNodeLeaf *dbBan = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:RIGHT_TO_BANISH", false); // Re-Test if can ban the selection bool okForBanPlayer= false; @@ -679,7 +679,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbTZ = pIM->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); + CCDBNodeLeaf *dbTZ = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:OUTPOST:TIME_ZONE", false); if(!dbTZ) return; diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index a24c49ad0..91a7687d5 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -68,8 +68,8 @@ const std::string PhraseMemoryAltCtrlBase= "ui:interface:gestionsets2:header_cl void debugUpdateActionBar() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->getDbProp("SERVER:USER:ACT_TSTART")->setValue64(NetMngr.getCurrentServerTick()); - pIM->getDbProp("SERVER:USER:ACT_TEND")->setValue64(NetMngr.getCurrentServerTick()+30); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TSTART")->setValue64(NetMngr.getCurrentServerTick()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TEND")->setValue64(NetMngr.getCurrentServerTick()+30); } @@ -1363,7 +1363,7 @@ public: fromString(Params, index); // Get the link counter. Used to verify that the client cancel the correct link according to server uint8 counter= 0; - CCDBNodeLeaf *node= pIM->getDbProp(toString("SERVER:EXECUTE_PHRASE:LINK:%d:COUNTER", index), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:EXECUTE_PHRASE:LINK:%d:COUNTER", index), false); if(node) counter= node->getValue8(); @@ -1585,7 +1585,7 @@ public: virtual void execute(CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:PHRASE:SELECT_MEMORY", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:SELECT_MEMORY", false); if(node) { sint32 val; @@ -1720,10 +1720,10 @@ void phraseBotChatBuyBySheet(NLMISC::CSheetId sheetId, uint16 phraseId) pPM->receiveBotChatConfirmBuy(phraseId, true); // synchronize uint counter= pIM->getLocalSyncActionCounter(); - pIM->getDbProp("SERVER:INVENTORY:COUNTER")->setValue32(counter); - pIM->getDbProp("SERVER:EXCHANGE:COUNTER")->setValue32(counter); - pIM->getDbProp("SERVER:TARGET:CONTEXT_MENU:COUNTER")->setValue32(counter); - pIM->getDbProp("SERVER:USER:COUNTER")->setValue32(counter); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:COUNTER")->setValue32(counter); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:EXCHANGE:COUNTER")->setValue32(counter); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_MENU:COUNTER")->setValue32(counter); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:COUNTER")->setValue32(counter); } } diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index 8503f2738..8fcd4726f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -63,7 +63,7 @@ static bool isContainerAuthorized(CGroupContainer *pGC) // no guild or not in guild hall. if (shortId == "inv_guild") { - if (pIM->getDbProp("SERVER:GUILD:NAME") == 0 + if (NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME") == 0 || !getInventory().isInventoryPresent(INVENTORIES::guild)) { return false; // can't open it right now @@ -447,9 +447,9 @@ class CAHNextSheath : public IActionHandler virtual void execute (CCtrlBase *pCaller, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNLCurSetWrite = pIM->getDbProp(pIM->getDefine("ui_set_active")); - CCDBNodeLeaf *pNLCurSetRead = pIM->getDbProp(pIM->getDefine("set_active")); - CCDBNodeLeaf *pNLNbSet = pIM->getDbProp(pIM->getDefine("set_nb")); + CCDBNodeLeaf *pNLCurSetWrite = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("ui_set_active")); + CCDBNodeLeaf *pNLCurSetRead = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_active")); + CCDBNodeLeaf *pNLNbSet = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_nb")); sint64 nVal = pNLCurSetRead->getValue64() - INVENTORIES::sheath1; sint64 nMax = pNLNbSet->getValue64(); nVal++; @@ -471,9 +471,9 @@ class CAHPreviousSheath : public IActionHandler virtual void execute (CCtrlBase *pCaller, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNLCurSetWrite = pIM->getDbProp(pIM->getDefine("ui_set_active")); - CCDBNodeLeaf *pNLCurSetRead = pIM->getDbProp(pIM->getDefine("set_active")); - CCDBNodeLeaf *pNLNbSet = pIM->getDbProp(pIM->getDefine("set_nb")); + CCDBNodeLeaf *pNLCurSetWrite = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("ui_set_active")); + CCDBNodeLeaf *pNLCurSetRead = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_active")); + CCDBNodeLeaf *pNLNbSet = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_nb")); sint64 nVal = pNLCurSetRead->getValue64() - INVENTORIES::sheath1; sint64 nMax = pNLNbSet->getValue64(); if (nVal == 0) nVal = nMax; @@ -495,8 +495,8 @@ class CAHSetSheath : public IActionHandler virtual void execute (CCtrlBase *pCaller, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNLCurSetWrite = pIM->getDbProp(pIM->getDefine("ui_set_active")); - CCDBNodeLeaf *pNLNbSet = pIM->getDbProp(pIM->getDefine("set_nb")); + CCDBNodeLeaf *pNLCurSetWrite = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("ui_set_active")); + CCDBNodeLeaf *pNLNbSet = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("set_nb")); sint64 nVal; fromString(Params, nVal); nVal -= INVENTORIES::sheath1; @@ -671,7 +671,7 @@ class CAHUIDockUndocChat : public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // change the DB (if exist) - CCDBNodeLeaf *node= pIM->getDbProp(toString("UI:SAVE:ISDETACHED:")+Params, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:SAVE:ISDETACHED:")+Params, false); if(node) { // swap diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 4cb128f89..b48a3a705 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -82,11 +82,11 @@ void CActionPhraseFaber::fillDBWithMP(const std::string &sheetBase, const CIte { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->getDbProp(sheetBase + ":SHEET")->setValue32(item.Sheet.asInt()); - pIM->getDbProp(sheetBase + ":QUALITY")->setValue32(item.Quality); - pIM->getDbProp(sheetBase + ":QUANTITY")->setValue32(item.Quantity); - pIM->getDbProp(sheetBase + ":USER_COLOR")->setValue32(item.UserColor); - pIM->getDbProp(sheetBase + ":WEIGHT")->setValue32(item.Weight); + NLGUI::CDBManager::getInstance()->getDbProp(sheetBase + ":SHEET")->setValue32(item.Sheet.asInt()); + NLGUI::CDBManager::getInstance()->getDbProp(sheetBase + ":QUALITY")->setValue32(item.Quality); + NLGUI::CDBManager::getInstance()->getDbProp(sheetBase + ":QUANTITY")->setValue32(item.Quantity); + NLGUI::CDBManager::getInstance()->getDbProp(sheetBase + ":USER_COLOR")->setValue32(item.UserColor); + NLGUI::CDBManager::getInstance()->getDbProp(sheetBase + ":WEIGHT")->setValue32(item.Weight); } @@ -144,7 +144,7 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn // Reset All Mps slots. for(uint mpSlot=0;mpSlotgetDbProp(toString("%s:%d:%d:SHEET", MPFaberDB.c_str(), itemReqLine, mpSlot), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:%d:SHEET", MPFaberDB.c_str(), itemReqLine, mpSlot), false); if(node) node->setValue32(0); } @@ -156,12 +156,12 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn } // Reset the selected plan - CCDBNodeLeaf *node= pIM->getDbProp(FaberPlanDB, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanDB, false); if(node) node->setValue32(0); // Reset the result item - node= pIM->getDbProp(ItemResultSheetDB, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetDB, false); if(node) node->setValue32(0); @@ -185,23 +185,23 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn // **** setup DB observer! // ensure remove (if setuped before), then add CCDBNodeBranch *branch; - branch= pIM->getDbBranch("LOCAL:INVENTORY:BAG"); - if(branch) pIM->removeBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); - if(branch) pIM->addBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); + branch= NLGUI::CDBManager::getInstance()->getDbBranch("LOCAL:INVENTORY:BAG"); + if(branch) NLGUI::CDBManager::getInstance()->removeBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); + if(branch) NLGUI::CDBManager::getInstance()->addBranchObserver( "LOCAL:INVENTORY:BAG",&_DBInventoryObs); // and for all pack animals uint i; for(i=0;igetDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i)); - if(branch) pIM->removeBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); - if(branch) pIM->addBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); + branch= NLGUI::CDBManager::getInstance()->getDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i)); + if(branch) NLGUI::CDBManager::getInstance()->removeBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); + if(branch) NLGUI::CDBManager::getInstance()->addBranchObserver( toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i).c_str(), &_DBInventoryObs); } // Add observers on animal status, cause inventory may become unavailabe during the process for(i=0;igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i), false); if(node) { ICDBNode::CTextId textId; @@ -223,19 +223,19 @@ void CActionPhraseFaber::onCloseFaberCastWindow() // No more need to listen inventory change CCDBNodeBranch *branch; - branch= pIM->getDbBranch("LOCAL:INVENTORY:BAG"); + branch= NLGUI::CDBManager::getInstance()->getDbBranch("LOCAL:INVENTORY:BAG"); if(branch) branch->removeBranchObserver(&_DBInventoryObs); // and for all pack animals for(uint i=0;igetDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i)); + branch= NLGUI::CDBManager::getInstance()->getDbBranch(toString("LOCAL:INVENTORY:PACK_ANIMAL%d", i)); if(branch) branch->removeBranchObserver(&_DBInventoryObs); } // remove observers on animal status, cause inventory may become unavailabe during the process for(uint i=0;igetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS",i), false); if(node) { ICDBNode::CTextId textId; @@ -270,9 +270,9 @@ void CActionPhraseFaber::fillFaberPlanSelection(const std::string &brickDB, ui for(i=0;igetDbProp(brickDB + ":" + toString(i) + ":SHEET")->setValue32(bricks[i].asInt()); + NLGUI::CDBManager::getInstance()->getDbProp(brickDB + ":" + toString(i) + ":SHEET")->setValue32(bricks[i].asInt()); else - pIM->getDbProp(brickDB + ":" + toString(i) + ":SHEET")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(brickDB + ":" + toString(i) + ":SHEET")->setValue32(0); } } @@ -302,7 +302,7 @@ CItemImage *CActionPhraseFaber::getInvMirrorItemImage(uint slotIndex, uint& inv if (getInventory().isInventoryAvailable(INVENTORIES::guild)) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeBranch *itemBranch = im->getDbBranch(SERVER_INVENTORY ":GUILD:" + toString(slotIndex)); + CCDBNodeBranch *itemBranch = NLGUI::CDBManager::getInstance()->getDbBranch(SERVER_INVENTORY ":GUILD:" + toString(slotIndex)); static CItemImage image; image.build(itemBranch); invId = INVENTORIES::guild; @@ -318,7 +318,7 @@ CItemImage *CActionPhraseFaber::getInvMirrorItemImage(uint slotIndex, uint& inv if (getInventory().isInventoryAvailable(INVENTORIES::player_room)) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeBranch *itemBranch = im->getDbBranch(SERVER_INVENTORY ":ROOM:" + toString(slotIndex)); + CCDBNodeBranch *itemBranch = NLGUI::CDBManager::getInstance()->getDbBranch(SERVER_INVENTORY ":ROOM:" + toString(slotIndex)); static CItemImage image; image.build(itemBranch); invId = INVENTORIES::player_room; @@ -370,17 +370,17 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick // Setup the selected plan - CCDBNodeLeaf *node= pIM->getDbProp(FaberPlanDB, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(FaberPlanDB, false); if(node) node->setValue32(_ExecuteFromItemPlanBrick->Id.asInt()); // Setup the result item - node= pIM->getDbProp(ItemResultSheetDB, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetDB, false); if(node) node->setValue32(itemPlanBrick->FaberPlan.ItemBuilt.asInt()); // Setup the result quantity (for stacked items) - node= pIM->getDbProp(ItemResultQuantityDB, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultQuantityDB, false); if(node) node->setValue32(itemPlanBrick->FaberPlan.NbItemBuilt); @@ -483,7 +483,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick // Reset All Mps slots. for(uint mpSlot=0;mpSlotgetDbProp(toString("%s:%d:%d:SHEET", MPFaberDB.c_str(), itemReqLine, mpSlot), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:%d:SHEET", MPFaberDB.c_str(), itemReqLine, mpSlot), false); if(node) node->setValue32(0); } @@ -577,7 +577,7 @@ void CActionPhraseFaber::resetSelection() for(uint i=0;igetDbProp(MPSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(MPSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); } } @@ -595,7 +595,7 @@ void CActionPhraseFaber::fillSelection(const std::vector &mps) fillDBWithMP(MPSelectionDB+ ":" + toString(i), item); } else - pIM->getDbProp(MPSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(MPSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); } } @@ -692,9 +692,9 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) uint maxQuantity= getMaxQuantityChange(itemReqLine, mpSlot); // set the max quantity as the default quantity to set up. - CCDBNodeLeaf *node= pIM->getDbProp(MPQuantitySelectDb + ":CUR_QUANTITY", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(MPQuantitySelectDb + ":CUR_QUANTITY", false); if(node) node->setValue32(maxQuantity); - node= pIM->getDbProp(MPQuantitySelectDb + ":MAX_QUANTITY", false); + node= NLGUI::CDBManager::getInstance()->getDbProp(MPQuantitySelectDb + ":MAX_QUANTITY", false); if(node) node->setValue32(maxQuantity); // bkup for validation @@ -841,7 +841,7 @@ void CActionPhraseFaber::validateMpSelectQuantity() // get the quantity selected uint quantitySelected= 0; - CCDBNodeLeaf *node= pIM->getDbProp(MPQuantitySelectDb + ":CUR_QUANTITY", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(MPQuantitySelectDb + ":CUR_QUANTITY", false); if(node) quantitySelected= node->getValue32(); // maximize (if error) @@ -1056,10 +1056,10 @@ void CActionPhraseFaber::updateQuantityView(uint itemReqLine) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(toString("%s:%d:SELECTED", MPQuantityDb.c_str(), itemReqLine), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:SELECTED", MPQuantityDb.c_str(), itemReqLine), false); if(node) node->setValue32(getTotalQuantitySetuped(itemReqLine)); - node= pIM->getDbProp(toString("%s:%d:REQUIRED", MPQuantityDb.c_str(), itemReqLine), false); + node= NLGUI::CDBManager::getInstance()->getDbProp(toString("%s:%d:REQUIRED", MPQuantityDb.c_str(), itemReqLine), false); if(node) node->setValue32(_MPBuild[itemReqLine].QuantityReq); } @@ -1668,7 +1668,7 @@ void CActionPhraseFaber::updateItemResult() // **** setup Level if(minLevel==INT_MAX) minLevel= 0; - CCDBNodeLeaf *node= pIM->getDbProp(ItemResultSheetLevel, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetLevel, false); if(node) node->setValue32(minLevel); @@ -1682,7 +1682,7 @@ void CActionPhraseFaber::updateItemResult() uint phraseSlot= pPM->getMemorizedPhrase(_ExecuteFromMemoryLine, _ExecuteFromMemoryIndex); sint32 craftSuccessModifier = 0; - CCDBNodeLeaf *nodeCSM= pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:CRAFT", false); + CCDBNodeLeaf *nodeCSM= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:CRAFT", false); if(nodeCSM) { craftSuccessModifier = nodeCSM->getValue32(); @@ -1730,7 +1730,7 @@ void CActionPhraseFaber::updateItemResult() dominanteColor = i; } } - node= pIM->getDbProp(ItemResultSheetColor, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetColor, false); if(node) node->setValue32(dominanteColor); @@ -1815,7 +1815,7 @@ void CActionPhraseFaber::updateItemResult() // **** BestStat (for text over) - node= pIM->getDbProp(ItemResultSheetStatType, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetStatType, false); if(node) { float bestStatValue =-1.0f; @@ -1838,7 +1838,7 @@ void CActionPhraseFaber::updateItemResult() // **** ClassType (for text over) - node= pIM->getDbProp(ItemResultSheetClassType, false); + node= NLGUI::CDBManager::getInstance()->getDbProp(ItemResultSheetClassType, false); if(node) { // Setup DB diff --git a/code/ryzom/client/src/interface_v3/animal_position_state.cpp b/code/ryzom/client/src/interface_v3/animal_position_state.cpp index 910230ce0..71bbd6e03 100644 --- a/code/ryzom/client/src/interface_v3/animal_position_state.cpp +++ b/code/ryzom/client/src/interface_v3/animal_position_state.cpp @@ -74,7 +74,7 @@ void CPositionState::serialNodeLeaf(NLMISC::IStream &f, CCDBNodeLeaf *&dbNode) if (!dbPath.empty()) { CInterfaceManager *im = CInterfaceManager::getInstance(); - dbNode = im->getDbProp(dbPath, false); + dbNode = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false); } } else @@ -156,8 +156,8 @@ void CUIDEntityPositionState::build(const std::string &baseDB) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - _DBPos= pIM->getDbProp(baseDB+":POS", false); - _Uid= pIM->getDbProp(baseDB+":UID", false); + _DBPos= NLGUI::CDBManager::getInstance()->getDbProp(baseDB+":POS", false); + _Uid= NLGUI::CDBManager::getInstance()->getDbProp(baseDB+":UID", false); // reset _EntitySlot= CLFECOMMON::INVALID_SLOT; } @@ -177,7 +177,7 @@ CTeammatePositionState::CTeammatePositionState() : CUIDEntityPositionState() void CTeammatePositionState::build(const std::string &baseDB) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - _Present = pIM->getDbProp(baseDB+":NAME", false); + _Present = NLGUI::CDBManager::getInstance()->getDbProp(baseDB+":NAME", false); CUIDEntityPositionState::build(baseDB); } @@ -217,7 +217,7 @@ CAnimalPositionState::CAnimalPositionState() : CUIDEntityPositionState() void CAnimalPositionState::build(const std::string &baseDB) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - _Status= pIM->getDbProp(baseDB+":STATUS", false); + _Status= NLGUI::CDBManager::getInstance()->getDbProp(baseDB+":STATUS", false); CUIDEntityPositionState::build(baseDB); } diff --git a/code/ryzom/client/src/interface_v3/bar_manager.cpp b/code/ryzom/client/src/interface_v3/bar_manager.cpp index 1cf99a631..3de83ee0a 100644 --- a/code/ryzom/client/src/interface_v3/bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bar_manager.cpp @@ -107,30 +107,30 @@ void CBarManager::CBarDataEntry::connectDB(const std::string &baseDBin, const st // try to connect each input entry (don't create) if(!baseDBin.empty()) { - UIDIn= pIM->getDbProp(baseDBin+"UID", false); + UIDIn= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+"UID", false); if(!presentDB.empty()) - PresentIn= pIM->getDbProp(baseDBin+presentDB, false); + PresentIn= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+presentDB, false); if(!hpDB.empty()) - ScoreIn[SCORES::hit_points]= pIM->getDbProp(baseDBin+hpDB, false); + ScoreIn[SCORES::hit_points]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+hpDB, false); if(!sapDB.empty()) - ScoreIn[SCORES::sap]= pIM->getDbProp(baseDBin+sapDB, false); + ScoreIn[SCORES::sap]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+sapDB, false); if(!staDB.empty()) - ScoreIn[SCORES::stamina]= pIM->getDbProp(baseDBin+staDB, false); + ScoreIn[SCORES::stamina]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+staDB, false); if(!focusDB.empty()) - ScoreIn[SCORES::focus]= pIM->getDbProp(baseDBin+focusDB, false); + ScoreIn[SCORES::focus]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBin+focusDB, false); } // try to connect each output entry (don't create) if(!baseDBout.empty()) { if(!hpDB.empty()) - ScoreOut[SCORES::hit_points]= pIM->getDbProp(baseDBout+hpDB, false); + ScoreOut[SCORES::hit_points]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBout+hpDB, false); if(!sapDB.empty()) - ScoreOut[SCORES::sap]= pIM->getDbProp(baseDBout+sapDB, false); + ScoreOut[SCORES::sap]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBout+sapDB, false); if(!staDB.empty()) - ScoreOut[SCORES::stamina]= pIM->getDbProp(baseDBout+staDB, false); + ScoreOut[SCORES::stamina]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBout+staDB, false); if(!focusDB.empty()) - ScoreOut[SCORES::focus]= pIM->getDbProp(baseDBout+focusDB, false); + ScoreOut[SCORES::focus]= NLGUI::CDBManager::getInstance()->getDbProp(baseDBout+focusDB, false); } } @@ -199,7 +199,7 @@ void CBarManager::initInGame() change MaxTeamMember if no more the case */ uint i=0; - while( pIM->getDbProp(toString("SERVER:GROUP:%d:NAME", i), false) ) + while( NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:GROUP:%d:NAME", i), false) ) i++; nlassert(i==MaxTeamMember); @@ -247,20 +247,20 @@ void CBarManager::initInGame() // user now can only manage 4 scores nlctassert(SCORES::NUM_SCORES==4); // Input max values - _UserScores[SCORES::hit_points].DBInMax= pIM->getDbProp("SERVER:CHARACTER_INFO:SCORES0:Max", false); - _UserScores[SCORES::sap].DBInMax= pIM->getDbProp("SERVER:CHARACTER_INFO:SCORES2:Max", false); - _UserScores[SCORES::stamina].DBInMax= pIM->getDbProp("SERVER:CHARACTER_INFO:SCORES1:Max", false); - _UserScores[SCORES::focus].DBInMax= pIM->getDbProp("SERVER:CHARACTER_INFO:SCORES3:Max", false); + _UserScores[SCORES::hit_points].DBInMax= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SCORES0:Max", false); + _UserScores[SCORES::sap].DBInMax= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SCORES2:Max", false); + _UserScores[SCORES::stamina].DBInMax= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SCORES1:Max", false); + _UserScores[SCORES::focus].DBInMax= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SCORES3:Max", false); // Output real values - _UserScores[SCORES::hit_points].DBOutVal= pIM->getDbProp("UI:VARIABLES:USER:HP", false); - _UserScores[SCORES::sap].DBOutVal= pIM->getDbProp("UI:VARIABLES:USER:SAP", false); - _UserScores[SCORES::stamina].DBOutVal= pIM->getDbProp("UI:VARIABLES:USER:STA", false); - _UserScores[SCORES::focus].DBOutVal= pIM->getDbProp("UI:VARIABLES:USER:FOCUS", false); + _UserScores[SCORES::hit_points].DBOutVal= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:HP", false); + _UserScores[SCORES::sap].DBOutVal= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:SAP", false); + _UserScores[SCORES::stamina].DBOutVal= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:STA", false); + _UserScores[SCORES::focus].DBOutVal= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:FOCUS", false); // Output ratio values - _UserScores[SCORES::hit_points].DBOutRatio= pIM->getDbProp("UI:VARIABLES:USER:HP_RATIO", false); - _UserScores[SCORES::sap].DBOutRatio= pIM->getDbProp("UI:VARIABLES:USER:SAP_RATIO", false); - _UserScores[SCORES::stamina].DBOutRatio= pIM->getDbProp("UI:VARIABLES:USER:STA_RATIO", false); - _UserScores[SCORES::focus].DBOutRatio= pIM->getDbProp("UI:VARIABLES:USER:FOCUS_RATIO", false); + _UserScores[SCORES::hit_points].DBOutRatio= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:HP_RATIO", false); + _UserScores[SCORES::sap].DBOutRatio= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:SAP_RATIO", false); + _UserScores[SCORES::stamina].DBOutRatio= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:STA_RATIO", false); + _UserScores[SCORES::focus].DBOutRatio= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:FOCUS_RATIO", false); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index 4efa1067a..e7d4c2d7a 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -38,7 +38,7 @@ void CBotChatPageCreateGuild::begin() CBotChatPage::begin(); CInterfaceManager *im = CInterfaceManager::getInstance(); // clear intro text - im->getDbProp(BOT_CHAT_BASE_DB_PATH ":CREATE_GUILD")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":CREATE_GUILD")->setValue32(0); // show the dialog activateWindow(WIN_BOT_CHAT_PAGE_CREATE_GUILD, true); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index a9f9624fd..0d53ef84b 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -64,9 +64,9 @@ CBotChatPageDynamicMission::CBotChatPageDynamicMission() void CBotChatPageDynamicMission::invalidateMission() { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp(DM_DESCRIPTION_DB_PATH)->setValue32(0); - im->getDbProp(DM_TITLE_DB_PATH)->setValue32(0); - im->getDbProp(DM_VALID_DB_PATH)->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(DM_DESCRIPTION_DB_PATH)->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(DM_TITLE_DB_PATH)->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(DM_VALID_DB_PATH)->setValue32(0); _MissionValid = false; } @@ -80,10 +80,10 @@ void CBotChatPageDynamicMission::begin() // clear all choices options for(uint k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k) { - im->getDbProp(toString(DM_CHOICE "%d:TITLE", (int) k))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:TITLE", (int) k))->setValue32(0); for(uint l = 0; l < DYNAMIC_MISSION_MAX_NUM_OPTIONS; ++l) { - im->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->setValue32(0); } } activateWindow(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION, true); @@ -113,7 +113,7 @@ void CBotChatPageDynamicMission::begin() std::fill(_Choice, _Choice + DYNAMIC_MISSION_NUM_CHOICES, -1); for(uint k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k) { - im->getDbProp(toString("UI:TEMP:DYNAMIC_MISSION:CHOICE%d", (int) k))->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:TEMP:DYNAMIC_MISSION:CHOICE%d", (int) k))->setValue32(-1); } } @@ -158,7 +158,7 @@ void CBotChatPageDynamicMission::update() } else { - uint32 textID = (uint32) im->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); + uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); // see if text has been receive ucstring result; bool received = CStringManagerClient::instance()->getDynString(textID, result); @@ -173,7 +173,7 @@ void CBotChatPageDynamicMission::update() for(l = _ChoiceCB[k]->getNumTexts(); l < DYNAMIC_MISSION_NUM_CHOICES; ++l) { // see if text id has been received - uint32 textID = (uint32) im->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); + uint32 textID = (uint32) NLGUI::CDBManager::getInstance()->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->getValue32(); if (textID == 0 && !ClientCfg.Local) break; // see if text has been received ucstring result; @@ -193,25 +193,25 @@ void CBotChatPageDynamicMission::update() } if (ClientCfg.Local) { - im->getDbProp(DM_VALID_DB_PATH)->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp(DM_VALID_DB_PATH)->setValue32(1); } else { if (!_MissionValid) { // activate 'regen' and 'accept' button when the description has been received - uint32 textID = im->getDbProp(DM_TITLE_DB_PATH)->getValue32(); + uint32 textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_TITLE_DB_PATH)->getValue32(); if (textID != 0) { ucstring result; if (CStringManagerClient::instance()->getDynString(textID, result)) { - textID = im->getDbProp(DM_DESCRIPTION_DB_PATH)->getValue32(); + textID = NLGUI::CDBManager::getInstance()->getDbProp(DM_DESCRIPTION_DB_PATH)->getValue32(); if (textID != 0) { if (CStringManagerClient::instance()->getDynString(textID, result)) { - im->getDbProp(DM_VALID_DB_PATH)->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp(DM_VALID_DB_PATH)->setValue32(1); _MissionValid = true; } } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index aa8e1cab4..5b2c06083 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -49,8 +49,8 @@ CBotChatPageMission::CBotChatPageMission() void CBotChatPageMission::init() { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getDbBranch("SERVER:CHOOSE_MISSIONS")) - im->addBranchObserver("SERVER:CHOOSE_MISSIONS", &_MissionPagesObs); + if (NLGUI::CDBManager::getInstance()->getDbBranch("SERVER:CHOOSE_MISSIONS")) + NLGUI::CDBManager::getInstance()->addBranchObserver("SERVER:CHOOSE_MISSIONS", &_MissionPagesObs); } @@ -60,12 +60,12 @@ void CBotChatPageMission::begin() CBotChatPage::begin(); CInterfaceManager *im = CInterfaceManager::getInstance(); // clear intro text - im->getDbProp(BOT_CHAT_BASE_DB_PATH ":CHOOSE_MISSION")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":CHOOSE_MISSION")->setValue32(0); _MissionPagesObs.setMissionClientType(_MType); _MissionPagesObs.start(); // Select the Mission Aspect according to mission type - im->getDbProp("UI:TEMP:MISSION:MISSION_TYPE")->setValue32(_MType); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION:MISSION_TYPE")->setValue32(_MType); CGroupContainer *gc = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_PAGE_MISSION)); if (gc) @@ -116,7 +116,7 @@ void CBotChatPageMission::selectMission(CDBCtrlSheet *missionSheet) viewTextID->setTextId(detailTextLeaf->getValue32()); } // copy icon - CCDBNodeLeaf *iconLeaf = im->getDbProp("UI:TEMP:MISSION:ICON"); + CCDBNodeLeaf *iconLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION:ICON"); if (iconLeaf) { iconLeaf->setValue32(missionSheet->getSheetId()); @@ -196,43 +196,43 @@ NLMISC_COMMAND( testMissionPage, " debug mission page", "") if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:0:ICON")->setValue32(CSheetId("generic_craft.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:0:TEXT")->setValue32(1); - im->getDbProp("SERVER:CHOOSE_MISSIONS:0:DETAIL_TEXT")->setValue32(11); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:0:ICON")->setValue32(CSheetId("generic_craft.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:0:TEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:0:DETAIL_TEXT")->setValue32(11); - im->getDbProp("SERVER:CHOOSE_MISSIONS:1:ICON")->setValue32(CSheetId("generic_fight.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:1:TEXT")->setValue32(2); - im->getDbProp("SERVER:CHOOSE_MISSIONS:1:DETAIL_TEXT")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:1:ICON")->setValue32(CSheetId("generic_fight.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:1:TEXT")->setValue32(2); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:1:DETAIL_TEXT")->setValue32(12); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:2:ICON")->setValue32(CSheetId("generic_forage.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:2:TEXT")->setValue32(3); - im->getDbProp("SERVER:CHOOSE_MISSIONS:2:DETAIL_TEXT")->setValue32(13); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:2:ICON")->setValue32(CSheetId("generic_forage.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:2:TEXT")->setValue32(3); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:2:DETAIL_TEXT")->setValue32(13); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:3:ICON")->setValue32(CSheetId("generic_generic.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:3:TEXT")->setValue32(4); - im->getDbProp("SERVER:CHOOSE_MISSIONS:3:DETAIL_TEXT")->setValue32(14); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:3:ICON")->setValue32(CSheetId("generic_generic.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:3:TEXT")->setValue32(4); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:3:DETAIL_TEXT")->setValue32(14); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:4:ICON")->setValue32(CSheetId("generic_rite.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:4:TEXT")->setValue32(5); - im->getDbProp("SERVER:CHOOSE_MISSIONS:4:DETAIL_TEXT")->setValue32(15); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:4:ICON")->setValue32(CSheetId("generic_rite.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:4:TEXT")->setValue32(5); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:4:DETAIL_TEXT")->setValue32(15); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:5:ICON")->setValue32(CSheetId("generic_travel.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:5:TEXT")->setValue32(6); - im->getDbProp("SERVER:CHOOSE_MISSIONS:5:DETAIL_TEXT")->setValue32(16); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:5:ICON")->setValue32(CSheetId("generic_travel.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:5:TEXT")->setValue32(6); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:5:DETAIL_TEXT")->setValue32(16); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:6:ICON")->setValue32(CSheetId("generic_craft.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:6:TEXT")->setValue32(7); - im->getDbProp("SERVER:CHOOSE_MISSIONS:6:DETAIL_TEXT")->setValue32(17); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:6:ICON")->setValue32(CSheetId("generic_craft.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:6:TEXT")->setValue32(7); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:6:DETAIL_TEXT")->setValue32(17); // - im->getDbProp("SERVER:CHOOSE_MISSIONS:7:ICON")->setValue32(CSheetId("generic_fight.mission_icon").asInt()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:7:TEXT")->setValue32(8); - im->getDbProp("SERVER:CHOOSE_MISSIONS:7:DETAIL_TEXT")->setValue32(18); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:7:ICON")->setValue32(CSheetId("generic_fight.mission_icon").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:7:TEXT")->setValue32(8); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:7:DETAIL_TEXT")->setValue32(18); // sint32 pageId; fromString(args[0], pageId); - im->getDbProp("SERVER:CHOOSE_MISSIONS:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); - im->getDbProp("SERVER:CHOOSE_MISSIONS:PAGE_ID")->setValue32(pageId); - im->getDbProp("SERVER:CHOOSE_MISSIONS:HAS_NEXT")->setValue32(0); // not relevant for test .. + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:PAGE_ID")->setValue32(pageId); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHOOSE_MISSIONS:HAS_NEXT")->setValue32(0); // not relevant for test .. return true; } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp index b6361a5ca..58161417b 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp @@ -48,7 +48,7 @@ void CBotChatPageMissionEnd::begin() if ((flags & 1) || ClientCfg.Local) // is reward text needed { rewardText->setActive(true); - im->getDbProp(BOT_CHAT_BASE_DB_PATH ":MISSION_END_REWARD")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":MISSION_END_REWARD")->setValue32(0); } else { @@ -61,7 +61,7 @@ void CBotChatPageMissionEnd::begin() rewardSlots->setActive(((flags & 2) != 0) || ClientCfg.Local); } // - im->getDbProp(BOT_CHAT_BASE_DB_PATH ":MISSION_END")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":MISSION_END")->setValue32(0); // ig->setActive(true); diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp index 5ec5631b6..da960c5a5 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp @@ -29,7 +29,7 @@ void CBotChatPageNews::begin() CBotChatPage::begin(); CInterfaceManager *im = CInterfaceManager::getInstance(); // clear intro text - im->getDbProp(BOT_CHAT_BASE_DB_PATH ":NEWS")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":NEWS")->setValue32(0); // activateWindow(WIN_BOT_CHAT_PAGE_NEWS, true); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp index 2e54f41f9..0a310db57 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp @@ -38,14 +38,14 @@ void CBotChatPagePlayerGift::begin() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // clear intro text - pIM->getDbProp(BOT_CHAT_BASE_DB_PATH ":PLAYER_GIFT")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":PLAYER_GIFT")->setValue32(0); // clear money proposal value - CCDBNodeLeaf *moneyProposal = pIM->getDbProp(pIM->getDefine("money_proposal")); + CCDBNodeLeaf *moneyProposal = NLGUI::CDBManager::getInstance()->getDbProp(pIM->getDefine("money_proposal")); if (moneyProposal) moneyProposal->setValue64(0); // clear 'accept' button - pIM->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:ACCEPTED")->setValue32(0); // Default is not validated PlayerGiftValidated= false; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index b17021cde..356845d35 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -159,12 +159,12 @@ CBotChatPageTrade::CBotChatPageTrade() void CBotChatPageTrade::init() { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getDbBranch("SERVER:TRADING")) + if (NLGUI::CDBManager::getInstance()->getDbBranch("SERVER:TRADING")) { - im->addBranchObserver( "SERVER:TRADING", &_TradePagesObs); + NLGUI::CDBManager::getInstance()->addBranchObserver( "SERVER:TRADING", &_TradePagesObs); } - _FamePriceFactorLeaf = im->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR"); + _FamePriceFactorLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR"); } // ******************************************************************************************* @@ -190,21 +190,21 @@ void CBotChatPageTrade::begin() activateWindow(WIN_BOT_CHAT_PAGE_BUY, true); } CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp(BOT_CHAT_BASE_DB_PATH ":TRADE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BOT_CHAT_BASE_DB_PATH ":TRADE")->setValue32(0); // at each new bot chat trade, we must reset filter for ItemPart and ItemType (NB: server should do the same) resetItemPartAndTypeFilters(); // reset also the filters at each open if user wants to - CCDBNodeLeaf *dbResetFilterOnOpen= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":RESET_ON_OPEN" , false); + CCDBNodeLeaf *dbResetFilterOnOpen= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":RESET_ON_OPEN" , false); if(dbResetFilterOnOpen && dbResetFilterOnOpen->getValueBool() && (_BuyMean == Money) ) { // temporary value for conversions sint32 value; // Reset Price - CCDBNodeLeaf *dbPriceMin= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_PRICE") , false); - CCDBNodeLeaf *dbPriceMax= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_PRICE") , false); + CCDBNodeLeaf *dbPriceMin= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_PRICE") , false); + CCDBNodeLeaf *dbPriceMax= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_PRICE") , false); if(dbPriceMin) dbPriceMin->setValue32(0); if(dbPriceMax) { @@ -213,8 +213,8 @@ void CBotChatPageTrade::begin() } // Reset Quality - CCDBNodeLeaf *dbQualityMin= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_QUALITY") , false); - CCDBNodeLeaf *dbQualityMax= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_QUALITY") , false); + CCDBNodeLeaf *dbQualityMin= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_QUALITY") , false); + CCDBNodeLeaf *dbQualityMax= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_QUALITY") , false); if(dbQualityMin) dbQualityMin->setValue32(0); if(dbQualityMax) { @@ -223,8 +223,8 @@ void CBotChatPageTrade::begin() } // Reset Class - CCDBNodeLeaf *dbClassMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); - CCDBNodeLeaf *dbClassMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); + CCDBNodeLeaf *dbClassMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); + CCDBNodeLeaf *dbClassMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); if(dbClassMin) dbClassMin->setValue32(0); if(dbClassMax) dbClassMax->setValue32(RM_CLASS_TYPE::NumTRMClassType-1); @@ -495,7 +495,7 @@ uint32 CBotChatPageTrade::getUserFactionPoints(PVP_CLAN::TPVPClan clan) const uint32 nClan = clan - PVP_CLAN::BeginClans; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pLeaf = pIM->getDbProp(toString("LOCAL:USER:FACTION_POINTS_%d:VALUE", nClan), false); + CCDBNodeLeaf *pLeaf = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:USER:FACTION_POINTS_%d:VALUE", nClan), false); if (pLeaf == NULL) return 0; @@ -584,7 +584,7 @@ void CBotChatPageTrade::updateTradeModal() if ((_BuyMean == MoneyGuildXP) || (_BuyMean == GuildMoney) || (_BuyMean == GuildMoneyGuildXP)) { uint64 totalPrice = (uint64) priceWithoutFame * (uint64) quantity; - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(totalPrice); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(totalPrice); uint64 totalXP = (uint64) getCurrItemXP() * (uint64) quantity; CGuildManager *pGM = CGuildManager::getInstance(); @@ -647,21 +647,21 @@ void CBotChatPageTrade::updateTradeModal() { // basic price uint64 totalPriceWithoutFame = (uint64) priceWithoutFame * (uint64) quantity; - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE")->setValue64(priceWithoutFame); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(totalPriceWithoutFame); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE")->setValue64(priceWithoutFame); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(totalPriceWithoutFame); // price with fame uint64 totalPriceWithFame = (uint64) priceWithFame * (uint64) quantity; - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_WITH_FAME")->setValue64(priceWithFame); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_WITH_FAME")->setValue64(totalPriceWithFame); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_WITH_FAME")->setValue64(priceWithFame); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_WITH_FAME")->setValue64(totalPriceWithFame); // resale price uint64 totalResalePrice = (uint64) resalePrice * (uint64) quantity; - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_RESALE")->setValue64(resalePrice); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_RESALE")->setValue64(totalResalePrice); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_RESALE")->setValue64(resalePrice); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_RESALE")->setValue64(totalResalePrice); // quantity edit box - im->getDbProp("UI:TEMP:TRADE_ITEM:EDIT_QUANTITY")->setValue64(quantity); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:EDIT_QUANTITY")->setValue64(quantity); // Faction Points - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_FACTION")->setValue64(fpCost); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_FACTION")->setValue64(fpCost*quantity); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_FACTION")->setValue64(fpCost); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_FACTION")->setValue64(fpCost*quantity); // Special retire Check @@ -792,15 +792,15 @@ void CBotChatPageTrade::updateTradeModal() else { // set value in database - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_WITH_FAME")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_WITH_FAME")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_RESALE")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_RESALE")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:EDIT_QUANTITY")->setValue64(0); - im->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_FACTION")->setValue64(-1); - im->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_FACTION")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_WITH_FAME")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_WITH_FAME")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_RESALE")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_RESALE")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:EDIT_QUANTITY")->setValue64(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:UNIT_PRICE_FACTION")->setValue64(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:PRICE_FACTION")->setValue64(-1); // and update ok/cancel groups if (confirmTradeGroup) confirmTradeGroup->setActive(false); if (confirmResellGroup) confirmResellGroup->setActive(false); @@ -928,7 +928,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall _CurrItemIndex = sheet->getIndexInDB(); _CurrItemCheck.init(_CurrItemSheet); _BuyDlgOn = true; - im->getDbProp("UI:TEMP:TRADE_ITEM:IS_SELL_DLG")->setValueBool( false ); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:IS_SELL_DLG")->setValueBool( false ); // setup trade mean setupBuyMeanInModal(ig); // Add waiter to refresh items infos @@ -1027,7 +1027,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal _CurrItemInventory = sheet->getInventoryIndex(); _CurrItemCheck.init(_CurrItemSheet); _SellDlgOn = true; - im->getDbProp("UI:TEMP:TRADE_ITEM:IS_SELL_DLG")->setValueBool( true ); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:IS_SELL_DLG")->setValueBool( true ); updateTradeModal(); setupBuyMeanInModal(ig); // Add waiter to refresh items infos @@ -1302,7 +1302,7 @@ void CBotChatPageTrade::confirmTrade( bool enableResale ) CGroupEditBox *eb = dynamic_cast(ig->getGroup("header_opened:resell_group:can_resell:choose_resell:edit:eb")); if (eb) { - pIM->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->setValue32( eb->getInputStringAsInt() ); + NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->setValue32( eb->getInputStringAsInt() ); } } } @@ -1351,9 +1351,9 @@ sint32 CBotChatPageTrade::getSkillPointUsedForCurrentRoleMaster() const { // get the current phrase rolemaster type CInterfaceManager *pIM= CInterfaceManager::getInstance(); - uint rmt= pIM->getDbProp("SERVER:BOTCHAT:ROLEMASTER_TYPE")->getValue32(); + uint rmt= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:BOTCHAT:ROLEMASTER_TYPE")->getValue32(); // get the prop (use local for less lag) - CCDBNodeLeaf *node= pIM->getDbProp(toString("LOCAL:USER:SKILL_POINTS_%d:VALUE", rmt), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:USER:SKILL_POINTS_%d:VALUE", rmt), false); if(node) return node->getValue32(); else @@ -1366,9 +1366,9 @@ void CBotChatPageTrade::addSkillPointForCurrentRoleMaster(sint32 addValue) const { // get the current phrase rolemaster type CInterfaceManager *pIM= CInterfaceManager::getInstance(); - uint rmt= pIM->getDbProp("SERVER:BOTCHAT:ROLEMASTER_TYPE")->getValue32(); + uint rmt= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:BOTCHAT:ROLEMASTER_TYPE")->getValue32(); // add the local prop !! - CCDBNodeLeaf *node= pIM->getDbProp(toString("LOCAL:USER:SKILL_POINTS_%d:VALUE", rmt), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:USER:SKILL_POINTS_%d:VALUE", rmt), false); if(node) { node->setValue32(node->getValue32() + addValue); @@ -1563,7 +1563,7 @@ void CBotChatPageTrade::setupResellGroup(bool sellMode, uint defaultQuantity, CI CGroupEditBox *eb = dynamic_cast(chooseResellGroup->getGroup("edit:eb")); if (eb) { - sint32 resaleMargin= CInterfaceManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32(); + sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32(); clamp(resaleMargin, 0, (sint32)MaxResaleMargin); eb->setInputString( toString( resaleMargin ) ); eb->setPositiveIntegerMaxValue(MaxResaleMargin); @@ -1715,8 +1715,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con // init min and max edit box CGroupEditBox *edMin = dynamic_cast(ig->getGroup("edit_min:eb")); CGroupEditBox *edMax = dynamic_cast(ig->getGroup("edit_max:eb")); - CCDBNodeLeaf *dbRangeMin= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); - CCDBNodeLeaf *dbRangeMax= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMin= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMax= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); sint rangeMin= 0; sint rangeMax= 0; if(dbRangeMin) rangeMin= dbRangeMin->getValue32(); @@ -1745,8 +1745,8 @@ void CBotChatPageTrade::resetBuyFilterDialog() // reset the edited values CGroupEditBox *edMin = dynamic_cast(ig->getGroup("edit_min:eb")); CGroupEditBox *edMax = dynamic_cast(ig->getGroup("edit_max:eb")); - CCDBNodeLeaf *dbRangeMin= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); - CCDBNodeLeaf *dbRangeMax= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMin= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMax= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); sint rangeMin= 0; sint rangeMax= _FilterBuyDlgMaxValue; // write result in EditBox, and in db @@ -1774,8 +1774,8 @@ void CBotChatPageTrade::confirmChangeBuyFilterDialog() // retrieve the edited values CGroupEditBox *edMin = dynamic_cast(ig->getGroup("edit_min:eb")); CGroupEditBox *edMax = dynamic_cast(ig->getGroup("edit_max:eb")); - CCDBNodeLeaf *dbRangeMin= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); - CCDBNodeLeaf *dbRangeMax= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMin= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_") + _FilterBuyDlgDBExt, false); + CCDBNodeLeaf *dbRangeMax= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_") + _FilterBuyDlgDBExt, false); sint rangeMin= 0; sint rangeMax= 0; if(edMin) rangeMin= edMin->getInputStringAsInt(); @@ -1830,7 +1830,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterMPDialog(uint ft) // set ItemPart DB CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbItemPart= pIM->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART"), false); + CCDBNodeLeaf *dbItemPart= NLGUI::CDBManager::getInstance()->getDbProp(string(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART"), false); if(dbItemPart) dbItemPart->setValue32(ft); // Then send new filter to Server, and reset item list @@ -1846,8 +1846,8 @@ void CBotChatPageTrade::resetItemPartAndTypeFilters() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbItemPart= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART" , false); - CCDBNodeLeaf *dbItemType= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); + CCDBNodeLeaf *dbItemPart= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART" , false); + CCDBNodeLeaf *dbItemType= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); if(dbItemPart) dbItemPart->setValue32(RM_FABER_TYPE::Unknown); if(dbItemType) dbItemType->setValue32(ITEM_TYPE::UNDEFINED); @@ -1859,14 +1859,14 @@ void CBotChatPageTrade::sendCurrentBuyFilterToServer(bool resetBuyList) CInterfaceManager *pIM= CInterfaceManager::getInstance(); // **** retrieve current DB values - CCDBNodeLeaf *dbQualityMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_QUALITY" , false); - CCDBNodeLeaf *dbQualityMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_QUALITY" , false); - CCDBNodeLeaf *dbPriceMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_PRICE" , false); - CCDBNodeLeaf *dbPriceMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_PRICE" , false); - CCDBNodeLeaf *dbClassMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); - CCDBNodeLeaf *dbClassMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); - CCDBNodeLeaf *dbItemPart= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART" , false); - CCDBNodeLeaf *dbItemType= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); + CCDBNodeLeaf *dbQualityMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_QUALITY" , false); + CCDBNodeLeaf *dbQualityMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_QUALITY" , false); + CCDBNodeLeaf *dbPriceMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_PRICE" , false); + CCDBNodeLeaf *dbPriceMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_PRICE" , false); + CCDBNodeLeaf *dbClassMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); + CCDBNodeLeaf *dbClassMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); + CCDBNodeLeaf *dbItemPart= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MP_ITEM_PART" , false); + CCDBNodeLeaf *dbItemType= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); uint32 qualityMin=0, qualityMax=0; uint32 priceMin=0, priceMax=0; @@ -2005,10 +2005,10 @@ void CBotChatPageTrade::startChangeBuyFilterClassDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Copy from save to Temp edition - CCDBNodeLeaf *dbClassMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); - CCDBNodeLeaf *dbClassMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); - CCDBNodeLeaf *tempClassMin= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); - CCDBNodeLeaf *tempClassMax= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); + CCDBNodeLeaf *dbClassMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); + CCDBNodeLeaf *dbClassMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); + CCDBNodeLeaf *tempClassMin= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); + CCDBNodeLeaf *tempClassMax= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); if(dbClassMin) tempClassMin->setValue32(dbClassMin->getValue32()); if(dbClassMax) tempClassMax->setValue32(dbClassMax->getValue32()); @@ -2027,10 +2027,10 @@ void CBotChatPageTrade::resetBuyFilterClassDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Copy from save to Temp edition - CCDBNodeLeaf *dbClassMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); - CCDBNodeLeaf *dbClassMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); - CCDBNodeLeaf *tempClassMin= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); - CCDBNodeLeaf *tempClassMax= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); + CCDBNodeLeaf *dbClassMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); + CCDBNodeLeaf *dbClassMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); + CCDBNodeLeaf *tempClassMin= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); + CCDBNodeLeaf *tempClassMax= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); // write in both DB tempClassMin->setValue32(0); tempClassMax->setValue32(RM_CLASS_TYPE::NumTRMClassType-1); @@ -2050,10 +2050,10 @@ void CBotChatPageTrade::confirmChangeBuyFilterClassDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Copy from temp edit to final - CCDBNodeLeaf *dbClassMin= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); - CCDBNodeLeaf *dbClassMax= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); - CCDBNodeLeaf *tempClassMin= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); - CCDBNodeLeaf *tempClassMax= pIM->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); + CCDBNodeLeaf *dbClassMin= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MIN_CLASS" , false); + CCDBNodeLeaf *dbClassMax= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":MAX_CLASS" , false); + CCDBNodeLeaf *tempClassMin= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MIN_CLASS"); + CCDBNodeLeaf *tempClassMax= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:BOTCHAT:TEMP_FILTER_MAX_CLASS"); sint minClass= tempClassMin->getValue32(); sint maxClass= tempClassMax->getValue32(); // min must be => 0 and max must be >= min @@ -2104,7 +2104,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterItemTypeDialog(ITEM_TYPE::TItemTy CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Copy result to final DB - CCDBNodeLeaf *dbItemType= pIM->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); + CCDBNodeLeaf *dbItemType= NLGUI::CDBManager::getInstance()->getDbProp(DB_BOT_CHAT_BASE_BUY_FILTER":ITEM_TYPE" , false); if(dbItemType) dbItemType->setValue32(itemType); // Then send new filter to Server, and reset item list @@ -2129,7 +2129,7 @@ void CBotChatPageTrade::startDestroyItemDialog() if(_QuantityCheck) quantity= min(quantity, (uint32)_QuantityCheck); // set view - pIM->getDbProp("UI:TEMP:TRADE_ITEM:DESTROY_QUANTITY")->setValue32(quantity); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:DESTROY_QUANTITY")->setValue32(quantity); // show the modal CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_DESTROY_ITEM)); @@ -2262,7 +2262,7 @@ class CAHConfirmTrade : public IActionHandler if(canTestConfirmation) { // Building: - if(pIM->getDbValue32("SERVER:TRADING:BUILDING_LOSS_WARNING") == 1) + if(NLGUI::CDBManager::getInstance()->getDbValue32("SERVER:TRADING:BUILDING_LOSS_WARNING") == 1) mustConfirm= true; } @@ -2492,7 +2492,7 @@ class CAHBotChatRefilItemTypeChoiceList : public IActionHandler nlctassert(ITEM_TYPE::UNDEFINED<=128); // get the src bitfield - CCDBNodeLeaf *nodeSrc= pIM->getDbProp(srcDB, false); + CCDBNodeLeaf *nodeSrc= NLGUI::CDBManager::getInstance()->getDbProp(srcDB, false); if(!nodeSrc) return; uint64 bfItemType= nodeSrc->getValue64(); @@ -2502,7 +2502,7 @@ class CAHBotChatRefilItemTypeChoiceList : public IActionHandler { bool present= ((bfItemType>>i)&1)!=0; // get the dest node - CCDBNodeLeaf *nodeDst= pIM->getDbProp(destDB+toString(":%d:SHEET", i+offset), false); + CCDBNodeLeaf *nodeDst= NLGUI::CDBManager::getInstance()->getDbProp(destDB+toString(":%d:SHEET", i+offset), false); if(nodeDst) { if(present) @@ -2620,59 +2620,59 @@ NLMISC_COMMAND( testColorItems, "Temp : test some items to trade", "" ) itemName = args[1]; } // - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); - im->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:USER_COLOR")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:USER_COLOR")->setValue32(0); // - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:1:USER_COLOR")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:USER_COLOR")->setValue32(1); // - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:USER_COLOR")->setValue32(2); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:USER_COLOR")->setValue32(2); // - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// - im->getDbProp("SERVER:TRADING:3:USER_COLOR")->setValue32(3); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:USER_COLOR")->setValue32(3); // - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(100); - im->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:USER_COLOR")->setValue32(4); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:USER_COLOR")->setValue32(4); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:5:USER_COLOR")->setValue32(5); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:USER_COLOR")->setValue32(5); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:USER_COLOR")->setValue32(6); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:USER_COLOR")->setValue32(6); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId(itemName).asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:USER_COLOR")->setValue32(7); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId(itemName).asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:USER_COLOR")->setValue32(7); // sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); // return true; } @@ -2683,57 +2683,57 @@ NLMISC_COMMAND( testTradeItems, "Temp : test some items to trade", "" ) if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); // - //im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("icfm1bm.sitem").asInt()); - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("guild_main_building.sitem").asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); - im->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); + //NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("icfm1bm.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("guild_main_building.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); // - //im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("guild_rm_craft.sitem").asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); + //NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("guild_rm_craft.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); // - //im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("guild_rm_fight.sitem").asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); + //NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("guild_rm_fight.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); // - //im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("guild_rm_harvest.sitem").asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// + //NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("guild_rm_harvest.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// // - //im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("ictr2b.sitem").asInt()); - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("guild_rm_magic.sitem").asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(100); - im->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); + //NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("ictr2b.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("guild_rm_magic.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("icragt.sitem").asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("icragt.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); // sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); // return true; } @@ -2745,68 +2745,68 @@ NLMISC_COMMAND( testTradeItems2, "Temp : test some items to trade (2)", "" ) if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("icfm1bm.sitem").asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); - im->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:FACTION_TYPE")->setValue32(0); -// im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(130); // should result to none + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("icfm1bm.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:FACTION_TYPE")->setValue32(0); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(130); // should result to none // - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:1:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); -// im->getDbProp("SERVER:TRADING:1:FACTION_POINT_PRICE")->setValue32(0); // should result to none + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:FACTION_POINT_PRICE")->setValue32(0); // should result to none // - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); - im->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); - im->getDbProp("SERVER:TRADING:2:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); -// im->getDbProp("SERVER:TRADING:2:FACTION_POINT_PRICE")->setValue32(13); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:FACTION_POINT_PRICE")->setValue32(13); // - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// - im->getDbProp("SERVER:TRADING:3:FACTION_TYPE")->setValue32(PVP_CLAN::Tryker); -// im->getDbProp("SERVER:TRADING:3:FACTION_POINT_PRICE")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0);// + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:FACTION_TYPE")->setValue32(PVP_CLAN::Tryker); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:FACTION_POINT_PRICE")->setValue32(10); // - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("ictr2b.sitem").asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:FACTION_TYPE")->setValue32(PVP_CLAN::Fyros); -// im->getDbProp("SERVER:TRADING:4:FACTION_POINT_PRICE")->setValue32(8); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("ictr2b.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:FACTION_TYPE")->setValue32(PVP_CLAN::Fyros); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:FACTION_POINT_PRICE")->setValue32(8); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); - im->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); - im->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:5:FACTION_TYPE")->setValue32(PVP_CLAN::Tryker); -// im->getDbProp("SERVER:TRADING:5:FACTION_POINT_PRICE")->setValue32(7); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:FACTION_TYPE")->setValue32(PVP_CLAN::Tryker); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:FACTION_POINT_PRICE")->setValue32(7); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("icragt.sitem").asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:FACTION_TYPE")->setValue32(PVP_CLAN::Karavan); -// im->getDbProp("SERVER:TRADING:6:FACTION_POINT_PRICE")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("icragt.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:FACTION_TYPE")->setValue32(PVP_CLAN::Karavan); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:FACTION_POINT_PRICE")->setValue32(1); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); -// im->getDbProp("SERVER:TRADING:7:FACTION_POINT_PRICE")->setValue32(1350); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:FACTION_TYPE")->setValue32(PVP_CLAN::Kami); +// NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:FACTION_POINT_PRICE")->setValue32(1350); // sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); // return true; } @@ -2815,25 +2815,25 @@ NLMISC_COMMAND( testTradeItems3, "Temp : test some items to trade (3)", "" ) { // items CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp("LOCAL:TRADING:0:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); - im->getDbProp("LOCAL:TRADING:0:PRICE")->setValue32(200); - im->getDbProp("LOCAL:TRADING:0:QUALITY")->setValue32(25); - im->getDbProp("LOCAL:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:1:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); - im->getDbProp("LOCAL:TRADING:1:PRICE")->setValue32(200); - im->getDbProp("LOCAL:TRADING:1:QUALITY")->setValue32(25); - im->getDbProp("LOCAL:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:2:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); - im->getDbProp("LOCAL:TRADING:2:PRICE")->setValue32(200); - im->getDbProp("LOCAL:TRADING:2:QUALITY")->setValue32(25); - im->getDbProp("LOCAL:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:3:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); - im->getDbProp("LOCAL:TRADING:3:PRICE")->setValue32(200); - im->getDbProp("LOCAL:TRADING:3:QUALITY")->setValue32(25); - im->getDbProp("LOCAL:TRADING:3:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:SHEET")->setValue32(CSheetId("fyros_buckler_lvl_01_05.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:PRICE")->setValue32(200); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:QUALITY")->setValue32(25); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:SLOT_TYPE")->setValue32(0); return true; } @@ -2843,21 +2843,21 @@ NLMISC_COMMAND( testTradeItems4, "Temp : test some items to trade (4)", "" ) // pacts CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("LOCAL:TRADING:0:SHEET")->setValue32(CSheetId("pacts.death_impact").asInt()); - im->getDbProp("LOCAL:TRADING:0:QUALITY")->setValue32(0); - im->getDbProp("LOCAL:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:SHEET")->setValue32(CSheetId("pacts.death_impact").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:0:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:1:SHEET")->setValue32(CSheetId("kami_pactes.death_impact").asInt()); - im->getDbProp("LOCAL:TRADING:1:QUALITY")->setValue32(0); - im->getDbProp("LOCAL:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:SHEET")->setValue32(CSheetId("kami_pactes.death_impact").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:1:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:2:SHEET")->setValue32(CSheetId("karavan_pactes.death_impact").asInt()); - im->getDbProp("LOCAL:TRADING:2:QUALITY")->setValue32(0); - im->getDbProp("LOCAL:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:SHEET")->setValue32(CSheetId("karavan_pactes.death_impact").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:2:SLOT_TYPE")->setValue32(0); // - im->getDbProp("LOCAL:TRADING:3:SHEET")->setValue32(CSheetId("kami_pactes.death_impact").asInt()); - im->getDbProp("LOCAL:TRADING:3:QUALITY")->setValue32(0); - im->getDbProp("LOCAL:TRADING:3:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:SHEET")->setValue32(CSheetId("kami_pactes.death_impact").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TRADING:3:SLOT_TYPE")->setValue32(0); // return true; } @@ -2868,46 +2868,46 @@ NLMISC_COMMAND( testPhrases, "Temp : test some items to trade", "" ) if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("abfaimhame09.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(11); - im->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("abfaimhame09.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(11); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("abfaimhcme07.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(22); - im->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("abfaimhcme07.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(22); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("abfaimhfme04.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(33); - im->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("abfaimhfme04.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(33); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("abfaimhfme08.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(44); - im->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("abfaimhfme08.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(44); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("abfma05.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(55); - im->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("abfma05.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(55); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("abm_mt_ae_acid_00055.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(66); - im->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("abm_mt_ae_acid_00055.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(66); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("abm_mt_heal_00140.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(77); - im->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("abm_mt_heal_00140.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(77); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("abm_mt_cannibalism_00020.sphrase").asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(88); - im->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("abm_mt_cannibalism_00020.sphrase").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(88); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); // sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); - im->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(0); return true; } @@ -2921,77 +2921,77 @@ NLMISC_COMMAND( testResaleItems, "Temp : test resale", "" ) uint pf= pageId+1; CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("m0006dxajf01.sitem").asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(1); - im->getDbProp("SERVER:TRADING:0:SELLER_TYPE")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:PRICE_RETIRE")->setValue32(111); - im->getDbProp("SERVER:TRADING:0:QUANTITY")->setValue32(62); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("m0006dxajf01.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:QUALITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SELLER_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE_RETIRE")->setValue32(111); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:QUANTITY")->setValue32(62); // - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(1*pf); - im->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(11); - im->getDbProp("SERVER:TRADING:1:SELLER_TYPE")->setValue32(1); - im->getDbProp("SERVER:TRADING:1:PRICE_RETIRE")->setValue32(222); - im->getDbProp("SERVER:TRADING:1:QUANTITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("icfm1bs.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(1*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:QUALITY")->setValue32(11); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SELLER_TYPE")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE_RETIRE")->setValue32(222); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:QUANTITY")->setValue32(1); // - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(-1); - im->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(22); - im->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); - im->getDbProp("SERVER:TRADING:2:SELLER_TYPE")->setValue32(2); - im->getDbProp("SERVER:TRADING:2:PRICE_RETIRE")->setValue32(333); - im->getDbProp("SERVER:TRADING:2:QUANTITY")->setValue32(1); - im->getDbProp("SERVER:TRADING:2:RESALE_TIME_LEFT")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("icfm1pd.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:QUALITY")->setValue32(22); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:NAMEID")->setValue32(8); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SELLER_TYPE")->setValue32(2); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE_RETIRE")->setValue32(333); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:QUANTITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:RESALE_TIME_LEFT")->setValue32(10); // - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(3*pf); - im->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(33); - im->getDbProp("SERVER:TRADING:3:SELLER_TYPE")->setValue32(3); - im->getDbProp("SERVER:TRADING:3:PRICE_RETIRE")->setValue32(444); - im->getDbProp("SERVER:TRADING:3:QUANTITY")->setValue32(1); - im->getDbProp("SERVER:TRADING:3:RESALE_TIME_LEFT")->setValue32(100); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("icfr2l.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(3*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:QUALITY")->setValue32(33); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SELLER_TYPE")->setValue32(3); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE_RETIRE")->setValue32(444); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:QUANTITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:RESALE_TIME_LEFT")->setValue32(100); // - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("m0006dxajf01.sitem").asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(4*pf); - im->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(44); - im->getDbProp("SERVER:TRADING:4:SELLER_TYPE")->setValue32(4); - im->getDbProp("SERVER:TRADING:4:PRICE_RETIRE")->setValue32(555); - im->getDbProp("SERVER:TRADING:4:QUANTITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("m0006dxajf01.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(4*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:QUALITY")->setValue32(44); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SELLER_TYPE")->setValue32(4); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE_RETIRE")->setValue32(555); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:QUANTITY")->setValue32(1); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(5*pf); - im->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(55); - im->getDbProp("SERVER:TRADING:5:SELLER_TYPE")->setValue32(5); - im->getDbProp("SERVER:TRADING:5:PRICE_RETIRE")->setValue32(666); - im->getDbProp("SERVER:TRADING:5:QUANTITY")->setValue32(23); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("icfp1pb.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(5*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:QUALITY")->setValue32(55); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SELLER_TYPE")->setValue32(5); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE_RETIRE")->setValue32(666); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:QUANTITY")->setValue32(23); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("m0119dxajd01.sitem").asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(6*pf); - im->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(66); - im->getDbProp("SERVER:TRADING:6:SELLER_TYPE")->setValue32(2); - im->getDbProp("SERVER:TRADING:6:PRICE_RETIRE")->setValue32(777); - im->getDbProp("SERVER:TRADING:6:QUANTITY")->setValue32(19); - im->getDbProp("SERVER:TRADING:6:RESALE_TIME_LEFT")->setValue32(48); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("m0119dxajd01.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(6*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:QUALITY")->setValue32(66); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SELLER_TYPE")->setValue32(2); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE_RETIRE")->setValue32(777); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:QUANTITY")->setValue32(19); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:RESALE_TIME_LEFT")->setValue32(48); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(7*pf); - im->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(77); - im->getDbProp("SERVER:TRADING:7:SELLER_TYPE")->setValue32(5); - im->getDbProp("SERVER:TRADING:7:PRICE_RETIRE")->setValue32(888); - im->getDbProp("SERVER:TRADING:7:QUANTITY")->setValue32(1); - im->getDbProp("SERVER:TRADING:7:RESALE_TIME_LEFT")->setValue32(10); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("icmss.sitem").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(7*pf); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:QUALITY")->setValue32(77); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SELLER_TYPE")->setValue32(5); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE_RETIRE")->setValue32(888); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:QUANTITY")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:RESALE_TIME_LEFT")->setValue32(10); // - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(pageId); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(pageId); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); // // Force for next page IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); return true; } @@ -3003,14 +3003,14 @@ NLMISC_COMMAND( testClientPhrases, "", "" ) CInterfaceManager *im = CInterfaceManager::getInstance(); sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); fromString(args[1], value); - im->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(value); fromString(args[2], value); - im->getDbProp("SERVER:TRADING:ROLEMASTER_RACE")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:ROLEMASTER_RACE")->setValue32(value); return true; } @@ -3021,46 +3021,46 @@ NLMISC_COMMAND( testOutpostBuildings, "Temp : test some items to trade", "" ) if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); // - im->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("driller_bountybeaches_kami_u1_100a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SHEET")->setValue32(CSheetId("driller_bountybeaches_kami_u1_100a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:0:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("driller_citiesofintuition_kami_u2_50a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SHEET")->setValue32(CSheetId("driller_citiesofintuition_kami_u2_50a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:1:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("driller_couloirbrule_kami_u2_150b.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SHEET")->setValue32(CSheetId("driller_couloirbrule_kami_u2_150b.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:2:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_100a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_100a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:3:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_150a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_150a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:4:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_200a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u1_200a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:5:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u2_100a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u2_100a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:6:SLOT_TYPE")->setValue32(0); // - im->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u2_150a.outpost_building").asInt()); - im->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(0); - im->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SHEET")->setValue32(CSheetId("driller_bountybeaches_karavan_u2_150a.outpost_building").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:PRICE")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:7:SLOT_TYPE")->setValue32(0); // sint32 value; - im->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION")->setValue32(CBotChatManager::getInstance()->getSessionID()); fromString(args[0], value); - im->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); - im->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); - im->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:PAGE_ID")->setValue32(value); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:HAS_NEXT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:ROLEMASTER_FLAGS")->setValue32(0); return true; } diff --git a/code/ryzom/client/src/interface_v3/character_3d.cpp b/code/ryzom/client/src/interface_v3/character_3d.cpp index bbea38059..2f9d71b40 100644 --- a/code/ryzom/client/src/interface_v3/character_3d.cpp +++ b/code/ryzom/client/src/interface_v3/character_3d.cpp @@ -475,7 +475,7 @@ void SCharacter3DSetup::setupFromCS_ModelCol (SLOTTYPE::EVisualSlot s, sint32 mo uint64 SCharacter3DSetup::getDB (const string &name) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNL = pIM->getDbProp(name); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(name); if (pNL == NULL) return 0; return pNL->getValue64(); } @@ -484,7 +484,7 @@ uint64 SCharacter3DSetup::getDB (const string &name) void SCharacter3DSetup::setDB (const string &name, uint64 val) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNL = pIM->getDbProp(name); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(name); if (pNL == NULL) return; pNL->setValue64(val); } diff --git a/code/ryzom/client/src/interface_v3/chat_filter.cpp b/code/ryzom/client/src/interface_v3/chat_filter.cpp index 9609fc1af..aa3c63acf 100644 --- a/code/ryzom/client/src/interface_v3/chat_filter.cpp +++ b/code/ryzom/client/src/interface_v3/chat_filter.cpp @@ -374,8 +374,8 @@ void CChatTargetFilter::setTargetGroup(CChatGroup::TGroupType groupType, uint32 // set the color string entry="UI:SAVE:CHAT:COLORS:"; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const bool teamActive = pIM->getDbProp("SERVER:GROUP:0:NAME")->getValueBool(); - const bool guildActive = pIM->getDbProp("SERVER:GUILD:NAME")->getValueBool(); + const bool teamActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:NAME")->getValueBool(); + const bool guildActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValueBool(); switch(groupType) { case CChatGroup::dyn_chat: entry+="DYN:" + NLMISC::toString(dynamicChannelDbIndex); break; @@ -389,7 +389,7 @@ void CChatTargetFilter::setTargetGroup(CChatGroup::TGroupType groupType, uint32 { entry+="UNIVERSE_NEW"; if(allowUniverseWarning) - pIM->getDbProp("UI:VARIABLES:UNIVERSE_CHANEL_WARNING_WANTED")->setValue64(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UNIVERSE_CHANEL_WARNING_WANTED")->setValue64(1); } break; case CChatGroup::region: entry+="REGION"; break; diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index 9b5113a55..8bf79b805 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -51,7 +51,7 @@ uint CChatTextManager::getTextFontSize() const if (!_TextFontSize) { CInterfaceManager *im = CInterfaceManager::getInstance(); - _TextFontSize = im->getDbProp("UI:SAVE:CHAT:FONT_SIZE", false); + _TextFontSize = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:FONT_SIZE", false); if (!_TextFontSize) return 12; } return (uint) _TextFontSize->getValue32(); @@ -63,7 +63,7 @@ uint CChatTextManager::getTextMultiLineSpace() const if (!_TextMultilineSpace) { CInterfaceManager *im = CInterfaceManager::getInstance(); - _TextMultilineSpace = im->getDbProp("UI:SAVE:CHAT:MULTI_LINE_SPACE", false); + _TextMultilineSpace = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:MULTI_LINE_SPACE", false); if (!_TextMultilineSpace) return 1; } return (uint) _TextMultilineSpace->getValue32(); @@ -75,7 +75,7 @@ bool CChatTextManager::isTextShadowed() const if (!_TextShadowed) { CInterfaceManager *im = CInterfaceManager::getInstance(); - _TextShadowed = im->getDbProp("UI:SAVE:CHAT:SHADOWED_TEXT", false); + _TextShadowed = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHADOWED_TEXT", false); if (!_TextShadowed) return false; } return _TextShadowed->getValueBool(); @@ -149,7 +149,7 @@ CViewBase *CChatTextManager::createMsgText(const ucstring &cstMsg, NLMISC::CRGBA vt->setModulateGlobalColor(false); ucstring cur_time; - static CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); + static CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TIMES_IN_CHAT_CB", false); if (node) { if (node->getValueBool()) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 18be552e9..344f8a761 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -607,7 +607,7 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC newmsg = newmsg.substr(0, pos + 1) + prefix + newmsg.substr(pos + 1); // Add dynchannel number and optionally name before text if user channel - CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false); + CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false); if (node && node->getValueBool()) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChatDbIndex); diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index 233f362ae..7ba05b25c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -348,7 +348,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (!_LeftLongClickHandled) { uint nVal = 50; - CCDBNodeLeaf *pNL = pIM->getDbProp("UI:SAVE:KEY_REPEAT_SPEED"); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED"); if (pNL != NULL) nVal = pNL->getValue32(); uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index e48178f77..f5d68f690 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -266,7 +266,7 @@ int CDBCtrlSheet::luaBuildCrystallizedSpellListBrick(CLuaState &ls) { //if ( ! (pBM->getBrick(itemInfo.Enchantment.Bricks[i])->isCredit() || pBM->getBrick(itemInfo.Enchantment.Bricks[i])->isParameter())) { - CCDBNodeLeaf *node= pIM->getDbProp(toString("UI:VARIABLES:CRYSTALBRICKS:%d:SHEET", currentBrick++)); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:VARIABLES:CRYSTALBRICKS:%d:SHEET", currentBrick++)); if(node) node->setValue32(itemInfo.Enchantment.Bricks[i].asInt()); } @@ -276,7 +276,7 @@ int CDBCtrlSheet::luaBuildCrystallizedSpellListBrick(CLuaState &ls) // Reset other to 0. for(;;currentBrick++) { - CCDBNodeLeaf *node= pIM->getDbProp(toString("UI:VARIABLES:CRYSTALBRICKS:%d:SHEET", currentBrick), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:VARIABLES:CRYSTALBRICKS:%d:SHEET", currentBrick), false); if(node) node->setValue32(0); else @@ -747,7 +747,7 @@ void CDBCtrlSheet::setupSheetDbLinks () CInterfaceManager *pIM= CInterfaceManager::getInstance(); // link to the DBBranch (NB: none for macros) - CCDBNodeBranch *dbBranch = pIM->getDbBranch( _DbBranchName ); + CCDBNodeBranch *dbBranch = NLGUI::CDBManager::getInstance()->getDbBranch( _DbBranchName ); //nlassert(dbBranch || _DbBranchName.empty()); // link if possible with the database, else dummy link to the interface @@ -2974,11 +2974,11 @@ void CDBCtrlSheet::setCurrSelection(CDBCtrlSheet *selected) { _CurrSelection = selected; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SHEET")->setValue64(selected ? selected->getSheetId() : 0); - im->getDbProp("UI:SELECTED_ITEM_SHEET_ID:QUALITY")->setValue64(selected ? selected->getQuality() : 0); - im->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SLOT_TYPE")->setValue64(selected ? selected->getBehaviour() : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SHEET")->setValue64(selected ? selected->getSheetId() : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:QUALITY")->setValue64(selected ? selected->getQuality() : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SLOT_TYPE")->setValue64(selected ? selected->getBehaviour() : 0); // set the selection group in the db - im->getDbProp("UI:SELECTED_ITEM_SELECTION_GROUP")->setValue64(selected ? selected->getSelectionGroup() : -1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SELECTION_GROUP")->setValue64(selected ? selected->getSelectionGroup() : -1); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 09bda7c53..e3b2fb407 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -102,13 +102,13 @@ bool CDBGroupBuildPhrase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) // Bricks and their Params for(i=0;igetDbProp(BrickBuildDB + ":MAIN:" + toString(i)+":SHEET"); + NLGUI::CDBManager::getInstance()->getDbProp(BrickBuildDB + ":MAIN:" + toString(i)+":SHEET"); for(uint j=0;jgetDbProp(BrickBuildDB + ":PARAM:" + toString(i) + ":" + toString(j) + ":SHEET"); + NLGUI::CDBManager::getInstance()->getDbProp(BrickBuildDB + ":PARAM:" + toString(i) + ":" + toString(j) + ":SHEET"); } // spellView: to update the icon, use a special phrase manager entry - pIM->getDbProp(BrickBuildDB + ":EDITION_PHRASE:PHRASE")->setValue32(CSPhraseManager::EditionSlot); + NLGUI::CDBManager::getInstance()->getDbProp(BrickBuildDB + ":EDITION_PHRASE:PHRASE")->setValue32(CSPhraseManager::EditionSlot); return true; } @@ -1047,8 +1047,8 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) pBM->getSabrinaCom().getPhraseCost(phrase.Bricks, totalCost, totalCredit); // update database - pIM->getDbProp("UI:PHRASE:BUILD:TOTAL_COST")->setValue32(totalCost); - pIM->getDbProp("UI:PHRASE:BUILD:TOTAL_CREDIT")->setValue32(totalCredit); + NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:BUILD:TOTAL_COST")->setValue32(totalCost); + NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:BUILD:TOTAL_CREDIT")->setValue32(totalCredit); // **** Update the Cost of All Root/Mandat/ops/Credits. if(phrase.Bricks.size()) @@ -1133,7 +1133,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) mandatOk= false; } // set DB value accordeing to it. - pIM->getDbProp("UI:PHRASE:BUILD:ROOT_EFFECT_VALID")->setValue32(mandatOk); + NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:BUILD:ROOT_EFFECT_VALID")->setValue32(mandatOk); // update valid button if(_ValidateButton) @@ -1187,7 +1187,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) if(rootBrick && rootBrick->isCombat()) { // show the weapon restriction interface - pIM->getDbProp("UI:PHRASE:BUILD:RESTRICT_COMBAT:ENABLED")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:BUILD:RESTRICT_COMBAT:ENABLED")->setValue32(1); // If not already done, retrieve the weapon skills, and fill the sbricks SHEET if(_WeaponSkills.empty()) @@ -1218,7 +1218,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) uint32 viewBrickCombatSheetId= pBM->getVisualBrickForSkill(_WeaponSkills[i]).asInt(); // And fill in DB - pIM->getDbProp(toString("UI:PHRASE:BUILD:RESTRICT_COMBAT:%d:SHEET", i))->setValue32(viewBrickCombatSheetId); + NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:PHRASE:BUILD:RESTRICT_COMBAT:%d:SHEET", i))->setValue32(viewBrickCombatSheetId); } } @@ -1226,13 +1226,13 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase) for(uint i=0;i<_WeaponSkills.size();i++) { bool ok= pPM->skillCompatibleWithCombatPhrase(_WeaponSkills[i], phrase.Bricks); - pIM->getDbProp(toString("UI:PHRASE:BUILD:RESTRICT_COMBAT:%d:LOCKED", i))->setValue32(!ok); + NLGUI::CDBManager::getInstance()->getDbProp(toString("UI:PHRASE:BUILD:RESTRICT_COMBAT:%d:LOCKED", i))->setValue32(!ok); } } else { // hide the weapon restriction interface - pIM->getDbProp("UI:PHRASE:BUILD:RESTRICT_COMBAT:ENABLED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:BUILD:RESTRICT_COMBAT:ENABLED")->setValue32(0); } // **** Setup the phrase Desc @@ -1267,7 +1267,7 @@ void CDBGroupBuildPhrase::resetSelection() for(uint i=0;igetDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); } } @@ -1280,9 +1280,9 @@ void CDBGroupBuildPhrase::fillSelection(const std::vector &bricks) for(uint i=0;igetDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(bricks[i].asInt()); + NLGUI::CDBManager::getInstance()->getDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(bricks[i].asInt()); else - pIM->getDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp(BrickSelectionDB+ ":" + toString(i) + ":SHEET")->setValue32(0); } } diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index b8461c9c3..0d9a9b0a1 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -113,7 +113,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if ( prop ) { // get a branch in the database. - CCDBNodeBranch *branch= pIM->getDbBranch(prop); + CCDBNodeBranch *branch= NLGUI::CDBManager::getInstance()->getDbBranch(prop); if(!branch) { nlinfo ("Branch not found in the database %s", (const char*)prop); @@ -123,7 +123,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) _DbBranch= branch; _DbBranchName= (const char*)prop; // add observer - pIM->addBranchObserver(branch, &_DbBranchObs); + NLGUI::CDBManager::getInstance()->addBranchObserver(branch, &_DbBranchObs); } // parse the common ctrl info @@ -224,7 +224,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"db_animal_status" ); if (prop) { - _AnimalStatus= pIM->getDbProp((const char*)prop, false); + _AnimalStatus= NLGUI::CDBManager::getInstance()->getDbProp((const char*)prop, false); } return true; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index af757d186..0b5d1f985 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp @@ -65,7 +65,7 @@ bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parent for(;;) { string db= toString("%s:%d:" DISABLE_LEAF, _DbBranchName.c_str(), i); - CCDBNodeLeaf *node= pIM->getDbProp(db, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(db, false); if(!node) { break; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index 80bfe50c7..68c0a8260 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -40,7 +40,7 @@ void CDBGroupListSheetMission::CSheetChildMission::init(CDBGroupListSheetText *p CCDBNodeLeaf *pNL; string sTmp = Ctrl->getSheet()+":PREREQ_STATE"; sTmp = "LOCAL:" + sTmp.substr(6,sTmp.size()); - pNL = pIM->getDbProp(sTmp, false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false); nlassert(pNL != NULL); CurrentPreReqState.link ( sTmp.c_str() ); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 2ec39cd85..ac3e6e45f 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -97,7 +97,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if ( prop ) { // get a branch in the database. - CCDBNodeBranch *branch= pIM->getDbBranch(prop); + CCDBNodeBranch *branch= NLGUI::CDBManager::getInstance()->getDbBranch(prop); if(!branch) { nlinfo ("Branch not found in the database %s", (const char*)prop); @@ -107,7 +107,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) _DbBranch= branch; _DbBranchName= (const char*)prop; // add observer - pIM->addBranchObserver( branch, &_DbBranchObs ); + NLGUI::CDBManager::getInstance()->addBranchObserver( branch, &_DbBranchObs ); } // parse the common ctrl info @@ -211,7 +211,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) prop = (char*) xmlGetProp( cur, (xmlChar*)"db_animal_status" ); if (prop) { - _AnimalStatus= pIM->getDbProp((const char*)prop, false); + _AnimalStatus= NLGUI::CDBManager::getInstance()->getDbProp((const char*)prop, false); } return true; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index e4efa0f52..c2633d567 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -158,19 +158,19 @@ void CDBGroupListSheetTextShare::CSheetChildShare::init(CDBGroupListSheetText *p CCDBNodeLeaf *pNL; string sTmp= Ctrl->getSheet()+":NB_MEMBER"; sTmp = "LOCAL" + sTmp.substr(6,sTmp.size()); - pNL = pIM->getDbProp(sTmp, false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false); nlassert(pNL != NULL); CurrentNbMember.link ( sTmp.c_str() ); sTmp= Ctrl->getSheet()+":CHANCE"; sTmp = "LOCAL" + sTmp.substr(6,sTmp.size()); - pNL = pIM->getDbProp(sTmp, false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false); nlassert(pNL != NULL); CurrentChance.link ( sTmp.c_str() ); sTmp= Ctrl->getSheet()+":WANTED"; sTmp = "LOCAL" + sTmp.substr(6,sTmp.size()); - pNL = pIM->getDbProp(sTmp, false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false); nlassert(pNL != NULL); CurrentWanted.link ( sTmp.c_str() ); @@ -279,15 +279,15 @@ class CHandlerTeamShareChoose : public IActionHandler localDB = "LOCAL" + localDB.substr(6,localDB.size()); // Retrieve index - if (pIM->getDbProp(localDB)->getValue8() == 0) + if (NLGUI::CDBManager::getInstance()->getDbProp(localDB)->getValue8() == 0) { strMsgName = "TEAM:SHARE_VALID_ITEM"; - pIM->getDbProp(localDB)->setValue8(1); // We can do it because it is in local + NLGUI::CDBManager::getInstance()->getDbProp(localDB)->setValue8(1); // We can do it because it is in local } else { strMsgName = "TEAM:SHARE_INVALID_ITEM"; - pIM->getDbProp(localDB)->setValue8(0); // We can do it because it is in local + NLGUI::CDBManager::getInstance()->getDbProp(localDB)->setValue8(0); // We can do it because it is in local } if (!GenericMsgHeaderMngr.pushNameToStream(strMsgName, out)) @@ -299,7 +299,7 @@ class CHandlerTeamShareChoose : public IActionHandler // Serialize item/phrase index out.serial(index); // Serialize session id - uint8 sessionid = pIM->getDbProp("LOCAL:INVENTORY:SHARE:SESSION")->getValue8(); + uint8 sessionid = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:SHARE:SESSION")->getValue8(); out.serial(sessionid); NetMngr.push (out); //nlinfo("impulseCallBack : %s %d %d sent", strMsgName.c_str(), index, sessionid); @@ -328,7 +328,7 @@ class CHandlerTeamShareValid : public IActionHandler else { // Serialize session id - uint8 sessionid = pIM->getDbProp("LOCAL:INVENTORY:SHARE:SESSION")->getValue8(); + uint8 sessionid = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:SHARE:SESSION")->getValue8(); out.serial(sessionid); NetMngr.push (out); //nlinfo("impulseCallBack : %s %d sent", strMsgName.c_str(), sessionid); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index bc8476c23..24efaaa88 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -55,7 +55,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath { // Basic quality string db= Ctrl->getSheet()+":QUALITY"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentQuality.link ( db.c_str() ); else { @@ -69,7 +69,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath { // Basic quantity string db= Ctrl->getSheet()+":QUANTITY"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentQuantity.link ( db.c_str() ); else { @@ -84,7 +84,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath { // Basic price string priceDB= Ctrl->getSheet()+":PRICE"; - if( pIM->getDbProp(priceDB, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(priceDB, false) ) CurrentPrice.link ( priceDB.c_str() ); else { @@ -95,7 +95,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath // Faction Type string factionTypeDB= Ctrl->getSheet()+":FACTION_TYPE"; - if( pIM->getDbProp(factionTypeDB, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(factionTypeDB, false) ) CurrentFactionType.link ( factionTypeDB.c_str() ); else { @@ -106,7 +106,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath // Faction Point Price string factionPointPriceDB= Ctrl->getSheet()+":PRICE"; - if( pIM->getDbProp(factionPointPriceDB, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(factionPointPriceDB, false) ) CurrentFactionPointPrice.link ( factionPointPriceDB.c_str() ); else { @@ -121,7 +121,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath { // seller type string db= Ctrl->getSheet()+":SELLER_TYPE"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentSellerType.link ( db.c_str() ); else { @@ -132,7 +132,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath // Retire price (only valid if sellerType is User or ResaleAndUser) db= Ctrl->getSheet()+":PRICE_RETIRE"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentPriceRetire.link ( db.c_str() ); else { @@ -143,7 +143,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath // Resale Time Left (only valid if sellerType is User or ResaleAndUser) db= Ctrl->getSheet()+":RESALE_TIME_LEFT"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentResaleTimeLeft.link ( db.c_str() ); else { @@ -154,7 +154,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::init(CDBGroupListSheetText *pFath // VendorNameId db= Ctrl->getSheet()+":VENDOR_NAMEID"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentVendorNameId.link ( db.c_str() ); else { @@ -370,7 +370,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT // check if we should apply fame factor if( zeFather->applyFamePriceFactor() ) { - priceFactor = CInterfaceManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR")->getValue16()/10000.0f; + priceFactor = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR")->getValue16()/10000.0f; } // display with correct format @@ -615,7 +615,7 @@ CDBGroupListSheetTrade::CDBGroupListSheetTrade(const TCtorParam ¶m) _ApplyFamePriceFactor = false; // **** keep link to fame price factor leaf - _FamePriceFactorLeaf = CInterfaceManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR"); + _FamePriceFactorLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR"); _LastFamePriceFactor = _FamePriceFactorLeaf->getValue16(); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index 49f477923..6f4bf906d 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -192,21 +192,21 @@ void CDBViewBar::draw () // ---------------------------------------------------------------------------- void CDBViewBar::setValueDbLink (const std::string &r) { - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(r,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); if (pNL != NULL) _Value.setNodePtr(pNL); } // ---------------------------------------------------------------------------- void CDBViewBar::setRangeDbLink (const std::string &r) { - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(r,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); if (pNL != NULL) _Range.setNodePtr(pNL); } // ---------------------------------------------------------------------------- void CDBViewBar::setReferenceDbLink (const std::string &r) { - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(r,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); if (pNL != NULL) _Reference.setNodePtr(pNL); } diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 13e830154..7ec68afab 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -295,7 +295,7 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName) pVT->setTextId(pAlbum->Name); // Setup brick reward - pIM->getDbProp("UI:VARIABLES:ENCY:ALBUMBRICK:SHEET")->setValue32(pAlbum->RewardBrick); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:ALBUMBRICK:SHEET")->setValue32(pAlbum->RewardBrick); CViewText *pRBVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_ALBUM ":reward:desc")); if (pRBVT != NULL) { @@ -347,7 +347,7 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) pVT->setTextId(pThema->RewardText); // Setup brick reward - pIM->getDbProp("UI:VARIABLES:ENCY:REWARDBRICK:SHEET")->setValue32(pThema->RewardSheet); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:REWARDBRICK:SHEET")->setValue32(pThema->RewardSheet); CViewText *pRBVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_THEMA ":reward:desc")); nlassert(pRBVT != NULL); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); @@ -373,14 +373,14 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) // Setup the total number of steps uint32 nNbSteps = pThema->NbTask - 1; // 0th is the rite - pIM->getDbProp("UI:VARIABLES:ENCY:STEPS")->setValue32(nNbSteps); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:STEPS")->setValue32(nNbSteps); // Count number of tasks done uint32 nNbTaskDone = 0; for (i = 0; i < pThema->NbTask; ++i) if (pThema->getTaskState((uint8)i) == 2) // 2 == finished ++nNbTaskDone; - pIM->getDbProp("UI:VARIABLES:ENCY:DONE")->setValue32(nNbTaskDone); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:DONE")->setValue32(nNbTaskDone); // setup rite & tasks for (i = 0; i < pThema->NbTask; ++i) diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index 10a8ac230..6d28b7ec7 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -279,7 +279,7 @@ void CGroupCompas::draw() case CCompassTarget::Home: { // get pos - CCDBNodeLeaf *pos = im->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); + CCDBNodeLeaf *pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); sint32 px = (sint32) (pos->getValue64() >> 32); sint32 py = pos->getValue32(); if (px != 0 || py != 0) @@ -410,7 +410,7 @@ bool CGroupCompas::handleEvent (const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - _RadarPos = pIM->getDbProp("UI:SAVE:RADARZOOM")->getValue32(); + _RadarPos = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RADARZOOM")->getValue32(); if (eventDesc.getWheel() > 0) { // Zoom out @@ -422,7 +422,7 @@ bool CGroupCompas::handleEvent (const NLGUI::CEventDescriptor &event) if (_RadarPos < 3) _RadarPos++; } - pIM->getDbProp("UI:SAVE:RADARZOOM")->setValue32(_RadarPos); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RADARZOOM")->setValue32(_RadarPos); } } } @@ -491,7 +491,7 @@ bool CGroupCompas::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (ptr) _NewTargetSelectedColor = convertColor(ptr); // - _DynamicTargetPos = CInterfaceManager::getInstance()->getDbProp(COMPASS_DB_PATH ":TARGET"); + _DynamicTargetPos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":TARGET"); return true; } @@ -501,8 +501,8 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *entityNode = pIM->getDbProp(toString(TEAM_DB_PATH ":%d:UID", teamMemberId), false); - CCDBNodeLeaf *nameNode = pIM->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", teamMemberId), false); + CCDBNodeLeaf *entityNode = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:UID", teamMemberId), false); + CCDBNodeLeaf *nameNode = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:NAME", teamMemberId), false); if (nameNode && nameNode->getValueBool() && entityNode && entityNode->getValue32()!=0 && nameNode) { CSmartPtr tracker = new CTeammatePositionState; @@ -532,7 +532,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) if(animalMemberIdgetDbProp("SERVER:PACK_ANIMAL:BEAST"+toString(animalMemberId-1)+":TYPE")->getValue32(); + at = (ANIMAL_TYPE::EAnimalType)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST"+toString(animalMemberId-1)+":TYPE")->getValue32(); string sPrefix; switch(at) { @@ -551,7 +551,7 @@ bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId) return false; // get if present or not - CCDBNodeLeaf *statusNode = pIM->getDbProp(dbBase + ":STATUS", false); + CCDBNodeLeaf *statusNode = NLGUI::CDBManager::getInstance()->getDbProp(dbBase + ":STATUS", false); if (statusNode && ANIMAL_STATUS::isSpawned((ANIMAL_STATUS::EAnimalStatus)statusNode->getValue32()) ) { CSmartPtr tracker = new CAnimalPositionState; @@ -665,7 +665,7 @@ void CGroupCompasMenu::setActive (bool state) Targets.push_back(ct); getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); // Home - CCDBNodeLeaf *pos = im->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); + CCDBNodeLeaf *pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); sint32 px = (sint32) (pos->getValue64() >> 32); sint32 py = pos->getValue32(); if (px != 0 || py != 0) @@ -676,7 +676,7 @@ void CGroupCompasMenu::setActive (bool state) getRootMenu()->addLineAtIndex(lineIndex ++, ct.Name, "set_compas", toString ("compass=%s|id=%d|menu=%s", _TargetCompass.c_str(), (int) Targets.size() - 1, _Id.c_str())); } // Respawn - pos = im->getDbProp(COMPASS_DB_PATH ":BIND_POINT"); + pos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT"); px = (sint32) (pos->getValue64() >> 32); py = pos->getValue32(); if (px != 0 || py != 0) @@ -726,14 +726,14 @@ void CGroupCompasMenu::setActive (bool state) { for(uint l = 0; l getDbProp(baseDbPath + toString(":%d:TARGET%d:TITLE", (int) k, (int) l), false); + CCDBNodeLeaf *textIDLeaf = NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:TITLE", (int) k, (int) l), false); if (textIDLeaf) { ucstring name; if (CStringManagerClient::instance()->getDynString(textIDLeaf->getValue32(), name)) { - CCDBNodeLeaf *leafPosX= im->getDbProp(baseDbPath + toString(":%d:TARGET%d:X", (int) k, (int) l), false); - CCDBNodeLeaf *leafPosY = im->getDbProp(baseDbPath + toString(":%d:TARGET%d:Y", (int) k, (int) l), false); + CCDBNodeLeaf *leafPosX= NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:X", (int) k, (int) l), false); + CCDBNodeLeaf *leafPosY = NLGUI::CDBManager::getInstance()->getDbProp(baseDbPath + toString(":%d:TARGET%d:Y", (int) k, (int) l), false); if (leafPosX && leafPosY) { CCompassTarget ct; diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index a493e3abe..0afbe81b5 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -586,7 +586,7 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) _CursorPos = 0; // loose the keyboard focus CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) + if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) { if(_LooseFocusOnEnter) pIM->setCaptureKeyboard(NULL); diff --git a/code/ryzom/client/src/interface_v3/group_html_forum.cpp b/code/ryzom/client/src/interface_v3/group_html_forum.cpp index 405b91645..079f319ff 100644 --- a/code/ryzom/client/src/interface_v3/group_html_forum.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_forum.cpp @@ -107,7 +107,7 @@ void CGroupHTMLForum::addHTTPPostParams (HTAssocList *formfields, bool /*trusted string CGroupHTMLForum::home () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:FORUM_UPDATED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FORUM_UPDATED")->setValue32(0); return Home; } diff --git a/code/ryzom/client/src/interface_v3/group_html_mail.cpp b/code/ryzom/client/src/interface_v3/group_html_mail.cpp index d527f0879..bff92ef0c 100644 --- a/code/ryzom/client/src/interface_v3/group_html_mail.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_mail.cpp @@ -76,7 +76,7 @@ void CGroupHTMLMail::addHTTPPostParams (HTAssocList *formfields, bool /*trustedD string CGroupHTMLMail::home () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:MAIL_WAITING")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIL_WAITING")->setValue32(0); return Home; } diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 38b92a8e2..0b84f7749 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -93,7 +93,7 @@ void addWebIGParams (string &url, bool trustedDomain) // Target fields const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false); if (node && (uint8)node->getValue32() != (uint8) CLFECOMMON::INVALID_SLOT) { CEntityCL *target = EntitiesMngr.entity((uint) node->getValue32()); @@ -195,7 +195,7 @@ struct CWebigNotificationThread : public NLMISC::IRunnable CInterfaceManager *pIM = CInterfaceManager::getInstance(); if(pIM) { - CCDBNodeLeaf *_CheckMailNode = pIM->getDbProp("UI:VARIABLES:MAIL_WAITING"); + CCDBNodeLeaf *_CheckMailNode = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIL_WAITING"); if(_CheckMailNode) { _CheckMailNode->setValue32(nbmail==0?0:1); @@ -222,7 +222,7 @@ struct CWebigNotificationThread : public NLMISC::IRunnable CInterfaceManager *pIM = CInterfaceManager::getInstance(); if(pIM) { - CCDBNodeLeaf *_CheckForumNode = pIM->getDbProp("UI:VARIABLES:FORUM_UPDATED"); + CCDBNodeLeaf *_CheckForumNode = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FORUM_UPDATED"); if(_CheckForumNode) { _CheckForumNode->setValue32(nbforum==0?0:1); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index cf5abc872..b29326aeb 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -48,7 +48,7 @@ void contextHelp (const std::string &name) CInterfaceManager *pIM = CInterfaceManager::getInstance(); // User want context help ? - if ( (ClientCfg.Local || !IngameDbMngr.initInProgress()) && pIM->getDbProp("UI:SAVE:ENTITY:CONTEXT_HELP")->getValueBool()) + if ( (ClientCfg.Local || !IngameDbMngr.initInProgress()) && NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ENTITY:CONTEXT_HELP")->getValueBool()) { // Look for the context help uint index = 0; @@ -519,7 +519,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t pViewSkillName->setText (sSkillName); // Skill value - CCDBNodeLeaf *skillLeaf = pIM->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); + CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false); if (skillLeaf) { pViewSkillName = dynamic_cast(group->getView("lvl")); @@ -831,11 +831,11 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, bool show = false; if (pChar->isUser()) - show = pIM->getDbProp ("UI:SAVE:INSCENE:USER:MESSAGES")->getValueBool(); + show = NLGUI::CDBManager::getInstance()->getDbProp ("UI:SAVE:INSCENE:USER:MESSAGES")->getValueBool(); else if (pChar->isFriend()) - show = pIM->getDbProp ("UI:SAVE:INSCENE:FRIEND:MESSAGES")->getValueBool(); + show = NLGUI::CDBManager::getInstance()->getDbProp ("UI:SAVE:INSCENE:FRIEND:MESSAGES")->getValueBool(); else - show = pIM->getDbProp ("UI:SAVE:INSCENE:ENEMY:MESSAGES")->getValueBool(); + show = NLGUI::CDBManager::getInstance()->getDbProp ("UI:SAVE:INSCENE:ENEMY:MESSAGES")->getValueBool(); if (show) { diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index d9fa10707..20929bf1b 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -130,7 +130,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) bool needPvPLogo= false; bool permanentContent = false; bool rpTags = false; - bool displayMissionIcons = pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); + bool displayMissionIcons = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); // Names const char *templateName; @@ -151,7 +151,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) string dbEntry = "UI:SAVE:INSCENE:SOURCE:"; CForageSourceCL *forageSource = static_cast(entity); - name = !entityName.empty() /*&& pIM->getDbProp(dbEntry+"NAME")->getValueBool()*/; + name = !entityName.empty() /*&& NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()*/; symbol = (forageSource->getKnowledge() != 0); title = false; guildName = false; @@ -159,7 +159,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) forageSourceBarDisplayed = (entity->slot() == UserEntity->selection()); bars[Time] = forageSourceBarDisplayed; bars[Amount] = forageSourceBarDisplayed; - //bool displayExtractingParams = true; //forageSource->isExtractionInProgress() /*&& pIM->getDbProp(dbEntry+"HP")*/; + //bool displayExtractingParams = true; //forageSource->isExtractionInProgress() /*&& NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"HP")*/; bars[Life] = forageSourceBarDisplayed;//displayExtractingParams; bars[Danger] = forageSourceBarDisplayed;//displayExtractingParams; bars[Spawn] = forageSourceBarDisplayed;//displayExtractingParams; @@ -177,22 +177,22 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) title= true; guildName= false; templateName = "in_scene_user_info"; - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && pIM->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); } else { // Base entry in database string dbEntry; getBarSettings( pIM, user, entity->isPlayer(), _friend, dbEntry, bars ); - name = !entityName.empty() && pIM->getDbProp(dbEntry+"NAME")->getValueBool(); - title = !entityTitle.empty() && pIM->getDbProp(dbEntry+"TITLE")->getValueBool(); - rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && pIM->getDbProp(dbEntry+"RPTAGS")->getValueBool(); + name = !entityName.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool(); + title = !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"TITLE")->getValueBool(); + rpTags = (!entityTag1.empty() || !entityTag2.empty() || !entityTag3.empty() || !entityTag4.empty() ) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"RPTAGS")->getValueBool(); // if name is empty but not title, title is displayed as name - if (!title && entityName.empty() && !entityTitle.empty() && pIM->getDbProp(dbEntry+"NAME")->getValueBool()) + if (!title && entityName.empty() && !entityTitle.empty() && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"NAME")->getValueBool()) title = true; templateName = "in_scene_user_info"; // special guild - if(pIM->getDbProp(dbEntry+"GUILD_SYMBOL")->getValueBool()) + if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_SYMBOL")->getValueBool()) { // if symbol not still available, wait for one when VP received symbol = (entity->getGuildSymbol() != 0); @@ -203,7 +203,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) symbol= false; needGuildSymbolId = false; } - if(pIM->getDbProp(dbEntry+"GUILD_NAME")->getValueBool()) + if(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"GUILD_NAME")->getValueBool()) { // if guild name not still available, wait for one when VP received guildName = (entity->getGuildNameID() != 0); @@ -214,7 +214,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) guildName= false; needGuildNameId= false; } - needPvPLogo = pIM->getDbProp(dbEntry+"PVP_LOGO")->getValueBool(); + needPvPLogo = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"PVP_LOGO")->getValueBool(); eventFaction = (entity->getEventFactionID() != 0); } @@ -537,7 +537,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) string dbLeaf = "UI:ENTITY:GUILD:"+toString (entity->slot()); sheet->setSheet(dbLeaf); - pIM->getDbProp(dbLeaf+":ICON")->setValue64(entity->getGuildSymbol()); + NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf+":ICON")->setValue64(entity->getGuildSymbol()); } } } @@ -548,7 +548,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) CViewBase * invisibleLogo = info->getView("invisible_logo"); if (entity->isUser() && invisibleLogo) { - bool invisible = pIM->getDbProp("SERVER:USER:IS_INVISIBLE")->getValueBool(); + bool invisible = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_INVISIBLE")->getValueBool(); invisibleLogo->setActive(invisible); } @@ -729,9 +729,9 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Init user leaf nodes if (entity->isUser()) { - _Value = pIM->getDbProp ("UI:VARIABLES:CURRENT_SMOOTH_SERVER_TICK"); - _ValueBegin = pIM->getDbProp ("UI:VARIABLES:SMOOTH_USER_ACT_START"); - _ValueEnd = pIM->getDbProp ("UI:VARIABLES:SMOOTH_USER_ACT_END"); + _Value = NLGUI::CDBManager::getInstance()->getDbProp ("UI:VARIABLES:CURRENT_SMOOTH_SERVER_TICK"); + _ValueBegin = NLGUI::CDBManager::getInstance()->getDbProp ("UI:VARIABLES:SMOOTH_USER_ACT_START"); + _ValueEnd = NLGUI::CDBManager::getInstance()->getDbProp ("UI:VARIABLES:SMOOTH_USER_ACT_END"); } // Update data @@ -806,11 +806,11 @@ void CGroupInSceneUserInfo::getBarSettings( CInterfaceManager* pIM, bool isUser, } else { - bars[HP] = pIM->getDbProp(dbEntry+"HP")->getValueBool(); - bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && pIM->getDbProp(dbEntry+"SAP")->getValueBool(); - bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && pIM->getDbProp(dbEntry+"STA")->getValueBool(); - bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && pIM->getDbProp(dbEntry+"FOCUS")->getValueBool(); - bars[Action] = (isUser) && pIM->getDbProp(dbEntry+"ACTION")->getValueBool(); + bars[HP] = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"HP")->getValueBool(); + bars[SAP] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"SAP")->getValueBool(); + bars[STA] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"STA")->getValueBool(); + bars[Focus] = (isUser || isFriend) && (isUser || isPlayer) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"FOCUS")->getValueBool(); + bars[Action] = (isUser) && NLGUI::CDBManager::getInstance()->getDbProp(dbEntry+"ACTION")->getValueBool(); } } @@ -934,7 +934,7 @@ void CGroupInSceneUserInfo::updateDynamicData () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dbLeaf = "UI:ENTITY:GUILD:"+toString (_Entity->slot())+":ICON"; - pIM->getDbProp(dbLeaf)->setValue64(_Entity->getGuildSymbol()); + NLGUI::CDBManager::getInstance()->getDbProp(dbLeaf)->setValue64(_Entity->getGuildSymbol()); } // Set the event faction diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index a47541b21..6cdd08bbc 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -117,12 +117,12 @@ static void popupLandMarkNameDialog() const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark); - im->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(userLM.Type); + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(userLM.Type); eb->setInputString(userLM.Title); } else { - im->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(CUserLandMark::Misc); + NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(CUserLandMark::Misc); eb->setInputString(ucstring()); } @@ -1060,9 +1060,9 @@ void CGroupMap::updateLMPosFromDBPos(CLandMarkButton *dest ,sint32 px, sint32 py static CSmartPtr buildMissionPositionState(CInterfaceManager *im, const std::string &baseDBpath, uint missionIndex, uint targetIndex) { nlassert(im); - CCDBNodeLeaf *name = im->getDbProp(baseDBpath + NLMISC::toString(":%d:TARGET%d:TITLE", (int) missionIndex, (int) targetIndex)); - CCDBNodeLeaf *x = im->getDbProp(baseDBpath + NLMISC::toString(":%d:TARGET%d:X", (int) missionIndex, (int) targetIndex)); - CCDBNodeLeaf *y = im->getDbProp(baseDBpath +NLMISC::toString(":%d:TARGET%d:Y", (int) missionIndex, (int) targetIndex)); + CCDBNodeLeaf *name = NLGUI::CDBManager::getInstance()->getDbProp(baseDBpath + NLMISC::toString(":%d:TARGET%d:TITLE", (int) missionIndex, (int) targetIndex)); + CCDBNodeLeaf *x = NLGUI::CDBManager::getInstance()->getDbProp(baseDBpath + NLMISC::toString(":%d:TARGET%d:X", (int) missionIndex, (int) targetIndex)); + CCDBNodeLeaf *y = NLGUI::CDBManager::getInstance()->getDbProp(baseDBpath +NLMISC::toString(":%d:TARGET%d:Y", (int) missionIndex, (int) targetIndex)); CSmartPtr ps = new CNamedEntityPositionState; ps->build(name, x, y); return ps; @@ -1096,8 +1096,8 @@ void CGroupMap::checkCoords() } } // also fill ptr for special landmarks (target, home & respawn) - _TargetPos = pIM->getDbProp(COMPASS_DB_PATH ":TARGET"); - _HomePos = pIM->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); + _TargetPos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":TARGET"); + _HomePos = NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT"); } // // bool mustInvalidateCoords = false; @@ -1218,9 +1218,9 @@ void CGroupMap::checkCoords() // Reset selection _RespawnSelected = 0; if (_MapMode == MapMode_Death) - pIM->getDbProp("UI:SAVE:RESPAWN_PT")->setValue32(_RespawnSelected); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RESPAWN_PT")->setValue32(_RespawnSelected); else if (_MapMode == MapMode_SpawnSquad) - pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT")->setValue32(_RespawnSelected); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT")->setValue32(_RespawnSelected); if (_RespawnLM.size() > 0) _RespawnSelectedBitmap->setParentPos(_RespawnLM[_RespawnSelected]); } @@ -1259,7 +1259,7 @@ void CGroupMap::checkCoords() _AnimalLM[i]->setActive(true); // update texture from animal status CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *statusNode = pIM->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d", i) + ":STATUS", false); + CCDBNodeLeaf *statusNode = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d", i) + ":STATUS", false); if (statusNode && ANIMAL_STATUS::isInStable((ANIMAL_STATUS::EAnimalStatus)statusNode->getValue32()) ) { _AnimalLM[i]->setTexture(_AnimalStableLMOptions.LandMarkTexNormal); @@ -1278,7 +1278,7 @@ void CGroupMap::checkCoords() // update tooltip text ANIMAL_TYPE::EAnimalType at; - at = (ANIMAL_TYPE::EAnimalType)pIM->getDbProp("SERVER:PACK_ANIMAL:BEAST"+toString(i)+":TYPE")->getValue32(); + at = (ANIMAL_TYPE::EAnimalType)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST"+toString(i)+":TYPE")->getValue32(); string sPrefix; switch(at) { @@ -1320,7 +1320,7 @@ void CGroupMap::checkCoords() if (_TeammatePosStates[i]->getPos(px, py)) { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint32 val = im->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); + uint32 val = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:GROUP:%d:NAME",i))->getValue32(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); ucstring res; @@ -2873,10 +2873,10 @@ void CGroupMap::targetLandmark(CCtrlButton *lm) fromString(sTmp, _RespawnSelected); CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (_MapMode == MapMode_Death) - pIM->getDbProp("UI:SAVE:RESPAWN_PT")->setValue32(_RespawnSelected); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RESPAWN_PT")->setValue32(_RespawnSelected); else if (_MapMode == MapMode_SpawnSquad) { - pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT")->setValue32(_RespawnSelected); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT")->setValue32(_RespawnSelected); // Close window containing the map CInterfaceGroup *pGrp = pIM->getWindow(this); if (pGrp != NULL) pGrp->setActive(false); @@ -3086,9 +3086,9 @@ sint32 CGroupMap::getRespawnSelected() const CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf *pNL = NULL; if (_MapMode == MapMode_Death) - pNL = pIM->getDbProp("UI:SAVE:RESPAWN_PT",false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RESPAWN_PT",false); else if (_MapMode == MapMode_SpawnSquad) - pNL = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT",false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT",false); if (pNL != NULL) return pNL->getValue32(); return 0; @@ -3103,9 +3103,9 @@ void CGroupMap::setRespawnSelected(sint32 nSpawnPointIndex) CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf *pNL = NULL; if (_MapMode == MapMode_Death) - pNL = pIM->getDbProp("UI:SAVE:RESPAWN_PT",false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:RESPAWN_PT",false); else if (_MapMode == MapMode_SpawnSquad) - pNL = pIM->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT",false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT",false); if (pNL != NULL) pNL->setValue32(nSpawnPointIndex); _RespawnSelected = nSpawnPointIndex; @@ -3205,7 +3205,7 @@ class CAHValidateUserLandMarkName : public IActionHandler CUserLandMark::EUserLandMarkType landMarkType = CUserLandMark::Misc; - sint8 nLandMarkType = im->getDbProp( "UI:TEMP:LANDMARKTYPE" )->getValue8(); + sint8 nLandMarkType = NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->getValue8(); if (nLandMarkType>=0 && nLandMarkType<=CUserLandMark::UserLandMarkTypeCount) { landMarkType = (CUserLandMark::EUserLandMarkType)nLandMarkType; @@ -3382,14 +3382,14 @@ class CAHRespawnMapValid : public IActionHandler - the user cannot reswpan.... Instead, I chose to hide the timer text in map.xml */ - /*sint64 val = im->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK")->getValue64(); - im->getDbProp("UI:VARIABLES:RESPAWN:END_DATE")->setValue64(val+10*10); - im->getDbProp("UI:VARIABLES:OPEN_RESPAWN_AT_TIME")->setValue64(0); + /*sint64 val = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK")->getValue64(); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:RESPAWN:END_DATE")->setValue64(val+10*10); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:OPEN_RESPAWN_AT_TIME")->setValue64(0); // must hide the window which contains this map, not the map itself!! CInterfaceGroup *rootWindow= gm->getRootWindow(); if(rootWindow) rootWindow->setActive(false); */ - im->getDbProp("UI:VARIABLES:RESPAWN:MSG_SENT")->setValue64(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:RESPAWN:MSG_SENT")->setValue64(1); } }; REGISTER_ACTION_HANDLER(CAHRespawnMapValid, "respawn_map_valid"); @@ -3479,36 +3479,36 @@ class CUpdateLandMarksColor : public IActionHandler{public: virtual void execute { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CUserLandMark::_LandMarksColor[CUserLandMark::Misc] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:MISC")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Tribe] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:TRIBE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Bandit] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:BANDIT")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Citizen] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:CITIZEN")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Fauna] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNA")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::FaunaExcel] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNAEXCEL")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::FaunaSup] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNASUP")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Forage] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::ForageExcel] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGEEXCEL")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::ForageSup] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGESUP")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Sap] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:SAP")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Amber] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:AMBER")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Node] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:NODE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Fiber] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FIBER")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Bark] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:BARK")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Seed] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:SEED")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Shell] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:SHELL")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Resin] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:RESIN")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Wood] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:WOOD")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Oil] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:OIL")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Mission] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:MISSION")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Food] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:FOOD")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Construction] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:CONSTRUCTION")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Goo] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:GOO")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Insect] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:INSECT")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Kitin] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:KITIN")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Nocive] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:NOCIVE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Preservative] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:PRESERVATIVE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Passage] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:PASSAGE")->getValueRGBA(); - CUserLandMark::_LandMarksColor[CUserLandMark::Teleporter] = pIM->getDbProp("UI:SAVE:LANDMARK:COLORS:TELEPORTER")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Misc] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:MISC")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Tribe] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:TRIBE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Bandit] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:BANDIT")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Citizen] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:CITIZEN")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Fauna] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNA")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::FaunaExcel] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNAEXCEL")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::FaunaSup] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FAUNASUP")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Forage] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::ForageExcel] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGEEXCEL")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::ForageSup] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FORAGESUP")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Sap] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:SAP")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Amber] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:AMBER")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Node] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:NODE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Fiber] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FIBER")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Bark] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:BARK")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Seed] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:SEED")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Shell] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:SHELL")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Resin] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:RESIN")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Wood] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:WOOD")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Oil] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:OIL")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Mission] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:MISSION")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Food] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:FOOD")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Construction] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:CONSTRUCTION")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Goo] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:GOO")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Insect] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:INSECT")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Kitin] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:KITIN")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Nocive] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:NOCIVE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Preservative] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:PRESERVATIVE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Passage] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:PASSAGE")->getValueRGBA(); + CUserLandMark::_LandMarksColor[CUserLandMark::Teleporter] = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:LANDMARK:COLORS:TELEPORTER")->getValueRGBA(); @@ -3531,7 +3531,7 @@ NLMISC_COMMAND( testMapHome, "Debug : test display of home on map", "" ) { if (!args.empty()) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp(COMPASS_DB_PATH ":HOME_POINT")->setValue64((((sint64) 4787 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3661 * 1000)); + NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":HOME_POINT")->setValue64((((sint64) 4787 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3661 * 1000)); return true; } /* @@ -3539,7 +3539,7 @@ NLMISC_COMMAND( testMapRespawn, "Debug : test display of respawn point on map", { if (!args.empty()) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp(COMPASS_DB_PATH ":BIND_POINT")->setValue64((((sint64) 4687 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3561 * 1000)); + NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT")->setValue64((((sint64) 4687 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3561 * 1000)); return true; } */ @@ -3574,7 +3574,7 @@ NLMISC_COMMAND( testRespawn, "Debug : test respawn map", "" ) /* CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp(COMPASS_DB_PATH ":BIND_POINT")->setValue64((((sint64) 4687 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3561 * 1000)); + NLGUI::CDBManager::getInstance()->getDbProp(COMPASS_DB_PATH ":BIND_POINT")->setValue64((((sint64) 4687 * 1000) << 32 )| (sint64) (uint32) ((sint64) -3561 * 1000)); */ return true; } diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index 8494e7213..a45487a8c 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -91,7 +91,7 @@ bool CGroupPhraseSkillFilter::parse (xmlNodePtr cur, CInterfaceGroup *parentGrou _BrickFamilyObs[k].Owner= this; _BrickFamilyObs[k].BrickFamily= (BRICK_FAMILIES::TBrickFamily)k; sTmp = string(DB_BRICKS)+":"+NLMISC::toString((sint32)k)+":BRICKS"; - pIM->addDBObserver (&(_BrickFamilyObs[k]), sTmp); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&(_BrickFamilyObs[k]), ICDBNode::CTextId( sTmp )); } _MustRebuild = true; diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 645149b46..234050eef 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -89,7 +89,7 @@ bool CGroupSkills::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) for (uint k = 0; k < SKILLS::NUM_SKILLS; ++k) { sTmp = string(DB_SKILLS)+":"+NLMISC::toString((sint32)k)+":BaseSKILL"; - pIM->addDBObserver (&_SkillsObs, sTmp); + NLGUI::CDBManager::getInstance()->getDB()->addObserver (&_SkillsObs, ICDBNode::CTextId( sTmp )); } _MustRebuild = true; @@ -283,7 +283,7 @@ CGroupSkills::~CGroupSkills() for (uint k = 0; k < SKILLS::NUM_SKILLS; ++k) { sTmp = string(DB_SKILLS)+":"+NLMISC::toString((sint32)k)+":BaseSKILL"; - pIM->removeDBObserver (&_SkillsObs, sTmp); + NLGUI::CDBManager::getInstance()->getDB()->removeObserver(&_SkillsObs, ICDBNode::CTextId( sTmp ) ); } // first remove any nodes from the tree group diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 44e3cd6fc..79a39c56d 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -163,7 +163,7 @@ void CGuildManager::sortGuildMembers(TSortOrder order) bool CGuildManager::isProxy() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - return pIM->getDbProp("SERVER:GUILD:PROXY")->getValueBool(); + return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:PROXY")->getValueBool(); } @@ -249,14 +249,14 @@ ucstring CGuildManager::getGuildName() uint64 CGuildManager::getMoney() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - return pIM->getDbProp("SERVER:GUILD:INVENTORY:MONEY")->getValue64(); + return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:MONEY")->getValue64(); } // *************************************************************************** uint64 CGuildManager::getXP() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - return pIM->getDbProp("SERVER:GUILD:XP")->getValue64(); + return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:XP")->getValue64(); } // *************************************************************************** @@ -275,12 +275,12 @@ void CGuildManager::update() // Guild stuff uint32 oldName = _Guild.NameID; - _Guild.NameID = pIM->getDbProp("SERVER:GUILD:NAME")->getValue32(); + _Guild.NameID = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValue32(); _Guild.Name = ""; _InGuild = (_Guild.NameID != 0); if (!_InGuild) closeAllInterfaces(); - _Guild.Icon = pIM->getDbProp("SERVER:GUILD:ICON")->getValue64(); + _Guild.Icon = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:ICON")->getValue64(); _Guild.QuitGuildAvailable = true; // Guild Members @@ -292,15 +292,15 @@ void CGuildManager::update() _GuildMembers.clear(); for (uint32 i = 0; i < MAX_GUILD_MEMBER; ++i) { - sint32 name = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":NAME")->getValue32(); + sint32 name = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":NAME")->getValue32(); if (name != 0) { SGuildMember gm; gm.NameID = name; gm.Index = i; - gm.Grade = (EGSPD::CGuildGrade::TGuildGrade)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":GRADE")->getValue32()); - gm.Online = (TCharConnectionState)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ONLINE")->getValue32()); - gm.EnterDate = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ENTER_DATE")->getValue32(); + gm.Grade = (EGSPD::CGuildGrade::TGuildGrade)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":GRADE")->getValue32()); + gm.Online = (TCharConnectionState)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ONLINE")->getValue32()); + gm.EnterDate = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ENTER_DATE")->getValue32(); _GuildMembers.push_back(gm); } } @@ -358,7 +358,7 @@ void CGuildManager::update() // If all is valid no more need update and if guild is opened update the interface if (bAllValid) { - CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_ONLINE_OFFLINE_NOTIFICATIONS_CB", false); + CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_ONLINE_OFFLINE_NOTIFICATIONS_CB", false); if (node && node->getValueBool()) { // See if we need to show any online/offline messages @@ -420,7 +420,7 @@ void CGuildManager::update() } // set this value in the database - pIM->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade); // update the guild display CGroupContainer *pGuild = dynamic_cast(pIM->getElementFromId(WIN_GUILD)); @@ -511,37 +511,37 @@ NLMISC_COMMAND(testAscensorPage, "Temp : Simulate the server that fills the data CInterfaceManager *im = CInterfaceManager::getInstance(); uint64 prop; // - im->getDbProp("LOCAL:ASCENSOR:0:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:0:NAME")->setValue32(12); prop = CGuildManager::iconMake(1, 1, false, CRGBA(255, 255, 0), CRGBA(0, 255, 0)); - im->getDbProp("LOCAL:ASCENSOR:0:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:0:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:1:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:1:NAME")->setValue32(12); prop = CGuildManager::iconMake(1, 2, false, CRGBA(0, 255, 255), CRGBA(255, 0, 255)); - im->getDbProp("LOCAL:ASCENSOR:1:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:1:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:2:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:2:NAME")->setValue32(12); prop = CGuildManager::iconMake(2, 3, false, CRGBA(255, 0, 0), CRGBA(0, 255, 0)); - im->getDbProp("LOCAL:ASCENSOR:2:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:2:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:3:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:3:NAME")->setValue32(12); prop = CGuildManager::iconMake(2, 4, false, CRGBA(255, 255, 0), CRGBA(0, 255, 255)); - im->getDbProp("LOCAL:ASCENSOR:3:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:3:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:4:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:4:NAME")->setValue32(12); prop = CGuildManager::iconMake(3, 5, false, CRGBA(255, 255, 0), CRGBA(255, 0, 255)); - im->getDbProp("LOCAL:ASCENSOR:4:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:4:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:5:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:5:NAME")->setValue32(12); prop = CGuildManager::iconMake(3, 6, false, CRGBA(0, 255, 255), CRGBA(255, 255, 0)); - im->getDbProp("LOCAL:ASCENSOR:5:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:5:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:6:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:6:NAME")->setValue32(12); prop = CGuildManager::iconMake(4, 7, false, CRGBA(0, 255, 255), CRGBA(255, 0, 255)); - im->getDbProp("SERVER:ASCENSOR:6:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:ASCENSOR:6:ICON")->setValue64(prop); // - im->getDbProp("LOCAL:ASCENSOR:7:NAME")->setValue32(12); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:7:NAME")->setValue32(12); prop = CGuildManager::iconMake(4, 8, false, CRGBA(255, 0, 255), CRGBA(0, 255, 255)); - im->getDbProp("LOCAL:ASCENSOR:7:ICON")->setValue64(prop); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:7:ICON")->setValue64(prop); return true; } @@ -593,7 +593,7 @@ void CGuildManager::openGuildWindow() // CInterfaceManager *pIM = CInterfaceManager::getInstance(); // // Open the guild window // -// CCDBNodeLeaf *node= pIM->getDbProp("CLIENT:GUILD:HAVE_JOINED", false); +// CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("CLIENT:GUILD:HAVE_JOINED", false); // if(node) // node->setValue64(1); // @@ -672,14 +672,14 @@ void CGuildManager::initDBObservers() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // add an observer on the whole guild - pIM->addBranchObserver( "SERVER:GUILD", &_DBObs ); + NLGUI::CDBManager::getInstance()->addBranchObserver( "SERVER:GUILD", &_DBObs ); // add an observer on members only => need to update all - pIM->addBranchObserver("SERVER:GUILD:MEMBERS", &_DBObsMembers); + NLGUI::CDBManager::getInstance()->addBranchObserver("SERVER:GUILD:MEMBERS", &_DBObsMembers); // observer on ascencors Ascensors.setListType(CHugeListObs::Ascensor); - pIM->addBranchObserver("SERVER:ASCENSOR", &Ascensors); + NLGUI::CDBManager::getInstance()->addBranchObserver("SERVER:ASCENSOR", &Ascensors); } // *************************************************************************** @@ -711,13 +711,13 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT CInterfaceManager *pIM = CInterfaceManager::getInstance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - uint32 nameID = pIM->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":NAME")->getValue32(); + uint32 nameID = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":NAME")->getValue32(); ucstring name; if (nameID && pSMC->getDynString(nameID, name)) { Text->setText(name); - uint64 icon = pIM->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":ICON")->getValue64(); + uint64 icon = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":ICON")->getValue64(); // Slot setup if ((icon & UINT64_CONSTANT(0x8000000000000000)) != 0) @@ -793,7 +793,7 @@ class CAHGuildSheetOpen : public IActionHandler // *** Update Members, if necessary if(updateMembers) { - CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); + CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); // Sort the members in Guild Manager pGM->sortGuildMembers(order); @@ -1007,7 +1007,7 @@ static void sendMsgSetGrade(EGSPD::CGuildGrade::TGuildGrade Grade) out.serial(u16MemberNb); uint8 u8Grade = Grade; out.serial(u8Grade); - uint8 u8Counter = (uint8)pIM->getDbProp("SERVER:GUILD:COUNTER")->getValue8(); + uint8 u8Counter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:COUNTER")->getValue8(); out.serial(u8Counter); NetMngr.push(out); //nlinfo("impulseCallBack : %s %d %d %d sent", message.c_str(), u16MemberNb, u8Grade, u8Counter); @@ -1026,7 +1026,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager* pIM= CInterfaceManager::getInstance(); - CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); + CGuildManager::TSortOrder order = (CGuildManager::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32()); order = (CGuildManager::TSortOrder)(order + 1); if (order == CGuildManager::END_SORT_ORDER) @@ -1034,7 +1034,7 @@ public: order = CGuildManager::START_SORT_ORDER; } - pIM->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->setValue32((sint32)order); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->setValue32((sint32)order); pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=1")); } }; @@ -1181,7 +1181,7 @@ class CAHGuildSheetKick : public IActionHandler { uint16 u16MemberNb = (uint16)rGuildMembers[MemberNb].Index; out.serial(u16MemberNb); - uint8 u8Counter = (uint8)pIM->getDbProp("SERVER:GUILD:COUNTER")->getValue8(); + uint8 u8Counter = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:COUNTER")->getValue8(); out.serial(u8Counter); NetMngr.push(out); //nlinfo("impulseCallBack : %s %d %d sent", message.c_str(), u16MemberNb, u8Counter); @@ -1230,8 +1230,8 @@ class CHandlerInvGuildToBag : public IActionHandler if (!pCSDst->isSheetValid()) return; string sTmp = pCSDst->getSheet(); - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp+":SHEET",false); - CCDBNodeLeaf *pNLquantity = pIM->getDbProp(sTmp+":QUANTITY",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false); + CCDBNodeLeaf *pNLquantity = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":QUANTITY",false); if (pNL == NULL) return; if (pNLquantity == NULL) return; @@ -1272,7 +1272,7 @@ class CHandlerInvGuildToBag : public IActionHandler if (!bPlaceFound) return; - uint16 Session = pIM->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); + uint16 Session = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); CBitMemStream out; const string sMsg = "GUILD:GUILD_TO_BAG"; @@ -1307,7 +1307,7 @@ class CHandlerInvBagToGuild : public IActionHandler uint8 BagIndex; fromString(sTmp, BagIndex); - uint16 Session = pIM->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); + uint16 Session = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); CBitMemStream out; const string sMsg = "GUILD:BAG_TO_GUILD"; @@ -1332,8 +1332,8 @@ REGISTER_ACTION_HANDLER (CHandlerInvBagToGuild, "inv_bag_to_guild"); static void sendMoneyServerMessage(const string &sMsg) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - uint64 nMoney = pIM->getDbProp("UI:VARIABLES:CHOOSE_MONEY")->getValue64(); - uint16 Session = pIM->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); + uint64 nMoney = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CHOOSE_MONEY")->getValue64(); + uint16 Session = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16(); CBitMemStream out; if (!GenericMsgHeaderMngr.pushNameToStream(sMsg, out)) { diff --git a/code/ryzom/client/src/interface_v3/interface_config.cpp b/code/ryzom/client/src/interface_v3/interface_config.cpp index 05f7d3b1c..b34db79f8 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.cpp +++ b/code/ryzom/client/src/interface_v3/interface_config.cpp @@ -706,7 +706,7 @@ void CInterfaceConfig::dataBaseToStream (NLMISC::IStream &f) // Save branch of the database SDBLeaf leafTmp; - CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE"); + CCDBNodeBranch *pDB = NLGUI::CDBManager::getInstance()->getDbBranch ("UI:SAVE"); if (pDB != NULL) { // Number of leaf to save @@ -742,7 +742,7 @@ void CInterfaceConfig::streamToDataBase (NLMISC::IStream &f, uint32 uiDbSaveVers // Load branch of the database SDBLeaf leafTmp; - CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE"); + CCDBNodeBranch *pDB = NLGUI::CDBManager::getInstance()->getDbBranch ("UI:SAVE"); if (pDB != NULL) { // Number of leaf to save @@ -776,7 +776,7 @@ void CInterfaceConfig::streamToDataBase (NLMISC::IStream &f, uint32 uiDbSaveVers // if want read the value from file, read it, else keep the default one if(wantRead) { - CCDBNodeLeaf *pNL = pIM->getDbProp(leafTmp.Name,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(leafTmp.Name,false); if (pNL != NULL) leafTmp.setTo(pNL); } diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index ff70ab120..c22c5204a 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -44,7 +44,7 @@ void CInterfaceDDX::CParam::DBToWidget() if (Widget == ColorButton) { CRGBA col = CRGBA::White; - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { uint32 intCol = (uint32)pNL->getValue32(); @@ -64,7 +64,7 @@ void CInterfaceDDX::CParam::DBToWidget() else if (Widget == BoolButton) { bool bVal = 0; - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { bVal = pNL->getValue32()==0?false:true; @@ -78,7 +78,7 @@ void CInterfaceDDX::CParam::DBToWidget() else if (Widget == ScrollBarInt) { sint32 nVal = 0; - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { nVal = pNL->getValue32(); @@ -154,7 +154,7 @@ void CInterfaceDDX::CParam::WidgetToDB() CCtrlBaseButton *pBut = dynamic_cast(Elt.getPtr()); if (pBut != NULL) col = pBut->getColor(); - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) pNL->setValue32(col.R+(col.G<<8)+(col.B<<16)+(col.A<<24)); } @@ -164,7 +164,7 @@ void CInterfaceDDX::CParam::WidgetToDB() CCtrlBaseButton *pBut = dynamic_cast(Elt.getPtr()); if (pBut != NULL) bVal = pBut->getPushed(); - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { pNL->setValue32(bVal?1:0); @@ -180,7 +180,7 @@ void CInterfaceDDX::CParam::WidgetToDB() CCtrlScroll *pCS = dynamic_cast(Elt.getPtr()); if (pCS != NULL) nVal = pCS->getValue(); - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) pNL->setValue32(nVal); } @@ -251,7 +251,7 @@ void CInterfaceDDX::CParam::backupDB() if (Widget == ColorButton) { CRGBA col = CRGBA::White; - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { uint32 intCol = (uint32)pNL->getValue32(); @@ -261,7 +261,7 @@ void CInterfaceDDX::CParam::backupDB() else if (Widget == ScrollBarInt) { sint32 nVal = 0; - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) { nVal = pNL->getValue32(); @@ -305,7 +305,7 @@ void CInterfaceDDX::CParam::restoreDB() if (Widget == ColorButton) { - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) pNL->setValue32(RTBackupValue); } @@ -315,7 +315,7 @@ void CInterfaceDDX::CParam::restoreDB() } else if (Widget == ScrollBarInt) { - CCDBNodeLeaf *pNL = pIM->getDbProp(Link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(Link,false); if (pNL != NULL) pNL->setValue32(RTBackupValue); } @@ -606,7 +606,7 @@ bool CInterfaceDDX::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) CXMLAutoPtr ptrPreset((const char*)xmlGetProp (cur, (xmlChar*)"preset")); if(ptrPreset) { - p.PresetDB = pIM->getDbProp((const char*)ptrPreset, false); + p.PresetDB = NLGUI::CDBManager::getInstance()->getDbProp((const char*)ptrPreset, false); if(p.PresetDB) { // if not exist in the set, add it and register callback @@ -791,7 +791,7 @@ void CInterfaceDDX::updateRealtime(CCtrlBase *pSB, bool updateOnScrollEnd) } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); for (i = 0; i < _Parameters.size(); ++i) { diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 47a11c3c3..34119f7fa 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -531,7 +531,7 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin sint32 decal = 0; if (val[0] == ':') decal = 1; - if (pIM->getDbProp(val+decal, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) { rIP.readSInt64 (val+decal, _Id+":"+prop); return; @@ -544,7 +544,7 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin while (pIEL != NULL) { sTmp = pIEL->getId()+":"+string(val+decal); - if (CInterfaceManager::getInstance()->getDbProp(sTmp, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) { rIP.readSInt64 (sTmp.c_str(), _Id+":"+prop); return; @@ -578,7 +578,7 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin sint32 decal = 0; if (val[0] == ':') decal = 1; - if (pIM->getDbProp(val+decal, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) { rIP.readSInt32 (val+decal, _Id+":"+prop); return; @@ -591,7 +591,7 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin while (pIEL != NULL) { sTmp = pIEL->getId()+":"+string(val+decal); - if (CInterfaceManager::getInstance()->getDbProp(sTmp, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) { rIP.readSInt32 (sTmp.c_str(), _Id+":"+prop); return; @@ -619,7 +619,7 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string sint32 decal = 0; if (val[0] == ':') decal = 1; - if (pIM->getDbProp(val+decal, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) { rIP.readBool (val+decal, _Id+":"+prop); return; @@ -632,7 +632,7 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string while (pIEL != NULL) { sTmp = pIEL->getId()+":"+string(val+decal); - if (CInterfaceManager::getInstance()->getDbProp(sTmp, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) { rIP.readBool (sTmp.c_str(), _Id+":"+prop); return; @@ -665,7 +665,7 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri sint32 decal = 0; if (val[0] == ':') decal = 1; - if (pIM->getDbProp(val+decal, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) { rIP.readRGBA (val+decal, _Id+":"+prop); return; @@ -678,7 +678,7 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri while (pIEL != NULL) { sTmp = pIEL->getId()+":"+string(val+decal); - if (CInterfaceManager::getInstance()->getDbProp(sTmp, false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) { rIP.readRGBA (sTmp.c_str(), _Id+":"+prop); return; diff --git a/code/ryzom/client/src/interface_v3/interface_expr.cpp b/code/ryzom/client/src/interface_v3/interface_expr.cpp index db184ef87..5888017ac 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr.cpp @@ -300,9 +300,9 @@ const char *CInterfaceExpr::evalDBEntry(const char *expr, CInterfaceExprValue &r expr = unpackDBentry(expr, nodes, dbEntry); if (!expr) return NULL; // TestYoyo - //nlassert(CInterfaceManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); // get the db value - CCDBNodeLeaf *nl = CInterfaceManager::getInstance()->getDbProp(dbEntry); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); if (nl) { if (nodes) @@ -318,7 +318,7 @@ const char *CInterfaceExpr::evalDBEntry(const char *expr, CInterfaceExprValue &r } else { - CCDBNodeBranch *nb = CInterfaceManager::getInstance()->getDbBranch(dbEntry); + CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); if (nodes && nb) { if (std::find(nodes->begin(), nodes->end(), nb) == nodes->end()) @@ -354,8 +354,8 @@ const char *CInterfaceExpr::buildDBEntryNode(const char *expr, CInterfaceExprNod else { // TestYoyo - //nlassert(CInterfaceManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); - CCDBNodeLeaf *nl = CInterfaceManager::getInstance()->getDbProp(dbEntry); + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); if (nl) { CInterfaceExprNodeDBLeaf *node = new CInterfaceExprNodeDBLeaf; @@ -365,7 +365,7 @@ const char *CInterfaceExpr::buildDBEntryNode(const char *expr, CInterfaceExprNod } else { - CCDBNodeBranch *nb = CInterfaceManager::getInstance()->getDbBranch(dbEntry); + CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); if (nb) { CInterfaceExprNodeDBBranch *node = new CInterfaceExprNodeDBBranch; @@ -418,8 +418,8 @@ const char *CInterfaceExpr::unpackDBentry(const char *expr, std::vectorgetDbProp(subEntry, false) || CInterfaceManager::getInstance()->getDbBranch(subEntry)); - CCDBNodeLeaf *nl = CInterfaceManager::getInstance()->getDbProp(subEntry); + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(subEntry, false) || CInterfaceManager::getInstance()->getDbBranch(subEntry)); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(subEntry); if (nodes) { if (std::find(nodes->begin(), nodes->end(), nl) == nodes->end()) diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp index 06595968b..dd67699f9 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp @@ -717,8 +717,8 @@ static DECLARE_INTERFACE_USER_FCT(userDBCount) while (!bExit) { sTmp = sFirstPart + NLMISC::toString(i) + sSecondPart; - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp,false); - CCDBNodeBranch *pNB = pIM->getDbBranch(sTmp); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false); + CCDBNodeBranch *pNB = NLGUI::CDBManager::getInstance()->getDbBranch(sTmp); if (pNL != NULL) { if (pNL->getValue64() == 0) @@ -1160,7 +1160,7 @@ static DECLARE_INTERFACE_USER_FCT(oldvalue) nlwarning("oldvalue : 1 arg required"); return false; } - CCDBNodeLeaf *nl = CInterfaceManager::getInstance()->getDbProp(args[0].getString()); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(args[0].getString()); if (!nl) { nlwarning("oldvalue : arg 0 required to be an interface leaf"); diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index d69956c0c..e71d37bdc 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -772,7 +772,7 @@ static DECLARE_INTERFACE_USER_FCT(isUserEntityDead) // Get the Visual Property for mode string dbName= toString("SERVER:Entities:E0:P%d", CLFECOMMON::PROPERTY_MODE ); - CCDBNodeLeaf *node= pIM->getDbProp(dbName, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbName, false); if(node) { result.setBool( node->getValue64()== MBEHAV::DEATH ); diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 447e7173f..0de076f35 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -542,7 +542,7 @@ static DECLARE_INTERFACE_USER_FCT(isRoomLeftFor) // see if there is room in the bags // get the number of bags std::string nbBagPath = im->getDefine("bag_nb"); - CCDBNodeLeaf *prop = im->getDbProp(nbBagPath); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp(nbBagPath); if (!prop) return false; uint nbItemInBags = 8 * (uint) prop->getValue32(); // there are 8 item per bag std::string bagsPath = im->getDefine("bag"); @@ -551,7 +551,7 @@ static DECLARE_INTERFACE_USER_FCT(isRoomLeftFor) for(k = 0; k < nbItemInBags; ++k) { std::string bagPath = bagsPath + ":" + toString(k) + ":SHEET"; - CCDBNodeLeaf *bagProp = im->getDbProp(bagPath); + CCDBNodeLeaf *bagProp = NLGUI::CDBManager::getInstance()->getDbProp(bagPath); if (!bagProp) return false; if (bagProp->getValue32() == 0) { @@ -583,7 +583,7 @@ static DECLARE_INTERFACE_USER_FCT(isRoomLeftFor) { std::string dbPath = im->getDefine(armourInfos[k].DefineName); if (dbPath.empty()) return false; - CCDBNodeLeaf *armorProp = im->getDbProp(dbPath + ":SHEET"); + CCDBNodeLeaf *armorProp = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":SHEET"); if (!armorProp) return false; if (armorProp->getValue32() == 0) { @@ -685,7 +685,7 @@ static double getItemsWeight(CCDBNodeBranch *branch, uint16 startItemIndex, uint static double getItemsWeight(const std::string &basePath, uint16 startItemIndex, uint16 numItems) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeBranch *branch = im->getDbBranch(basePath); + CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(basePath); if (!branch) { nlwarning(" Branch is NULL"); @@ -727,7 +727,7 @@ static double getItemBranchsWeight(const std::string &basePath, uint startBranch for(uint branchIndex = startBranchIndex; branchIndex < startBranchIndex + numBranchs; ++branchIndex) { std::string branchName = toString("%s:%d", basePath.c_str(), branchIndex); - CCDBNodeBranch *currBranch = im->getDbBranch(branchName); + CCDBNodeBranch *currBranch = NLGUI::CDBManager::getInstance()->getDbBranch(branchName); if (!currBranch) { nlwarning(" can't get branch %s:%d, or this is a leaf", basePath.c_str(), branchIndex); @@ -786,7 +786,7 @@ static double getWeightOfEquipmentPieces(const SLOT_EQUIPMENT::TSlotEquipment * for(uint k = 0; k < numSlots; ++k) { std::string dbPath = NLMISC::toString("LOCAL:INVENTORY:8:%d:SHEET", (int) slots[k]); - uint32 sheetID = im->getDbProp(dbPath)->getValue32(); + uint32 sheetID = NLGUI::CDBManager::getInstance()->getDbProp(dbPath)->getValue32(); if (sheetID) { CEntitySheet *es = SheetMngr.get(CSheetId(sheetID)); @@ -862,7 +862,7 @@ REGISTER_INTERFACE_USER_FCT("getJewelryWeight", getJewelryWeightUserFct) static double getSheathsWeight() { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint numSheaths = (uint) im->getDbProp("LOCAL:INVENTORY:NB_SHEATH")->getValue32(); + uint numSheaths = (uint) NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:NB_SHEATH")->getValue32(); return getItemBranchsWeight("LOCAL:INVENTORY", 1, numSheaths); } @@ -883,7 +883,7 @@ REGISTER_INTERFACE_USER_FCT("getSheathsWeight", getSheathsWeightUserFct) static double getBagsWeight() { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint numBags = (uint) im->getDbProp("LOCAL:INVENTORY:NB_BAG")->getValue32(); + uint numBags = (uint) NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:NB_BAG")->getValue32(); return getItemsWeight("LOCAL:INVENTORY:9", 0, 8 * numBags); } @@ -913,7 +913,7 @@ static DECLARE_INTERFACE_USER_FCT(getBranchSheetCategory) return false; } CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeBranch *branch = im->getDbBranch(args[0].getString()); + CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(args[0].getString()); if (!branch) { nlwarning(" Branch is NULL"); diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 582736412..c59b5b01f 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -24,6 +24,7 @@ #include "interface_manager.h" #include "interface_expr_node.h" #include "nel/gui/reflect.h" +#include "nel/gui/db_manager.h" #include "nel/misc/cdb_branch.h" using namespace std; @@ -132,7 +133,7 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() { - CInterfaceManager::getInstance()->addFlushObserver( this ); + NLGUI::CDBManager::getInstance()->addFlushObserver( this ); } CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() @@ -275,7 +276,7 @@ void CInterfaceLink::createObservers(const TNodeVect &nodes) else { CCDBNodeBranch *br = static_cast(*it); - CInterfaceManager::getInstance()->addBranchObserver( br, this ); + NLGUI::CDBManager::getInstance()->addBranchObserver( br, this ); } } } @@ -293,7 +294,7 @@ void CInterfaceLink::removeObservers(const TNodeVect &nodes) else { CCDBNodeBranch *br = static_cast(*it); - CInterfaceManager::getInstance()->removeBranchObserver( br, this ); + NLGUI::CDBManager::getInstance()->removeBranchObserver( br, this ); } } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 1ad33bdb4..89fccdb3e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -259,12 +259,12 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) : -_ViewRenderer( driver, textcontext ), -NLMISC::CCDBManager( "ROOT", NB_CDB_BANKS ) +_ViewRenderer( driver, textcontext ) { this->driver = driver; this->textcontext = textcontext; _Instance = this; + NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; @@ -363,13 +363,6 @@ CInterfaceManager::~CInterfaceManager() _Templates.clear(); _Instance = NULL; - if (_Database) - { - _Database->clear(); - delete _Database; - _Database = NULL; - } - // release the local string mapper delete _UIStringMapper; _UIStringMapper = NULL; @@ -377,9 +370,11 @@ CInterfaceManager::~CInterfaceManager() // release the database observers releaseServerToLocalAutoCopyObservers(); + /* removeFlushObserver( interfaceLinkUpdater ); delete interfaceLinkUpdater; interfaceLinkUpdater = NULL; + */ } // ------------------------------------------------------------------------------------------------ @@ -515,7 +510,7 @@ void CInterfaceManager::uninitLogin() CInterfaceLink::removeAllLinks(); ICDBNode::CTextId textId("UI"); - _Database->removeNode(textId); + NLGUI::CDBManager::getInstance()->getDB()->removeNode(textId); { uninitActions(); @@ -640,7 +635,7 @@ void CInterfaceManager::uninitOutGame() //nlinfo ("%d seconds for removeAllLinks", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); ICDBNode::CTextId textId("UI"); - _Database->removeNode(textId); + NLGUI::CDBManager::getInstance()->getDB()->removeNode(textId); //nlinfo ("%d seconds for removeNode", (uint32)(ryzomGetLocalTime ()-initStart)/1000); // Init the action manager @@ -800,8 +795,8 @@ void CInterfaceManager::initInGame() activateMasterGroup ("ui:interface", true); // Update the time in the ui database - _CheckMailNode = getDbProp("UI:VARIABLES:MAIL_WAITING"); - _CheckForumNode = getDbProp("UI:VARIABLES:FORUM_UPDATED"); + _CheckMailNode = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIL_WAITING"); + _CheckForumNode = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FORUM_UPDATED"); // Init the action manager { @@ -842,7 +837,7 @@ void CInterfaceManager::initInGame() gc->setTarget(gc->getSavedTarget()); } - CCDBNodeLeaf *node = getDbProp("UI:SAVE:CHATLOG_STATE", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHATLOG_STATE", false); if (node) { _LogState = (node->getValue32() != 0); @@ -1174,7 +1169,7 @@ void CInterfaceManager::uninitInGame1 () // remove DB entry ICDBNode::CTextId textId("UI"); - _Database->removeNode(textId); + NLGUI::CDBManager::getInstance()->getDB()->removeNode(textId); // Uninit the action manager { @@ -1251,7 +1246,7 @@ void CInterfaceManager::updateFrameEvents() pIA->update(); } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // // Next : Test if we have to remove anims for (i = 0; i < (sint)_ActiveAnims.size(); ++i) @@ -1265,7 +1260,7 @@ void CInterfaceManager::updateFrameEvents() } // IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Handle waiting texts from server processServerIDString(); @@ -1358,7 +1353,7 @@ void CInterfaceManager::updateFrameEvents() (*it)->handleEvent(clockTick); } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Update SPhrase manager CSPhraseManager *pPM= CSPhraseManager::getInstance(); @@ -1511,17 +1506,17 @@ void CInterfaceManager::setupOptions() bool CInterfaceManager::parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename) { // cache some commonly used db nodes - _DBB_UI_DUMMY = getDbBranch( "UI:DUMMY" ); - _DB_UI_DUMMY_QUANTITY = getDbProp( "UI:DUMMY:QUANTITY", true ); - _DB_UI_DUMMY_QUALITY = getDbProp( "UI:DUMMY:QUALITY", true ); - _DB_UI_DUMMY_SHEET = getDbProp( "UI:DUMMY:SHEET", true ); - _DB_UI_DUMMY_NAMEID = getDbProp( "UI:DUMMY:NAMEID", true ); - _DB_UI_DUMMY_ENCHANT = getDbProp( "UI:DUMMY:ENCHANT", true ); - _DB_UI_DUMMY_SLOT_TYPE = getDbProp( "UI:DUMMY:SLOT_TYPE", true ); - _DB_UI_DUMMY_PHRASE = getDbProp( "UI:DUMMY:PHRASE", true ); - _DB_UI_DUMMY_WORNED = getDbProp( "UI:DUMMY:WORNED", true ); - _DB_UI_DUMMY_PREREQUISIT_VALID = getDbProp( "UI:DUMMY:PREREQUISIT_VALID", true ); - _DB_UI_DUMMY_FACTION_TYPE = getDbProp( "UI:DUMMY:FACTION_TYPE", true ); + _DBB_UI_DUMMY = NLGUI::CDBManager::getInstance()->getDbBranch( "UI:DUMMY" ); + _DB_UI_DUMMY_QUANTITY = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:QUANTITY", true ); + _DB_UI_DUMMY_QUALITY = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:QUALITY", true ); + _DB_UI_DUMMY_SHEET = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:SHEET", true ); + _DB_UI_DUMMY_NAMEID = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:NAMEID", true ); + _DB_UI_DUMMY_ENCHANT = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:ENCHANT", true ); + _DB_UI_DUMMY_SLOT_TYPE = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:SLOT_TYPE", true ); + _DB_UI_DUMMY_PHRASE = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:PHRASE", true ); + _DB_UI_DUMMY_WORNED = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:WORNED", true ); + _DB_UI_DUMMY_PREREQUISIT_VALID = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:PREREQUISIT_VALID", true ); + _DB_UI_DUMMY_FACTION_TYPE = NLGUI::CDBManager::getInstance()->getDbProp( "UI:DUMMY:FACTION_TYPE", true ); _DB_UI_DUMMY_QUANTITY->setValue64(0); _DB_UI_DUMMY_QUALITY->setValue64(0); @@ -1646,10 +1641,10 @@ bool CInterfaceManager::loadConfig (const string &filename) // special for in game: backup last mission because of delayed update { - CCDBNodeLeaf *pNL = getDbProp("UI:SAVE:MISSION_SELECTED", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:MISSION_SELECTED", false); if (pNL) { - CCDBNodeLeaf *pSelectedMissionBackup = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION", true); + CCDBNodeLeaf *pSelectedMissionBackup = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION", true); pSelectedMissionBackup->setValue64(pNL->getValue64()); } } @@ -1665,7 +1660,7 @@ bool CInterfaceManager::loadConfig (const string &filename) // Load user landmarks ContinentMngr.serialUserLandMarks(f); - CCDBNodeLeaf *pNL = getDbProp( "SERVER:INTERFACES:NB_BONUS_LANDMARKS" ); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp( "SERVER:INTERFACES:NB_BONUS_LANDMARKS" ); if ( pNL ) { ICDBNode::CTextId textId; @@ -1723,7 +1718,7 @@ bool CInterfaceManager::loadConfig (const string &filename) _Modes[_CurrentMode].toCurrentDesktop(); // *** Apply the NPC icon display mode - CNPCIconCache::getInstance().init(!ClientCfg.R2EDEnabled && getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool()); + CNPCIconCache::getInstance().init(!ClientCfg.R2EDEnabled && NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool()); return true; } @@ -2004,7 +1999,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) _ViewRenderer.activateWorldSpaceMatrix (false); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // If an element has captured the keyboard, make sure it is alway visible (all parent windows active) if (_CaptureKeyboard != NULL) @@ -2037,25 +2032,25 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) } // Update global color from database - _GlobalColor = CRGBA ( (uint8)getDbProp("UI:SAVE:COLOR:R")->getValue32(), - (uint8)getDbProp("UI:SAVE:COLOR:G")->getValue32(), - (uint8)getDbProp("UI:SAVE:COLOR:B")->getValue32(), - (uint8)getDbProp("UI:SAVE:COLOR:A")->getValue32() ); + _GlobalColor = CRGBA ( (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R")->getValue32(), + (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G")->getValue32(), + (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B")->getValue32(), + (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A")->getValue32() ); _GlobalColorForContent.R = _GlobalColor.R; _GlobalColorForContent.G = _GlobalColor.G; _GlobalColorForContent.B = _GlobalColor.B; _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8); // Update global alphaS from database - _GlobalContentAlpha = (uint8)getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); - _GlobalContainerAlpha = (uint8)getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); - _GlobalRolloverFactorContent = (uint8)getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); - _GlobalRolloverFactorContainer = (uint8)getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); + _GlobalContentAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); + _GlobalContainerAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); + _GlobalRolloverFactorContent = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); + _GlobalRolloverFactorContainer = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); // Update Player characteristics (for Item carac requirement Redifying) nlctassert(CHARACTERISTICS::NUM_CHARACTERISTICS==8); for (uint i=0; igetDbValue32(toString("SERVER:CHARACTER_INFO:CHARACTERISTICS%d:VALUE", i)); // _CurrentPlayerCharac[CHARACTERISTICS::constitution]= getDbValue32("SERVER:CHARACTER_INFO:CHARACTERISTICS:Constitution"); // _CurrentPlayerCharac[CHARACTERISTICS::constitution]= getDbValue32("SERVER:CHARACTER_INFO:CHARACTERISTICS:Constitution"); @@ -2077,7 +2072,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) Computed String are rendered in on big drawQuads at last part of each layer */ IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { @@ -2129,7 +2124,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) H_AUTO ( RZ_Interface_DrawViews_After ) IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // draw the special over extend text drawOverExtendViewText(); @@ -2178,7 +2173,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // flush obs IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } } @@ -2626,10 +2621,10 @@ void CInterfaceManager::setGlobalColor (NLMISC::CRGBA col) { if (!_RProp) { - _RProp = getDbProp("UI:SAVE:COLOR:R"); - _GProp = getDbProp("UI:SAVE:COLOR:G"); - _BProp = getDbProp("UI:SAVE:COLOR:B"); - _AProp = getDbProp("UI:SAVE:COLOR:A"); + _RProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); + _GProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); + _BProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); + _AProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); } _RProp ->setValue32 (col.R); _GProp ->setValue32 (col.G); @@ -2766,7 +2761,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool result = _CaptureKeyboard->handleEvent(event); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); return result; } else @@ -2824,7 +2819,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool result = _CaptureKeyboard->handleEvent(event); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); return result; } } @@ -3105,7 +3100,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // event handled? return handled; } @@ -3407,18 +3402,6 @@ void CInterfaceManager::updateAllLocalisedElements() } -// ------------------------------------------------------------------------------------------------ -bool CInterfaceManager::addDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id) -{ - return _Database->addObserver(observer, id); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceManager::removeDBObserver (ICDBNode::IPropertyObserver* observer, ICDBNode::CTextId id) -{ - return _Database->removeObserver(observer, id); -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::addServerString (const std::string &sTarget, uint32 id, IStringProcess *cb) { @@ -3501,28 +3484,6 @@ void CInterfaceManager::processServerIDString() } } -// ------------------------------------------------------------------------------------------------ -sint32 CInterfaceManager::getDbValue32 (const std::string & name) -{ - CCDBNodeLeaf *node= getDbProp(name, false); - if(node) - return node->getValue32(); - else - return 0; -} - -// ------------------------------------------------------------------------------------------------ -CCDBNodeLeaf* CInterfaceManager::getDbProp(const std::string & name, bool bCreate) -{ - return getDbLeaf( name, bCreate ); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::delDbProp(const std::string & name) -{ - delDbNode( name ); -} - // ------------------------------------------------------------------------------------------------ CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y) { @@ -4443,9 +4404,9 @@ NLMISC::CRGBA CInterfaceManager::getDebugInfoColor(TSystemInfoMode mode) if (_NeutralColor == NULL) // not initialised ? { #define SYSTEM_INFO_COLOR_DB_PATH "UI:VARIABLES:SYSTEM_INFOS:COLORS" - _NeutralColor = getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":NEUTRAL"); - _WarningColor = getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":WARNING"); - _ErrorColor = getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":ERROR"); + _NeutralColor = NLGUI::CDBManager::getInstance()->getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":NEUTRAL"); + _WarningColor = NLGUI::CDBManager::getInstance()->getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":WARNING"); + _ErrorColor = NLGUI::CDBManager::getInstance()->getDbProp(SYSTEM_INFO_COLOR_DB_PATH ":ERROR"); } NLMISC::CRGBA color; switch(mode) @@ -5099,7 +5060,7 @@ void CInterfaceManager::removeRefOnGroup (CInterfaceGroup *group) uint CInterfaceManager::getUserDblClickDelay() { uint nVal = 50; - CCDBNodeLeaf *pNL = getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED"); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED"); if (pNL != NULL) nVal = pNL->getValue32(); uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f); @@ -5725,7 +5686,7 @@ void CInterfaceManager::connectYuboChat() _YuboChat.connect(string("chat.ryzom.com:")+toString(KlientChatPort), LoginLogin, LoginPassword); // Inform the interface that the chat is present - getDbProp("UI:VARIABLES:YUBO_CHAT_PRESENT")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:YUBO_CHAT_PRESENT")->setValue32(1); } } @@ -6049,7 +6010,7 @@ void CInterfaceManager::createLocalBranch(const std::string &fileName, NLMISC::I //Parse the parser output!!! CCDBNodeBranch *localNode = new CCDBNodeBranch("LOCAL"); localNode->init( read.getRootNode (), progressCallBack ); - _Database->attachChild(localNode,"LOCAL"); + NLGUI::CDBManager::getInstance()->getDB()->attachChild(localNode,"LOCAL"); // Create the observers for auto-copy SERVER->LOCAL of inventory ServerToLocalAutoCopyInventory.init("INVENTORY"); @@ -6131,21 +6092,21 @@ void CInterfaceManager::CServerToLocalAutoCopy::init(const std::string &dbPath) CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Get the synchronisation Counter in Server DB - _ServerCounter= pIM->getDbProp(string("SERVER:") + dbPath + ":COUNTER", false); + _ServerCounter= NLGUI::CDBManager::getInstance()->getDbProp(string("SERVER:") + dbPath + ":COUNTER", false); // if found if(_ServerCounter) { // **** Add Observers on all nodes // add the observers when server node change - pIM->addDBObserver(&_ServerObserver, string("SERVER:") + dbPath); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&_ServerObserver, ICDBNode::CTextId( string("SERVER:") + dbPath ) ); // add the observers when local node change - pIM->addDBObserver(&_LocalObserver, string("LOCAL:") + dbPath); + NLGUI::CDBManager::getInstance()->getDB()->addObserver(&_LocalObserver, ICDBNode::CTextId( string("LOCAL:") + dbPath ) ); // **** Init the Nodes shortcut // Parse all Local Nodes - CCDBNodeBranch *localBranch= pIM->getDbBranch(string("LOCAL:") + dbPath); + CCDBNodeBranch *localBranch= NLGUI::CDBManager::getInstance()->getDbBranch(string("LOCAL:") + dbPath); if(localBranch) { uint i; @@ -6169,7 +6130,7 @@ void CInterfaceManager::CServerToLocalAutoCopy::init(const std::string &dbPath) serverLeafStr= "SERVER:" + serverLeafStr; // try then to get this server node - CCDBNodeLeaf *serverLeaf= pIM->getDbProp(serverLeafStr, false); + CCDBNodeLeaf *serverLeaf= NLGUI::CDBManager::getInstance()->getDbProp(serverLeafStr, false); if(serverLeaf) { // Both server and local leaves exist, ok, append to _Nodes @@ -6465,11 +6426,11 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) if (indexInTeam < PeopleInterraction.TeamList.getNumPeople() ) { // Index is the database index (serverIndex() not used for team list) - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString(TEAM_DB_PATH ":%hu:NAME", indexInTeam ), false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp( NLMISC::toString(TEAM_DB_PATH ":%hu:NAME", indexInTeam ), false); if (pNL && pNL->getValueBool() ) { // There is a character corresponding to this index - pNL = CInterfaceManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:UID", indexInTeam ), false ); + pNL = NLGUI::CDBManager::getInstance()->getDbProp( NLMISC::toString( TEAM_DB_PATH ":%hu:UID", indexInTeam ), false ); if (pNL) { CLFECOMMON::TClientDataSetIndex compressedIndex = pNL->getValue32(); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 550a5e867..66c7a7987 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -43,6 +43,7 @@ #include "flying_text_manager.h" #include "nel/gui/input_event_listener.h" +#include "nel/gui/db_manager.h" // CLIENT #include "../string_manager_client.h" @@ -77,7 +78,7 @@ class CGroupMenu; * \author Nevrax France * \date 2002 */ -class CInterfaceManager : public CInterfaceParser, public NLMISC::CCDBManager, public NLGUI::IInputEventListener +class CInterfaceManager : public CInterfaceParser, public NLGUI::IInputEventListener { public: @@ -229,15 +230,6 @@ public: void addServerID (const std::string &sTarget, uint32 id, IStringProcess *cb = NULL); void processServerIDString(); - - /// Get the root of the database - NLMISC::CCDBNodeBranch *getDB() const { return _Database; } - // yoyo: should avoid to try creating DbPropr with this system... very dangerous - NLMISC::CCDBNodeLeaf* getDbProp (const std::string & name, bool bCreate=true); - void delDbProp(const std::string & name); - // return the DB as an int32. return 0 if the DB does not exist (never create) - sint32 getDbValue32 (const std::string & name); - /** * get the window under a spot * \param : X coord of the spot @@ -443,33 +435,6 @@ public: // display a system info string void displaySystemInfo(const ucstring &str, const std::string &Category = "SYS"); NLMISC::CRGBA getSystemInfoColor(const std::string &Category = "SYS"); - /** - * add an observer to a database entry - * \param observer : pointer on the observer - * \param id : the text id of the element to observe - * \return true if success - */ - bool addDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, NLMISC::ICDBNode::CTextId id); - - /** - * add an observer to a database entry - * \param observer : pointer on the observer - * \param id : the text id of the element to observe - * \return true if success - */ - bool addDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, const std::string& id) - { - return addDBObserver(observer, NLMISC::ICDBNode::CTextId(id)); - } - - /** remove the observer from the dataBase - */ - bool removeDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, NLMISC::ICDBNode::CTextId id); - bool removeDBObserver (NLMISC::ICDBNode::IPropertyObserver* observer, const std::string& id) - { - return removeDBObserver(observer, NLMISC::ICDBNode::CTextId(id)); - } - /// \name Global Interface Options // @{ @@ -671,7 +636,7 @@ public: float getAlphaRolloverSpeed() { if (!_AlphaRolloverSpeedDB) - _AlphaRolloverSpeedDB = getDbProp("UI:SAVE:ALPHA_ROLLOVER_SPEED"); + _AlphaRolloverSpeedDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ALPHA_ROLLOVER_SPEED"); float fTmp = ROLLOVER_MIN_DELTA_PER_MS + (ROLLOVER_MAX_DELTA_PER_MS - ROLLOVER_MIN_DELTA_PER_MS) * 0.01f * (100 - _AlphaRolloverSpeedDB->getValue32()); return fTmp*fTmp*fTmp; } diff --git a/code/ryzom/client/src/interface_v3/interface_observer.h b/code/ryzom/client/src/interface_v3/interface_observer.h index da508aeb7..fb5d69679 100644 --- a/code/ryzom/client/src/interface_v3/interface_observer.h +++ b/code/ryzom/client/src/interface_v3/interface_observer.h @@ -121,7 +121,7 @@ public: while(dataTok) { std::string data (dataTok); - if (iMngr->getDbProp(data,false) == NULL) // Full path provided ? No. + if (NLGUI::CDBManager::getInstance()->getDbProp(data,false) == NULL) // Full path provided ? No. { CInterfaceGroup *parent = parentGroup; while (parent != NULL) @@ -131,19 +131,19 @@ public: sTmp = parent->getId() + data; else sTmp = parent->getId() + ":" + data; - if (iMngr->getDbProp(sTmp,false) != NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false) != NULL) { data = sTmp; break; } parent = parent->getParent(); } - if (iMngr->getDbProp(data,false) == NULL) + if (NLGUI::CDBManager::getInstance()->getDbProp(data,false) == NULL) { std::string sTmp = std::string("data (")+std::string(dataTok)+std::string(") in a observer tag do not exist, CREATING!"); nlinfo (sTmp.c_str()); data = (const char*)dataTok; - iMngr->getDbProp (data, true); + NLGUI::CDBManager::getInstance()->getDbProp (data, true); } } if ( !obs ) @@ -160,7 +160,7 @@ public: return NULL; } } - if ( ! iMngr->addDBObserver(obs,NLMISC::ICDBNode::CTextId (data) ) ) + if ( ! NLGUI::CDBManager::getInstance()->getDB()->addObserver(obs,NLMISC::ICDBNode::CTextId (data) ) ) { return NULL; } diff --git a/code/ryzom/client/src/interface_v3/interface_property.cpp b/code/ryzom/client/src/interface_v3/interface_property.cpp index 8aec3db0c..35a6b5329 100644 --- a/code/ryzom/client/src/interface_v3/interface_property.cpp +++ b/code/ryzom/client/src/interface_v3/interface_property.cpp @@ -52,12 +52,12 @@ bool CInterfaceProperty::link( CCDBNodeBranch *dbNode, const string &leafId, CCD bool CInterfaceProperty::link (const char *DBProp) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(DBProp, false); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp, false); if (_VolatileValue == NULL) { nlinfo("prop not created : %s", DBProp); - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(DBProp); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp); return false; } return true; @@ -75,7 +75,7 @@ void CInterfaceProperty::readSInt64(const char * ptr,const string& id) //the value is volatile, and a database entry is created if ( isdigit(*ptr) || *ptr=='-') { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); sint64 i; fromString(ptr, i); _VolatileValue->setValue64( i ); @@ -83,7 +83,7 @@ void CInterfaceProperty::readSInt64(const char * ptr,const string& id) //the value is volatile and points to a db entry created elsewhere else { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } } @@ -101,7 +101,7 @@ void CInterfaceProperty::readDouble(const char * ptr,const string& id) string str (ptr); if ( isdigit(*ptr) || *ptr=='-') { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); double buf; fromString(ptr, buf); sint64 i = *(sint64*)&buf; @@ -109,7 +109,7 @@ void CInterfaceProperty::readDouble(const char * ptr,const string& id) } else { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } } @@ -125,7 +125,7 @@ void CInterfaceProperty::readSInt32 (const char *ptr, const string& id) //the value is volatile, and a database entry is created if ( isdigit(*ptr) || *ptr=='-') { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); sint32 i; fromString(ptr, i); _VolatileValue->setValue32( i ); @@ -133,7 +133,7 @@ void CInterfaceProperty::readSInt32 (const char *ptr, const string& id) //the value is volatile and points to a db entry created elsewhere else { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } } @@ -165,7 +165,7 @@ void CInterfaceProperty::readRGBA (const char *value,const string& id) string str (value); if (isdigit(*value)) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); int r=0, g=0, b=0, a=255; sscanf (value, "%d %d %d %d", &r, &g, &b, &a); clamp (r, 0, 255); @@ -178,7 +178,7 @@ void CInterfaceProperty::readRGBA (const char *value,const string& id) } else { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } } @@ -188,52 +188,52 @@ void CInterfaceProperty::readHotSpot (const char *ptr,const string& id) string str(ptr); if ( !strcmp(ptr,"TL") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64((sint64)Hotspot_TL ); } else if ( !strcmp(ptr,"TM") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_TM ); } else if ( !strcmp(ptr,"TR") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_TR ); } else if ( !strcmp(ptr,"ML") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_ML ); } else if ( !strcmp(ptr,"MM") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_MM ); } else if ( !strcmp(ptr,"MR") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_MR ); } else if ( !strcmp(ptr,"BL") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_BL ); } else if ( !strcmp(ptr,"BM") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_BM ); } else if ( !strcmp(ptr,"BR") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue64( (sint64)Hotspot_BR ); } else - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } @@ -252,23 +252,23 @@ void CInterfaceProperty::readBool (const char* value,const string& id) string str (value); if ( !strcmp(value,"true") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue8( (sint8)true ); } else if ( !strcmp(value,"false") ) { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); _VolatileValue->setValue8( (sint8)false ); } else if ( isdigit(*value) || *value=='-') { - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(id); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); sint8 value8; fromString(value, value8); _VolatileValue->setValue8( value8 ); } else - _VolatileValue = CInterfaceManager::getInstance()->getDbProp(str); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); } diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index bb050520e..7069d2a12 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -302,14 +302,14 @@ void CInventoryManager::init() // LOCAL DB initItemArray(LOCAL_INVENTORY ":BAG", Bag, MAX_BAGINV_ENTRIES); initItemArray(LOCAL_INVENTORY ":TEMP", TempInv, MAX_TEMPINV_ENTRIES); - Money = im->getDbProp(LOCAL_INVENTORY ":MONEY"); + Money = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":MONEY"); initIndirection (LOCAL_INVENTORY ":HAND:", Hands, MAX_HANDINV_ENTRIES, true); initIndirection (LOCAL_INVENTORY ":EQUIP:", Equip, MAX_EQUIPINV_ENTRIES, true); // Init observers for auto equipment { for (uint i = 0; i < MAX_BAGINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNL = im->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(i) + ":SHEET"); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(i) + ":SHEET"); ICDBNode::CTextId textId; pNL->addObserver(&_DBBagObs, textId); } @@ -322,7 +322,7 @@ void CInventoryManager::init() // SERVER DB initItemArray(SERVER_INVENTORY ":BAG", ServerBag, MAX_BAGINV_ENTRIES); initItemArray(SERVER_INVENTORY ":TEMP", ServerTempInv, MAX_TEMPINV_ENTRIES); - ServerMoney = im->getDbProp(SERVER_INVENTORY ":MONEY"); + ServerMoney = NLGUI::CDBManager::getInstance()->getDbProp(SERVER_INVENTORY ":MONEY"); // Init Animals for(uint i=0;igetDbProp("SERVER:TRADING:SESSION", false); + nodeTS= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:SESSION", false); if( nodeTS ) { ICDBNode::CTextId textId; @@ -391,8 +391,8 @@ void CInventoryManager::init() // since different size per inventory, stop when node not found.... for(uint j=0;;j++) { - CCDBNodeLeaf *nodeIV= im->getDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":INFO_VERSION", false); - CCDBNodeLeaf *nodeSH= im->getDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":SHEET", false); + CCDBNodeLeaf *nodeIV= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":INFO_VERSION", false); + CCDBNodeLeaf *nodeSH= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:" + InventoryDBs[i] + ":" + toString(j) + ":SHEET", false); if( nodeIV && nodeSH ) { ICDBNode::CTextId textIdIV, textIdSH; @@ -418,7 +418,7 @@ void CInventoryManager::initItemArray(const std::string &dbBranchName, CItemImag { nlassert(dest); CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeBranch *branch = im->getDbBranch(dbBranchName); + CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(dbBranchName); if (!branch) { nlwarning("Can't init inventory image from branch %s.", dbBranchName.c_str()); @@ -444,7 +444,7 @@ void CInventoryManager::initIndirection(const std::string &dbbranch, sint32 *ind CInterfaceManager *im = CInterfaceManager::getInstance(); for (uint i = 0 ; i < (uint)nbIndex; ++i) { - CCDBNodeLeaf *pNL = im->getDbProp(dbbranch + toString(i) + ":INDEX_IN_BAG"); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(dbbranch + toString(i) + ":INDEX_IN_BAG"); if (putObs) { ICDBNode::CTextId textId; @@ -590,11 +590,11 @@ uint32 CInventoryManager::getHandItemSheet( bool rightHand ) const CInterfaceManager *pIM= CInterfaceManager::getInstance(); string dbPropPath = toString("LOCAL:INVENTORY:HAND:%d:INDEX_IN_BAG",rightHand?0:1); // get the RightHand bag index - sint32 itemSlot= pIM->getDbProp(dbPropPath)->getValue32(); + sint32 itemSlot= NLGUI::CDBManager::getInstance()->getDbProp(dbPropPath)->getValue32(); // if something in hand if(itemSlot>0) { - CCDBNodeLeaf *node= pIM->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":SHEET", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":SHEET", false); if(node) item= node->getValue32(); } @@ -784,7 +784,7 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv } // Hands management : check if we have to unequip left hand because of incompatibility with right hand item - sint16 oldRightIndexInBag = pIM->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16(); + sint16 oldRightIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16(); if (inventory == INVENTORIES::handling && invSlot == 0) { CDBCtrlSheet *pCSLeftHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_LEFT)); @@ -795,14 +795,14 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv // get sheet of left item uint32 leftSheet = 0; - CCDBNodeLeaf *pNL = pIM->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); if (pNL == NULL) { return; } if (pNL->getValue32() > 0) { - CCDBNodeLeaf *pNL2 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false); + CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false); if (pNL2 == NULL) { return; @@ -814,7 +814,7 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv uint32 lastRightSheet = 0; if (oldRightIndexInBag > 0) { - pNL = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldRightIndexInBag-1) + ":SHEET", false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldRightIndexInBag-1) + ":SHEET", false); if (pNL == NULL) { return; @@ -826,7 +826,7 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv uint32 rightSheet = 0; if (indexInBag+1 > 0) { - pNL = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(indexInBag) + ":SHEET", false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(indexInBag) + ":SHEET", false); if (pNL == NULL) { return; @@ -842,7 +842,7 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv } // update the equip DB pointer - pIM->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(indexInBag+1); + NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(indexInBag+1); // Yoyo add: when the user equip an item, the action are invalid during some time if(indexInBag < MAX_BAGINV_ENTRIES) @@ -895,7 +895,7 @@ void CInventoryManager::unequip(const std::string &invPath) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint16 oldIndexInBag = pIM->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16(); + sint16 oldIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16(); if( oldIndexInBag == 0 ) { return; @@ -927,14 +927,14 @@ void CInventoryManager::unequip(const std::string &invPath) // get sheet of left item uint32 leftSheet = 0; - CCDBNodeLeaf *pNL = pIM->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); if (pNL == NULL) { return; } if (pNL->getValue32() > 0) { - CCDBNodeLeaf *pNL2 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false); + CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL->getValue32()-1) + ":SHEET", false); if (pNL2 == NULL) { return; @@ -946,7 +946,7 @@ void CInventoryManager::unequip(const std::string &invPath) uint32 lastRightSheet = 0; if (oldIndexInBag > 0) { - pNL = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldIndexInBag-1) + ":SHEET", false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldIndexInBag-1) + ":SHEET", false); if (pNL == NULL) { return; @@ -964,7 +964,7 @@ void CInventoryManager::unequip(const std::string &invPath) } } - pIM->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(0); + NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->setValue16(0); // Update trade window if any if ((BotChatPageAll != NULL) && (BotChatPageAll->Trade != NULL)) @@ -1121,11 +1121,11 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) // If something in left hand check if we have to remove { uint32 leftSheet = 0; - CCDBNodeLeaf *pNL3 = pIM->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); + CCDBNodeLeaf *pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:1:INDEX_IN_BAG", false); if (pNL3 == NULL) return; if (pNL3->getValue32() > 0) { - CCDBNodeLeaf *pNL4 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false); + CCDBNodeLeaf *pNL4 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false); if (pNL4 == NULL) return; leftSheet = pNL4->getValue32(); } @@ -1133,7 +1133,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) uint32 rightSheet = 0; if (newVal > 0) { - pNL3 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false); + pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false); if (pNL3 == NULL) return; rightSheet = pNL3->getValue32(); } @@ -1141,7 +1141,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) uint32 lastRightSheet = 0; if (oldVal > 0) { - pNL3 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldVal-1) + ":SHEET", false); + pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(oldVal-1) + ":SHEET", false); if (pNL3 == NULL) return; lastRightSheet = pNL3->getValue32(); } @@ -1161,7 +1161,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) // update display of left hand according to new right hand item if (newVal > 0) { - CCDBNodeLeaf *pNL2 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false); + CCDBNodeLeaf *pNL2 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(newVal-1) + ":SHEET", false); if (pNL2 == NULL) return; if (getInventory().is2HandItem(pNL2->getValue32())) @@ -1199,12 +1199,12 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) CDBCtrlSheet * pCSRightHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_RIGHT)); if ( pCSRightHand && pCSRightHand->getSheetId() ) { - CCDBNodeLeaf *pNL3 = pIM->getDbProp(LOCAL_INVENTORY ":HAND:0:INDEX_IN_BAG", false); + CCDBNodeLeaf *pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:0:INDEX_IN_BAG", false); if (pNL3) { if (pNL3->getValue32() > 0) { - CCDBNodeLeaf *pNL4 = pIM->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false); + CCDBNodeLeaf *pNL4 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":BAG:" + toString(pNL3->getValue32()-1) + ":SHEET", false); if (pNL4) { uint32 rightSheet = pNL4->getValue32(); @@ -1297,7 +1297,7 @@ bool CInventoryManager::autoEquip(sint bagEntryIndex, bool allowReplace) if (pCSDst == NULL) continue; string dstPath = getInventory().getDBIndexPath(pCSDst); - sint32 indexDstPath = pIM->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); + sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); // Already something in that slot? if (!allowReplace && indexDstPath > 0) @@ -1323,7 +1323,7 @@ bool CInventoryManager::autoEquip(sint bagEntryIndex, bool allowReplace) CDBCtrlSheet *pCSDst = getInventory().getEquipSheet(i); if (pCSDst == NULL) continue; string dstPath = getInventory().getDBIndexPath(pCSDst); - sint32 indexDstPath = pIM->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); + sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); // Already something in that slot? if (!allowReplace && indexDstPath > 0) @@ -1363,14 +1363,14 @@ void CInventoryManager::dropOrDestroyItem(CDBCtrlSheet *item, CBitMemStream &out static void checkEquipmentIntegrity(const string &equipVal) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pNL = pIM->getDbProp(equipVal+":INDEX_IN_BAG",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(equipVal+":INDEX_IN_BAG",false); if (pNL != NULL) { uint32 indexInBag = pNL->getValue16(); if (indexInBag != 0) { string sTmp = string(LOCAL_INVENTORY) + ":BAG:" + toString(indexInBag-1) + ":SHEET"; - CCDBNodeLeaf *pNLBag = pIM->getDbProp(sTmp,false); + CCDBNodeLeaf *pNLBag = NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false); if (pNLBag != NULL) { if (pNLBag->getValue32() == 0) // If no more item in this slot bag @@ -1389,7 +1389,7 @@ static void checkEquipmentIntegrity(const string &equipVal) CDBCtrlSheet *pCSDst = getInventory().getEquipSheet(i); if (pCSDst == NULL) continue; string dstPath = getInventory().getDBIndexPath(pCSDst); - sint32 indexDstPath = pIM->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); + sint32 indexDstPath = NLGUI::CDBManager::getInstance()->getDbProp(dstPath+":INDEX_IN_BAG")->getValue16(); // Update the sheet id of the control sheet if (indexDstPath == (sint32)indexInBag) @@ -1427,7 +1427,7 @@ void CInventoryManager::checkIndexInBagIntegrity() double CInventoryManager::getBranchBulk(const string &basePath, uint16 startItemIndex, uint16 numItems) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeBranch *branch = pIM->getDbBranch(basePath); + CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(basePath); if (!branch) { nlwarning(" Branch is NULL"); @@ -1469,7 +1469,7 @@ double CInventoryManager::getBranchBulk(const string &basePath, uint16 startItem void CInventoryManager::getBranchSlotCounts(const std::string &basePath, uint& nbUsedSlots, uint& nbMaxSlots ) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeBranch *branch = pIM->getDbBranch(basePath); + CCDBNodeBranch *branch = NLGUI::CDBManager::getInstance()->getDbBranch(basePath); if (!branch) { nlwarning(" Branch is NULL"); @@ -1540,15 +1540,15 @@ double CInventoryManager::getMaxBagBulk(uint32 inventoryIndex) CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCDBNodeLeaf *pNL=NULL; if (inventoryIndex == 0) - pNL = pIM->getDbProp("SERVER:STATIC_DATA:BAG_BULK_MAX"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:STATIC_DATA:BAG_BULK_MAX"); else if (inventoryIndex == 1) - pNL = pIM->getDbProp("SERVER:PACK_ANIMAL:BEAST0:BULK_MAX"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST0:BULK_MAX"); else if (inventoryIndex == 2) - pNL = pIM->getDbProp("SERVER:PACK_ANIMAL:BEAST1:BULK_MAX"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST1:BULK_MAX"); else if (inventoryIndex == 3) - pNL = pIM->getDbProp("SERVER:PACK_ANIMAL:BEAST2:BULK_MAX"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST2:BULK_MAX"); else if (inventoryIndex == 4) - pNL = pIM->getDbProp("SERVER:PACK_ANIMAL:BEAST3:BULK_MAX"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:PACK_ANIMAL:BEAST3:BULK_MAX"); if (pNL != NULL) return pNL->getValue32(); return 0; @@ -1561,8 +1561,8 @@ bool CInventoryManager::isSpaceInAllBagsForItem(CDBCtrlSheet *item) CDBCtrlSheet *pCSDst = item; if (!pCSDst->isSheetValid()) return false; string sTmp = pCSDst->getSheet(); - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp+":SHEET",false); - CCDBNodeLeaf *pNLquantity = pIM->getDbProp(sTmp+":QUANTITY",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false); + CCDBNodeLeaf *pNLquantity = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":QUANTITY",false); if (pNL == NULL) return false; if (pNLquantity == NULL) return false; @@ -1589,7 +1589,7 @@ bool CInventoryManager::isSpaceInBagForItem(CDBCtrlSheet *item, uint32 quantity, CDBCtrlSheet *pCSDst = item; if (!pCSDst->isSheetValid()) return false; string sTmp = pCSDst->getSheet(); - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp+":SHEET",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false); if (pNL == NULL) return false; // Check if we can find empty space for this item (or stack of item) @@ -1635,7 +1635,7 @@ CTempInvManager::CTempInvManager() string sPath = string("LOCAL:INVENTORY:TEMP"); for (uint i = 0; i < MAX_TEMPINV_ENTRIES; ++i) { - CCDBNodeLeaf *pNL = pIM->getDbProp(sPath+":"+toString(i)+":SHEET", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":"+toString(i)+":SHEET", false); if (pNL != NULL) { ICDBNode::CTextId textId; @@ -1643,7 +1643,7 @@ CTempInvManager::CTempInvManager() } } // Add Also the Mode to observe - CCDBNodeLeaf *pNL = pIM->getDbProp(sPath+":TYPE", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":TYPE", false); if(pNL) { ICDBNode::CTextId textId; @@ -1651,20 +1651,20 @@ CTempInvManager::CTempInvManager() } // Forage - pNL = pIM->getDbProp(sPath+":ENABLE_TAKE"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":ENABLE_TAKE"); if (pNL != NULL) { ICDBNode::CTextId textId; pNL->addObserver(&_DBObs, textId); } - pNL = pIM->getDbProp(sPath+":0:QUANTITY"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":0:QUANTITY"); _DBForageQQObs[0].WhichOne = 0; if (pNL != NULL) { ICDBNode::CTextId textId; pNL->addObserver(&_DBForageQQObs[0], textId); } - pNL = pIM->getDbProp(sPath+":0:QUALITY"); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+":0:QUALITY"); _DBForageQQObs[1].WhichOne = 1; if (pNL != NULL) { @@ -1696,14 +1696,14 @@ void CTempInvManager::update() for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++) { string sTmp = sPath + ":" + toString(i) + ":SHEET"; - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp); // uint32 nOldSheet = pNL->getOldValue32(); uint32 nSheet = pNL->getValue32(); if (nSheet != 0) bAllEmpty = false; } - _Mode = (TEMP_INV_MODE::TInventoryMode)pIM->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); + _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); if (pGC == NULL) @@ -1721,8 +1721,8 @@ void CTempInvManager::update() if (_Mode == TEMP_INV_MODE::Forage) { // Disable/enable "Take all" button - bool disableTake = (pIM->getDbProp(sPath+":ENABLE_TAKE")->getValue32() == 0); - pIM->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(disableTake); + bool disableTake = (NLGUI::CDBManager::getInstance()->getDbProp(sPath+":ENABLE_TAKE")->getValue32() == 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(disableTake); if ( disableTake ) { // Display begin of forage @@ -1739,7 +1739,7 @@ void CTempInvManager::update() else { // Write to the UI db the empty state - pIM->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(bAllEmpty); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP_INV:ALL_EMPTY")->setValue32(bAllEmpty); } if (bAllEmpty) @@ -1773,7 +1773,7 @@ void CTempInvManager::update() void CTempInvManager::updateType() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - _Mode = (TEMP_INV_MODE::TInventoryMode)pIM->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); + _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); // Something arrived, change text switch(_Mode) @@ -1808,7 +1808,7 @@ void CTempInvManager::updateForageQQ( uint whichOne ) // Display forage progress with counters CInterfaceManager *pIM = CInterfaceManager::getInstance(); - bool disableTake = (pIM->getDbProp("LOCAL:INVENTORY:TEMP:ENABLE_TAKE")->getValue32() == 0); + bool disableTake = (NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:ENABLE_TAKE")->getValue32() == 0); if ( disableTake ) { float qt = 0.f, ql = 0.f; @@ -1816,7 +1816,7 @@ void CTempInvManager::updateForageQQ( uint whichOne ) { case 0: { - CCDBNodeLeaf *leafQt = pIM->getDbProp("LOCAL:INVENTORY:TEMP:0:QUANTITY"); + CCDBNodeLeaf *leafQt = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:0:QUANTITY"); uint16 qtX10 = (uint16)(leafQt->getValue16()); qt = _DBForageQQObs[whichOne].FullValue = (((float)(uint)qtX10) / 10.0f); leafQt->setValue16( (sint16)(sint)qt ); @@ -1825,7 +1825,7 @@ void CTempInvManager::updateForageQQ( uint whichOne ) break; case 1: { - CCDBNodeLeaf *leafQl = pIM->getDbProp("LOCAL:INVENTORY:TEMP:0:QUALITY"); + CCDBNodeLeaf *leafQl = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:0:QUALITY"); uint16 qlX10 = (uint16)(leafQl->getValue16()); ql = _DBForageQQObs[whichOne].FullValue = (((float)(uint)qlX10) / 10.0f); leafQl->setValue16( (sint16)(sint)ql ); @@ -1858,14 +1858,14 @@ void CTempInvManager::open(TEMP_INV_MODE::TInventoryMode m) for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++) { string sTmp = sPath + ":" + toString(i) + ":SHEET"; - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp); pNL->setValue32(0); } } - pIM->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->setValue8((uint8)_Mode); + NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->setValue8((uint8)_Mode); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); if (pGC != NULL) { @@ -1898,7 +1898,7 @@ void CTempInvManager::close() for (uint i = 0; i < MAX_TEMPINV_ENTRIES; i++) { string sTmp = sPath + ":" + toString(i) + ":SHEET"; - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp); pNL->setValue32(0); } @@ -1988,22 +1988,22 @@ bool SBagOptions::parse(xmlNodePtr cur, CInterfaceGroup * /* parentGroup */) } prop = xmlGetProp (cur, (xmlChar*)"filter_armor"); - if (prop) DbFilterArmor = pIM->getDbProp(prop); + if (prop) DbFilterArmor = NLGUI::CDBManager::getInstance()->getDbProp(prop); prop = xmlGetProp (cur, (xmlChar*)"filter_weapon"); - if (prop) DbFilterWeapon = pIM->getDbProp(prop); + if (prop) DbFilterWeapon = NLGUI::CDBManager::getInstance()->getDbProp(prop); prop = xmlGetProp (cur, (xmlChar*)"filter_tool"); - if (prop) DbFilterTool = pIM->getDbProp(prop); + if (prop) DbFilterTool = NLGUI::CDBManager::getInstance()->getDbProp(prop); prop = xmlGetProp (cur, (xmlChar*)"filter_mp"); - if (prop) DbFilterMP = pIM->getDbProp(prop); + if (prop) DbFilterMP = NLGUI::CDBManager::getInstance()->getDbProp(prop); prop = xmlGetProp (cur, (xmlChar*)"filter_missmp"); - if (prop) DbFilterMissMP = pIM->getDbProp(prop); + if (prop) DbFilterMissMP = NLGUI::CDBManager::getInstance()->getDbProp(prop); prop = xmlGetProp (cur, (xmlChar*)"filter_tp"); - if (prop) DbFilterTP = pIM->getDbProp(prop); + if (prop) DbFilterTP = NLGUI::CDBManager::getInstance()->getDbProp(prop); return true; } @@ -2178,7 +2178,7 @@ void CDBGroupListSheetBag::CSheetChildBag::init(CDBGroupListSheetText *pFather, { // Basic quality string db= Ctrl->getSheet()+":QUALITY"; - if( pIM->getDbProp(db, false) ) + if( NLGUI::CDBManager::getInstance()->getDbProp(db, false) ) CurrentQuality.link ( db.c_str() ); else { @@ -2749,8 +2749,8 @@ class CHandlerInvDropTo : public IActionHandler // Get the index in the equipment string invPath2 = getInventory().getDBIndexPath(pCSDst); - sint32 i1 = pIM->getDbProp(invPath1+":INDEX_IN_BAG")->getValue16(); - sint32 i2 = pIM->getDbProp(invPath2+":INDEX_IN_BAG")->getValue16(); + sint32 i1 = NLGUI::CDBManager::getInstance()->getDbProp(invPath1+":INDEX_IN_BAG")->getValue16(); + sint32 i2 = NLGUI::CDBManager::getInstance()->getDbProp(invPath2+":INDEX_IN_BAG")->getValue16(); getInventory().unequip(invPath1); getInventory().unequip(invPath2); @@ -2849,7 +2849,7 @@ class CHandlerInvTempToBag : public IActionHandler // Disable the direct click on item in Forage mode and Can't take all if ( (CTempInvManager::getInstance()->getMode() == TEMP_INV_MODE::Forage) && - (pIM->getDbProp("LOCAL:INVENTORY:TEMP:ENABLE_TAKE")->getValue32() == 0) ) + (NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:ENABLE_TAKE")->getValue32() == 0) ) return; CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); @@ -2870,7 +2870,7 @@ class CHandlerInvTempToBag : public IActionHandler } sTmp = pCSDst->getSheet(); - CCDBNodeLeaf *pNL = pIM->getDbProp(sTmp+":SHEET",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false); pNL->setValue32(0); CBitMemStream out; @@ -2915,8 +2915,8 @@ class CHandlerInvTempAll : public IActionHandler for (uint32 itemNb = 0; itemNb < MAX_TEMPINV_ENTRIES; ++itemNb) { - CCDBNodeLeaf *pNL = pIM->getDbProp(LOCAL_INVENTORY ":TEMP:" + toString(itemNb) + ":SHEET"); - CCDBNodeLeaf *pNLquantity = pIM->getDbProp(LOCAL_INVENTORY ":TEMP:" + toString(itemNb) + ":QUANTITY"); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":TEMP:" + toString(itemNb) + ":SHEET"); + CCDBNodeLeaf *pNLquantity = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":TEMP:" + toString(itemNb) + ":QUANTITY"); if (pNL == NULL || pNLquantity == NULL) continue; if (pNL->getValue32() == 0 || pNLquantity->getValue32() == 0) continue; double itemBulk = pNLquantity->getValue32() * pInv->getItemBulk(pNL->getValue32()); @@ -3031,7 +3031,7 @@ uint CInventoryManager::getItemSheetForSlotId(uint slotId) const { if( InventoryIndexes[i] == (slotId>>CItemInfos::SlotIdIndexBitSize) ) { - CCDBNodeLeaf *node= pIM->getDbProp( toString( "SERVER:%s:%d:SHEET", InventoryDBs[i].c_str(), (slotId&CItemInfos::SlotIdIndexBitMask)), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp( toString( "SERVER:%s:%d:SHEET", InventoryDBs[i].c_str(), (slotId&CItemInfos::SlotIdIndexBitMask)), false); if(node) return node->getValue32(); else @@ -3353,7 +3353,7 @@ bool CInventoryManager::isInventoryPresent(INVENTORIES::TInventory invId) // PA present? if(invId>=INVENTORIES::pet_animal && invIdgetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", invId-INVENTORIES::pet_animal), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", invId-INVENTORIES::pet_animal), false); if(!node) return false; uint status= node->getValue32(); @@ -3361,11 +3361,11 @@ bool CInventoryManager::isInventoryPresent(INVENTORIES::TInventory invId) } else if (invId == INVENTORIES::guild) { - return (pIM->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED", true)->getValue8() != 0); + return (NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED", true)->getValue8() != 0); } else if (invId == INVENTORIES::player_room) { - return (pIM->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED", true)->getValue8() != 0); + return (NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED", true)->getValue8() != 0); } // other inventories (Bag...) are always present else @@ -3381,7 +3381,7 @@ bool CInventoryManager::isInventoryAvailable(INVENTORIES::TInventory invId) // PA available? if(invId>=INVENTORIES::pet_animal && invIdgetDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", invId-INVENTORIES::pet_animal), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:PACK_ANIMAL:BEAST%d:STATUS", invId-INVENTORIES::pet_animal), false); if(!node) return false; uint status= node->getValue32(); @@ -3389,11 +3389,11 @@ bool CInventoryManager::isInventoryAvailable(INVENTORIES::TInventory invId) } else if (invId == INVENTORIES::guild) { - return (pIM->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED", true)->getValue8() != 0); + return (NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED", true)->getValue8() != 0); } else if (invId == INVENTORIES::player_room) { - return (pIM->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED", true)->getValue8() != 0); + return (NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED", true)->getValue8() != 0); } // other inventories (Bag...) are always available else @@ -3433,7 +3433,7 @@ bool CInventoryManager::isInventoryEmpty(INVENTORIES::TInventory invId) for (uint32 i = 0; (sint)i < nNbEntries; ++i) { CCDBNodeLeaf *pNL; - pNL = pIM->getDbProp(sPath+toString(":%d:SHEET", i), false); + pNL = NLGUI::CDBManager::getInstance()->getDbProp(sPath+toString(":%d:SHEET", i), false); if (pNL == NULL) return true; if (pNL->getValue32() != 0) return false; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 73ae6a813..f6f881a47 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -969,7 +969,7 @@ static sint32 getTargetSlotNr() { const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false); if (!node) return 0; if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) { @@ -982,7 +982,7 @@ static CEntityCL *getTargetEntity() { const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp(dbPath, false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false); if (!node) return NULL; if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT) { @@ -2224,7 +2224,7 @@ int CLuaIHMRyzom::isPlayerNewbie(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "isPlayerNewbie", 0); CInterfaceManager *im = CInterfaceManager::getInstance(); - ls.push(im->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool()); + ls.push(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool()); return 1; } @@ -2754,7 +2754,7 @@ sint32 CLuaIHMRyzom::getDbProp(const std::string &dbProp) { //H_AUTO(Lua_CLuaIHM_getDbProp) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false); if(node) return node->getValue32(); else @@ -2784,7 +2784,7 @@ void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value) // Write to the DB if found CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false); if(node) node->setValue32(value); @@ -2812,7 +2812,7 @@ void CLuaIHMRyzom::delDbProp(const string &dbProp) // Write to the DB if found CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->delDbProp(dbProp); + NLGUI::CDBManager::getInstance()->delDbProp(dbProp); } void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value) @@ -2835,7 +2835,7 @@ void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value) // Write to the DB if found CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp(dbProp, true); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, true); if(node) node->setValue32(value); } @@ -3666,21 +3666,21 @@ sint32 CLuaIHMRyzom::getPlayerLevel() // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpa() { - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpb() { - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpc() { - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } @@ -3692,7 +3692,7 @@ sint32 CLuaIHMRyzom::getTargetLevel() if ( target->isPlayer() ) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("target_player_level") ); return pDbPlayerLevel ? pDbPlayerLevel->getValue32() : -1; } else @@ -3722,7 +3722,7 @@ sint64 CLuaIHMRyzom::getTargetVpa() CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } @@ -3733,7 +3733,7 @@ sint64 CLuaIHMRyzom::getTargetVpb() CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } @@ -3744,7 +3744,7 @@ sint64 CLuaIHMRyzom::getTargetVpc() CEntityCL *target = getTargetEntity(); if (!target) return 0; - sint64 prop = CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } @@ -3757,7 +3757,7 @@ sint32 CLuaIHMRyzom::getTargetForceRegion() if ( target->isPlayer() ) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("target_player_level") ); if (!pDbPlayerLevel) return -1; sint nLevel = pDbPlayerLevel->getValue32(); if ( nLevel < 250 ) @@ -3785,7 +3785,7 @@ sint32 CLuaIHMRyzom::getTargetLevelForce() if ( target->isPlayer() ) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDbPlayerLevel = pIM->getDbProp( pIM->getDefine("target_player_level") ); + CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( pIM->getDefine("target_player_level") ); if (!pDbPlayerLevel) return -1; sint nLevel = pDbPlayerLevel->getValue32(); if ( nLevel < 250 ) diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 2c4fbc24c..5aa4c7823 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -408,12 +408,12 @@ void CModalContainerEditCmd::create(const std::string &name, bool bDefKey, bool DbComboDisp2P = prefix + DB_EDITCMD_COMBO_DISPLAY_SECOND_PARAM; // Create DB entry - pIM->getDbProp(DbComboSelCat); - pIM->getDbProp(DbComboSelAct); - pIM->getDbProp(DbComboSel1P); - pIM->getDbProp(DbComboSel2P); - pIM->getDbProp(DbComboDisp1P); - pIM->getDbProp(DbComboDisp2P); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboSelCat); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboSelAct); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboSel1P); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboSel2P); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboDisp1P); + NLGUI::CDBManager::getInstance()->getDbProp(DbComboDisp2P); vector< pair > vArgs; vArgs.push_back(pair("id",name)); @@ -497,12 +497,12 @@ void CModalContainerEditCmd::activate() if (pCB != NULL) pCB->resetTexts(); // Clean up CurAM = NULL; - pIM->getDbProp( DbComboSelCat )->setValue32(-1); - pIM->getDbProp( DbComboSelAct )->setValue32(-1); - pIM->getDbProp( DbComboSel1P )->setValue32(-1); - pIM->getDbProp( DbComboSel2P )->setValue32(-1); - pIM->getDbProp( DbComboDisp1P )->setValue32(-1); - pIM->getDbProp( DbComboDisp2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelCat )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelAct )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); @@ -583,13 +583,13 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std pCB->setSelection(catCBIndex); onChangeCategory(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); //pIM->runActionHandler("editcmd_change_category",NULL); pCB = dynamic_cast(pIM->getElementFromId(WinName+WIN_EDITCMD_COMBO_ACTION)); pCB->setSelection(actCBIndex); onChangeAction(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); //pIM->runActionHandler("editcmd_change_action",NULL); // Count number of displayed param @@ -639,8 +639,8 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std } else if (rP.Type == CBaseAction::CParameter::Constant) { - if (noParam == 0) pIM->getDbProp( DbComboDisp1P )->setValue32(0); - else pIM->getDbProp( DbComboDisp2P )->setValue32(0); + if (noParam == 0) NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(0); + else NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(0); // Search the param value to get the position in combo box bool bValFound = false; @@ -664,8 +664,8 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std } else if ((rP.Type == CBaseAction::CParameter::User) || (rP.Type == CBaseAction::CParameter::UserName)) { - if (noParam == 0) pIM->getDbProp( DbComboDisp1P )->setValue32(1); - else pIM->getDbProp( DbComboDisp2P )->setValue32(1); + if (noParam == 0) NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(1); + else NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(1); string sEditBox; if (noParam == 0) sEditBox = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX; @@ -792,9 +792,9 @@ void CModalContainerEditCmd::invalidCurrentCommand() void CModalContainerEditCmd::validCurrentCommand() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint32 catIndex= pIM->getDbProp( DbComboSelCat )->getValue32(); + sint32 catIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelCat )->getValue32(); if(catIndex < 0) return; - sint32 actIndex= pIM->getDbProp( DbComboSelAct )->getValue32(); + sint32 actIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelAct )->getValue32(); if(actIndex < 0) return; CActionsManager *pAM; @@ -829,8 +829,8 @@ void CModalContainerEditCmd::validCurrentCommand() // cannot use index directly because some options may be disabled in current context sint32 paramIndex; const std::vector &rVVal = rP.Values; - if (noParam == 0) paramIndex = pIM->getDbProp(DbComboSel1P)->getValue32(); - else paramIndex = pIM->getDbProp(DbComboSel2P)->getValue32(); + if (noParam == 0) paramIndex = NLGUI::CDBManager::getInstance()->getDbProp(DbComboSel1P)->getValue32(); + else paramIndex = NLGUI::CDBManager::getInstance()->getDbProp(DbComboSel2P)->getValue32(); uint currIndex = 0; for (uint k = 0; k < rVVal.size(); ++k) @@ -917,14 +917,14 @@ bool CModalContainerEditCmd::isParamValid (sint32 nParamIndex) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 paramType; - if (nParamIndex == 0) paramType = pIM->getDbProp(DbComboDisp1P)->getValue32(); - else paramType = pIM->getDbProp(DbComboDisp2P)->getValue32(); + if (nParamIndex == 0) paramType = NLGUI::CDBManager::getInstance()->getDbProp(DbComboDisp1P)->getValue32(); + else paramType = NLGUI::CDBManager::getInstance()->getDbProp(DbComboDisp2P)->getValue32(); if (paramType == 0) // combo box list { sint32 paramListIndex; - if (nParamIndex == 0) paramListIndex = pIM->getDbProp( DbComboSel1P )->getValue32(); - else paramListIndex = pIM->getDbProp( DbComboSel2P )->getValue32(); + if (nParamIndex == 0) paramListIndex = NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel1P )->getValue32(); + else paramListIndex = NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel2P )->getValue32(); if (paramListIndex < 0) return false; else return true; @@ -949,11 +949,11 @@ void CModalContainerEditCmd::checkCurrentCommandValidity() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the category selected - sint32 catIndex= pIM->getDbProp( DbComboSelCat )->getValue32(); + sint32 catIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelCat )->getValue32(); if(catIndex < 0) return; // Get the action index selected - sint32 actIndex= pIM->getDbProp( DbComboSelAct )->getValue32(); + sint32 actIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelAct )->getValue32(); if(actIndex < 0) return; CActionsManager *pAM; @@ -1003,7 +1003,7 @@ void CModalContainerEditCmd::onChangeCategory() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the category selected - sint32 catIndex= pIM->getDbProp( DbComboSelCat )->getValue32(); + sint32 catIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelCat )->getValue32(); if(catIndex < 0) return; @@ -1033,11 +1033,11 @@ void CModalContainerEditCmd::onChangeCategory() } // reset the action and dont display params - pIM->getDbProp( DbComboSelAct )->setValue32(-1); - pIM->getDbProp( DbComboSel1P )->setValue32(-1); - pIM->getDbProp( DbComboSel2P )->setValue32(-1); - pIM->getDbProp( DbComboDisp1P )->setValue32(-1); - pIM->getDbProp( DbComboDisp2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelAct )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); @@ -1055,12 +1055,12 @@ void CModalContainerEditCmd::onChangeAction() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the category selected - sint32 catIndex= pIM->getDbProp( DbComboSelCat )->getValue32(); + sint32 catIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelCat )->getValue32(); if(catIndex < 0) return; // Get the action index selected - sint32 actIndex= pIM->getDbProp( DbComboSelAct )->getValue32(); + sint32 actIndex= NLGUI::CDBManager::getInstance()->getDbProp( DbComboSelAct )->getValue32(); if(actIndex < 0) return; @@ -1072,10 +1072,10 @@ void CModalContainerEditCmd::onChangeAction() const vector &rVBA = CurAM->getCategories()[catIndex].BaseActions; const vector &rVParams = rVBA[actIndex].Parameters; - pIM->getDbProp( DbComboDisp1P )->setValue32(-1); - pIM->getDbProp( DbComboDisp2P )->setValue32(-1); - pIM->getDbProp( DbComboSel1P )->setValue32(-1); - pIM->getDbProp( DbComboSel2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel1P )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel2P )->setValue32(-1); // reset name of params CViewText *pViewParamName; pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); @@ -1131,7 +1131,7 @@ void CModalContainerEditCmd::onChangeAction() } } } - pIM->getDbProp( sDB )->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(0); } else if ((rP.Type == CBaseAction::CParameter::User) || (rP.Type == CBaseAction::CParameter::UserName)) { @@ -1143,7 +1143,7 @@ void CModalContainerEditCmd::onChangeAction() { pEB->setInputString(ucstring("")); } - pIM->getDbProp( sDB )->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1); } noParam++; } diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index e4555d092..3effb37cd 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -232,7 +232,7 @@ void CMacroCmdManager::initInGame() } // Do not begin at 0 - pIM->getDbProp("SERVER:USER:ACT_NUMBER")->setValue64(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_NUMBER")->setValue64(0); // Create the NewKey container. Can edit key, and can assign all actions (not only macroisable ones) NewKey = new CModalContainerEditCmd; @@ -489,7 +489,7 @@ void CMacroCmdManager::updateMacroExecution () // Flush interface links (else bug with Macro "Select ShortCutBar/Run Shortcut" IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); if (bWaitForServer) { @@ -553,7 +553,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pMCM->receiveActionEnd((uint8)pIM->getDbProp("SERVER:USER:ACT_NUMBER")->getValue64()); + pMCM->receiveActionEnd((uint8)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_NUMBER")->getValue64()); } }; REGISTER_ACTION_HANDLER( CHandlerMacroRecActEnd, "macro_receive_action_end"); diff --git a/code/ryzom/client/src/interface_v3/obs_huge_list.cpp b/code/ryzom/client/src/interface_v3/obs_huge_list.cpp index ac0c05c29..6d7121a88 100644 --- a/code/ryzom/client/src/interface_v3/obs_huge_list.cpp +++ b/code/ryzom/client/src/interface_v3/obs_huge_list.cpp @@ -142,16 +142,16 @@ bool CHugeListObs::init() break; } CInterfaceManager *im = CInterfaceManager::getInstance(); - _Session = im->getDbProp(dbPath + ":SESSION", false); + _Session = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":SESSION", false); if (!_Session) return false; - _PageID = im->getDbProp(dbPath + ":PAGE_ID", false); + _PageID = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":PAGE_ID", false); if (!_PageID) return false; - _HasNext = im->getDbProp(dbPath + ":HAS_NEXT", false); + _HasNext = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":HAS_NEXT", false); if (!_HasNext) return false; // optional (rolemaster Trading only) - _RoleMasterFlagDB = im->getDbProp(dbPath + ":ROLEMASTER_FLAGS", false); - _RoleMasterRaceDB = im->getDbProp(dbPath + ":ROLEMASTER_RACE", false); + _RoleMasterFlagDB = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":ROLEMASTER_FLAGS", false); + _RoleMasterRaceDB = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + ":ROLEMASTER_RACE", false); // get all items for(uint k = 0; k < TRADE_PAGE_NUM_ITEMS; ++k) @@ -159,25 +159,25 @@ bool CHugeListObs::init() switch(_Category) { case Trading: - _Items[k].SlotType = im->getDbProp(toString((dbPath + ":%d:SLOT_TYPE").c_str(), (int) k), false); - _Items[k].Quality = im->getDbProp(toString((dbPath + ":%d:QUALITY").c_str(), (int) k), false); - _Items[k].SheetIDOrSkill = im->getDbProp(toString((dbPath + ":%d:SHEET").c_str(), (int) k), false); - _Items[k].Price = im->getDbProp(toString((dbPath + ":%d:PRICE").c_str(), (int) k), false); - _Items[k].Weight = im->getDbProp(toString((dbPath + ":%d:WEIGHT").c_str(), (int) k), false); - _Items[k].NameId = im->getDbProp(toString((dbPath + ":%d:NAMEID").c_str(), (int) k), false); - _Items[k].UserColor = im->getDbProp(toString((dbPath + ":%d:USER_COLOR").c_str(), (int) k), false); - _Items[k].Enchant = im->getDbProp(toString((dbPath + ":%d:ENCHANT").c_str(), (int) k), false); - _Items[k].RMClassType = im->getDbProp(toString((dbPath + ":%d:RM_CLASS_TYPE").c_str(), (int) k), false); - _Items[k].RMFaberStatType = im->getDbProp(toString((dbPath + ":%d:RM_FABER_STAT_TYPE").c_str(), (int) k), false); - _Items[k].PrerequisitValid = im->getDbProp(toString((dbPath + ":%d:PREREQUISIT_VALID").c_str(), (int) k), false); - _Items[k].InfoVersion = im->getDbProp(toString((dbPath + ":%d:INFO_VERSION").c_str(), (int) k), false); - _Items[k].Quantity = im->getDbProp(toString((dbPath + ":%d:QUANTITY").c_str(), (int) k), false); - _Items[k].PriceRetire = im->getDbProp(toString((dbPath + ":%d:PRICE_RETIRE").c_str(), (int) k), false); - _Items[k].ResaleTimeLeft = im->getDbProp(toString((dbPath + ":%d:RESALE_TIME_LEFT").c_str(), (int) k), false); - _Items[k].VendorNameId = im->getDbProp(toString((dbPath + ":%d:VENDOR_NAMEID").c_str(), (int) k), false); - _Items[k].FactionType = im->getDbProp(toString((dbPath + ":%d:FACTION_TYPE").c_str(), (int) k), false); - _Items[k].FactionPointPrice = im->getDbProp(toString((dbPath + ":%d:PRICE").c_str(), (int) k), false); - _Items[k].SellerType = im->getDbProp(toString((dbPath + ":%d:SELLER_TYPE").c_str(), (int) k), false); + _Items[k].SlotType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:SLOT_TYPE").c_str(), (int) k), false); + _Items[k].Quality = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:QUALITY").c_str(), (int) k), false); + _Items[k].SheetIDOrSkill = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:SHEET").c_str(), (int) k), false); + _Items[k].Price = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:PRICE").c_str(), (int) k), false); + _Items[k].Weight = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:WEIGHT").c_str(), (int) k), false); + _Items[k].NameId = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:NAMEID").c_str(), (int) k), false); + _Items[k].UserColor = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:USER_COLOR").c_str(), (int) k), false); + _Items[k].Enchant = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:ENCHANT").c_str(), (int) k), false); + _Items[k].RMClassType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:RM_CLASS_TYPE").c_str(), (int) k), false); + _Items[k].RMFaberStatType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:RM_FABER_STAT_TYPE").c_str(), (int) k), false); + _Items[k].PrerequisitValid = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:PREREQUISIT_VALID").c_str(), (int) k), false); + _Items[k].InfoVersion = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:INFO_VERSION").c_str(), (int) k), false); + _Items[k].Quantity = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:QUANTITY").c_str(), (int) k), false); + _Items[k].PriceRetire = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:PRICE_RETIRE").c_str(), (int) k), false); + _Items[k].ResaleTimeLeft = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:RESALE_TIME_LEFT").c_str(), (int) k), false); + _Items[k].VendorNameId = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:VENDOR_NAMEID").c_str(), (int) k), false); + _Items[k].FactionType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:FACTION_TYPE").c_str(), (int) k), false); + _Items[k].FactionPointPrice = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:PRICE").c_str(), (int) k), false); + _Items[k].SellerType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:SELLER_TYPE").c_str(), (int) k), false); if ((_Items[k].SlotType == NULL) || (_Items[k].Quality == NULL) || (_Items[k].SheetIDOrSkill == NULL) || (_Items[k].Price == NULL) || (_Items[k].Weight==NULL) || (_Items[k].InfoVersion==NULL) || (_Items[k].UserColor==NULL) || (_Items[k].NameId==NULL) || (_Items[k].Quantity==NULL) || @@ -189,18 +189,18 @@ bool CHugeListObs::init() return false; break; case ItemForMissions: - _Items[k].SlotType = im->getDbProp(toString((dbPath + ":%d:SLOT_TYPE").c_str(), (int) k), false); - _Items[k].Quality = im->getDbProp(toString((dbPath + ":%d:QUALITY").c_str(), (int) k), false); - _Items[k].SheetIDOrSkill = im->getDbProp(toString((dbPath + ":%d:SHEET").c_str(), (int) k), false); - _Items[k].LogicTextID = im->getDbProp(toString((dbPath + ":%d:LOGIC_TEXT_ID").c_str(), (int) k), false); - _Items[k].DescTextID = im->getDbProp(toString((dbPath + ":%d:DESC_TEXT_ID").c_str(), (int) k), false); - _Items[k].Weight = im->getDbProp(toString((dbPath + ":%d:WEIGHT").c_str(), (int) k), false); - _Items[k].NameId = im->getDbProp(toString((dbPath + ":%d:NAMEID").c_str(), (int) k), false); - _Items[k].UserColor = im->getDbProp(toString((dbPath + ":%d:USER_COLOR").c_str(), (int) k), false); - _Items[k].Enchant = im->getDbProp(toString((dbPath + ":%d:ENCHANT").c_str(), (int) k), false); - _Items[k].RMClassType = im->getDbProp(toString((dbPath + ":%d:RM_CLASS_TYPE").c_str(), (int) k), false); - _Items[k].RMFaberStatType = im->getDbProp(toString((dbPath + ":%d:RM_FABER_STAT_TYPE").c_str(), (int) k), false); - _Items[k].InfoVersion = im->getDbProp(toString((dbPath + ":%d:INFO_VERSION").c_str(), (int) k), false); + _Items[k].SlotType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:SLOT_TYPE").c_str(), (int) k), false); + _Items[k].Quality = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:QUALITY").c_str(), (int) k), false); + _Items[k].SheetIDOrSkill = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:SHEET").c_str(), (int) k), false); + _Items[k].LogicTextID = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:LOGIC_TEXT_ID").c_str(), (int) k), false); + _Items[k].DescTextID = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:DESC_TEXT_ID").c_str(), (int) k), false); + _Items[k].Weight = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:WEIGHT").c_str(), (int) k), false); + _Items[k].NameId = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:NAMEID").c_str(), (int) k), false); + _Items[k].UserColor = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:USER_COLOR").c_str(), (int) k), false); + _Items[k].Enchant = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:ENCHANT").c_str(), (int) k), false); + _Items[k].RMClassType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:RM_CLASS_TYPE").c_str(), (int) k), false); + _Items[k].RMFaberStatType = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:RM_FABER_STAT_TYPE").c_str(), (int) k), false); + _Items[k].InfoVersion = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:INFO_VERSION").c_str(), (int) k), false); if ((_Items[k].SlotType == NULL) || (_Items[k].Quality == NULL) || (_Items[k].SheetIDOrSkill == NULL) || (_Items[k].LogicTextID == NULL) || (_Items[k].DescTextID == NULL) || (_Items[k].Weight==NULL) || (_Items[k].InfoVersion==NULL) || (_Items[k].UserColor==NULL) || @@ -210,16 +210,16 @@ bool CHugeListObs::init() return false; break; case Ascensor: - _Items[k].GuildIcon = im->getDbProp(toString((dbPath + ":%d:ICON").c_str(), (int) k), false); - _Items[k].GuildName = im->getDbProp(toString((dbPath + ":%d:NAME").c_str(), (int) k), false); + _Items[k].GuildIcon = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:ICON").c_str(), (int) k), false); + _Items[k].GuildName = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:NAME").c_str(), (int) k), false); if ((_Items[k].GuildIcon == NULL) || (_Items[k].GuildName == NULL)) return false; break; case Missions: - _Items[k].MissionDetailText = im->getDbProp(toString((dbPath + ":%d:DETAIL_TEXT").c_str(), (int) k), false); - _Items[k].MissionText = im->getDbProp(toString((dbPath + ":%d:TEXT").c_str(), (int) k), false); - _Items[k].MissionIcon = im->getDbProp(toString((dbPath + ":%d:ICON").c_str(), (int) k), false); - _Items[k].MissionPreReqState = im->getDbProp(toString((dbPath + ":%d:PREREQ_STATE").c_str(), (int) k), false); + _Items[k].MissionDetailText = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:DETAIL_TEXT").c_str(), (int) k), false); + _Items[k].MissionText = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:TEXT").c_str(), (int) k), false); + _Items[k].MissionIcon = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:ICON").c_str(), (int) k), false); + _Items[k].MissionPreReqState = NLGUI::CDBManager::getInstance()->getDbProp(toString((dbPath + ":%d:PREREQ_STATE").c_str(), (int) k), false); if ((_Items[k].MissionText == NULL) || (_Items[k].MissionIcon == NULL) || (_Items[k].MissionDetailText == NULL) || (_Items[k].MissionPreReqState == NULL)) return false; @@ -249,29 +249,29 @@ void CHugeListObs::start() switch(_Category) { case Trading: - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SHEET", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SHEET", (int) k), false); if (leaf) leaf->setValue32(0); - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SLOT_TYPE", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":%d:SLOT_TYPE", (int) k), false); if (leaf) leaf->setValue32(0); break; case ItemForMissions: - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SHEET", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SHEET", (int) k), false); if (leaf) leaf->setValue32(0); - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SLOT_TYPE", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":%d:SLOT_TYPE", (int) k), false); if (leaf) leaf->setValue32(0); break; case Ascensor: - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:ICON", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:ICON", (int) k), false); if (leaf) leaf->setValue64(0); - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:NAME", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_ASCENSOR":%d:NAME", (int) k), false); if (leaf) leaf->setValue32(0); break; case Missions: - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:ICON", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:ICON", (int) k), false); if (leaf) leaf->setValue64(0); - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:TEXT", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:TEXT", (int) k), false); if (leaf) leaf->setValue32(0); - leaf = im->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:DETAIL_TEXT", (int) k), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString(DB_LOCAL_BRANCH_FOR_MISSIONS":%d:DETAIL_TEXT", (int) k), false); if (leaf) leaf->setValue32(0); break; default: @@ -519,7 +519,7 @@ void CHugeListObs::updateUIItemPage(uint index) listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY)); } if (!listSheet) return; - itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_TO_BUY", false); + itemListCategoryLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TYPE_OF_ITEMS_TO_BUY", false); } break; case ItemForMissions: @@ -527,7 +527,7 @@ void CHugeListObs::updateUIItemPage(uint index) dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":"; listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MISSION)); if (!listSheet) return; - itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_FOR_MISSION", false); + itemListCategoryLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TYPE_OF_ITEMS_FOR_MISSION", false); if (!itemListCategoryLeaf) return; // display the group for mission items CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_MISSION); @@ -567,86 +567,86 @@ void CHugeListObs::updateUIItemPage(uint index) switch(_Category) { case Trading: - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); if (leaf) leaf->setValue32(currItem.Quality); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); if (leaf) leaf->setValue32(currItem.SlotType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); if (leaf) leaf->setValue32(currItem.SheetIDOrSkill); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); if (leaf) leaf->setValue32(currItem.Price); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); if (leaf) leaf->setValue32(currItem.Weight); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); if (leaf) leaf->setValue32(currItem.NameId); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); if (leaf) leaf->setValue32(currItem.UserColor); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); if (leaf) leaf->setValue32(currItem.Enchant); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS_TYPE", false); if (leaf) leaf->setValue32(currItem.RMClassType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); if (leaf) leaf->setValue32(currItem.RMFaberStatType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQUISIT_VALID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQUISIT_VALID", false); if (leaf) leaf->setValue32(currItem.PrerequisitValid); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); if (leaf) leaf->setValue32(currItem.InfoVersion); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUANTITY", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUANTITY", false); if (leaf) leaf->setValue32(currItem.Quantity); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE_RETIRE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE_RETIRE", false); if (leaf) leaf->setValue32(currItem.PriceRetire); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RESALE_TIME_LEFT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RESALE_TIME_LEFT", false); if (leaf) leaf->setValue32(currItem.ResaleTimeLeft); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SELLER_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SELLER_TYPE", false); if (leaf) leaf->setValue32(currItem.SellerType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":VENDOR_NAMEID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":VENDOR_NAMEID", false); if (leaf) leaf->setValue32(currItem.VendorNameId); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":FACTION_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":FACTION_TYPE", false); if (leaf) leaf->setValue32(currItem.FactionType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false); if (leaf) leaf->setValue32(currItem.FactionPointPrice); break; case ItemForMissions: - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false); if (leaf) leaf->setValue32(currItem.Quality); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false); if (leaf) leaf->setValue32(currItem.SlotType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false); if (leaf) leaf->setValue32(currItem.SheetIDOrSkill); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":LOGIC_TEXT_ID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":LOGIC_TEXT_ID", false); if (leaf) leaf->setValue32(currItem.LogicTextID); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DESC_TEXT_ID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DESC_TEXT_ID", false); if (leaf) leaf->setValue32(currItem.DescTextID); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false); if (leaf) leaf->setValue32(currItem.Weight); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false); if (leaf) leaf->setValue32(currItem.NameId); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false); if (leaf) leaf->setValue32(currItem.UserColor); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false); if (leaf) leaf->setValue32(currItem.Enchant); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS", false); if (leaf) leaf->setValue32(currItem.RMClassType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false); if (leaf) leaf->setValue32(currItem.RMFaberStatType); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false); if (leaf) leaf->setValue32(currItem.InfoVersion); break; case Ascensor: - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); if (leaf) leaf->setValue64(currItem.GuildIcon); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAME", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAME", false); if (leaf) leaf->setValue32(currItem.GuildName); break; case Missions: - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":TEXT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":TEXT", false); if (leaf) leaf->setValue64(currItem.MissionText); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DETAIL_TEXT", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DETAIL_TEXT", false); if (leaf) leaf->setValue64(currItem.MissionDetailText); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false); if (leaf) leaf->setValue32(currItem.MissionIcon); - leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQ_STATE", false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQ_STATE", false); if (leaf) leaf->setValue32(currItem.MissionPreReqState); break; default: @@ -717,10 +717,10 @@ void CHugeListObs::setPriceInDB(uint32 value, const std::string &ls, const std:: CSeeds money; money.setTotal(value); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp(ls)->setValue64(money.getLS()); - im->getDbProp(ms)->setValue64(money.getMS()); - im->getDbProp(bs)->setValue64(money.getBS()); - im->getDbProp(vbs)->setValue64(money.getVBS()); + NLGUI::CDBManager::getInstance()->getDbProp(ls)->setValue64(money.getLS()); + NLGUI::CDBManager::getInstance()->getDbProp(ms)->setValue64(money.getMS()); + NLGUI::CDBManager::getInstance()->getDbProp(bs)->setValue64(money.getBS()); + NLGUI::CDBManager::getInstance()->getDbProp(vbs)->setValue64(money.getVBS()); } diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index ba67661bf..6a1b54f56 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -934,9 +934,9 @@ class CHandlerChatGroupFilter : public IActionHandler } // inform DB for write right. - pIM->getDbProp("UI:VARIABLES:MAIN_CHAT:WRITE_RIGHT")->setValue32(writeRight); - pIM->getDbProp("UI:VARIABLES:MAIN_CHAT:IS_DYN_CHAT")->setValue32(isDynChat); - pIM->getDbProp("UI:VARIABLES:MAIN_CHAT:INDEX_DYN_CHAT")->setValue32(dynChatDbIndex); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIN_CHAT:WRITE_RIGHT")->setValue32(writeRight); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIN_CHAT:IS_DYN_CHAT")->setValue32(isDynChat); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIN_CHAT:INDEX_DYN_CHAT")->setValue32(dynChatDbIndex); // Update Chat Group Window from user chat button @@ -968,7 +968,7 @@ class CHandlerChatGroupFilter : public IActionHandler case CChatGroup::universe: pUserBut->setHardText("uiFilterUniverse"); break; case CChatGroup::dyn_chat: uint32 index = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex(); - uint32 textId = pIM->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); + uint32 textId = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+toString(index)+":NAME")->getValue32(); ucstring title; STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); if (title.empty()) @@ -1326,7 +1326,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, const ucstring &nam } CInterfaceManager* pIM= CInterfaceManager::getInstance(); - CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); FriendList.sortEx(order); } @@ -1351,7 +1351,7 @@ void CPeopleInterraction::addContactInList(uint32 contactId, uint32 nameID, TCha WaitingContacts.push_back(w); CInterfaceManager* pIM= CInterfaceManager::getInstance(); - CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); FriendList.sortEx(order); } } @@ -1423,7 +1423,7 @@ void CPeopleInterraction::updateContactInList(uint32 contactId, TCharConnectionS // Only do work if online status has changed if (FriendList.getOnline(index) != online) { - CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_ONLINE_OFFLINE_NOTIFICATIONS_CB", false); + CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_ONLINE_OFFLINE_NOTIFICATIONS_CB", false); if (node && node->getValueBool()) { // Only show the message if this player is not in my guild (because then the guild manager will show a message) @@ -1979,7 +1979,7 @@ class CHandlerTeamTarget : public IActionHandler { // Get the team name id. CLFECOMMON::TClientDataSetIndex entityId= CLFECOMMON::INVALID_CLIENT_DATASET_INDEX; - CCDBNodeLeaf *prop = pIM->getDbProp(toString(TEAM_DB_PATH ":%d:UID", peopleIndex), false); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp(toString(TEAM_DB_PATH ":%d:UID", peopleIndex), false); if (prop) entityId= prop->getValue32(); @@ -2082,7 +2082,7 @@ public: { if (ClientCfg.Local) { - CInterfaceManager::getInstance()->getDbProp(TEAM_DB_PATH ":SUCCESSOR_INDEX")->setValue32(peopleIndex); + NLGUI::CDBManager::getInstance()->getDbProp(TEAM_DB_PATH ":SUCCESSOR_INDEX")->setValue32(peopleIndex); } else { @@ -2350,8 +2350,8 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager* pIM= CInterfaceManager::getInstance(); - nlinfo("Load Order : %d", pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); - CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + nlinfo("Load Order : %d", NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); order = (CPeopleList::TSortOrder)(order + 1); if (order == CPeopleList::END_SORT_ORDER) @@ -2360,7 +2360,7 @@ public: } nlinfo("Save Order : %d", order); - pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->setValue32((sint32)order); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->setValue32((sint32)order); CPeopleList *pl = PeopleInterraction.getPeopleListFromCurrentMenu(); if (pl) pl->sortEx(order); @@ -2645,8 +2645,8 @@ public: CViewTextMenu *pMenuUniverse = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:universe")); CViewTextMenu *pMenuTeam = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:team")); CViewTextMenu *pMenuGuild = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:guild")); - const bool teamActive = pIM->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool(); - const bool guildActive = pIM->getDbProp("SERVER:GUILD:NAME")->getValueBool(); + const bool teamActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool(); + const bool guildActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValueBool(); if (pMenuAround) pMenuAround->setGrayed (false); if (pMenuRegion) pMenuRegion->setGrayed (false); if (pMenuUniverse) pMenuUniverse->setGrayed (false); @@ -2668,7 +2668,7 @@ public: bool active = (textId != 0); if (active) { - uint32 canWrite = im->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":WRITE_RIGHT")->getValue32(); + uint32 canWrite = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DYN_CHAT:CHANNEL"+s+":WRITE_RIGHT")->getValue32(); if (canWrite != 0) { ucstring title; @@ -2787,7 +2787,7 @@ class CHandlerLeaveTeamChat : public IActionHandler CInterfaceManager *im = CInterfaceManager::getInstance(); if( im ) { - if( !im->getDbProp("UI:VARIABLES:IS_TEAM_PRESENT")->getValueBool() ) + if( !NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:IS_TEAM_PRESENT")->getValueBool() ) { ChatMngr.updateChatModeAndButton(CChatGroup::say); } @@ -2893,8 +2893,8 @@ class CHandlerSelectChatSource : public IActionHandler { // This is neither the ChatGroup, nor the UserChat. Should not be here. // Just open the STD chat menu, and quit - im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); - im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); CInterfaceManager::getInstance()->enableModalWindow(pCaller, STD_CHAT_SOURCE_MENU); return; } @@ -2995,8 +2995,8 @@ class CHandlerSelectChatSource : public IActionHandler // *** active the menu - im->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); - im->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); im->enableModalWindow(pCaller, menu); } }; @@ -3313,7 +3313,7 @@ NLMISC_COMMAND(chatLog, "", "") if (pIM->getLogState()) pIM->displaySystemInfo(CI18N::get("uiLogTurnedOn")); - CCDBNodeLeaf *node = pIM->getDbProp("UI:SAVE:CHATLOG_STATE", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHATLOG_STATE", false); if (node) { node->setValue32(pIM->getLogState() ? 1 : 0); diff --git a/code/ryzom/client/src/interface_v3/player_trade.cpp b/code/ryzom/client/src/interface_v3/player_trade.cpp index ebc618ec7..47d8bfecc 100644 --- a/code/ryzom/client/src/interface_v3/player_trade.cpp +++ b/code/ryzom/client/src/interface_v3/player_trade.cpp @@ -174,7 +174,7 @@ class CPlayerTradeStartHandler : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getDbProp("LOCAL:EXCHANGE:BEGUN")->getValue8() != 0) + if (NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:EXCHANGE:BEGUN")->getValue8() != 0) { //PlayerTrade.reset(); diff --git a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp index ec29be009..d4d8217b1 100644 --- a/code/ryzom/client/src/interface_v3/sbrick_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sbrick_manager.cpp @@ -128,11 +128,11 @@ void CSBrickManager::initInGame() { //get the known brick entries in the database sprintf(buf,"SERVER:BRICK_FAMILY:%d:BRICKS",i); - _FamiliesBits[i] = pIM->getDbProp(buf); + _FamiliesBits[i] = NLGUI::CDBManager::getInstance()->getDbProp(buf); } // Add a branch observer on brick family - pIM->addBranchObserver( "SERVER:BRICK_FAMILY", &_BrickFamilyObs); + NLGUI::CDBManager::getInstance()->addBranchObserver( "SERVER:BRICK_FAMILY", &_BrickFamilyObs); } // *************************************************************************** @@ -147,7 +147,7 @@ void CSBrickManager::uninitInGame() } // remove branch observer on brick family - CCDBNodeBranch *branch= pIM->getDbBranch("SERVER:BRICK_FAMILY"); + CCDBNodeBranch *branch= NLGUI::CDBManager::getInstance()->getDbBranch("SERVER:BRICK_FAMILY"); if(branch) branch->removeBranchObserver(&_BrickFamilyObs); } diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index d335f0c33..e72ab80c6 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -148,17 +148,17 @@ void CSkillManager::initInGame() // get now the nodes on Skill values for(i=0;igetDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", i), false); - _SkillBaseValues[i]= pIM->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", i), false); + _SkillValues[i]= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", i), false); + _SkillBaseValues[i]= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", i), false); } // compute max child values computeMaxChildValues(); // must be called after setting all _SkillBaseValues // Get a node used to inform interface that a skill has changed - _TrackSkillChange= pIM->getDbProp("UI:VARIABLES:TRACK_SKILL_CHANGE", true); + _TrackSkillChange= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TRACK_SKILL_CHANGE", true); // Add a branch observer on skill value change - pIM->addBranchObserver( "SERVER:CHARACTER_INFO:SKILLS", &_SkillChangeObs ); + NLGUI::CDBManager::getInstance()->addBranchObserver( "SERVER:CHARACTER_INFO:SKILLS", &_SkillChangeObs ); } @@ -779,15 +779,15 @@ void CSkillManager::tryToUnblockTitleFromCiv(bool show_message) if (IngameDbMngr.initInProgress()) { - if (im->getDbProp("UI:SAVE:FAME:CIV_ALLEGIANCE")->getValue32() != civNeeded) + if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:FAME:CIV_ALLEGIANCE")->getValue32() != civNeeded) _TitlesUnblocked[i].UnblockedCiv = false; continue; } else { - CCDBNodeLeaf * civLeaf = im->getDbProp("SERVER:FAME:CIV_ALLEGIANCE"); + CCDBNodeLeaf * civLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:FAME:CIV_ALLEGIANCE"); uint8 civDBValue = civLeaf->getValue8(); - im->getDbProp("UI:SAVE:FAME:CIV_ALLEGIANCE")->setValue32((uint32)civDBValue); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:FAME:CIV_ALLEGIANCE")->setValue32((uint32)civDBValue); if( civDBValue != civNeeded ) { @@ -818,15 +818,15 @@ void CSkillManager::tryToUnblockTitleFromCult(bool show_message) if (IngameDbMngr.initInProgress()) { - if (im->getDbProp("UI:SAVE:FAME:CULT_ALLEGIANCE")->getValue32() != cultNeeded) + if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:FAME:CULT_ALLEGIANCE")->getValue32() != cultNeeded) _TitlesUnblocked[i].UnblockedCult = false; continue; } else { - CCDBNodeLeaf * cultLeaf = im->getDbProp("SERVER:FAME:CULT_ALLEGIANCE"); + CCDBNodeLeaf * cultLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:FAME:CULT_ALLEGIANCE"); uint8 cultDBValue = cultLeaf->getValue8(); - im->getDbProp("UI:SAVE:FAME:CULT_ALLEGIANCE")->setValue32((uint32)cultDBValue); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:FAME:CULT_ALLEGIANCE")->setValue32((uint32)cultDBValue); if( cultDBValue != cultNeeded ) { @@ -943,7 +943,7 @@ void CSkillManager::tryToUnblockTitleFromItems(bool show_message) CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get inventory in bag - CCDBNodeBranch *nb = pIM->getDbBranch(branch); + CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(branch); if (!nb) return; @@ -978,7 +978,7 @@ void CSkillManager::tryToUnblockTitleFromItems(bool show_message) sint32 qualityItem = 0; // get sheetid - CCDBNodeLeaf *node = pIM->getDbProp(branch + ":" + toString(itemSlot) + ":SHEET", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(branch + ":" + toString(itemSlot) + ":SHEET", false); if (node) sheetItem = (uint32)node->getValue32(); @@ -987,7 +987,7 @@ void CSkillManager::tryToUnblockTitleFromItems(bool show_message) continue; // get quality - node = pIM->getDbProp(branch + ":" + toString(itemSlot) + ":QUALITY", false); + node = NLGUI::CDBManager::getInstance()->getDbProp(branch + ":" + toString(itemSlot) + ":QUALITY", false); if (node) qualityItem = node->getValue32(); @@ -1061,7 +1061,7 @@ public: { if (i == pSM->_CurrentTitle) { - pIM->getDbProp("UI:TITLE")->setValue32(j); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TITLE")->setValue32(j); break; } j++; diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index 5fb3244d8..26245b2c5 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -114,7 +114,7 @@ void CSPhraseManager::initInGame() _BookDbLeaves.resize(PHRASE_MAX_BOOK_SLOT, NULL); for(i=0;igetDbProp(PHRASE_DB_BOOK + ":" + toString(i) + ":PHRASE"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_BOOK + ":" + toString(i) + ":PHRASE"); node->setValue32(0); _BookDbLeaves[i]= node; } @@ -123,10 +123,10 @@ void CSPhraseManager::initInGame() for(i=0;igetDbProp(PHRASE_DB_MEMORY + ":" + toString(i) + ":PHRASE"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_MEMORY + ":" + toString(i) + ":PHRASE"); node->setValue32(0); _MemoryDbLeaves[i]= node; - CCDBNodeLeaf *node_alt= pIM->getDbProp(PHRASE_DB_MEMORY_ALT + ":" + toString(i) + ":PHRASE"); + CCDBNodeLeaf *node_alt= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_MEMORY_ALT + ":" + toString(i) + ":PHRASE"); node_alt->setValue32(0); _MemoryAltDbLeaves[i]= node_alt; } @@ -144,15 +144,15 @@ void CSPhraseManager::initInGame() for(uint j=0;jgetDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":SHEET"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":SHEET"); node->setValue32(0); _ProgressionDbSheets[j][i]= node; // LEVEL - node= pIM->getDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":LEVEL"); + node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":LEVEL"); node->setValue32(0); _ProgressionDbLevels[j][i]= node; // LOCKED - node= pIM->getDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":LOCKED"); + node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_PROGRESSION[j] + ":" + toString(i) + ":LOCKED"); node->setValue32(0); _ProgressionDbLocks[j][i]= node; } @@ -160,10 +160,10 @@ void CSPhraseManager::initInGame() // init the UI Next Execute slot { - CCDBNodeLeaf *node= pIM->getDbProp(PHRASE_DB_EXECUTE_NEXT); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_EXECUTE_NEXT); node->setValue32(0); _NextExecuteLeaf= node; - node= pIM->getDbProp(PHRASE_DB_EXECUTE_NEXT_IS_CYCLIC); + node= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_EXECUTE_NEXT_IS_CYCLIC); node->setValue32(0); _NextExecuteIsCyclicLeaf= node; } @@ -172,8 +172,8 @@ void CSPhraseManager::initInGame() _BotChatPhrasePriceLeaves.resize(PHRASE_MAX_BOTCHAT_SLOT, NULL); for(i=0;igetDbProp(PHRASE_DB_BOTCHAT+ ":" + toString(i) + ":SHEET"); - CCDBNodeLeaf *nodePrice= pIM->getDbProp(PHRASE_DB_BOTCHAT+ ":" + toString(i) + ":PRICE"); + CCDBNodeLeaf *nodeSheet= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_BOTCHAT+ ":" + toString(i) + ":SHEET"); + CCDBNodeLeaf *nodePrice= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_BOTCHAT+ ":" + toString(i) + ":PRICE"); _BotChatPhraseSheetLeaves[i]= nodeSheet; _BotChatPhrasePriceLeaves[i]= nodePrice; } @@ -787,7 +787,7 @@ void CSPhraseManager::buildPhraseFromSheet(CSPhraseCom &phrase, sint32 sheetI bool CSPhraseManager::isPhraseNextExecuteCounterSync() const { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - sint32 srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); + sint32 srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_NEXT)->getValue32(); return srvVal==(sint32)_PhraseNextExecuteCounter; } @@ -795,7 +795,7 @@ bool CSPhraseManager::isPhraseNextExecuteCounterSync() const bool CSPhraseManager::isPhraseCycleExecuteCounterSync() const { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - sint32 srvVal= pIM->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); + sint32 srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); return srvVal==(sint32)_PhraseCycleExecuteCounter; } @@ -1098,7 +1098,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // **** Compute Phrase Elements from phrase // get the current action malus (0-100) uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= pIM->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if(actMalus && !rootBrick->isSpecialPower()) @@ -1134,11 +1134,11 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, uint32 rightHandSheet = inv->getRightHandItemSheet(); if( inv->isRangeWeaponItem(rightHandSheet) ) { - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); } else { - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); } } } @@ -1146,19 +1146,19 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // phrase usable only in melee fight if( usableWithMelee ) { - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MELEE", false); } else // phrase usable only in range fight if( usableWithRange ) { - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:RANGE", false); } } else if(rootBrick->isMagic()) { - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MAGIC", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:MAGIC", false); } if(nodeSM) { @@ -1190,14 +1190,14 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // Replace forage success rate in any ecotype successModifier = 0; sint32 commonModifier = 0; - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:0:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:0:FORAGE", false); if(nodeSM) { commonModifier = nodeSM->getValue32(); } //desert success= getForageExtractionPhraseSuccessRate(phrase, SKILLS::SHFDAEM); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:1:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:1:FORAGE", false); if(nodeSM) successModifier = nodeSM->getValue32(); if( successModifier == 0 ) successModifier = commonModifier; @@ -1207,7 +1207,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, //forest success= getForageExtractionPhraseSuccessRate(phrase, SKILLS::SHFFAEM); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:2:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:2:FORAGE", false); if(nodeSM) successModifier = nodeSM->getValue32(); if( successModifier == 0 ) successModifier = commonModifier; @@ -1217,7 +1217,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // lake success= getForageExtractionPhraseSuccessRate(phrase, SKILLS::SHFLAEM); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:3:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:3:FORAGE", false); if(nodeSM) successModifier = nodeSM->getValue32(); if( successModifier == 0 ) successModifier = commonModifier; @@ -1227,7 +1227,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, // jungle success= getForageExtractionPhraseSuccessRate(phrase, SKILLS::SHFJAEM); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:4:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:4:FORAGE", false); if(nodeSM) successModifier = nodeSM->getValue32(); if( successModifier == 0 ) successModifier = commonModifier; @@ -1237,7 +1237,7 @@ void CSPhraseManager::buildPhraseDesc(ucstring &text, const CSPhraseCom &phrase, //prime roots success= getForageExtractionPhraseSuccessRate(phrase, SKILLS::SHFPAEM); - nodeSM = pIM->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:6:FORAGE", false); + nodeSM = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SUCCESS_MODIFIER:ECO:6:FORAGE", false); if(nodeSM) successModifier = nodeSM->getValue32(); if( successModifier == 0 ) successModifier = commonModifier; @@ -1628,7 +1628,7 @@ float CSPhraseManager::getPhraseSumBrickProp(const CSPhraseCom &phrase, uint else if(propId==CSBrickManager::getInstance()->StaPropId && brick->Properties[j].PropId==CSBrickManager::getInstance()->StaWeightFactorId) { CInterfaceManager *im = CInterfaceManager::getInstance(); - uint32 weight = (uint32) im->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS")->getValue32() / 10; // weight must be in dg here + uint32 weight = (uint32) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS")->getValue32() / 10; // weight must be in dg here CDBCtrlSheet *ctrlSheet = dynamic_cast(im->getElementFromId("ui:interface:gestionsets:hands:handr")); if (ctrlSheet) { @@ -2351,18 +2351,18 @@ public: if(T1>pPM->_PhraseDebugEndNextAction) { // copy counter - pIM->getDbProp(PHRASE_DB_COUNTER_NEXT)->setValue32(pPM->_PhraseNextExecuteCounter); + NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_NEXT)->setValue32(pPM->_PhraseNextExecuteCounter); } if(T1>pPM->_PhraseDebugEndCyclicAction) { // copy counter - pIM->getDbProp(PHRASE_DB_COUNTER_CYCLE)->setValue32(pPM->_PhraseCycleExecuteCounter); + NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->setValue32(pPM->_PhraseCycleExecuteCounter); } - sint64 st= pIM->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK")->getValue64(); - sint64 stEnd= pIM->getDbProp("SERVER:USER:ACT_TEND")->getValue64(); + sint64 st= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK")->getValue64(); + sint64 stEnd= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TEND")->getValue64(); if(stEnd && st>stEnd+20) - pIM->getDbProp("SERVER:USER:ACT_TEND")->setValue64(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TEND")->setValue64(0); } } }; @@ -2569,11 +2569,11 @@ CSheetId getRightHandItem() CSheetId item; // get the RightHand bag index - sint32 itemSlot= pIM->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); + sint32 itemSlot= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); // if something in hand if(itemSlot>0) { - CCDBNodeLeaf *node= pIM->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":SHEET", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":SHEET", false); if(node) item= node->getValue32(); } @@ -2637,11 +2637,11 @@ uint32 getRightHandEffectiveLevel() // **** get the right hand item 'required skill' // get the RightHand bag index - sint32 itemSlot= pIM->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); + sint32 itemSlot= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); // if something in hand if(itemSlot>0) { - CCDBNodeLeaf *node= pIM->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":QUALITY", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":QUALITY", false); if(node) // if the right hand item quality is less than our skill value, take it.... effectiveLevel= min(effectiveLevel, (uint32)node->getValue32()); @@ -2658,11 +2658,11 @@ static sint getRightHandEnchantValue() sint ret= 0; // get the RightHand bag index - sint32 itemSlot= pIM->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); + sint32 itemSlot= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG")->getValue32(); // if something in hand if(itemSlot>0) { - CCDBNodeLeaf *node= pIM->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":ENCHANT", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:BAG:"+toString(itemSlot-1) +":ENCHANT", false); if(node) ret= node->getValue32(); } @@ -4477,7 +4477,7 @@ uint32 CSPhraseManager::getTotalActionMalus(const CSPhraseCom &phrase) const CInterfaceManager *pIM = CInterfaceManager::getInstance(); CSBrickManager *pBM= CSBrickManager::getInstance(); uint32 totalActionMalus= 0; - CCDBNodeLeaf *actMalus= pIM->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); + CCDBNodeLeaf *actMalus= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TOTAL_MALUS_EQUIP", false); // root brick must not be Power or aura, because Action malus don't apply to them // (ie leave 0 ActionMalus for Aura or Powers if (!phrase.Bricks.empty()) @@ -4494,7 +4494,7 @@ uint32 CSPhraseManager::getTotalActionMalus(const CSPhraseCom &phrase) const CCDBNodeLeaf *CSPhraseManager::getRegenTickRangeDbLeaf(uint powerIndex) const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *dbLeaf = pIM->getDbProp(toString("SERVER:FLAGS:BRICK_TICK_RANGE:%d:TICK_RANGE", (int) powerIndex), false); + CCDBNodeLeaf *dbLeaf = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:FLAGS:BRICK_TICK_RANGE:%d:TICK_RANGE", (int) powerIndex), false); return dbLeaf; } diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 7f3d222b4..933d57b80 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -124,8 +124,8 @@ void CViewRadar::draw () float maxSqrRadius= (float)sqr(_WorldSize/2); - const bool displayMissionSpots = pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); - const bool displayMiniMissionSpots = pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MINI_MISSION_ICON")->getValueBool(); + const bool displayMissionSpots = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); + const bool displayMiniMissionSpots = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:INSCENE:FRIEND:MINI_MISSION_ICON")->getValueBool(); for (sint32 i = 1; i < 256; ++i) { diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 533ccf194..041745571 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -213,7 +213,7 @@ string CViewTextID::getTextIdDbLink() const // *************************************************************************** void CViewTextID::setTextIdDbLink(const string &link) { - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp(link,false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(link,false); if (pNL == NULL) { nlwarning("cant set textidlink for %s",link.c_str()); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index d8cfa7878..ef014f6bc 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -209,7 +209,7 @@ void initEula() CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (!ClientCfg.SkipEULA && CFile::fileExists(getLogDirectory() + "show_eula")) { - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_EULA); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_EULA); // if we display the eula, it means we make a patch so we clean the cache directory // (clear cache after each patch) @@ -260,7 +260,7 @@ void initCatDisplay() (InfoOnPatch.ReqCat.size() > 0)) { createOptionalCatUI(); - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CATDISP); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CATDISP); } else { @@ -272,7 +272,7 @@ void initCatDisplay() void initReboot() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_REBOOT); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_REBOOT); } @@ -361,7 +361,7 @@ void loginMainLoop() // while (loginFinished == false) { IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Update the DT T0 and T1 global variables updateClientTime(); @@ -380,7 +380,7 @@ void loginMainLoop() pIM->updateFrameEvents(); pIM->updateFrameViews(NULL); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); @@ -399,7 +399,7 @@ void loginMainLoop() // Display Driver->swapBuffers(); -// sint32 screen = pIM->getDbProp("UI:VARIABLES:SCREEN")->getValue32(); +// sint32 screen = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->getValue32(); if (LoginSM.getCurrentState() == CLoginStateMachine::st_check_patch) // if (screen == UI_VARIABLES_SCREEN_CHECKING) // If we are in checking mode { @@ -487,7 +487,7 @@ void loginMainLoop() { LoginSM.pushEvent(CLoginStateMachine::ev_patch_needed); // createOptionalCatUI(); - // pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CATDISP); + // NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CATDISP); } else { @@ -525,10 +525,10 @@ void loginMainLoop() if (pPM->isScanDataThreadEnded(res)) { // if interface consider it was running before - if(pIM->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->getValue32()!=0) + if(NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->getValue32()!=0) { // no more running - pIM->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(0); if(res) { @@ -722,8 +722,8 @@ void initLoginScreen() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); - pIM->getDbProp("UI:VARIABLES:DISPLAY_ACCOUNT_BUTTONS")->setValue32(ClientCfg.DisplayAccountButtons); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DISPLAY_ACCOUNT_BUTTONS")->setValue32(ClientCfg.DisplayAccountButtons); // Active inputs Actions.enable(true); @@ -813,7 +813,7 @@ bool login() pIM->initLogin(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); bool tmpDI = ClientCfg.DisableDirectInput; ClientCfg.DisableDirectInput = true; @@ -828,7 +828,7 @@ bool login() // if (ClientCfg.TestBrowser) // { -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // // // hide 'back to login' button // CInterfaceElement *backToLogin = pIM->getElementFromId(CTRL_BUTTON_BACKTOLOGIN); @@ -848,8 +848,8 @@ bool login() // } // else // { -//// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); -//// pIM->getDbProp("UI:VARIABLES:DISPLAY_ACCOUNT_BUTTONS")->setValue32(ClientCfg.DisplayAccountButtons); +//// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); +//// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DISPLAY_ACCOUNT_BUTTONS")->setValue32(ClientCfg.DisplayAccountButtons); // } // Active inputs @@ -1020,7 +1020,7 @@ void initPatchCheck() CBGDownloaderAccess::getInstance().requestDownloadThreadPriority(BGDownloader::ThreadPriority_Normal, false); CBGDownloaderAccess::getInstance().startTask(taskDesc, getBGDownloaderCommandLine(), true /* showDownloader */); } - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); setPatcherStateText("ui:login:checking", ucstring()); setPatcherProgressText("ui:login:checking", ucstring()); @@ -1029,7 +1029,7 @@ void initPatchCheck() void initShardDisplay() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD)); if (pList == NULL) @@ -1113,7 +1113,7 @@ void onlogin(bool vanishScreen = true) } if(vanishScreen) - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(-1); // Check the login/pass @@ -1138,12 +1138,12 @@ void onlogin(bool vanishScreen = true) // pPM->init(R2PatchURLs, R2BackupPatchURL, R2ServerVersion); // // pPM->startCheckThread(); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); // } // else // { // // go directly to web browser -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // // CInterfaceManager *pIM = CInterfaceManager::getInstance(); // // start the browser @@ -1155,7 +1155,7 @@ void onlogin(bool vanishScreen = true) } else { -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); } // CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD)); @@ -1230,7 +1230,7 @@ void onlogin(bool vanishScreen = true) pIM->messageBoxWithHelp("Error : " + res, "ui:login"); LoginSM.pushEvent(CLoginStateMachine::ev_bad_login); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); // // if (LoginLogin.empty()) // pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); @@ -1317,7 +1317,7 @@ class CAHLoginTab : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CHECKPASS) + if (NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CHECKPASS) { CCtrlBase *pCB = pIM->getCaptureKeyboard(); if (pCB != NULL) @@ -1331,7 +1331,7 @@ class CAHLoginTab : public IActionHandler pIM->setCaptureKeyboard(pNewCB); } } - else if (pIM->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CREATE_ACCOUNT) + else if (NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CREATE_ACCOUNT) { CCtrlBase *pCB = pIM->getCaptureKeyboard(); if (pCB != NULL) @@ -1466,7 +1466,7 @@ class CAHLoginConnect : public IActionHandler // if (ClientCfg.PatchWanted) // { // pPM->startCheckThread(); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); // } // else // { @@ -1511,7 +1511,7 @@ class CAHLoginConnect2 : public IActionHandler // (Shards[ShardSelected].Version != pPM->getClientVersion())) // { // pPM->startCheckThread(); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKING); // } // else // { @@ -1571,7 +1571,7 @@ void initPatch() // release lock on bnp, so that they can be written NLMISC::CBigFile::getInstance().removeAll(); } - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); CInterfaceElement *closeBtn = pIM->getElementFromId(CTRL_BUTTON_CLOSE_PATCH); if (closeBtn) @@ -1629,7 +1629,7 @@ class CAHLoginPatch : public IActionHandler // if (ClientCfg.PatchWanted) // { // pPM->startPatchThread(vCategories); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); // } // else // { @@ -1758,7 +1758,7 @@ class CAHAcceptEula : public IActionHandler // { // // open web browser // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // // // start the browser // CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); @@ -2122,8 +2122,8 @@ void initDataScan() // Start Scanning pPM->startScanDataThread(); - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_DATASCAN); - pIM->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_DATASCAN); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->setValue32(1); } @@ -2152,7 +2152,7 @@ class CAHOnScanDataClose : public IActionHandler CPatchManager *pPM = CPatchManager::getInstance(); // if the scan is still running - if(pIM->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->getValue32()!=0) + if(NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DATASCAN_RUNNING")->getValue32()!=0) { // request to stop the thread pPM->askForStopScanDataThread(); @@ -2164,7 +2164,7 @@ class CAHOnScanDataClose : public IActionHandler { LoginSM.pushEvent(CLoginStateMachine::ev_close_data_scan); // Come Back to Login Screen. -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); // // // Give focus to password if some login entered // string loginEB; @@ -2358,7 +2358,7 @@ bool initCreateAccount() } - pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CREATE_ACCOUNT); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CREATE_ACCOUNT); return true; } @@ -2643,7 +2643,7 @@ class CAHOnBackToLogin: public IActionHandler // CInterfaceManager *pIM = CInterfaceManager::getInstance(); // // need to reset password and current screen -// pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); +// NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); } }; REGISTER_ACTION_HANDLER (CAHOnBackToLogin, "on_back_to_login"); @@ -3035,7 +3035,7 @@ void loginIntro() const ucstring nmsg(""); ProgressBar.newMessage (nmsg); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } } beginLoading(StartBackground); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index d3c8023a4..4989b3f71 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -242,7 +242,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); if(pIM) { - CCDBNodeLeaf *pNodeLeaf = pIM->getDbProp("SERVER:DEBUG_INFO:Ping", false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DEBUG_INFO:Ping", false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -260,7 +260,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); if(pIM) { - CCDBNodeLeaf *pNodeLeaf = pIM->getDbProp("SERVER:DEBUG_INFO:Ping", false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:DEBUG_INFO:Ping", false); if(pNodeLeaf) { ICDBNode::CTextId textId; @@ -1642,7 +1642,7 @@ bool mainLoop() // flush observers IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); } @@ -1660,7 +1660,7 @@ bool mainLoop() // NetWork Update. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // lets some CPU. NetMngr.send(); nlSleep(100); @@ -1770,7 +1770,7 @@ bool mainLoop() NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); bool prevDatabaseInitStatus = IngameDbMngr.initInProgress(); IngameDbMngr.setChangesProcessed(); bool newDatabaseInitStatus = IngameDbMngr.initInProgress(); @@ -1841,7 +1841,7 @@ bool mainLoop() // update bot chat CBotChatManager::getInstance()->update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // updateItemEdition CInterfaceItemEdition::getInstance()->update(); @@ -2296,7 +2296,7 @@ bool mainLoop() deltaTime = smoothFPS.getSmoothValue (); if (deltaTime > 0.0) { - CCDBNodeLeaf*pNL = pIMinstance->getDbProp("UI:VARIABLES:FPS"); + CCDBNodeLeaf*pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:FPS"); pNL->setValue64((sint64)(1.f/deltaTime)); } } diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index ec8b46af7..6353029d8 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -813,10 +813,10 @@ void getSeedsFromDB(CSeeds &dest) string bs = im->getDefine("money_3"); string vbs = im->getDefine("money_4"); - dest = CSeeds(im->getDbProp(ls)->getValue32(), - im->getDbProp(ms)->getValue32(), - im->getDbProp(bs)->getValue32(), - im->getDbProp(vbs)->getValue32()); + dest = CSeeds(NLGUI::CDBManager::getInstance()->getDbProp(ls)->getValue32(), + NLGUI::CDBManager::getInstance()->getDbProp(ms)->getValue32(), + NLGUI::CDBManager::getInstance()->getDbProp(bs)->getValue32(), + NLGUI::CDBManager::getInstance()->getDbProp(vbs)->getValue32()); } // getSeedsFromDB // diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index 7ce5523b2..158465420 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -294,7 +294,7 @@ void CUserControls::update() // update camera collision once per frame View.updateCameraCollision(); - CInterfaceManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")->setValue32(autowalkState()); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MK_MOVE")->setValue32(autowalkState()); }// update // diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 8116ccaea..26104a445 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -775,7 +775,7 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c PeopleInterraction.ChatInput.DynamicChat[dbIndex].displayMessage(finalString, col, 2, &windowVisible); // Add dynchannel info before text so that the chat log will show the correct string. - CCDBNodeLeaf* node = pIM->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false); + CCDBNodeLeaf* node = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false); if (pIM->getLogState()) { // Add dyn chan number before string @@ -1185,10 +1185,10 @@ static void setupBotChatBotGift(CInterfaceGroup *botChatGroup) { // create dummy item in the db CInterfaceManager *im = CInterfaceManager::getInstance(); - im->getDbProp("SERVER:INVENTORY:20:0:SHEET")->setValue32(CSheetId("ai_flesh_poisson.item").asInt()); - im->getDbProp("SERVER:INVENTORY:20:0:QUALITY")->setValue32(0); - im->getDbProp("SERVER:INVENTORY:20:1:SHEET")->setValue32(CSheetId("fyros_sword_lvl_01_05.item").asInt()); - im->getDbProp("SERVER:INVENTORY:20:1:QUALITY")->setValue32(2); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:0:SHEET")->setValue32(CSheetId("ai_flesh_poisson.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:0:QUALITY")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:SHEET")->setValue32(CSheetId("fyros_sword_lvl_01_05.item").asInt()); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:20:1:QUALITY")->setValue32(2); CBotChat::setBotGift(botChatGroup, ucstring("Thanks to have succeeded the mission"), ucstring("Here's your reward"), ucstring("The bot has taken the object quest from your inventory")); } */ @@ -1360,9 +1360,9 @@ void impulseBeginCast(NLMISC::CBitMemStream &impulse) impulse.serial(end); if (PermanentlyBanned) return; CInterfaceManager* iMngr = CInterfaceManager::getInstance(); - iMngr->getDbProp("UI:VARIABLES:SPELL_CAST")->setValue32(1); - iMngr->getDbProp("UI:VARIABLES:CAST_BEGIN")->setValue32(begin); - iMngr->getDbProp("UI:VARIABLES:CAST_END")->setValue32(end); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SPELL_CAST")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CAST_BEGIN")->setValue32(begin); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CAST_END")->setValue32(end); } @@ -1836,7 +1836,7 @@ void impulseTeamContactStatus(NLMISC::CBitMemStream &impulse) // Resort the contact list if needed CInterfaceManager* pIM= CInterfaceManager::getInstance(); - CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(pIM->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); + CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); if (order == CPeopleList::sort_online) { @@ -2409,7 +2409,7 @@ void impulseJournalCantAbandon (NLMISC::CBitMemStream &impulse) { if (PermanentlyBanned) return; /// reactivate abandon button - CCDBNodeLeaf *pNL = CInterfaceManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION_ABANDON_BUTTON",false); if (pNL != NULL) pNL->setValue64(1); } @@ -2551,7 +2551,7 @@ void impulseGuildOpenGuildWindow(NLMISC::CBitMemStream &impulse) void impulseGuildOpenInventory (NLMISC::CBitMemStream &impulse) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED")->setValue32(1); } //----------------------------------------------- @@ -2560,7 +2560,7 @@ void impulseGuildOpenInventory (NLMISC::CBitMemStream &impulse) void impulseGuildCloseInventory (NLMISC::CBitMemStream &impulse) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_GUILD_OPENED")->setValue32(0); } //----------------------------------------------- @@ -3124,7 +3124,7 @@ void impulseItemOpenRoomInventory(NLMISC::CBitMemStream &impulse) if (PermanentlyBanned) return; // This is a message because we may do other things there CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED")->setValue32(1); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED")->setValue32(1); } //----------------------------------------------- @@ -3134,7 +3134,7 @@ void impulseItemCloseRoomInventory(NLMISC::CBitMemStream &impulse) if (PermanentlyBanned) return; // This is a message because we may do other things there CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED")->setValue32(0); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED")->setValue32(0); // deactivate the pop up window CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:inv_room")); @@ -3198,17 +3198,17 @@ void impulseOutpostDeclareWarAck(NLMISC::CBitMemStream &impulse) CInterfaceManager *pIM= CInterfaceManager::getInstance(); // ack reception - CCDBNodeLeaf *node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_RECEIVED"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_RECEIVED"); if(node) node->setValueBool(true); // set result of ACK - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_OK"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_OK"); if(node) node->setValueBool(canValidate); - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TEXTID"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TEXTID"); if(node) node->setValue32(docTextId); - node= pIM->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:DECLARE_WAR_ACK_TIME_RANGE_ATT"); if(node) node->setValue32(timeStartAttack); } @@ -3407,7 +3407,7 @@ void impulseUserPopup(NLMISC::CBitMemStream &impulse) // setup TEMP DB for title CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:TEMP:SERVER_POPUP:TITLE"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:SERVER_POPUP:TITLE"); if(node) node->setValue32(titleTextId); // Open the Popup only when the 2 dyn strings are available @@ -3862,22 +3862,22 @@ bool CNetManager::update() CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CCDBNodeLeaf *node = im->getDbProp("UI:VARIABLES:PING", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PING", false); if (node) node->setValue32(getPing()); - node = im->getDbProp("UI:VARIABLES:UPLOAD", false); + node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:UPLOAD", false); if (node) node->setValue32((sint32)(getMeanUpload()*1024.f/8.f)); - node = im->getDbProp("UI:VARIABLES:DOWNLOAD", false); + node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DOWNLOAD", false); if (node) node->setValue32((sint32)(getMeanDownload()*1024.f/8.f)); - node = im->getDbProp("UI:VARIABLES:PACKETLOST", false); + node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PACKETLOST", false); if (node) node->setValue32((sint32)getMeanPacketLoss()); - node = im->getDbProp("UI:VARIABLES:SERVERSTATE", false); + node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SERVERSTATE", false); if (node) node->setValue32((sint32)getConnectionState()); - node = im->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false); + node = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CONNECTION_QUALITY", false); if (node) node->setValue32((sint32)getConnectionQuality()); } diff --git a/code/ryzom/client/src/outpost_manager.cpp b/code/ryzom/client/src/outpost_manager.cpp index 7f43189d2..01b073cc9 100644 --- a/code/ryzom/client/src/outpost_manager.cpp +++ b/code/ryzom/client/src/outpost_manager.cpp @@ -46,15 +46,15 @@ void COutpostManager::startPvpJoinProposal(bool playerGuildInConflict, bool play // setup TEMP DB CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IN_CONFLICT"); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IN_CONFLICT"); if(node) node->setValueBool(playerGuildInConflict); - node= pIM->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IS_ATTACKER"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IS_ATTACKER"); if(node) node->setValueBool(playerGuildIsAttacker); - node= pIM->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_ATTACKER"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_ATTACKER"); if(node) node->setValue32(attackerGuildNameId); - node= pIM->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_DEFENDER"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_DEFENDER"); if(node) node->setValue32(ownerGuildNameId); - node= pIM->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_TICK_END"); + node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_TICK_END"); if(node) node->setValue32(_EndTickForPvpJoinProposal); // open Popup diff --git a/code/ryzom/client/src/player_cl.cpp b/code/ryzom/client/src/player_cl.cpp index d74cf6ae1..69755bab2 100644 --- a/code/ryzom/client/src/player_cl.cpp +++ b/code/ryzom/client/src/player_cl.cpp @@ -844,9 +844,9 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle * sint64 vB, vC; string propName; propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPB); - vB = IM->getDbProp(propName)->getValue64(); + vB = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPC); - vC = IM->getDbProp(propName)->getValue64(); + vC = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); updateVisualPropertyVpb(0, vB); updateVisualPropertyVpc(0, vC); @@ -1015,7 +1015,7 @@ void CPlayerCL::updateVisualPropertyPvpMode(const NLMISC::TGameCycle &gameCycle, if(isTarget()) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDB= pIM->getDbProp("UI:VARIABLES:USER:TRACK_TARGET_PVP_CHANGE_MODE"); + CCDBNodeLeaf *pDB= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:TRACK_TARGET_PVP_CHANGE_MODE"); if(pDB) { sint32 val= pDB->getValue32(); @@ -1265,7 +1265,7 @@ void CPlayerCL::load() // virtual if(!_WaitForAppearance) { // Visual properties A - sint64 prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); updateVisualPropertyVpa(0, prop); // Vpa udapte vpb and vpc too. } }// load // diff --git a/code/ryzom/client/src/player_r2_cl.cpp b/code/ryzom/client/src/player_r2_cl.cpp index 8c5619a34..9488c44f8 100644 --- a/code/ryzom/client/src/player_r2_cl.cpp +++ b/code/ryzom/client/src/player_r2_cl.cpp @@ -122,7 +122,7 @@ CPlayerR2CL::~CPlayerR2CL() CGenderInfo * CPlayerR2CL::getGenderInfo() { string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPB); - sint64 vA = CInterfaceManager::getInstance ()->getDbProp(propName)->getValue64(); + sint64 vA = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); SPropVisualA visualA = *(SPropVisualA *)(&vA); EGSPD::CPeople::TPeople ePeople = _Sheet->Race; bool bMale = (_Sheet->Gender == GSGENDER::male); @@ -624,9 +624,9 @@ void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle sint64 vB, vC; string propName; propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPB); - vB = IM->getDbProp(propName)->getValue64(); + vB = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPC); - vC = IM->getDbProp(propName)->getValue64(); + vC = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); updateVisualPropertyVpb(0, vB); updateVisualPropertyVpc(0, vC); @@ -1033,7 +1033,7 @@ void CPlayerR2CL::load() // virtual if(!_WaitForAppearance) { // Visual properties A - sint64 prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); updateVisualPropertyVpa(0, prop); // Vpa udapte vpb and vpc too. } }// load // diff --git a/code/ryzom/client/src/progress.cpp b/code/ryzom/client/src/progress.cpp index 6bce2a735..2d2fd36e0 100644 --- a/code/ryzom/client/src/progress.cpp +++ b/code/ryzom/client/src/progress.cpp @@ -395,7 +395,7 @@ void CProgress::internalProgress (float value) // \todo GUIGUI : Remove this when possible. NetMngr.update(); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // update system dependent progress bar static uint previousValue = 0; diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.cpp b/code/ryzom/client/src/r2/displayer_visual_entity.cpp index 63a0d029b..744d99246 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -756,7 +756,7 @@ void CDisplayerVisualEntity::updateRaceAndSex() // update sex SPropVisualA vA; const string propNameA = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPA); - CCDBNodeLeaf *leafA = CInterfaceManager::getInstance()->getDbProp(propNameA); + CCDBNodeLeaf *leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); @@ -792,9 +792,9 @@ void CDisplayerVisualEntity::updateEntity() const string propNameA = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPC); - leafA = CInterfaceManager::getInstance()->getDbProp(propNameA); - leafB = CInterfaceManager::getInstance()->getDbProp(propNameB); - leafC = CInterfaceManager::getInstance()->getDbProp(propNameC); + leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); + leafB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB); + leafC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); @@ -1085,9 +1085,9 @@ std::string CDisplayerVisualEntity::getVisualProperties() const const std::string propNameB = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPB); const std::string propNameC = toString("SERVER:Entities:E%d:P%d", _Entity->slot(), CLFECOMMON::PROPERTY_VPC); - CCDBNodeLeaf *leafA = CInterfaceManager::getInstance()->getDbProp(propNameA); - CCDBNodeLeaf *leafB = CInterfaceManager::getInstance()->getDbProp(propNameB); - CCDBNodeLeaf *leafC = CInterfaceManager::getInstance()->getDbProp(propNameC); + CCDBNodeLeaf *leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); + CCDBNodeLeaf *leafB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB); + CCDBNodeLeaf *leafC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index b3c932a02..89507f57b 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -330,12 +330,12 @@ void CEditorConfig::setDisplayInfo(const std::string& formName, bool displayInfo //H_AUTO(R2_CEditorConfig_setDisplayInfo) CInterfaceManager *IM = CInterfaceManager::getInstance (); uint32 index = _NameToId[formName]; - uint32 newValue = static_cast(IM->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); + uint32 newValue = static_cast(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); if (displayInfo == false ) newValue &= ~(1 << index); else newValue |= (1 << index); - IM->getDbProp("UI:SAVE:R2:DISPLAYINFO")->setValue32(static_cast(newValue)); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:R2:DISPLAYINFO")->setValue32(static_cast(newValue)); } @@ -343,7 +343,7 @@ void CEditorConfig::setDisplayInfo(uint32 displayInfo) { //H_AUTO(R2_CEditorConfig_setDisplayInfo) CInterfaceManager *IM = CInterfaceManager::getInstance (); - IM->getDbProp("UI:SAVE:R2:DISPLAYINFO")->setValue32(static_cast(displayInfo)); + NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:R2:DISPLAYINFO")->setValue32(static_cast(displayInfo)); } @@ -356,7 +356,7 @@ bool CEditorConfig::mustDisplayInfo(const std::string& formName) const if (found == _NameToId.end()) return false; uint32 index = (*found).second; - uint32 newValue = static_cast(IM->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); + uint32 newValue = static_cast(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); uint32 ok = (newValue >> index) & 0x00000001; if (ok != 0) return true; @@ -376,7 +376,7 @@ uint32 CEditorConfig::getDisplayInfo() const { //H_AUTO(R2_CEditorConfig_getDisplayInfo) CInterfaceManager *IM = CInterfaceManager::getInstance (); - return static_cast(IM->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); + return static_cast(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:R2:DISPLAYINFO")->getValue32()); } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 5dc606010..567a9a864 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -1728,7 +1728,7 @@ void CEditor::waitScenarioScreen() } IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // check if we can send another dated block if (NetMngr.getCurrentServerTick() != serverTick) @@ -1774,7 +1774,7 @@ void CEditor::waitScenarioScreen() getUI().updateFrameViews(NULL); IngameDbMngr.flushObserverCalls(); - CInterfaceManager::getInstance()->flushObserverCalls(); + NLGUI::CDBManager::getInstance()->flushObserverCalls(); // Movie shooter globalMenuMovieShooter(); @@ -2741,14 +2741,14 @@ uint CEditor::getMaxNumPlotItems() CCDBNodeLeaf *CEditor::getRefPlotItemSheetDBLeaf(uint index) { //H_AUTO(R2_CEditor_getRefPlotItemSheetDBLeaf) - return getUI().getDbProp(toString("LOCAL:R2:REFERENCE_PLOT_ITEMS:%d:SHEET", (int) index), false); + return NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:R2:REFERENCE_PLOT_ITEMS:%d:SHEET", (int) index), false); } // ********************************************************************************************************* CCDBNodeLeaf *CEditor::getPlotItemSheetDBLeaf(uint index) { //H_AUTO(R2_CEditor_getPlotItemSheetDBLeaf) - return getUI().getDbProp(toString("LOCAL:R2:PLOT_ITEMS:%d:SHEET", (int) index), false); + return NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:R2:PLOT_ITEMS:%d:SHEET", (int) index), false); } @@ -2761,7 +2761,7 @@ void CEditor::setReferencePlotItemSheet(uint index, uint32 sheetId) { leaf->setValue32(sheetId); } - leaf = getUI().getDbProp(toString("LOCAL:R2:AVAILABLE_PLOT_ITEMS:%d:SHEET", (int) index), false); + leaf = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:R2:AVAILABLE_PLOT_ITEMS:%d:SHEET", (int) index), false); if (leaf) { leaf->setValue32(sheetId); @@ -4841,24 +4841,24 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con sint64 *prop = 0; CCDBNodeLeaf *node = 0; // Set The property 'CLFECOMMON::PROPERTY_POSITION'. - node = im->getDbProp("SERVER:Entities:E" + NLMISC::toString("%d", slot)+":P" + NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSX), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + NLMISC::toString("%d", slot)+":P" + NLMISC::toString("%d", CLFECOMMON::PROPERTY_POSX), false); if(node) { sint64 x = (sint64)(pos.x*1000.0); sint64 y = (sint64)(pos.y*1000.0); sint64 z = (sint64)(pos.z*1000.0); node->setValue64(x); - node = im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSY), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSY), false); if(node) { node->setValue64(y); - node = im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSZ), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_POSZ), false); if(node) node->setValue64(z); } } // Set The property 'PROPERTY_ORIENTATION'. - node = im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_ORIENTATION), false); if(node) { union @@ -4870,7 +4870,7 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con node->setValue64(heading64); } // Set Mode - node = im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); + node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_MODE), false); if(node) { MBEHAV::EMode m = MBEHAV::NORMAL; @@ -4915,7 +4915,7 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con } // Set the database. - im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); // Set Visual Properties SPropVisualB visualB; @@ -4924,7 +4924,7 @@ CEntityCL *CEditor::createEntity(uint slot, const NLMISC::CSheetId &sheetId, con sint64 *propB = 0; propB = (sint64 *)&visualB; // Set the database. - im->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*propB); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*propB); // Apply Changes. EntitiesMngr.updateVisualProperty(0, slot, CLFECOMMON::PROPERTY_VPA); @@ -7191,13 +7191,13 @@ class CAHCreateEntity : public IActionHandler } prop = (sint64 *)&vA; - im->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); prop = (sint64 *)&vB; - im->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); prop = (sint64 *)&vC; - im->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", entity->slot())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); EntitiesMngr.updateVisualProperty(0, entity->slot(), CLFECOMMON::PROPERTY_VPA); EntitiesMngr.updateVisualProperty(0, entity->slot(), CLFECOMMON::PROPERTY_VPB); @@ -7205,7 +7205,7 @@ class CAHCreateEntity : public IActionHandler } } - getEditor().setCurrentTool(new CToolCreateEntity(ghostSlot, paletteId, im->getDbProp("UI:TEMP:R2_DRAW_ARRAY")->getValueBool())); + getEditor().setCurrentTool(new CToolCreateEntity(ghostSlot, paletteId, NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:R2_DRAW_ARRAY")->getValueBool())); } }; REGISTER_ACTION_HANDLER(CAHCreateEntity, "r2ed_create_entity"); @@ -7624,9 +7624,9 @@ class CAHR2DMGiftValidate : public IActionHandler { uint32 sheetId = 0; uint8 quantity = 0; - CCDBNodeLeaf *sheetLeaf = im->getDbProp(toString("LOCAL:R2:DM_GIFT:%d:SHEET", (int) k)); + CCDBNodeLeaf *sheetLeaf = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:R2:DM_GIFT:%d:SHEET", (int) k)); if (sheetLeaf) sheetId = (uint32) sheetLeaf->getValue32(); - CCDBNodeLeaf *quantityLeaf = im->getDbProp(toString("LOCAL:R2:DM_GIFT:%d:QUANTITY", (int) k)); + CCDBNodeLeaf *quantityLeaf = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:R2:DM_GIFT:%d:QUANTITY", (int) k)); if (quantityLeaf) quantity = (uint8) quantityLeaf->getValue8(); out.serial(sheetId); out.serial(quantity); diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index ead70db66..eb5083806 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -550,7 +550,7 @@ void CTool::handleMouseOverPlayer(bool over) { //H_AUTO(R2_CTool_handleMouseOverPlayer) // If the mouse is over the player make the player transparent - CCDBNodeLeaf *pNL = getUI().getDbProp("UI:SAVE:USER_CHAR_FADE", false); + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false); if ((pNL != NULL) && (pNL->getValue32() == 1) && UserEntity->selectable()) { // If the nearest entity is the player, hide! diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index 44f79d0fe..cbbcf6283 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -240,9 +240,9 @@ std::string CToolCreateEntity::cloneEntityIntoScenario(CEntityCL *clonee, const string propNameA = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPA); const string propNameB = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPB); const string propNameC = toString("SERVER:Entities:E%d:P%d", clonee->slot(), CLFECOMMON::PROPERTY_VPC); - CCDBNodeLeaf *leafA = CInterfaceManager::getInstance()->getDbProp(propNameA); - CCDBNodeLeaf *leafB = CInterfaceManager::getInstance()->getDbProp(propNameB); - CCDBNodeLeaf *leafC = CInterfaceManager::getInstance()->getDbProp(propNameC); + CCDBNodeLeaf *leafA = NLGUI::CDBManager::getInstance()->getDbProp(propNameA); + CCDBNodeLeaf *leafB = NLGUI::CDBManager::getInstance()->getDbProp(propNameB); + CCDBNodeLeaf *leafC = NLGUI::CDBManager::getInstance()->getDbProp(propNameC); if (!leafA) { nlwarning("Can't find DB leaf %s", propNameA.c_str()); @@ -821,7 +821,7 @@ class CAHR2EDToggleDrawArray : public IActionHandler CCtrlBaseButton *but = dynamic_cast(pCaller); if (but) { - im->getDbProp("UI:TEMP:R2_DRAW_ARRAY")->setValueBool(but->getPushed()); + NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:R2_DRAW_ARRAY")->setValueBool(but->getPushed()); CToolCreateEntity *tce = dynamic_cast(getEditor().getCurrentTool()); if (tce) { diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 018cc964a..46bfafbac 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -335,8 +335,8 @@ void releaseMainLoopReselect() pIM->releaseServerToLocalAutoCopyObservers(); // Then remove the SERVER and LOCAL database (NB: "UI" node was removed by uninitIngame1()) ICDBNode::CTextId serverId("SERVER"), localId("LOCAL"); - pIM->getDB()->removeNode(serverId); - pIM->getDB()->removeNode(localId); + NLGUI::CDBManager::getInstance()->getDB()->removeNode(serverId); + NLGUI::CDBManager::getInstance()->getDB()->removeNode(localId); nlassert(IngameDbMngr.getNodePtr()==NULL); // actually it is the "SERVER" node kept by CRefPtr => should be NULL IngameDbMngr.clear(); // still important for CDBBranch statics data release // NB: "SERVER" and "LOCAL" node will be recreated by initMainLoop @@ -635,6 +635,7 @@ void release() CPdrTokenRegistry::releaseInstance(); NLNET::IModuleManager::releaseInstance(); delete &CLuaManager::getInstance(); + NLGUI::CDBManager::release(); diff --git a/code/ryzom/client/src/time_client.cpp b/code/ryzom/client/src/time_client.cpp index 5c71203b7..fa8dd9f72 100644 --- a/code/ryzom/client/src/time_client.cpp +++ b/code/ryzom/client/src/time_client.cpp @@ -250,15 +250,15 @@ void initClientTime() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get a direct link to the database - pIM->getDbProp("UI:VARIABLES:CURRENT_TIME"); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_TIME"); InterfaceTime->link("UI:VARIABLES:CURRENT_TIME"); - pIM->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK"); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_SERVER_TICK"); InterfaceServerTick->link("UI:VARIABLES:CURRENT_SERVER_TICK"); - pIM->getDbProp("UI:VARIABLES:CURRENT_SMOOTH_SERVER_TICK"); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_SMOOTH_SERVER_TICK"); InterfaceSmoothServerTick->link("UI:VARIABLES:CURRENT_SMOOTH_SERVER_TICK"); - pIM->getDbProp("UI:VARIABLES:CURRENT_DAY"); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CURRENT_DAY"); InterfaceDay->link("UI:VARIABLES:CURRENT_DAY"); - pIM->getDbProp("UI:VARIABLES:DAY_BEFORE_ZC_DISTRIB"); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:DAY_BEFORE_ZC_DISTRIB"); InterfaceDayBeforeNextZCDistrib->link("UI:VARIABLES:DAY_BEFORE_ZC_DISTRIB"); } diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index f1e4aeff2..2a713554e 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -200,7 +200,7 @@ CUserEntity::~CUserEntity() CInterfaceManager *pIM = CInterfaceManager::getInstance(); { - CCDBNodeLeaf *node = pIM->getDbProp("SERVER:USER:IS_INVISIBLE", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_INVISIBLE", false); if (node) { ICDBNode::CTextId textId; @@ -210,7 +210,7 @@ CUserEntity::~CUserEntity() for(uint i=0;igetDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); if(node) { ICDBNode::CTextId textId; @@ -224,7 +224,7 @@ CUserEntity::~CUserEntity() uint32 fameIndexInDatabase = CStaticFames::getInstance().getDatabaseIndex(factionIndex); string sDBPath = toString("SERVER:FAME:PLAYER%d:VALUE",fameIndexInDatabase); - CCDBNodeLeaf * node = pIM->getDbProp(sDBPath, false); + CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp(sDBPath, false); if(node) { ICDBNode::CTextId textId; @@ -340,11 +340,11 @@ bool CUserEntity::build(const CEntitySheet *sheet) // virtual visualC.PropertySubData.BreastSize = 7; // Set the Database sint64 *prop = (sint64 *)&visualA; - CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); // Set the database + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->setValue64(*prop); // Set the database prop = (sint64 *)&visualB; - CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); // Set the database + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->setValue64(*prop); // Set the database prop = (sint64 *)&visualC; - CInterfaceManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); // Set the database + NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPC))->setValue64(*prop); // Set the database // Apply Changes. updateVisualProperty(0, CLFECOMMON::PROPERTY_VPA); } @@ -360,7 +360,7 @@ bool CUserEntity::build(const CEntitySheet *sheet) // virtual // Add observer on invisible property CInterfaceManager *pIM = CInterfaceManager::getInstance(); { - CCDBNodeLeaf *node = pIM->getDbProp("SERVER:USER:IS_INVISIBLE", false); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_INVISIBLE", false); if (node) { ICDBNode::CTextId textId; @@ -372,7 +372,7 @@ bool CUserEntity::build(const CEntitySheet *sheet) // virtual for(uint i=0;igetDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); if(node) { ICDBNode::CTextId textId; @@ -391,7 +391,7 @@ bool CUserEntity::build(const CEntitySheet *sheet) // virtual if( fameObs ) { fameObs->FactionIndex = factionIndex; - CCDBNodeLeaf * node = pIM->getDbProp(sDBPath, false); + CCDBNodeLeaf * node = NLGUI::CDBManager::getInstance()->getDbProp(sDBPath, false); if(node) { ICDBNode::CTextId textId; @@ -619,14 +619,14 @@ void CUserEntity::updateVisualPropertyPvpMode(const NLMISC::TGameCycle &gameCycl // Additionaly, inform interface of the change CInterfaceManager *pIM= CInterfaceManager::getInstance(); // For PVP ZoneFaction - CCDBNodeLeaf *pDB= pIM->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_MODE"); + CCDBNodeLeaf *pDB= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_MODE"); if(pDB) { sint32 val= pDB->getValue32(); pDB->setValue32(val+1); } // For Any PVP change - pDB= pIM->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); + pDB= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); if(pDB) { sint32 val= pDB->getValue32(); @@ -641,7 +641,7 @@ void CUserEntity::updateVisualPropertyOutpostInfos(const NLMISC::TGameCycle &gam CPlayerCL::updateVisualPropertyOutpostInfos(gameCycle, prop); // For Any PVP change CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDB= pIM->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); + CCDBNodeLeaf *pDB= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); if(pDB) { sint32 val= pDB->getValue32(); @@ -656,7 +656,7 @@ void CUserEntity::updateVisualPropertyPvpClan(const NLMISC::TGameCycle &gameCycl CPlayerCL::updateVisualPropertyPvpClan(gameCycle, prop); // For Any PVP change CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *pDB= pIM->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); + CCDBNodeLeaf *pDB= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:TRACK_PVP_CHANGE_ANY"); if(pDB) { sint32 val= pDB->getValue32(); @@ -791,7 +791,7 @@ bool CUserEntity::mode(MBEHAV::EMode m) { // Compute the angle const string propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_ORIENTATION); - sint64 ang = CInterfaceManager::getInstance()->getDbProp(propName)->getValue64(); + sint64 ang = NLGUI::CDBManager::getInstance()->getDbProp(propName)->getValue64(); _TargetAngle = *(float *)(&ang); // Initialize controls for the combat. @@ -2220,7 +2220,7 @@ void CUserEntity::setDead() // virtual uint kamiFameIndex = CStaticFames::getInstance().getFactionIndex("kami"); if (pIM && kamiFameIndex != CStaticFames::INVALID_FACTION_INDEX) { - CCDBNodeLeaf *pLeafKamiFame = pIM->getDbProp(toString("SERVER:FAME:PLAYER%d:VALUE", kamiFameIndex - 1), false); + CCDBNodeLeaf *pLeafKamiFame = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:FAME:PLAYER%d:VALUE", kamiFameIndex - 1), false); if (pLeafKamiFame != NULL) kamiFame = pLeafKamiFame->getValue8(); } @@ -2230,7 +2230,7 @@ void CUserEntity::setDead() // virtual uint karavanFameIndex = CStaticFames::getInstance().getFactionIndex("karavan"); if (pIM && karavanFameIndex != CStaticFames::INVALID_FACTION_INDEX) { - CCDBNodeLeaf *pLeafKaravanFame = pIM->getDbProp(toString("SERVER:FAME:PLAYER%d:VALUE", karavanFameIndex - 1), false); + CCDBNodeLeaf *pLeafKaravanFame = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:FAME:PLAYER%d:VALUE", karavanFameIndex - 1), false); if (pLeafKaravanFame != NULL) karavanFame = pLeafKaravanFame->getValue8(); } @@ -2610,7 +2610,7 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual // **** Update Target interface //get the new target slot and set it in the database CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->getDbProp("UI:VARIABLES:TARGET:SLOT")->setValue64(slot); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TARGET:SLOT")->setValue64(slot); // Get the new target UID, and set in Database uint tgtSlot= _Selection; @@ -2624,7 +2624,7 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual } // Set the User Target - CCDBNodeLeaf *prop = pIM->getDbProp("UI:VARIABLES:TARGET:UID", false); + CCDBNodeLeaf *prop = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:TARGET:UID", false); if(prop) prop->setValue32(tgtEntityId); @@ -2635,23 +2635,23 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual // clear the entries for mission option for(uint k = 0; k < NUM_MISSION_OPTIONS; ++k) { - CCDBNodeLeaf *missionOption = pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); + CCDBNodeLeaf *missionOption = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); if (missionOption) { missionOption->setValue32(0); } - CCDBNodeLeaf *playerGiftNeeded = pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", (int) k), false); + CCDBNodeLeaf *playerGiftNeeded = NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", (int) k), false); if (playerGiftNeeded) { playerGiftNeeded->setValue32(0); } // - missionOption = pIM->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); + missionOption = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k), false); if (missionOption) { missionOption->setValue32(0); } - playerGiftNeeded = pIM->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", (int) k), false); + playerGiftNeeded = NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PLAYER_GIFT_NEEDED", (int) k), false); if (playerGiftNeeded) { playerGiftNeeded->setValue32(0); @@ -2694,22 +2694,22 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual } // clear web page - prop= pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_URL", false); + prop= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_URL", false); if(prop) prop->setValue32(0); - prop= pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); + prop= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false); if(prop) prop->setValue32(0); // clear mission ring for(uint k = 0; k < BOTCHATTYPE::MaxR2MissionEntryDatabase; ++k) { - prop= pIM->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", k), false); + prop= NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", k), false); if(prop) prop->setValue32(0); } // clear programs - prop= pIM->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES", false); + prop= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES", false); if(prop) prop->setValue32(0); - prop= pIM->getDbProp("SERVER:TARGET:CONTEXT_MENU:PROGRAMMES"); + prop= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_MENU:PROGRAMMES"); if(prop) prop->setValue32(0); // increment db counter for context menu pIM->incLocalSyncActionCounter(); @@ -2977,7 +2977,7 @@ bool CUserEntity::sit(bool s) if(ok) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCDBNodeLeaf *node= pIM->getDbProp("UI:VARIABLES:PLAYER_STAND", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PLAYER_STAND", false); if(node) node->setValue32(_Mode != MBEHAV::SIT); } @@ -3014,13 +3014,13 @@ void CUserEntity::setAFK(bool b, string afkTxt) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - //sint64 start = pIM->getDbProp("SERVER:USER:ACT_TSTART")->getValue64(); - //sint64 end = pIM->getDbProp("SERVER:USER:ACT_TEND")->getValue64(); - //sint64 type = pIM->getDbProp("SERVER:USER:ACT_TYPE")->getValue64(); - //sint64 num = pIM->getDbProp("SERVER:USER:ACT_NUMBER")->getValue64(); + //sint64 start = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TSTART")->getValue64(); + //sint64 end = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TEND")->getValue64(); + //sint64 type = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TYPE")->getValue64(); + //sint64 num = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_NUMBER")->getValue64(); if( pIM ) { - if( pIM->getDbProp("SERVER:USER:ACT_TYPE")->getValue64() != 0 ) + if( NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:ACT_TYPE")->getValue64() != 0 ) return; } @@ -3268,7 +3268,7 @@ bool CUserEntity::isBusy() const // TODO : put the right DB entry ! - CCDBNodeLeaf *nod = IM->getDbProp("SERVER:INVENTORY:EXCHANGE:BEGUN", false); + CCDBNodeLeaf *nod = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:INVENTORY:EXCHANGE:BEGUN", false); if(nod) { if(nod->getValueBool()) @@ -3283,7 +3283,7 @@ bool CUserEntity::isBusy() const uint i; for(i=0; igetDbProp(NLMISC::toString("SERVER:INVENTORY:%d:%d:SHEET", INVENTORIES::pickup, i), false); + nod = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:INVENTORY:%d:%d:SHEET", INVENTORIES::pickup, i), false); if(nod) { if(nod->getValue32() != 0) @@ -3296,7 +3296,7 @@ bool CUserEntity::isBusy() const // Check Harvest for(i=0; igetDbProp(NLMISC::toString("SERVER:INVENTORY:%d:%d:SHEET", INVENTORIES::harvest, i), false); + nod = NLGUI::CDBManager::getInstance()->getDbProp(NLMISC::toString("SERVER:INVENTORY:%d:%d:SHEET", INVENTORIES::harvest, i), false); if(nod) { if(nod->getValue32() != 0) @@ -3457,7 +3457,7 @@ void CUserEntity::CSpeedFactor::init() { _Value = 1.0f; // Default speed factor is 1. CInterfaceManager *IM = CInterfaceManager::getInstance (); - CCDBNodeLeaf *pNodeLeaf = IM->getDbProp("SERVER:USER:SPEED_FACTOR", false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:SPEED_FACTOR", false); if(pNodeLeaf) { /* if(!pNodeLeaf->addToLeaves(this)) @@ -3483,7 +3483,7 @@ void CUserEntity::CMountHunger::init() void CUserEntity::CMountSpeeds::init() { CInterfaceManager *IM = CInterfaceManager::getInstance (); - CCDBNodeLeaf *pNodeLeaf = IM->getDbProp( "SERVER:USER:MOUNT_WALK_SPEED", false ); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp( "SERVER:USER:MOUNT_WALK_SPEED", false ); BOMB_IF( ! pNodeLeaf, "MOUNT_WALK_SPEED not found", return ); if(pNodeLeaf) { @@ -3491,7 +3491,7 @@ void CUserEntity::CMountSpeeds::init() pNodeLeaf->addObserver(this, textId); _WalkSpeed = ((float)pNodeLeaf->getValue32()) / 1000.0f; // may have been received before } - pNodeLeaf = IM->getDbProp( "SERVER:USER:MOUNT_RUN_SPEED", false ); + pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp( "SERVER:USER:MOUNT_RUN_SPEED", false ); BOMB_IF( ! pNodeLeaf, "MOUNT_RUN_SPEED not found", return ); if(pNodeLeaf) { @@ -3506,7 +3506,7 @@ void CUserEntity::CMountSpeeds::init() void CUserEntity::CSpeedFactor::release() { CInterfaceManager *IM = CInterfaceManager::getInstance (); - CCDBNodeLeaf *pNodeLeaf = IM->getDbProp("SERVER:USER:SPEED_FACTOR", false); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:SPEED_FACTOR", false); if(pNodeLeaf) { /* if(!pNodeLeaf->addToLeaves(this)) @@ -3524,14 +3524,14 @@ void CUserEntity::CMountHunger::release() void CUserEntity::CMountSpeeds::release() { CInterfaceManager *IM = CInterfaceManager::getInstance (); - CCDBNodeLeaf *pNodeLeaf = IM->getDbProp( "SERVER:USER:MOUNT_WALK_SPEED", false ); + CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp( "SERVER:USER:MOUNT_WALK_SPEED", false ); BOMB_IF( ! pNodeLeaf, "MOUNT_WALK_SPEED not found", return ); if(pNodeLeaf) { ICDBNode::CTextId textId; pNodeLeaf->removeObserver(this, textId); } - pNodeLeaf = IM->getDbProp( "SERVER:USER:MOUNT_RUN_SPEED", false ); + pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp( "SERVER:USER:MOUNT_RUN_SPEED", false ); BOMB_IF( ! pNodeLeaf, "MOUNT_RUN_SPEED not found", return ); if(pNodeLeaf) { @@ -3572,7 +3572,7 @@ bool CUserEntity::CMountHunger::canRun() const // Find the mount's db leaf and check hunger CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeBranch *animalsNode = safe_cast(pIM->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); + CCDBNodeBranch *animalsNode = safe_cast(NLGUI::CDBManager::getInstance()->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); BOMB_IF( ! animalsNode, "! animalsNode", return false; ); uint nbAnimals = (uint)animalsNode->getNbNodes(); for ( uint i=0; i!=nbAnimals; ++i ) @@ -3597,8 +3597,8 @@ bool CUserEntity::CMountHunger::canRun() const void CUserEntity::CMountSpeeds::update(ICDBNode * /* node */) // virtual { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - _WalkSpeed = ((float)(pIM->getDbProp("SERVER:USER:MOUNT_WALK_SPEED")->getValue32())) / 1000.0f; - _RunSpeed = ((float)(pIM->getDbProp("SERVER:USER:MOUNT_RUN_SPEED")->getValue32())) / 1000.0f; + _WalkSpeed = ((float)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:MOUNT_WALK_SPEED")->getValue32())) / 1000.0f; + _RunSpeed = ((float)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:MOUNT_RUN_SPEED")->getValue32())) / 1000.0f; } @@ -3621,7 +3621,7 @@ CCDBNodeBranch *CUserEntity::getBeastDBEntry( CLFECOMMON::TClientDataSetIndex ui { // Find animal entry corresponding to datasetId CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCDBNodeBranch *animalsNode = safe_cast(pIM->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); + CCDBNodeBranch *animalsNode = safe_cast(NLGUI::CDBManager::getInstance()->getDB()->getNode( ICDBNode::CTextId( "SERVER:PACK_ANIMAL" ), false )); BOMB_IF( ! animalsNode, "! animalsNode", return NULL ); uint nbAnimals = (uint)animalsNode->getNbNodes(); for ( uint i=0; i!=nbAnimals; ++i ) @@ -3713,7 +3713,7 @@ void CUserEntity::load() // virtual if(!_WaitForAppearance) { // Visual properties A - sint64 prop = IM->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", _Slot)+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); updateVisualPropertyVpa(0, prop); // Vpa udapte vpb and vpc too. } }// load // @@ -4063,7 +4063,7 @@ void CUserEntity::switchVelocity(bool userRequest) pIM->displaySystemInfo(msg, cat); // Write to the UI database, to update views - CCDBNodeLeaf *node= pIM->getDbProp("UI:VARIABLES:PLAYER_RUNNING", false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:PLAYER_RUNNING", false); if(node) node->setValue32(_Run); } @@ -4292,7 +4292,7 @@ void CUserEntity::setR2CharMode(R2::TCharMode mode) bool CUserEntity::isInNpcControl() const { CInterfaceManager* pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *sheet = pIM->getDbProp("SERVER:USER:NPC_CONTROL:SHEET", false); + CCDBNodeLeaf *sheet = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:NPC_CONTROL:SHEET", false); return sheet && NLMISC::CSheetId(sheet->getValue32())!=NLMISC::CSheetId::Unknown; } @@ -4300,9 +4300,9 @@ bool CUserEntity::isInNpcControl() const void CUserEntity::updateNpcContolSpeed() { CInterfaceManager* pIM = CInterfaceManager::getInstance(); - CCDBNodeLeaf *sheet = pIM->getDbProp("SERVER:USER:NPC_CONTROL:SHEET", false); - CCDBNodeLeaf *walk = pIM->getDbProp("SERVER:USER:NPC_CONTROL:WALK", false); - CCDBNodeLeaf *run = pIM->getDbProp("SERVER:USER:NPC_CONTROL:RUN", false); + CCDBNodeLeaf *sheet = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:NPC_CONTROL:SHEET", false); + CCDBNodeLeaf *walk = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:NPC_CONTROL:WALK", false); + CCDBNodeLeaf *run = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:NPC_CONTROL:RUN", false); if (!sheet || !walk || !run) { return; @@ -4422,7 +4422,7 @@ sint CUserEntity::getLevel() const sint level = -1; for(uint i=0;igetDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); + CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:USER:SKILL_POINTS_%d:VALUE", i), false); if(node) { level = std::max(level, (sint) node->getValue32()); diff --git a/code/ryzom/client/src/weather.cpp b/code/ryzom/client/src/weather.cpp index 4ce91055f..11cbd2d4f 100644 --- a/code/ryzom/client/src/weather.cpp +++ b/code/ryzom/client/src/weather.cpp @@ -197,8 +197,7 @@ const float WEATHER_BLEND_SPEED = 1.f / 8.f; // number of seconds to blend betwe // *************************************************************************** static uint16 getServerWeather() { - CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *node = im->getDbProp("SERVER:WEATHER:VALUE"); + CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:WEATHER:VALUE"); if (!node) return 0; return (uint16) node->getValue16(); } @@ -243,8 +242,7 @@ float getBlendedWeather(uint64 day, uint8 getSeasonDBValue() { - CInterfaceManager *im = CInterfaceManager::getInstance(); - CCDBNodeLeaf *serverSeason = im->getDbProp("SERVER:SEASON:VALUE"); + CCDBNodeLeaf *serverSeason = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:SEASON:VALUE"); return serverSeason ? serverSeason->getValue8() : 0; } From 2fff0616a58c61effc6a85c53eb114a9e614d2a1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 24 May 2012 18:23:51 +0200 Subject: [PATCH 033/339] CHANGED: #1471 CInterfaceProperty is not part of the NELGUI library and is under NLGUI namespace. --- code/nel/include/nel/gui/interface_common.h | 57 ++++ code/nel/include/nel/gui/interface_property.h | 106 +++++++ code/nel/src/gui/interface_property.cpp | 288 ++++++++++++++++++ .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../interface_v3/dbgroup_select_number.cpp | 2 +- .../client/src/interface_v3/interface_anim.h | 2 +- .../src/interface_v3/interface_element.cpp | 2 +- .../src/interface_v3/interface_element.h | 39 +-- .../src/interface_v3/interface_property.cpp | 286 ----------------- .../src/interface_v3/interface_property.h | 107 ------- code/ryzom/client/src/time_client.cpp | 2 +- 11 files changed, 458 insertions(+), 435 deletions(-) create mode 100644 code/nel/include/nel/gui/interface_common.h create mode 100644 code/nel/include/nel/gui/interface_property.h create mode 100644 code/nel/src/gui/interface_property.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_property.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_property.h diff --git a/code/nel/include/nel/gui/interface_common.h b/code/nel/include/nel/gui/interface_common.h new file mode 100644 index 000000000..1e28dde58 --- /dev/null +++ b/code/nel/include/nel/gui/interface_common.h @@ -0,0 +1,57 @@ +// Ryzom - MMORPG Framework +// 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 INTERFACE_COMMON_H +#define INTERFACE_COMMON_H + +enum THotSpot +{ + Hotspot_BL = 36, // 100100, + Hotspot_BM = 34, // 100010, + Hotspot_BR = 33, // 100001, + Hotspot_ML = 20, // 010100, + Hotspot_MM = 18, // 010010 + Hotspot_MR = 17, // 010001 + Hotspot_TL = 12, // 001100 + Hotspot_TM = 10, // 001010 + Hotspot_TR = 9, // 001001 + Hotspot_xR = 1, // 000001 + Hotspot_xM = 2, // 000010 + Hotspot_xL = 4, // 000100 + Hotspot_Bx = 32, // 100000 + Hotspot_Mx = 16, // 010000 + Hotspot_Tx = 8, // 001000 + Hotspot_TTAuto = 0, // Special For Tooltip PosRef. Auto mode. see CCtrlBase and tooltip info +}; + +#define DECLARE_UI_CLASS(_class_) \ + virtual std::string getClassName() {return #_class_;} \ + static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());} +#define REGISTER_UI_CLASS(_class_) \ + class CRegisterUIClassHelper_##_class_ \ + { \ + public: \ + CRegisterUIClassHelper_##_class_() \ + { \ + NLMISC::CClassRegistry::init(); \ + NLMISC::CClassRegistry::registerClass(#_class_, _class_::creator, typeid(_class_).name()); \ + } \ + } RegisterUIClassHelper_##_class_; + + + +#endif + diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h new file mode 100644 index 000000000..e9c88a9b4 --- /dev/null +++ b/code/nel/include/nel/gui/interface_property.h @@ -0,0 +1,106 @@ +// Ryzom - MMORPG Framework +// 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 NL_INTERFACE_PROPERTY_H +#define NL_INTERFACE_PROPERTY_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/misc/cdb.h" +#include "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" + +namespace NLGUI +{ + + /** + * interface property + * class used to managed all the interface member values + * As the database contains only sint64, several methods are needed to do the conversion + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CInterfaceProperty + { + public: + //enum defining a hot spot + + /// Constructor + CInterfaceProperty() + { + _VolatileValue = NULL; + } + + NLMISC::CCDBNodeLeaf* getNodePtr() const + { + return _VolatileValue; + } + + void setNodePtr(NLMISC::CCDBNodeLeaf *ptr) + { + _VolatileValue = ptr; + } + + + bool link (const char *DBProp); + bool link( NLMISC::CCDBNodeLeaf *dbNode ); + bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); + + /// float operations + void setDouble (double value) {setSInt64((sint64&) value);} + double getDouble () const {sint64 i = getSInt64(); return (double &) i; } + void readDouble (const char* value, const std::string& id); + + /// sint32 operations + void setSInt32 (sint32 value) {_VolatileValue->setValue32 (value);} + sint32 getSInt32 () const {return _VolatileValue->getValue32();} + void readSInt32(const char* value, const std::string& id); + + /// sint64 operations + void setSInt64 (sint64 value) {_VolatileValue->setValue64(value);} + sint64 getSInt64 () const {return _VolatileValue->getValue64();} + void readSInt64(const char* value, const std::string& id); + + /// CRGBA operations + void setRGBA (const NLMISC::CRGBA & value); + NLMISC::CRGBA getRGBA () const; + void readRGBA (const char* value, const std::string& id); + + /// HotSpot operations + + void readHotSpot (const char* value, const std::string& id); + + /// bool operations + void setBool (bool value); + bool getBool () const; + void readBool (const char* value, const std::string& id); + + // Swap the content of this 2 property (no-op if one is NULL) + void swap32(CInterfaceProperty &o); + + private: + /// volatile value of the property (pointer to a leaf of the database) + NLMISC::CCDBNodeLeaf* _VolatileValue; + }; + +} + +#endif // NL_INTERFACE_PROPERTY_H + +/* End of interface_property.h */ diff --git a/code/nel/src/gui/interface_property.cpp b/code/nel/src/gui/interface_property.cpp new file mode 100644 index 000000000..a8445f0d2 --- /dev/null +++ b/code/nel/src/gui/interface_property.cpp @@ -0,0 +1,288 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/rgba.h" +#include "nel/gui/interface_property.h" +#include "nel/gui/interface_common.h" +#include "nel/gui/db_manager.h" + +using namespace NLMISC; +using namespace std; + +namespace NLGUI +{ + + bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) + { + _VolatileValue = dbNode; + return (dbNode != NULL); + } + + bool CInterfaceProperty::link( CCDBNodeBranch *dbNode, const string &leafId, CCDBNodeLeaf *defaultLeaf ) + { + // no branch => default leaf + if( !dbNode ) + { + _VolatileValue = defaultLeaf; + return false; + } + + // get the leaf + _VolatileValue = dbNode->getLeaf( leafId.c_str(), false ); + if( _VolatileValue ) + return true; + + // default + _VolatileValue = defaultLeaf; + return false; + } + + bool CInterfaceProperty::link (const char *DBProp) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp, false); + if (_VolatileValue == NULL) + { + + nlinfo("prop not created : %s", DBProp); + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp); + return false; + } + return true; + } + + + // ***************** + // sint64 operations + // ***************** + + + void CInterfaceProperty::readSInt64(const char * ptr,const string& id) + { + string str (ptr); + //the value is volatile, and a database entry is created + if ( isdigit(*ptr) || *ptr=='-') + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + sint64 i; + fromString(ptr, i); + _VolatileValue->setValue64( i ); + } + //the value is volatile and points to a db entry created elsewhere + else + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + } + + + + + // **************** + // float operations + // **************** + + + // ---------------------------------------------------------------------------- + void CInterfaceProperty::readDouble(const char * ptr,const string& id) + { + string str (ptr); + if ( isdigit(*ptr) || *ptr=='-') + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + double buf; + fromString(ptr, buf); + sint64 i = *(sint64*)&buf; + _VolatileValue->setValue64( i ); + } + else + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + } + + // ***************** + // sint32 operations + // ***************** + + + // ---------------------------------------------------------------------------- + void CInterfaceProperty::readSInt32 (const char *ptr, const string& id) + { + string str (ptr); + //the value is volatile, and a database entry is created + if ( isdigit(*ptr) || *ptr=='-') + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + sint32 i; + fromString(ptr, i); + _VolatileValue->setValue32( i ); + } + //the value is volatile and points to a db entry created elsewhere + else + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + } + + + + // ***************** + // rgba operations + // ***************** + CRGBA CInterfaceProperty::getRGBA() const + { + CRGBA rgba; + sint64 buf = getSInt64(); + rgba.R = (sint8) (buf &255); + rgba.G = (sint8) ((buf>>8)&255 ); + rgba.B = (sint8) ((buf>>16)&255); + rgba.A = (sint8) ((buf>>24)&255); + return rgba; + } + + + void CInterfaceProperty::setRGBA (const CRGBA& value) + { + setSInt64( (value.R )+ (((sint32)value.G)<<8) + (((sint32)value.B)<<16) + (((sint32)value.A)<<24)); + } + + + void CInterfaceProperty::readRGBA (const char *value,const string& id) + { + string str (value); + if (isdigit(*value)) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + int r=0, g=0, b=0, a=255; + sscanf (value, "%d %d %d %d", &r, &g, &b, &a); + clamp (r, 0, 255); + clamp (g, 0, 255); + clamp (b, 0, 255); + clamp (a, 0, 255); + sint64 val = r+(g<<8)+(b<<16)+(a<<24); + setSInt64(val); + CRGBA rgba = getRGBA(); + } + else + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + } + + + void CInterfaceProperty::readHotSpot (const char *ptr,const string& id) + { + string str(ptr); + if ( !strcmp(ptr,"TL") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64((sint64)Hotspot_TL ); + } + else if ( !strcmp(ptr,"TM") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_TM ); + } + else if ( !strcmp(ptr,"TR") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_TR ); + } + else if ( !strcmp(ptr,"ML") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_ML ); + } + else if ( !strcmp(ptr,"MM") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_MM ); + } + else if ( !strcmp(ptr,"MR") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_MR ); + } + else if ( !strcmp(ptr,"BL") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_BL ); + } + else if ( !strcmp(ptr,"BM") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_BM ); + } + else if ( !strcmp(ptr,"BR") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue64( (sint64)Hotspot_BR ); + } + + else + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + + + void CInterfaceProperty::setBool(bool value) + { + _VolatileValue->setValue8 (value); + } + + bool CInterfaceProperty::getBool() const + { + return _VolatileValue->getValue8() != 0 ? true : false; + } + + void CInterfaceProperty::readBool (const char* value,const string& id) + { + string str (value); + if ( !strcmp(value,"true") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue8( (sint8)true ); + } + else if ( !strcmp(value,"false") ) + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + _VolatileValue->setValue8( (sint8)false ); + } + else if ( isdigit(*value) || *value=='-') + { + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); + sint8 value8; + fromString(value, value8); + _VolatileValue->setValue8( value8 ); + } + else + _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); + } + + + // *************************************************************************** + void CInterfaceProperty::swap32(CInterfaceProperty &o) + { + CCDBNodeLeaf *a= getNodePtr(); + CCDBNodeLeaf *b= o.getNodePtr(); + if(!a || !b) + return; + sint32 val= a->getValue32(); + a->setValue32(b->getValue32()); + b->setValue32(val); + } + +} \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 0d9a9b0a1..c56b90d9e 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -22,7 +22,7 @@ #include "dbgroup_list_sheet.h" #include "group_container.h" #include "ctrl_button.h" -#include "interface_property.h" +#include "nel/gui/interface_property.h" #include "interface_manager.h" #include "action_handler.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index adce780f7..3e99469fd 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -24,7 +24,7 @@ #include "view_text.h" #include "view_bitmap.h" #include "ctrl_button.h" -#include "interface_property.h" +#include "nel/gui/interface_property.h" #include "interface_manager.h" #include "action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/interface_anim.h b/code/ryzom/client/src/interface_v3/interface_anim.h index 46c28b793..9965d3723 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.h +++ b/code/ryzom/client/src/interface_v3/interface_anim.h @@ -19,7 +19,7 @@ #ifndef RZ_INTERFACE_ANIM_H #define RZ_INTERFACE_ANIM_H -#include "interface_property.h" +#include "nel/gui/interface_property.h" #include "interface_group.h" #include "interface_link.h" diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 34119f7fa..63494ff53 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "interface_group.h" -#include "interface_property.h" +#include "nel/gui/interface_property.h" #include "interface_manager.h" #include "group_container.h" #include "../misc.h" diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 3b5a878cb..72663f09a 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -22,8 +22,9 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" #include "nel/misc/smart_ptr.h" -#include "interface_property.h" +#include "nel/gui/interface_property.h" #include "nel/gui/reflect.h" +#include "nel/gui/interface_common.h" using namespace NLGUI; @@ -31,26 +32,6 @@ using namespace NLGUI; class CInterfaceGroup; // ---------------------------------------------------------------------------- -enum THotSpot -{ - Hotspot_BL = 36, // 100100, - Hotspot_BM = 34, // 100010, - Hotspot_BR = 33, // 100001, - Hotspot_ML = 20, // 010100, - Hotspot_MM = 18, // 010010 - Hotspot_MR = 17, // 010001 - Hotspot_TL = 12, // 001100 - Hotspot_TM = 10, // 001010 - Hotspot_TR = 9, // 001001 - Hotspot_xR = 1, // 000001 - Hotspot_xM = 2, // 000010 - Hotspot_xL = 4, // 000100 - Hotspot_Bx = 32, // 100000 - Hotspot_Mx = 16, // 010000 - Hotspot_Tx = 8, // 001000 - Hotspot_TTAuto = 0, // Special For Tooltip PosRef. Auto mode. see CCtrlBase and tooltip info -}; - class CInterfaceLink; class CInterfaceElement; @@ -82,22 +63,6 @@ public: }; -#define DECLARE_UI_CLASS(_class_) \ - virtual std::string getClassName() {return #_class_;} \ - static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());} -#define REGISTER_UI_CLASS(_class_) \ - class CRegisterUIClassHelper_##_class_ \ - { \ - public: \ - CRegisterUIClassHelper_##_class_() \ - { \ - NLMISC::CClassRegistry::init(); \ - NLMISC::CClassRegistry::registerClass(#_class_, _class_::creator, typeid(_class_).name()); \ - } \ - } RegisterUIClassHelper_##_class_; - - - /** * class describing a localisable interface element, i.e. : an element with coordinates * \author Nicolas Brigand diff --git a/code/ryzom/client/src/interface_v3/interface_property.cpp b/code/ryzom/client/src/interface_v3/interface_property.cpp deleted file mode 100644 index 35a6b5329..000000000 --- a/code/ryzom/client/src/interface_v3/interface_property.cpp +++ /dev/null @@ -1,286 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_property.h" -#include "interface_manager.h" -#include "nel/misc/rgba.h" - -using namespace NLMISC; -using namespace std; - -bool CInterfaceProperty::link( CCDBNodeLeaf *dbNode ) -{ - _VolatileValue = dbNode; - return (dbNode != NULL); -} - -bool CInterfaceProperty::link( CCDBNodeBranch *dbNode, const string &leafId, CCDBNodeLeaf *defaultLeaf ) -{ - // no branch => default leaf - if( !dbNode ) - { - _VolatileValue = defaultLeaf; - return false; - } - - // get the leaf - _VolatileValue = dbNode->getLeaf( leafId.c_str(), false ); - if( _VolatileValue ) - return true; - - // default - _VolatileValue = defaultLeaf; - return false; -} - -bool CInterfaceProperty::link (const char *DBProp) -{ - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp, false); - if (_VolatileValue == NULL) - { - - nlinfo("prop not created : %s", DBProp); - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(DBProp); - return false; - } - return true; -} - - -// ***************** -// sint64 operations -// ***************** - - -void CInterfaceProperty::readSInt64(const char * ptr,const string& id) -{ - string str (ptr); - //the value is volatile, and a database entry is created - if ( isdigit(*ptr) || *ptr=='-') - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - sint64 i; - fromString(ptr, i); - _VolatileValue->setValue64( i ); - } - //the value is volatile and points to a db entry created elsewhere - else - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); - } -} - - - - -// **************** -// float operations -// **************** - - -// ---------------------------------------------------------------------------- -void CInterfaceProperty::readDouble(const char * ptr,const string& id) -{ - string str (ptr); - if ( isdigit(*ptr) || *ptr=='-') - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - double buf; - fromString(ptr, buf); - sint64 i = *(sint64*)&buf; - _VolatileValue->setValue64( i ); - } - else - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); - } -} - -// ***************** -// sint32 operations -// ***************** - - -// ---------------------------------------------------------------------------- -void CInterfaceProperty::readSInt32 (const char *ptr, const string& id) -{ - string str (ptr); - //the value is volatile, and a database entry is created - if ( isdigit(*ptr) || *ptr=='-') - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - sint32 i; - fromString(ptr, i); - _VolatileValue->setValue32( i ); - } - //the value is volatile and points to a db entry created elsewhere - else - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); - } -} - - - -// ***************** -// rgba operations -// ***************** -CRGBA CInterfaceProperty::getRGBA() const -{ - CRGBA rgba; - sint64 buf = getSInt64(); - rgba.R = (sint8) (buf &255); - rgba.G = (sint8) ((buf>>8)&255 ); - rgba.B = (sint8) ((buf>>16)&255); - rgba.A = (sint8) ((buf>>24)&255); - return rgba; -} - - -void CInterfaceProperty::setRGBA (const CRGBA& value) -{ - setSInt64( (value.R )+ (((sint32)value.G)<<8) + (((sint32)value.B)<<16) + (((sint32)value.A)<<24)); -} - - -void CInterfaceProperty::readRGBA (const char *value,const string& id) -{ - string str (value); - if (isdigit(*value)) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - int r=0, g=0, b=0, a=255; - sscanf (value, "%d %d %d %d", &r, &g, &b, &a); - clamp (r, 0, 255); - clamp (g, 0, 255); - clamp (b, 0, 255); - clamp (a, 0, 255); - sint64 val = r+(g<<8)+(b<<16)+(a<<24); - setSInt64(val); - CRGBA rgba = getRGBA(); - } - else - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); - } -} - - -void CInterfaceProperty::readHotSpot (const char *ptr,const string& id) -{ - string str(ptr); - if ( !strcmp(ptr,"TL") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64((sint64)Hotspot_TL ); - } - else if ( !strcmp(ptr,"TM") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_TM ); - } - else if ( !strcmp(ptr,"TR") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_TR ); - } - else if ( !strcmp(ptr,"ML") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_ML ); - } - else if ( !strcmp(ptr,"MM") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_MM ); - } - else if ( !strcmp(ptr,"MR") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_MR ); - } - else if ( !strcmp(ptr,"BL") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_BL ); - } - else if ( !strcmp(ptr,"BM") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_BM ); - } - else if ( !strcmp(ptr,"BR") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue64( (sint64)Hotspot_BR ); - } - - else - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); -} - - -void CInterfaceProperty::setBool(bool value) -{ - _VolatileValue->setValue8 (value); -} - -bool CInterfaceProperty::getBool() const -{ - return _VolatileValue->getValue8() != 0 ? true : false; -} - -void CInterfaceProperty::readBool (const char* value,const string& id) -{ - string str (value); - if ( !strcmp(value,"true") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue8( (sint8)true ); - } - else if ( !strcmp(value,"false") ) - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - _VolatileValue->setValue8( (sint8)false ); - } - else if ( isdigit(*value) || *value=='-') - { - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(id); - sint8 value8; - fromString(value, value8); - _VolatileValue->setValue8( value8 ); - } - else - _VolatileValue = NLGUI::CDBManager::getInstance()->getDbProp(str); -} - - -// *************************************************************************** -void CInterfaceProperty::swap32(CInterfaceProperty &o) -{ - CCDBNodeLeaf *a= getNodePtr(); - CCDBNodeLeaf *b= o.getNodePtr(); - if(!a || !b) - return; - sint32 val= a->getValue32(); - a->setValue32(b->getValue32()); - b->setValue32(val); -} - diff --git a/code/ryzom/client/src/interface_v3/interface_property.h b/code/ryzom/client/src/interface_v3/interface_property.h deleted file mode 100644 index 06355f17a..000000000 --- a/code/ryzom/client/src/interface_v3/interface_property.h +++ /dev/null @@ -1,107 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_INTERFACE_PROPERTY_H -#define NL_INTERFACE_PROPERTY_H - -#include "nel/misc/types_nl.h" -#include "nel/misc/rgba.h" - -#include "nel/misc/cdb.h" -#include "nel/misc/cdb_leaf.h" -#include "nel/misc/cdb_branch.h" -#include "../cdb_synchronised.h" - - -class CDBNodeProperty; -class IGetProperty; - -/** - * interface property - * class used to managed all the interface member values - * As the database contains only sint64, several methods are needed to do the conversion - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 - */ -class CInterfaceProperty -{ -public: - //enum defining a hot spot - - /// Constructor - CInterfaceProperty() - { - _VolatileValue = NULL; - } - - NLMISC::CCDBNodeLeaf* getNodePtr() const - { - return _VolatileValue; - } - - void setNodePtr(NLMISC::CCDBNodeLeaf *ptr) - { - _VolatileValue = ptr; - } - - - bool link (const char *DBProp); - bool link( NLMISC::CCDBNodeLeaf *dbNode ); - bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); - - /// float operations - void setDouble (double value) {setSInt64((sint64&) value);} - double getDouble () const {sint64 i = getSInt64(); return (double &) i; } - void readDouble (const char* value, const std::string& id); - - /// sint32 operations - void setSInt32 (sint32 value) {_VolatileValue->setValue32 (value);} - sint32 getSInt32 () const {return _VolatileValue->getValue32();} - void readSInt32(const char* value, const std::string& id); - - /// sint64 operations - void setSInt64 (sint64 value) {_VolatileValue->setValue64(value);} - sint64 getSInt64 () const {return _VolatileValue->getValue64();} - void readSInt64(const char* value, const std::string& id); - - /// CRGBA operations - void setRGBA (const NLMISC::CRGBA & value); - NLMISC::CRGBA getRGBA () const; - void readRGBA (const char* value, const std::string& id); - - /// HotSpot operations - - void readHotSpot (const char* value, const std::string& id); - - /// bool operations - void setBool (bool value); - bool getBool () const; - void readBool (const char* value, const std::string& id); - - // Swap the content of this 2 property (no-op if one is NULL) - void swap32(CInterfaceProperty &o); - -private: - /// volatile value of the property (pointer to a leaf of the database) - NLMISC::CCDBNodeLeaf* _VolatileValue; -}; - -#endif // NL_INTERFACE_PROPERTY_H - -/* End of interface_property.h */ diff --git a/code/ryzom/client/src/time_client.cpp b/code/ryzom/client/src/time_client.cpp index fa8dd9f72..f07bfbf49 100644 --- a/code/ryzom/client/src/time_client.cpp +++ b/code/ryzom/client/src/time_client.cpp @@ -27,7 +27,7 @@ // client. #include "time_client.h" #include "interface_v3/interface_manager.h" -#include "interface_v3/interface_property.h" +#include "nel/gui/interface_property.h" #include "client_cfg.h" #include "net_manager.h" #include "game_share/zc_shard_common.h" From 42919dc86bedcdf14dea4974b75ffb2a1cf716a9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 25 May 2012 03:21:03 +0200 Subject: [PATCH 034/339] CHANGED: #1471 CInterfaceExpr, CInterfaceExprNode and related classes are now in NELGUI and under NLGUI namespace. --- code/nel/include/nel/gui/interface_expr.h | 239 +++++ .../nel/include/nel/gui/interface_expr_node.h | 118 +++ code/nel/include/nel/misc/rgba.h | 2 + code/nel/src/gui/interface_expr.cpp | 939 ++++++++++++++++++ code/nel/src/gui/interface_expr_node.cpp | 161 +++ code/nel/src/misc/rgba.cpp | 15 + code/ryzom/client/src/client_cfg.cpp | 2 +- code/ryzom/client/src/connection.cpp | 10 +- .../src/interface_v3/action_handler.cpp | 4 +- .../src/interface_v3/action_handler_game.cpp | 4 +- .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/action_handler_misc.cpp | 4 +- .../interface_v3/action_handler_outpost.cpp | 2 +- .../client/src/interface_v3/bar_manager.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.h | 2 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../group_phrase_skill_filter.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../src/interface_v3/interface_anim.cpp | 4 +- .../src/interface_v3/interface_element.cpp | 2 +- .../src/interface_v3/interface_expr.cpp | 930 ----------------- .../client/src/interface_v3/interface_expr.h | 242 ----- .../src/interface_v3/interface_expr_node.cpp | 159 --- .../src/interface_v3/interface_expr_node.h | 123 --- .../interface_v3/interface_expr_user_fct.cpp | 4 +- .../interface_expr_user_fct_game.cpp | 2 +- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_link.cpp | 88 +- .../client/src/interface_v3/interface_link.h | 15 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 84 +- .../src/interface_v3/interface_parser.h | 10 - .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 6 +- code/ryzom/client/src/misc.cpp | 15 - code/ryzom/client/src/misc.h | 3 - 39 files changed, 1607 insertions(+), 1604 deletions(-) create mode 100644 code/nel/include/nel/gui/interface_expr.h create mode 100644 code/nel/include/nel/gui/interface_expr_node.h create mode 100644 code/nel/src/gui/interface_expr.cpp create mode 100644 code/nel/src/gui/interface_expr_node.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_expr.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_expr.h delete mode 100644 code/ryzom/client/src/interface_v3/interface_expr_node.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_expr_node.h diff --git a/code/nel/include/nel/gui/interface_expr.h b/code/nel/include/nel/gui/interface_expr.h new file mode 100644 index 000000000..edfb0645b --- /dev/null +++ b/code/nel/include/nel/gui/interface_expr.h @@ -0,0 +1,239 @@ +// Ryzom - MMORPG Framework +// 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 CL_INTERFACE_EXPR_H +#define CL_INTERFACE_EXPR_H + + +#include "nel/misc/ucstring.h" +#include "nel/misc/rgba.h" + +namespace NLMISC{ + class ICDBNode; + class CCDBNodeLeaf; + class CCDBNodeBranch; +} + +namespace NLGUI +{ + + struct CInterfaceExprUserType; + class CInterfaceExprNode; + + /** a value that can be returned by a CInterfaceExpr instance + * It supports basic type; + * It can be extended by user defined types + */ + class CInterfaceExprValue + { + public: + enum TType { Boolean = 0, Integer, Double, String, RGBA, UserType, NoType }; + public: + // default ctor + CInterfaceExprValue() : _Type(NoType) {} + // copy ctor + CInterfaceExprValue(const CInterfaceExprValue &other); + // assignment operator + CInterfaceExprValue &operator = (const CInterfaceExprValue &other); + // dtor + ~CInterfaceExprValue() { clean(); } + + TType getType() const { return _Type; } + // get. Should be used only if the type is valid + bool getBool() const; + sint64 getInteger() const; + double getDouble() const; + std::string getString() const; + NLMISC::CRGBA getRGBA() const; + const ucstring &getUCString() const; + CInterfaceExprUserType *getUserType() const; + // set + void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; } + void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } + void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } + void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } + void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; } + void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } + void setUserType(CInterfaceExprUserType *value); + // reset this object to initial state (no type) + void clean(); + // conversions. They return true if success + bool toBool(); + bool toInteger(); + bool toDouble(); + bool toString(); + bool toType(TType type); + bool toRGBA(); + // test if the value if a bool, double, or integer + bool isNumerical() const; + /** evaluate a from a string + * \param expr : where to start the evaluation + * \return the position following the token, or NULL if the parsing failed + */ + const char *initFromString(const char *expr); + + ///////////////////////////////////////////////////////////////////////////////////////////// + private: + TType _Type; + union + { + bool _BoolValue; + sint64 _IntegerValue; + double _DoubleValue; + CInterfaceExprUserType *_UserTypeValue; + uint32 _RGBAValue; + }; + ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack.. + private: + const char *evalBoolean(const char *expr); + const char *evalNumber(const char *expr); + const char *evalString(const char *expr); + }; + + /** + * Base class for user defined types that are use by the 'CInterfaceExprValue' class + * Derivers should include the 'clone' method + * + * CInterfaceExprValue instances have ownership of this object. + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2003 + */ + struct CInterfaceExprUserType + { + // cloning method + virtual CInterfaceExprUserType *clone() const = 0; + // dtor + virtual ~CInterfaceExprUserType() {} + }; + + + /** Evaluate expressions used in interface. + * It can retrieve values from the database. + * It can also build a list of database values it depends of. + * + * An expression can be : + * + * - a string : 'toto', 'abcd', 'a\nbcd', 'a\\t', the escape sequences are the one of C + * - a integer 1, 2, 3 + * - a double 1.1, 2.2 + * - a database entry : @ui:interface:toto:truc. If the address is a leaf, it returns the leaf value and put an observer on it. If not a leaf, it returns 0, but put an observer on it. + * - a database indirection @db:value[db:index] is replaced by @db:value0 if db:index == 0 for example + * - a user function call : fct(expr0, epxr1, ...). + * + * NB : The lua language has been integrated since then (2005), and should be more suited + * for most of the tasks. + * + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CInterfaceExpr + { + public: + // list of argument for a function + typedef std::vector TArgList; + /** prototype of a user callable function + * It should return true if the result is meaningful. If not, the rest of the evaluation is stopped + */ + typedef bool (* TUserFct) (TArgList &args, CInterfaceExprValue &result); + public: + + // release memory + static void release(); + + /** This try to eval the provided expression. + * - This returns a result + * - This eventually fill a vector with a set of database entries it has dependencies on + * \param expr The expression to evaluate + * \param result The result value + * \param nodes If not NULL, will be filled with the database nodes this expression depends on + * Node will only be inserted once, so we end up with a set of node (not ordered) + * \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on. + */ + static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes = NULL, bool noFctCalls = false); + + /** Build a tree from the given expression so that it can be evaluated quickly. + * This is useful for a fixed expression that must be evaluated often + */ + static CInterfaceExprNode *buildExprTree(const std::string &expr); + + + /** Register a function that can have several arguments + * // NB : this is case sensitive + */ + static void registerUserFct(const char *name, TUserFct fct); + // Simple evaluations + static bool evalAsInt(const std::string &expr, sint64 &dest); + static bool evalAsDouble(const std::string &expr, double &dest); + static bool evalAsBool(const std::string &expr, bool &dest); + static bool evalAsString(const std::string &expr, std::string &dest); + ///////////////////////////////////////////////////////////////////////////////////////////// + private: + // map of user functions + typedef std::map TUserFctMap; + private: + static TUserFctMap *_UserFct; + private: + /** eval the value of a single expression + * \return position to the next valid character + */ + static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls); + static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector *nodes, bool noFctCalls); + static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector *nodes); + public: + static const char *unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections = NULL); + + /** Build tree of a single expression + * \return position to the next valid character + */ + private: + static const char *buildExprTree(const char *expr, CInterfaceExprNode *&result); + static const char *buildFctNode(const char *expr, CInterfaceExprNode *&result); + static const char *buildDBEntryNode(const char *expr,CInterfaceExprNode *&result); + }; + + + // helper macro to register user functions at startup + #define REGISTER_INTERFACE_USER_FCT(name, fct) \ + const struct __InterUserFctRegister__##fct\ + {\ + __InterUserFctRegister__##fct() { CInterfaceExpr::registerUserFct(name, fct); }\ + } __InterUserFctRegisterInstance__##fct; + + + // helper macro to declare a user function + // the code must follow + // arguments are available in 'args', result should be put in 'result' + #define DECLARE_INTERFACE_USER_FCT(name) \ + bool name(CInterfaceExpr::TArgList &args, CInterfaceExprValue &result) + + + // helper macro to declare a C constant mirroring + #define DECLARE_INTERFACE_CONSTANT(_name, _cconst) \ + static DECLARE_INTERFACE_USER_FCT(_name) \ + { \ + result.setInteger(_cconst); \ + return true; \ + } \ + REGISTER_INTERFACE_USER_FCT(#_name, _name) + +} + +#endif + diff --git a/code/nel/include/nel/gui/interface_expr_node.h b/code/nel/include/nel/gui/interface_expr_node.h new file mode 100644 index 000000000..f8b8aea90 --- /dev/null +++ b/code/nel/include/nel/gui/interface_expr_node.h @@ -0,0 +1,118 @@ +// Ryzom - MMORPG Framework +// 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 CL_INTERFACE_EXPR_NODE_H +#define CL_INTERFACE_EXPR_NODE_H + +#include "interface_expr.h" + +namespace NLGUI +{ + + /** Base node of an interface expression parse tree + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2003 + */ + class CInterfaceExprNode + { + public: + virtual ~CInterfaceExprNode() {} + // eval result of expression, and eventually get the nodes the epression depends on + virtual void eval(CInterfaceExprValue &result) = 0; + // The same, but get db nodes the expression depends on (appended to vector) + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) = 0; + // Get dependencies of the node (appended to vector) + virtual void getDepends(std::vector &nodes) = 0; + }; + + + // ******************************************************************************************************* + /** A constant value already parsed by interface (in a interface expr parse tree) + */ + class CInterfaceExprNodeValue : public CInterfaceExprNode + { + public: + CInterfaceExprValue Value; + public: + virtual void eval(CInterfaceExprValue &result); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); + }; + + // ******************************************************************************************************* + /** A fct call (in a interface expr parse tree) + */ + class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode + { + public: + CInterfaceExpr::TUserFct Func; + // list of parameters + std::vector Params; + public: + virtual void eval(CInterfaceExprValue &result); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); + virtual ~CInterfaceExprNodeValueFnCall(); + }; + + // ******************************************************************************************************* + /** A db leaf read (in a interface expr parse tree) + */ + class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode + { + public: + class NLMISC::CCDBNodeLeaf *Leaf; + public: + virtual void eval(CInterfaceExprValue &result); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); + }; + + // ******************************************************************************************************* + /** A db branch read (in a interface expr parse tree) + */ + class CInterfaceExprNodeDBBranch : public CInterfaceExprNode + { + public: + class NLMISC::CCDBNodeBranch *Branch; + public: + virtual void eval(CInterfaceExprValue &result); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); + }; + + // ******************************************************************************************************* + /** A dependant db read (in a interface expr parse tree) + * This is rarely used so no real optim there.. + */ + class CInterfaceExprNodeDependantDBRead : public CInterfaceExprNode + { + public: + std::string Expr; + public: + virtual void eval(CInterfaceExprValue &result); + virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); + virtual void getDepends(std::vector &nodes); + }; + + +} + + +#endif diff --git a/code/nel/include/nel/misc/rgba.h b/code/nel/include/nel/misc/rgba.h index a9aa1316e..700c98a41 100644 --- a/code/nel/include/nel/misc/rgba.h +++ b/code/nel/include/nel/misc/rgba.h @@ -326,6 +326,8 @@ public: void buildFromHLS(float h, float l, float s); //@} + static CRGBA stringToRGBA( const char *ptr ); + /// Swap the B and R components, to simulate a CBRGA void swapBR() diff --git a/code/nel/src/gui/interface_expr.cpp b/code/nel/src/gui/interface_expr.cpp new file mode 100644 index 000000000..1feed6e26 --- /dev/null +++ b/code/nel/src/gui/interface_expr.cpp @@ -0,0 +1,939 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/algo.h" +#include +#include "nel/gui/db_manager.h" +#include "nel/gui/interface_expr.h" +#include "nel/gui/interface_expr_node.h" + +using namespace std; +using namespace NLMISC; + +namespace NLGUI +{ + + // Yoyo: Act like a singleton, else registerUserFct may crash. + CInterfaceExpr::TUserFctMap *CInterfaceExpr::_UserFct= NULL; + + static const std::string ExprLuaId="lua:"; + + //================================================================== + // release memory + void CInterfaceExpr::release() + { + delete _UserFct; + _UserFct = NULL; + } + + //================================================================== + void formatLuaCall(const std::string &expr, std::string &tempStr) + { + /* Call the LUA interface exp fct, with the script as line, and resolve string definition conflicts: + eg: replace + lua:getSkillFromName('SM') + into + lua('getSkillFromName(\"SM\")') + */ + tempStr= expr.substr(ExprLuaId.size()); // eg: tempStr= getSkillFromName('SM') + while(strFindReplace(tempStr, "'", "\\\"")); // eg: tempStr= getSkillFromName(\"SM\") + tempStr= string("lua('") + tempStr + "')"; // eg: tempStr= lua('getSkillFromName(\"SM\")') + } + + //================================================================== + bool CInterfaceExpr::eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls /* = false */) + { + // Yoyo: Special InterfaceExpr Form to execute lua code? + if(expr.compare(0, ExprLuaId.size(), ExprLuaId) ==0 ) + { + std::string tempStr; + formatLuaCall(expr, tempStr); + return evalExpr(tempStr.c_str(), result, nodes, noFctCalls) != NULL; + } + else + { + return evalExpr(expr.c_str(), result, nodes, noFctCalls) != NULL; + } + } + + //================================================================== + CInterfaceExprNode *CInterfaceExpr::buildExprTree(const std::string &expr) + { + CInterfaceExprNode *node; + + // Yoyo: Special InterfaceExpr Form to execute lua code? + if(expr.compare(0, ExprLuaId.size(), ExprLuaId) ==0 ) + { + std::string tempStr; + formatLuaCall(expr, tempStr); + if (!buildExprTree(tempStr.c_str(), node)) return false; + } + else + { + if (!buildExprTree(expr.c_str(), node)) return false; + } + + return node; + } + + + //================================================================== + void CInterfaceExpr::registerUserFct(const char *name,TUserFct fct) + { + if(!_UserFct) _UserFct= new TUserFctMap; + + nlassert(fct != NULL); + (*_UserFct)[std::string(name)] = fct; + } + + //================================================================== + /** tool fct : skip space, tab and carret-returns + */ + static const char *skipBlank(const char *start) + { + nlassert(start); + while (*start == ' ' || *start == '\t' || *start == '\r' || *start == '\n') ++start; + return start; + } + + //================================================================== + const char *CInterfaceExpr::evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls) + { + nlassert(expr != NULL); + expr = skipBlank(expr); + if (isalpha(*expr)) // alpha character means this is a function name + { + return evalFct(expr, result, nodes, noFctCalls); + } + else if (*expr == '@') // is it a database entry ? + { + ++ expr; + expr = skipBlank(expr); + return evalDBEntry(expr, result, nodes); + } + + // try to parse a literal value + const char *newExpr = result.initFromString(expr); + if (!newExpr) + { + nlwarning(" : syntax error : %s", expr); + return NULL; + } + return newExpr; + } + + //================================================================== + const char *CInterfaceExpr::buildExprTree(const char *expr, CInterfaceExprNode *&result) + { + nlassert(expr != NULL); + expr = skipBlank(expr); + if (isalpha(*expr)) // alpha character means this is a function name + { + return buildFctNode(expr, result); + } + else if (*expr == '@') // is it a database entry ? + { + ++ expr; + expr = skipBlank(expr); + return buildDBEntryNode(expr, result); + } + else + { + CInterfaceExprValue value; + // try to parse a literal value + const char *newExpr = value.initFromString(expr); + if (!newExpr) + { + nlwarning(" : syntax error : %s", expr); + return NULL; + } + CInterfaceExprNodeValue *node = new CInterfaceExprNodeValue; + node->Value = value; + result = node; + return newExpr; + } + return NULL; + } + + + //================================================================== + const char *CInterfaceExpr::evalFct(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls) + { + if(!_UserFct) _UserFct= new TUserFctMap; + + const char *start = expr; + while (isalnum(*expr)) ++ expr; + std::string fctName(start, expr - start); + // find entry in the map + TUserFctMap::iterator fctIt = _UserFct->find(fctName); + if (fctIt == _UserFct->end()) + { + nlwarning(" : Unknown function %s", fctName.c_str()); + return NULL; + } + nlassert(fctIt->second != NULL); + // eval list of arguments + TArgList argList; + expr = skipBlank(expr); + if (*expr != '(') + { + nlwarning(" : '(' expected for function %s", fctName.c_str()); + return NULL; + } + ++ expr; + expr = skipBlank(expr); + if (*expr != ')') + { + for(;;) + { + expr = skipBlank(expr); + // parse an argument + argList.push_back(CInterfaceExprValue()); + expr = evalExpr(expr, argList.back(), nodes, noFctCalls); + if (expr == NULL) return NULL; + expr = skipBlank(expr); + if (*expr == ')') break; + // if it isn't the end of the expression, then we should find a ',' before next argument + if (*expr != ',') + { + nlwarning(" : ',' expected in function %s", fctName.c_str()); + return NULL; + } + ++ expr; + } + } + ++ expr; + // call the fct + if (!noFctCalls) // should we make terminal function calls ? + { + if (fctIt->second(argList, result)) return expr; + } + else + { + return expr; + } + return NULL; + } + + //================================================================== + const char *CInterfaceExpr::buildFctNode(const char *expr, CInterfaceExprNode *&result) + { + if(!_UserFct) _UserFct= new TUserFctMap; + + const char *start = expr; + while (isalnum(*expr)) ++ expr; + std::string fctName(start, expr - start); + // find entry in the map + TUserFctMap::iterator fctIt = _UserFct->find(fctName); + if (fctIt == _UserFct->end()) + { + nlwarning(" : Unknown function %s", fctName.c_str()); + return NULL; + } + nlassert(fctIt->second != NULL); + // List of parameters + expr = skipBlank(expr); + if (*expr != '(') + { + nlwarning(" : '(' expected for function %s", fctName.c_str()); + return NULL; + } + ++ expr; + expr = skipBlank(expr); + std::vector Params; + if (*expr != ')') + { + for(;;) + { + expr = skipBlank(expr); + // parse an argument + CInterfaceExprNode *node = NULL; + expr = buildExprTree(expr, node); + if (expr == NULL) + { + for(uint k = 0; k < Params.size(); ++k) + { + delete Params[k]; + } + return NULL; + } + Params.push_back(node); + expr = skipBlank(expr); + if (*expr == ')') break; + // if it isn't the end of the expression, then we should find a ',' before next argument + if (*expr != ',') + { + for(uint k = 0; k < Params.size(); ++k) + { + delete Params[k]; + } + nlwarning("CInterfaceExpr::evalFct : ',' expected in function %s", fctName.c_str()); + return NULL; + } + ++ expr; + } + } + ++ expr; + CInterfaceExprNodeValueFnCall *node = new CInterfaceExprNodeValueFnCall; + node->Params.swap(Params); + node->Func = fctIt->second; + result = node; + return expr; + } + + //================================================================== + const char *CInterfaceExpr::evalDBEntry(const char *expr, CInterfaceExprValue &result, std::vector *nodes) + { + std::string dbEntry; + expr = unpackDBentry(expr, nodes, dbEntry); + if (!expr) return NULL; + // TestYoyo + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); + // get the db value + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); + if (nl) + { + if (nodes) + { + // insert node if not already present + if (std::find(nodes->begin(), nodes->end(), nl) == nodes->end()) + { + nodes->push_back(nl); + } + } + result.setInteger(nl->getValue64()); + return expr; + } + else + { + CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); + if (nodes && nb) + { + if (std::find(nodes->begin(), nodes->end(), nb) == nodes->end()) + { + nodes->push_back(nb); + } + } + if (!nb) return NULL; + result.setInteger(0); + return expr; + } + return NULL; + } + + //================================================================== + const char *CInterfaceExpr::buildDBEntryNode(const char *expr, CInterfaceExprNode *&result) + { + std::string dbEntry; + bool indirection; + const char *startChar = expr; + expr = unpackDBentry(expr, NULL, dbEntry, &indirection); + if (!expr) return NULL; + if (indirection) + { + // special node with no optimisation + CInterfaceExprNodeDependantDBRead *node = new CInterfaceExprNodeDependantDBRead; + node->Expr.resize(expr - startChar + 1); + std::copy(startChar, expr, node->Expr.begin() + 1); + node->Expr[0] = '@'; + result = node; + return expr; + } + else + { + // TestYoyo + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); + if (nl) + { + CInterfaceExprNodeDBLeaf *node = new CInterfaceExprNodeDBLeaf; + node->Leaf = nl; + result = node; + return expr; + } + else + { + CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); + if (nb) + { + CInterfaceExprNodeDBBranch *node = new CInterfaceExprNodeDBBranch; + node->Branch = nb; + result = node; + return expr; + } + } + return NULL; + } + } + + //================================================================== + const char *CInterfaceExpr::unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections /* = NULL*/) + { + std::string entryName; + bool indirection = false; + for (;;) + { + if (*expr == '[') + { + indirection = true; + ++ expr; + std::string subEntry; + expr = unpackDBentry(expr, nodes, subEntry); + if (!expr) return NULL; + // Read DB Index Offset. + sint32 indirectionOffset= 0; + if (*expr == '-' || *expr =='+' ) + { + bool negative= *expr == '-'; + std::string offsetString; + ++ expr; + while(*expr!=0 && isdigit(*expr)) + { + offsetString.push_back(*expr); + ++ expr; + } + // get offset + fromString(offsetString, indirectionOffset); + if(negative) + indirectionOffset= -indirectionOffset; + } + // Test end of indirection + if (*expr != ']') + { + nlwarning("CInterfaceExpr::unpackDBentry: ']' expected"); + return NULL; + } + ++ expr; + // get the db value at sub entry + // TestYoyo + //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(subEntry, false) || CInterfaceManager::getInstance()->getDbBranch(subEntry)); + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(subEntry); + if (nodes) + { + if (std::find(nodes->begin(), nodes->end(), nl) == nodes->end()) + { + nodes->push_back(nl); + } + } + // compute indirection, (clamp). + sint32 indirectionValue= nl->getValue32() + indirectionOffset; + indirectionValue= std::max((sint32)0, indirectionValue); + + // Append to entry name. + entryName += NLMISC::toString(indirectionValue); + } + else if (isalnum(*expr) || *expr == '_' || *expr == ':') + { + entryName += *expr; + ++ expr; + } + else + { + break; + } + } + if (hasIndirections) + { + *hasIndirections = indirection; + } + dest = entryName; + return expr; + } + + + //================================================================== + bool CInterfaceExpr::evalAsInt(const std::string &expr, sint64 &dest) + { + CInterfaceExprValue result; + if (!eval(expr, result)) return false; + if (!result.toInteger()) + { + nlwarning(" Can't convert value to an integer, expr = %s", expr.c_str()); + return false; + } + dest = result.getInteger(); + return true; + } + + //================================================================== + bool CInterfaceExpr::evalAsDouble(const std::string &expr, double &dest) + { + CInterfaceExprValue result; + if (!eval(expr, result)) return false; + if (!result.toDouble()) + { + nlwarning(" Can't convert value to a double, expr = %s", expr.c_str()); + return false; + } + dest = result.getDouble(); + return true; + } + + //================================================================== + bool CInterfaceExpr::evalAsBool(const std::string &expr, bool &dest) + { + CInterfaceExprValue result; + if (!eval(expr, result)) return false; + if (!result.toBool()) + { + nlwarning(" Can't convert value to a boolean, expr = %s", expr.c_str()); + return false; + } + dest = result.getBool(); + return true; + } + + //================================================================== + bool CInterfaceExpr::evalAsString(const std::string &expr, std::string &dest) + { + CInterfaceExprValue result; + if (!eval(expr, result)) return false; + if (!result.toString()) + { + nlwarning(" Can't convert value to a string, expr = %s", expr.c_str()); + return false; + } + dest = result.getString(); + return true; + } + + //================================================================== + //================================================================== + //================================================================== + //================================================================== + + + //================================================================== + bool CInterfaceExprValue::toBool() + { + switch(_Type) + { + case Boolean: return true; + case Integer: setBool(_IntegerValue != 0); return true; + case Double: setBool(_DoubleValue != 0); return true; + case String: return evalBoolean(_StringValue.toString().c_str()) != NULL; + default: break; + } + return false; + + } + + //================================================================== + bool CInterfaceExprValue::toInteger() + { + switch(_Type) + { + case Boolean: setInteger(_BoolValue ? 1 : 0); return true; + case Integer: return true; + case Double: setInteger((sint64) _DoubleValue); return true; + case String: + if (evalNumber(_StringValue.toString().c_str())) return toInteger(); + return false; + case RGBA: setInteger((sint64) _RGBAValue); return true; + default: break; + } + return false; + } + + //================================================================== + bool CInterfaceExprValue::toDouble() + { + switch(_Type) + { + case Boolean: setDouble(_BoolValue ? 1 : 0); return true; + case Integer: setDouble((double) _IntegerValue); return true; + case Double: return true; + case String: + if (evalNumber(_StringValue.toString().c_str())) return toBool(); + return false; + case RGBA: setDouble((double) _RGBAValue); return true; + default: break; + } + return false; + } + + //================================================================== + bool CInterfaceExprValue::toString() + { + switch(_Type) + { + case Boolean: setString(_BoolValue ? "true" : "false"); return true; + case Integer: setString(NLMISC::toString(_IntegerValue)); return true; + case Double: setString(NLMISC::toString("%.2f", _DoubleValue)); return true; + case String: return true; + case RGBA: + { + uint r,g,b,a; + r= (_RGBAValue&0xff); + g= ((_RGBAValue>>8)&0xff); + b= ((_RGBAValue>>16)&0xff); + a= ((_RGBAValue>>24)&0xff); + setString(NLMISC::toString("%d %d %d %d", r, g, b, a)); + return true; + } + default: break; + } + return false; + } + + //================================================================== + bool CInterfaceExprValue::toRGBA() + { + switch(_Type) + { + case RGBA: + return true; + + case Integer: + setRGBA(NLMISC::CRGBA((uint8)(_IntegerValue&0xff), (uint8)((_IntegerValue>>8)&0xff), + (uint8)((_IntegerValue>>16)&0xff), (uint8)((_IntegerValue>>24)&0xff))); + return true; + + case String: + setRGBA( NLMISC::CRGBA::stringToRGBA(_StringValue.toString().c_str())); + return true; + + default: + break; + } + return false; + } + + //================================================================== + bool CInterfaceExprValue::isNumerical() const + { + return _Type == Boolean || _Type == Integer || _Type == Double; + } + + //================================================================== + const char *CInterfaceExprValue::initFromString(const char *expr) + { + nlassert(expr); + expr = skipBlank(expr); + if (isdigit(*expr) || *expr == '.' || *expr == '-') return evalNumber(expr); + switch(*expr) + { + case 't': + case 'T': + case 'f': + case 'F': + return evalBoolean(expr); + case '\'': + return evalString(expr); + default: + return NULL; + } + } + + //================================================================== + const char *CInterfaceExprValue::evalBoolean(const char *expr) + { + nlassert(expr); + expr = skipBlank(expr); + if (toupper(expr[0]) == 'T' && + toupper(expr[1]) == 'R' && + toupper(expr[2]) == 'U' && + toupper(expr[3]) == 'E') + { + setBool(true); + return expr + 4; + } + // + if (toupper(expr[0]) == 'F' && + toupper(expr[1]) == 'A' && + toupper(expr[2]) == 'L' && + toupper(expr[3]) == 'S' && + toupper(expr[4]) == 'E') + { + setBool(false); + return expr + 5; + } + return NULL; + } + + //================================================================== + const char *CInterfaceExprValue::evalNumber(const char *expr) + { + bool negative; + bool hasPoint = false; + + expr = skipBlank(expr); + + if (*expr == '-') + { + negative = true; + ++ expr; + expr = skipBlank(expr); + } + else + { + negative = false; + } + + const char *start = expr; + while (*expr == '.' || isdigit(*expr)) + { + if (*expr == '.') hasPoint = true; + ++ expr; + } + if (start == expr) return NULL; + if (!hasPoint) + { + sint64 value = 0; + // this is an integer + for (const char *nbPtr = start; nbPtr < expr; ++ nbPtr) + { + value *= 10; + value += (sint64) (*nbPtr - '0'); + } + setInteger(negative ? - value : value); + return expr; + } + else // floating point value : use scanf + { + // well, for now, we only parse a float + float value; + std::string floatValue(start, expr - start); + if (fromString(floatValue, value)) + { + setDouble(negative ? - value : value); + return expr; + } + else + { + return NULL; + } + } + } + + //================================================================== + const char *CInterfaceExprValue::evalString(const char *expr) + { + expr = skipBlank(expr); + if (*expr != '\'') return NULL; + ++expr; + std::string str; + for (;;) + { + if (expr == '\0') + { + nlwarning("CInterfaceExprValue::evalString : end of buffer encountered in a string"); + return NULL; + } + else + if (*expr == '\'') + { + ++ expr; + break; + } + if (*expr == '\\') // special char + { + ++ expr; + switch (*expr) + { + case 't': str += '\t'; break; + case 'r': str += '\r'; break; + case 'n': str += '\n'; break; + case '\'': str += '\''; break; + case '"': str += '"'; break; + case '\\': str += '\\'; break; + case '\n': + case '\r': + // string continue on next line, so do nothing + break; + case '\0': continue; + default: + nlwarning("CInterfaceExprValue::evalString : unknown escape sequence : \\%c", *expr); + if (*expr) str += *expr; + break; + } + } + else if (*expr == '\n' || *expr == '\r') + { + nlwarning("CInterfaceExprValue::evalString : line break encountered in a string"); + return NULL; + } + else + { + str += *expr; + } + ++ expr; + } + setString(str); + return expr; + } + + //================================================================== + bool CInterfaceExprValue::toType(TType type) + { + switch(type) + { + case Boolean: return toBool(); + case Integer: return toInteger(); + case Double: return toDouble(); + case String: return toString(); + case RGBA: return toRGBA(); + default: return false; + } + } + + + //================================================================== + void CInterfaceExprValue::clean() + { + switch (_Type) + { + case String: _StringValue.clear(); break; + case UserType: delete _UserTypeValue; break; + default: break; + } + } + + //================================================================== + void CInterfaceExprValue::setUserType(CInterfaceExprUserType *value) + { + if (_Type == UserType && value == _UserTypeValue) return; + clean(); + _Type = UserType; + _UserTypeValue = value; + } + + //================================================================== + bool CInterfaceExprValue::getBool() const + { + if (_Type != Boolean) + { + nlwarning(" bad type!"); + return false; + } + return _BoolValue; + } + + //================================================================== + sint64 CInterfaceExprValue::getInteger() const + { + if (_Type != Integer) + { + nlwarning(" bad type!"); + return 0; + } + return _IntegerValue; + } + + //================================================================== + double CInterfaceExprValue::getDouble() const + { + if (_Type != Double) + { + nlwarning(" bad type!"); + return 0; + } + return _DoubleValue; + } + + //================================================================== + std::string CInterfaceExprValue::getString() const + { + if (_Type != String) + { + nlwarning(" bad type!"); + return ""; + } + return _StringValue.toString(); + } + + //================================================================== + NLMISC::CRGBA CInterfaceExprValue::getRGBA() const + { + if (_Type != RGBA) + { + nlwarning(" bad type!"); + return CRGBA::White; + } + NLMISC::CRGBA col; + col.R = (uint8)(_RGBAValue&0xff); + col.G = (uint8)((_RGBAValue>>8)&0xff); + col.B = (uint8)((_RGBAValue>>16)&0xff); + col.A = (uint8)((_RGBAValue>>24)&0xff); + return col; + } + + + //================================================================== + const ucstring &CInterfaceExprValue::getUCString() const + { + if (_Type != String) + { + nlwarning(" bad type!"); + static ucstring emptyString; + return emptyString; + } + return _StringValue; + } + + //================================================================== + CInterfaceExprUserType *CInterfaceExprValue::getUserType() const + { + if (_Type != UserType) + { + nlwarning(" bad type!"); + return NULL; + } + return _UserTypeValue; + } + + //================================================================== + CInterfaceExprValue::CInterfaceExprValue(const CInterfaceExprValue &other) : _Type(NoType) + { + *this = other; + } + + //================================================================== + CInterfaceExprValue &CInterfaceExprValue::operator = (const CInterfaceExprValue &other) + { + if (this != &other) + { + clean(); + switch(other._Type) + { + case Boolean: _BoolValue = other._BoolValue; break; + case Integer: _IntegerValue = other._IntegerValue; break; + case Double: _DoubleValue = other._DoubleValue; break; + case String: _StringValue = other._StringValue; break; + case RGBA: _RGBAValue = other._RGBAValue; break; + case UserType: + if (other._UserTypeValue != NULL) + { + _UserTypeValue = other._UserTypeValue->clone(); + } + else + { + _UserTypeValue = NULL; + } + break; + case NoType: break; + default: + nlwarning(" bad source type") ; + return *this; + break; + } + _Type = other._Type; + } + return *this; + } + +} + diff --git a/code/nel/src/gui/interface_expr_node.cpp b/code/nel/src/gui/interface_expr_node.cpp new file mode 100644 index 000000000..1328153b1 --- /dev/null +++ b/code/nel/src/gui/interface_expr_node.cpp @@ -0,0 +1,161 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/cdb_leaf.h" +#include "nel/misc/cdb_branch.h" +#include "nel/gui/interface_expr_node.h" + +using NLMISC::ICDBNode; +using NLMISC::CCDBNodeBranch; +using NLMISC::CCDBNodeLeaf; + +namespace NLGUI +{ + + // ******************************************************************************************************* + void CInterfaceExprNodeValue::eval(CInterfaceExprValue &result) + { + result = Value; + } + + void CInterfaceExprNodeValue::evalWithDepends(CInterfaceExprValue &result, std::vector &/* nodes */) + { + result = Value; + } + + void CInterfaceExprNodeValue::getDepends(std::vector &/* nodes */) + { + } + + + // ******************************************************************************************************* + void CInterfaceExprNodeValueFnCall::eval(CInterfaceExprValue &result) + { + nlassert(Func); + uint numParams = (uint)Params.size(); + std::vector params(numParams); + for(uint k = 0; k < numParams; ++k) + { + Params[k]->eval(params[k]); + } + Func(params, result); // do actual call + } + + void CInterfaceExprNodeValueFnCall::evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) + { + nlassert(Func); + uint numParams = (uint)Params.size(); + std::vector params(numParams); + for(uint k = 0; k < numParams; ++k) + { + Params[k]->evalWithDepends(params[k], nodes); + } + Func(params, result); // do actual call + } + + void CInterfaceExprNodeValueFnCall::getDepends(std::vector &nodes) + { + uint numParams = (uint)Params.size(); + for(uint k = 0; k < numParams; ++k) + { + Params[k]->getDepends(nodes); + } + } + + + CInterfaceExprNodeValueFnCall::~CInterfaceExprNodeValueFnCall() + { + for(uint k = 0; k < Params.size(); ++k) + { + delete Params[k]; + } + } + + // ******************************************************************************************************* + void CInterfaceExprNodeDBLeaf::eval(CInterfaceExprValue &result) + { + nlassert(Leaf); + result.setInteger(Leaf->getValue64()); + } + + void CInterfaceExprNodeDBLeaf::evalWithDepends(CInterfaceExprValue &result,std::vector &nodes) + { + nlassert(Leaf); + result.setInteger(Leaf->getValue64()); + if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end()) + { + nodes.push_back(Leaf); + } + } + + void CInterfaceExprNodeDBLeaf::getDepends(std::vector &nodes) + { + nlassert(Leaf); + if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end()) + { + nodes.push_back(Leaf); + } + } + + + // ******************************************************************************************************* + void CInterfaceExprNodeDBBranch::eval(CInterfaceExprValue &result) + { + nlassert(Branch); + result.setInteger(0); + } + + void CInterfaceExprNodeDBBranch::evalWithDepends(CInterfaceExprValue &result,std::vector &nodes) + { + nlassert(Branch); + result.setInteger(0); + if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end()) + { + nodes.push_back(Branch); + } + } + + void CInterfaceExprNodeDBBranch::getDepends(std::vector &nodes) + { + nlassert(Branch); + if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end()) + { + nodes.push_back(Branch); + } + } + + + // ******************************************************************************************************* + void CInterfaceExprNodeDependantDBRead::eval(CInterfaceExprValue &result) + { + // no gain there, but barely used + CInterfaceExpr::eval(Expr, result); + } + + void CInterfaceExprNodeDependantDBRead::evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) + { + CInterfaceExpr::eval(Expr, result, &nodes); + } + + void CInterfaceExprNodeDependantDBRead::getDepends(std::vector &nodes) + { + CInterfaceExprValue dummyResult; + CInterfaceExpr::eval(Expr, dummyResult, &nodes, true); + } + +} + diff --git a/code/nel/src/misc/rgba.cpp b/code/nel/src/misc/rgba.cpp index 598d8eb53..b0ae2edc9 100644 --- a/code/nel/src/misc/rgba.cpp +++ b/code/nel/src/misc/rgba.cpp @@ -728,6 +728,21 @@ void CRGBA::buildFromHLS(float h, float l, float s) } } +CRGBA CRGBA::stringToRGBA( const char *ptr ) +{ + if (!ptr) + return NLMISC::CRGBA::White; + + int r = 255, g = 255, b = 255, a = 255; + sscanf( ptr, "%d %d %d %d", &r, &g, &b, &a ); + clamp( r, 0, 255 ); + clamp( g, 0, 255 ); + clamp( b, 0, 255 ); + clamp( a, 0, 255 ); + + return CRGBA( r,g,b,a ); +} + // *************************************************************************** // *************************************************************************** diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index e0ed33abe..46e04d3f9 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -1374,7 +1374,7 @@ void CClientConfig::setValues() SPrintfCommand pcom; pcom.X = pc->asInt(i); pcom.Y = pc->asInt(i+1); - pcom.Color = stringToRGBA( pc->asString(i+2).c_str() ); + pcom.Color = CRGBA::stringToRGBA( pc->asString(i+2).c_str() ); pcom.FontSize = pc->asInt(i+3); pcom.Text = pc->asString(i+4); diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 03b63e232..d2efd56bb 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -67,7 +67,7 @@ #include "interface_v3/ctrl_button.h" #include "interface_v3/input_handler_manager.h" #include "interface_v3/group_editbox.h" -#include "interface_v3/interface_expr.h" +#include "nel/gui/interface_expr.h" #include "init_main_loop.h" #include "continent_manager.h" #include "interface_v3/group_quick_help.h" @@ -1338,7 +1338,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, ucstring &value) CInterfaceExprValue exprValue; exprValue.setUCString(value); - CInterfaceParser::splitLinkTargets(targetName, ig, targets); + CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) { if (targets[k].Elem) targets[k].affect(exprValue); @@ -1364,7 +1364,7 @@ void setTarget(CCtrlBase *ctrl, const string &targetName, uint32 value) CInterfaceExprValue exprValue; exprValue.setInteger(value); - CInterfaceParser::splitLinkTargets(targetName, ig, targets); + CInterfaceLink::splitLinkTargets(targetName, ig, targets); for(uint k = 0; k < targets.size(); ++k) { if (targets[k].Elem) targets[k].affect(exprValue); @@ -1813,7 +1813,7 @@ string getTarget(CCtrlBase * /* ctrl */, const string &targetName) { string sTmp = targetName; std::vector targetsVector; - CInterfaceParser::splitLinkTargets(sTmp, NULL, targetsVector); + CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector); CInterfaceLink::CTargetInfo &rTI = targetsVector[0]; @@ -1835,7 +1835,7 @@ ucstring getUCTarget(CCtrlBase * /* ctrl */, const string &targetName) { string sTmp = targetName; std::vector targetsVector; - CInterfaceParser::splitLinkTargets(sTmp, NULL, targetsVector); + CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector); CInterfaceLink::CTargetInfo &rTI = targetsVector[0]; diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index 323bdd3a5..07af4a28f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -21,7 +21,7 @@ #include "action_handler.h" #include "action_handler_misc.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "interface_manager.h" #include "group_container.h" @@ -298,7 +298,7 @@ public: if (ig != NULL) { - CInterfaceParser::splitLinkTargets(property, ig, targets); + CInterfaceLink::splitLinkTargets(property, ig, targets); for(uint k = 0; k < targets.size(); ++k) { if (targets[k].Elem) targets[k].affect(value); diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 1e91de65b..2d6ee545d 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -35,7 +35,7 @@ #include "bot_chat_page_ring_sessions.h" #include "dbctrl_sheet.h" #include "ctrl_sheet_selection.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "group_menu.h" #include "group_container.h" #include "group_editbox.h" @@ -3902,7 +3902,7 @@ public: uint entity; fromString(getParam(sParams, "entity"), entity); - CRGBA color = stringToRGBA(getParam(sParams, "color").c_str()); + CRGBA color = CRGBA::stringToRGBA(getParam(sParams, "color").c_str()); if (entity < 256) EntitiesMngr.entity (entity)->addHPOutput (CI18N::get (text), color); } diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index ccb220e1f..16b5c93b5 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -25,7 +25,7 @@ #include "../sheet_manager.h" #include "skill_manager.h" #include "dbctrl_sheet.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "group_container.h" #include "group_editbox.h" #include "group_quick_help.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index d15f910cf..b5fb53fea 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -25,7 +25,7 @@ #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" #include "group_editbox.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "player_trade.h" #include "../user_entity.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index fad47b05f..358b94d88 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -22,7 +22,7 @@ #include "group_editbox.h" #include "people_interraction.h" #include "nel/misc/algo.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "interface_link.h" #include "../client_chat_manager.h" #include "../motion/user_controls.h" @@ -427,7 +427,7 @@ class CActionHandlerAddLink : public IActionHandler } std::vector targetsVect; - bool result = CInterfaceParser::splitLinkTargets(targets, parentGroup, targetsVect); + bool result = CInterfaceLink::splitLinkTargets(targets, parentGroup, targetsVect); if (!result) { nlwarning(" Couldn't parse all links"); diff --git a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp index 02c34e921..34808c9bf 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -21,7 +21,7 @@ #include "action_handler.h" #include "action_handler_tools.h" #include "game_share/outpost.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "group_map.h" #include "../sheet_manager.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/bar_manager.cpp b/code/ryzom/client/src/interface_v3/bar_manager.cpp index 3de83ee0a..88ebc2b6a 100644 --- a/code/ryzom/client/src/interface_v3/bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bar_manager.cpp @@ -18,7 +18,7 @@ #include "bar_manager.h" #include "interface_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 344f8a761..1bbd86d89 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -554,7 +554,7 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC // on a new message, change the Tab color CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CRGBA newMsgColor= stringToRGBA(pIM->getDefine("chat_group_tab_color_newmsg").c_str()); + CRGBA newMsgColor= CRGBA::stringToRGBA(pIM->getDefine("chat_group_tab_color_newmsg").c_str()); ucstring newmsg = msg; ucstring prefix; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 7b6021415..ed6abde2b 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -25,7 +25,7 @@ // client #include "nel/gui/reflect.h" #include "ctrl_base.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "action_handler.h" #include "sphrase_manager.h" // game share diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 2aaac86c6..dcadb3e82 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -19,7 +19,7 @@ // ------------------------------------------------------------------------------------------------ #include "stdpch.h" #include "interface_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index a45487a8c..775a0acf2 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -20,7 +20,7 @@ #include "group_phrase_skill_filter.h" #include "interface_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 234050eef..619438f12 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -21,7 +21,7 @@ #include "group_skills.h" #include "interface_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "view_text.h" #include "view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index 18e3f9b08..436b84133 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -21,7 +21,7 @@ #include "interface_anim.h" #include "interface_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" @@ -75,7 +75,7 @@ bool CInterfaceTrack::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) } // - if (!CInterfaceParser::splitLinkTargets (ptr, parentGroup, _Targets)) + if (!CInterfaceLink::splitLinkTargets (ptr, parentGroup, _Targets)) { nlwarning ("no target for track"); return false; diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 63494ff53..bca3816af 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -761,7 +761,7 @@ void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parent // ------------------------------------------------------------------------------------------------ NLMISC::CRGBA CInterfaceElement::convertColor (const char *ptr) { - return stringToRGBA(ptr); + return NLMISC::CRGBA::stringToRGBA(ptr); } // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/interface_expr.cpp b/code/ryzom/client/src/interface_v3/interface_expr.cpp deleted file mode 100644 index 5888017ac..000000000 --- a/code/ryzom/client/src/interface_v3/interface_expr.cpp +++ /dev/null @@ -1,930 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_expr.h" -#include "interface_manager.h" -#include "interface_expr_node.h" -#include "../misc.h" -#include "nel/misc/algo.h" -#include - -using namespace std; -using namespace NLMISC; - -// Yoyo: Act like a singleton, else registerUserFct may crash. -CInterfaceExpr::TUserFctMap *CInterfaceExpr::_UserFct= NULL; - -static const std::string ExprLuaId="lua:"; - -//================================================================== -// release memory -void CInterfaceExpr::release() -{ - delete _UserFct; - _UserFct = NULL; -} - -//================================================================== -void formatLuaCall(const std::string &expr, std::string &tempStr) -{ - /* Call the LUA interface exp fct, with the script as line, and resolve string definition conflicts: - eg: replace - lua:getSkillFromName('SM') - into - lua('getSkillFromName(\"SM\")') - */ - tempStr= expr.substr(ExprLuaId.size()); // eg: tempStr= getSkillFromName('SM') - while(strFindReplace(tempStr, "'", "\\\"")); // eg: tempStr= getSkillFromName(\"SM\") - tempStr= string("lua('") + tempStr + "')"; // eg: tempStr= lua('getSkillFromName(\"SM\")') -} - -//================================================================== -bool CInterfaceExpr::eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls /* = false */) -{ - // Yoyo: Special InterfaceExpr Form to execute lua code? - if(expr.compare(0, ExprLuaId.size(), ExprLuaId) ==0 ) - { - std::string tempStr; - formatLuaCall(expr, tempStr); - return evalExpr(tempStr.c_str(), result, nodes, noFctCalls) != NULL; - } - else - { - return evalExpr(expr.c_str(), result, nodes, noFctCalls) != NULL; - } -} - -//================================================================== -CInterfaceExprNode *CInterfaceExpr::buildExprTree(const std::string &expr) -{ - CInterfaceExprNode *node; - - // Yoyo: Special InterfaceExpr Form to execute lua code? - if(expr.compare(0, ExprLuaId.size(), ExprLuaId) ==0 ) - { - std::string tempStr; - formatLuaCall(expr, tempStr); - if (!buildExprTree(tempStr.c_str(), node)) return false; - } - else - { - if (!buildExprTree(expr.c_str(), node)) return false; - } - - return node; -} - - -//================================================================== -void CInterfaceExpr::registerUserFct(const char *name,TUserFct fct) -{ - if(!_UserFct) _UserFct= new TUserFctMap; - - nlassert(fct != NULL); - (*_UserFct)[std::string(name)] = fct; -} - -//================================================================== -/** tool fct : skip space, tab and carret-returns - */ -static const char *skipBlank(const char *start) -{ - nlassert(start); - while (*start == ' ' || *start == '\t' || *start == '\r' || *start == '\n') ++start; - return start; -} - -//================================================================== -const char *CInterfaceExpr::evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls) -{ - nlassert(expr != NULL); - expr = skipBlank(expr); - if (isalpha(*expr)) // alpha character means this is a function name - { - return evalFct(expr, result, nodes, noFctCalls); - } - else if (*expr == '@') // is it a database entry ? - { - ++ expr; - expr = skipBlank(expr); - return evalDBEntry(expr, result, nodes); - } - - // try to parse a literal value - const char *newExpr = result.initFromString(expr); - if (!newExpr) - { - nlwarning(" : syntax error : %s", expr); - return NULL; - } - return newExpr; -} - -//================================================================== -const char *CInterfaceExpr::buildExprTree(const char *expr, CInterfaceExprNode *&result) -{ - nlassert(expr != NULL); - expr = skipBlank(expr); - if (isalpha(*expr)) // alpha character means this is a function name - { - return buildFctNode(expr, result); - } - else if (*expr == '@') // is it a database entry ? - { - ++ expr; - expr = skipBlank(expr); - return buildDBEntryNode(expr, result); - } - else - { - CInterfaceExprValue value; - // try to parse a literal value - const char *newExpr = value.initFromString(expr); - if (!newExpr) - { - nlwarning(" : syntax error : %s", expr); - return NULL; - } - CInterfaceExprNodeValue *node = new CInterfaceExprNodeValue; - node->Value = value; - result = node; - return newExpr; - } - return NULL; -} - - -//================================================================== -const char *CInterfaceExpr::evalFct(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls) -{ - if(!_UserFct) _UserFct= new TUserFctMap; - - const char *start = expr; - while (isalnum(*expr)) ++ expr; - std::string fctName(start, expr - start); - // find entry in the map - TUserFctMap::iterator fctIt = _UserFct->find(fctName); - if (fctIt == _UserFct->end()) - { - nlwarning(" : Unknown function %s", fctName.c_str()); - return NULL; - } - nlassert(fctIt->second != NULL); - // eval list of arguments - TArgList argList; - expr = skipBlank(expr); - if (*expr != '(') - { - nlwarning(" : '(' expected for function %s", fctName.c_str()); - return NULL; - } - ++ expr; - expr = skipBlank(expr); - if (*expr != ')') - { - for(;;) - { - expr = skipBlank(expr); - // parse an argument - argList.push_back(CInterfaceExprValue()); - expr = evalExpr(expr, argList.back(), nodes, noFctCalls); - if (expr == NULL) return NULL; - expr = skipBlank(expr); - if (*expr == ')') break; - // if it isn't the end of the expression, then we should find a ',' before next argument - if (*expr != ',') - { - nlwarning(" : ',' expected in function %s", fctName.c_str()); - return NULL; - } - ++ expr; - } - } - ++ expr; - // call the fct - if (!noFctCalls) // should we make terminal function calls ? - { - if (fctIt->second(argList, result)) return expr; - } - else - { - return expr; - } - return NULL; -} - -//================================================================== -const char *CInterfaceExpr::buildFctNode(const char *expr, CInterfaceExprNode *&result) -{ - if(!_UserFct) _UserFct= new TUserFctMap; - - const char *start = expr; - while (isalnum(*expr)) ++ expr; - std::string fctName(start, expr - start); - // find entry in the map - TUserFctMap::iterator fctIt = _UserFct->find(fctName); - if (fctIt == _UserFct->end()) - { - nlwarning(" : Unknown function %s", fctName.c_str()); - return NULL; - } - nlassert(fctIt->second != NULL); - // List of parameters - expr = skipBlank(expr); - if (*expr != '(') - { - nlwarning(" : '(' expected for function %s", fctName.c_str()); - return NULL; - } - ++ expr; - expr = skipBlank(expr); - std::vector Params; - if (*expr != ')') - { - for(;;) - { - expr = skipBlank(expr); - // parse an argument - CInterfaceExprNode *node = NULL; - expr = buildExprTree(expr, node); - if (expr == NULL) - { - for(uint k = 0; k < Params.size(); ++k) - { - delete Params[k]; - } - return NULL; - } - Params.push_back(node); - expr = skipBlank(expr); - if (*expr == ')') break; - // if it isn't the end of the expression, then we should find a ',' before next argument - if (*expr != ',') - { - for(uint k = 0; k < Params.size(); ++k) - { - delete Params[k]; - } - nlwarning("CInterfaceExpr::evalFct : ',' expected in function %s", fctName.c_str()); - return NULL; - } - ++ expr; - } - } - ++ expr; - CInterfaceExprNodeValueFnCall *node = new CInterfaceExprNodeValueFnCall; - node->Params.swap(Params); - node->Func = fctIt->second; - result = node; - return expr; -} - -//================================================================== -const char *CInterfaceExpr::evalDBEntry(const char *expr, CInterfaceExprValue &result, std::vector *nodes) -{ - std::string dbEntry; - expr = unpackDBentry(expr, nodes, dbEntry); - if (!expr) return NULL; - // TestYoyo - //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); - // get the db value - CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); - if (nl) - { - if (nodes) - { - // insert node if not already present - if (std::find(nodes->begin(), nodes->end(), nl) == nodes->end()) - { - nodes->push_back(nl); - } - } - result.setInteger(nl->getValue64()); - return expr; - } - else - { - CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); - if (nodes && nb) - { - if (std::find(nodes->begin(), nodes->end(), nb) == nodes->end()) - { - nodes->push_back(nb); - } - } - if (!nb) return NULL; - result.setInteger(0); - return expr; - } - return NULL; -} - -//================================================================== -const char *CInterfaceExpr::buildDBEntryNode(const char *expr, CInterfaceExprNode *&result) -{ - std::string dbEntry; - bool indirection; - const char *startChar = expr; - expr = unpackDBentry(expr, NULL, dbEntry, &indirection); - if (!expr) return NULL; - if (indirection) - { - // special node with no optimisation - CInterfaceExprNodeDependantDBRead *node = new CInterfaceExprNodeDependantDBRead; - node->Expr.resize(expr - startChar + 1); - std::copy(startChar, expr, node->Expr.begin() + 1); - node->Expr[0] = '@'; - result = node; - return expr; - } - else - { - // TestYoyo - //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(dbEntry, false) || CInterfaceManager::getInstance()->getDbBranch(dbEntry)); - CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(dbEntry); - if (nl) - { - CInterfaceExprNodeDBLeaf *node = new CInterfaceExprNodeDBLeaf; - node->Leaf = nl; - result = node; - return expr; - } - else - { - CCDBNodeBranch *nb = NLGUI::CDBManager::getInstance()->getDbBranch(dbEntry); - if (nb) - { - CInterfaceExprNodeDBBranch *node = new CInterfaceExprNodeDBBranch; - node->Branch = nb; - result = node; - return expr; - } - } - return NULL; - } -} - -//================================================================== -const char *CInterfaceExpr::unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections /* = NULL*/) -{ - std::string entryName; - bool indirection = false; - for (;;) - { - if (*expr == '[') - { - indirection = true; - ++ expr; - std::string subEntry; - expr = unpackDBentry(expr, nodes, subEntry); - if (!expr) return NULL; - // Read DB Index Offset. - sint32 indirectionOffset= 0; - if (*expr == '-' || *expr =='+' ) - { - bool negative= *expr == '-'; - std::string offsetString; - ++ expr; - while(*expr!=0 && isdigit(*expr)) - { - offsetString.push_back(*expr); - ++ expr; - } - // get offset - fromString(offsetString, indirectionOffset); - if(negative) - indirectionOffset= -indirectionOffset; - } - // Test end of indirection - if (*expr != ']') - { - nlwarning("CInterfaceExpr::unpackDBentry: ']' expected"); - return NULL; - } - ++ expr; - // get the db value at sub entry - // TestYoyo - //nlassert(NLGUI::CDBManager::getInstance()->getDbProp(subEntry, false) || CInterfaceManager::getInstance()->getDbBranch(subEntry)); - CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(subEntry); - if (nodes) - { - if (std::find(nodes->begin(), nodes->end(), nl) == nodes->end()) - { - nodes->push_back(nl); - } - } - // compute indirection, (clamp). - sint32 indirectionValue= nl->getValue32() + indirectionOffset; - indirectionValue= std::max((sint32)0, indirectionValue); - - // Append to entry name. - entryName += NLMISC::toString(indirectionValue); - } - else if (isalnum(*expr) || *expr == '_' || *expr == ':') - { - entryName += *expr; - ++ expr; - } - else - { - break; - } - } - if (hasIndirections) - { - *hasIndirections = indirection; - } - dest = entryName; - return expr; -} - - -//================================================================== -bool CInterfaceExpr::evalAsInt(const std::string &expr, sint64 &dest) -{ - CInterfaceExprValue result; - if (!eval(expr, result)) return false; - if (!result.toInteger()) - { - nlwarning(" Can't convert value to an integer, expr = %s", expr.c_str()); - return false; - } - dest = result.getInteger(); - return true; -} - -//================================================================== -bool CInterfaceExpr::evalAsDouble(const std::string &expr, double &dest) -{ - CInterfaceExprValue result; - if (!eval(expr, result)) return false; - if (!result.toDouble()) - { - nlwarning(" Can't convert value to a double, expr = %s", expr.c_str()); - return false; - } - dest = result.getDouble(); - return true; -} - -//================================================================== -bool CInterfaceExpr::evalAsBool(const std::string &expr, bool &dest) -{ - CInterfaceExprValue result; - if (!eval(expr, result)) return false; - if (!result.toBool()) - { - nlwarning(" Can't convert value to a boolean, expr = %s", expr.c_str()); - return false; - } - dest = result.getBool(); - return true; -} - -//================================================================== -bool CInterfaceExpr::evalAsString(const std::string &expr, std::string &dest) -{ - CInterfaceExprValue result; - if (!eval(expr, result)) return false; - if (!result.toString()) - { - nlwarning(" Can't convert value to a string, expr = %s", expr.c_str()); - return false; - } - dest = result.getString(); - return true; -} - -//================================================================== -//================================================================== -//================================================================== -//================================================================== - - -//================================================================== -bool CInterfaceExprValue::toBool() -{ - switch(_Type) - { - case Boolean: return true; - case Integer: setBool(_IntegerValue != 0); return true; - case Double: setBool(_DoubleValue != 0); return true; - case String: return evalBoolean(_StringValue.toString().c_str()) != NULL; - default: break; - } - return false; - -} - -//================================================================== -bool CInterfaceExprValue::toInteger() -{ - switch(_Type) - { - case Boolean: setInteger(_BoolValue ? 1 : 0); return true; - case Integer: return true; - case Double: setInteger((sint64) _DoubleValue); return true; - case String: - if (evalNumber(_StringValue.toString().c_str())) return toInteger(); - return false; - case RGBA: setInteger((sint64) _RGBAValue); return true; - default: break; - } - return false; -} - -//================================================================== -bool CInterfaceExprValue::toDouble() -{ - switch(_Type) - { - case Boolean: setDouble(_BoolValue ? 1 : 0); return true; - case Integer: setDouble((double) _IntegerValue); return true; - case Double: return true; - case String: - if (evalNumber(_StringValue.toString().c_str())) return toBool(); - return false; - case RGBA: setDouble((double) _RGBAValue); return true; - default: break; - } - return false; -} - -//================================================================== -bool CInterfaceExprValue::toString() -{ - switch(_Type) - { - case Boolean: setString(_BoolValue ? "true" : "false"); return true; - case Integer: setString(NLMISC::toString(_IntegerValue)); return true; - case Double: setString(NLMISC::toString("%.2f", _DoubleValue)); return true; - case String: return true; - case RGBA: - { - uint r,g,b,a; - r= (_RGBAValue&0xff); - g= ((_RGBAValue>>8)&0xff); - b= ((_RGBAValue>>16)&0xff); - a= ((_RGBAValue>>24)&0xff); - setString(NLMISC::toString("%d %d %d %d", r, g, b, a)); - return true; - } - default: break; - } - return false; -} - -//================================================================== -bool CInterfaceExprValue::toRGBA() -{ - switch(_Type) - { - case RGBA: return true; - case Integer: setRGBA(NLMISC::CRGBA((uint8)(_IntegerValue&0xff), (uint8)((_IntegerValue>>8)&0xff), - (uint8)((_IntegerValue>>16)&0xff), (uint8)((_IntegerValue>>24)&0xff))); return true; - case String: - setRGBA(stringToRGBA(_StringValue.toString().c_str())); return true; - default: break; - } - return false; -} - -//================================================================== -bool CInterfaceExprValue::isNumerical() const -{ - return _Type == Boolean || _Type == Integer || _Type == Double; -} - -//================================================================== -const char *CInterfaceExprValue::initFromString(const char *expr) -{ - nlassert(expr); - expr = skipBlank(expr); - if (isdigit(*expr) || *expr == '.' || *expr == '-') return evalNumber(expr); - switch(*expr) - { - case 't': - case 'T': - case 'f': - case 'F': - return evalBoolean(expr); - case '\'': - return evalString(expr); - default: - return NULL; - } -} - -//================================================================== -const char *CInterfaceExprValue::evalBoolean(const char *expr) -{ - nlassert(expr); - expr = skipBlank(expr); - if (toupper(expr[0]) == 'T' && - toupper(expr[1]) == 'R' && - toupper(expr[2]) == 'U' && - toupper(expr[3]) == 'E') - { - setBool(true); - return expr + 4; - } - // - if (toupper(expr[0]) == 'F' && - toupper(expr[1]) == 'A' && - toupper(expr[2]) == 'L' && - toupper(expr[3]) == 'S' && - toupper(expr[4]) == 'E') - { - setBool(false); - return expr + 5; - } - return NULL; -} - -//================================================================== -const char *CInterfaceExprValue::evalNumber(const char *expr) -{ - bool negative; - bool hasPoint = false; - - expr = skipBlank(expr); - - if (*expr == '-') - { - negative = true; - ++ expr; - expr = skipBlank(expr); - } - else - { - negative = false; - } - - const char *start = expr; - while (*expr == '.' || isdigit(*expr)) - { - if (*expr == '.') hasPoint = true; - ++ expr; - } - if (start == expr) return NULL; - if (!hasPoint) - { - sint64 value = 0; - // this is an integer - for (const char *nbPtr = start; nbPtr < expr; ++ nbPtr) - { - value *= 10; - value += (sint64) (*nbPtr - '0'); - } - setInteger(negative ? - value : value); - return expr; - } - else // floating point value : use scanf - { - // well, for now, we only parse a float - float value; - std::string floatValue(start, expr - start); - if (fromString(floatValue, value)) - { - setDouble(negative ? - value : value); - return expr; - } - else - { - return NULL; - } - } -} - -//================================================================== -const char *CInterfaceExprValue::evalString(const char *expr) -{ - expr = skipBlank(expr); - if (*expr != '\'') return NULL; - ++expr; - std::string str; - for (;;) - { - if (expr == '\0') - { - nlwarning("CInterfaceExprValue::evalString : end of buffer encountered in a string"); - return NULL; - } - else - if (*expr == '\'') - { - ++ expr; - break; - } - if (*expr == '\\') // special char - { - ++ expr; - switch (*expr) - { - case 't': str += '\t'; break; - case 'r': str += '\r'; break; - case 'n': str += '\n'; break; - case '\'': str += '\''; break; - case '"': str += '"'; break; - case '\\': str += '\\'; break; - case '\n': - case '\r': - // string continue on next line, so do nothing - break; - case '\0': continue; - default: - nlwarning("CInterfaceExprValue::evalString : unknown escape sequence : \\%c", *expr); - if (*expr) str += *expr; - break; - } - } - else if (*expr == '\n' || *expr == '\r') - { - nlwarning("CInterfaceExprValue::evalString : line break encountered in a string"); - return NULL; - } - else - { - str += *expr; - } - ++ expr; - } - setString(str); - return expr; -} - -//================================================================== -bool CInterfaceExprValue::toType(TType type) -{ - switch(type) - { - case Boolean: return toBool(); - case Integer: return toInteger(); - case Double: return toDouble(); - case String: return toString(); - case RGBA: return toRGBA(); - default: return false; - } -} - - -//================================================================== -void CInterfaceExprValue::clean() -{ - switch (_Type) - { - case String: _StringValue.clear(); break; - case UserType: delete _UserTypeValue; break; - default: break; - } -} - -//================================================================== -void CInterfaceExprValue::setUserType(CInterfaceExprUserType *value) -{ - if (_Type == UserType && value == _UserTypeValue) return; - clean(); - _Type = UserType; - _UserTypeValue = value; -} - -//================================================================== -bool CInterfaceExprValue::getBool() const -{ - if (_Type != Boolean) - { - nlwarning(" bad type!"); - return false; - } - return _BoolValue; -} - -//================================================================== -sint64 CInterfaceExprValue::getInteger() const -{ - if (_Type != Integer) - { - nlwarning(" bad type!"); - return 0; - } - return _IntegerValue; -} - -//================================================================== -double CInterfaceExprValue::getDouble() const -{ - if (_Type != Double) - { - nlwarning(" bad type!"); - return 0; - } - return _DoubleValue; -} - -//================================================================== -std::string CInterfaceExprValue::getString() const -{ - if (_Type != String) - { - nlwarning(" bad type!"); - return ""; - } - return _StringValue.toString(); -} - -//================================================================== -NLMISC::CRGBA CInterfaceExprValue::getRGBA() const -{ - if (_Type != RGBA) - { - nlwarning(" bad type!"); - return CRGBA::White; - } - NLMISC::CRGBA col; - col.R = (uint8)(_RGBAValue&0xff); - col.G = (uint8)((_RGBAValue>>8)&0xff); - col.B = (uint8)((_RGBAValue>>16)&0xff); - col.A = (uint8)((_RGBAValue>>24)&0xff); - return col; -} - - -//================================================================== -const ucstring &CInterfaceExprValue::getUCString() const -{ - if (_Type != String) - { - nlwarning(" bad type!"); - static ucstring emptyString; - return emptyString; - } - return _StringValue; -} - -//================================================================== -CInterfaceExprUserType *CInterfaceExprValue::getUserType() const -{ - if (_Type != UserType) - { - nlwarning(" bad type!"); - return NULL; - } - return _UserTypeValue; -} - -//================================================================== -CInterfaceExprValue::CInterfaceExprValue(const CInterfaceExprValue &other) : _Type(NoType) -{ - *this = other; -} - -//================================================================== -CInterfaceExprValue &CInterfaceExprValue::operator = (const CInterfaceExprValue &other) -{ - if (this != &other) - { - clean(); - switch(other._Type) - { - case Boolean: _BoolValue = other._BoolValue; break; - case Integer: _IntegerValue = other._IntegerValue; break; - case Double: _DoubleValue = other._DoubleValue; break; - case String: _StringValue = other._StringValue; break; - case RGBA: _RGBAValue = other._RGBAValue; break; - case UserType: - if (other._UserTypeValue != NULL) - { - _UserTypeValue = other._UserTypeValue->clone(); - } - else - { - _UserTypeValue = NULL; - } - break; - case NoType: break; - default: - nlwarning(" bad source type") ; - return *this; - break; - } - _Type = other._Type; - } - return *this; -} - - - diff --git a/code/ryzom/client/src/interface_v3/interface_expr.h b/code/ryzom/client/src/interface_v3/interface_expr.h deleted file mode 100644 index 33c6b70af..000000000 --- a/code/ryzom/client/src/interface_v3/interface_expr.h +++ /dev/null @@ -1,242 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_INTERFACE_EXPR_H -#define CL_INTERFACE_EXPR_H - - -#include "nel/misc/ucstring.h" -#include "nel/misc/rgba.h" - -namespace NLMISC{ -class ICDBNode; -class CCDBNodeLeaf; -class CCDBNodeBranch; -} - - -struct CInterfaceExprUserType; -class CInterfaceExprNode; - -/** a value that can be returned by a CInterfaceExpr instance - * It supports basic type; - * It can be extended by user defined types - */ -class CInterfaceExprValue -{ -public: - enum TType { Boolean = 0, Integer, Double, String, RGBA, UserType, NoType }; -public: - // default ctor - CInterfaceExprValue() : _Type(NoType) {} - // copy ctor - CInterfaceExprValue(const CInterfaceExprValue &other); - // assignment operator - CInterfaceExprValue &operator = (const CInterfaceExprValue &other); - // dtor - ~CInterfaceExprValue() { clean(); } - - TType getType() const { return _Type; } - // get. Should be used only if the type is valid - bool getBool() const; - sint64 getInteger() const; - double getDouble() const; - std::string getString() const; - NLMISC::CRGBA getRGBA() const; - const ucstring &getUCString() const; - CInterfaceExprUserType *getUserType() const; - // set - void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; } - void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; } - void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; } - void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; } - void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; } - void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); } - void setUserType(CInterfaceExprUserType *value); - // reset this object to initial state (no type) - void clean(); - // conversions. They return true if success - bool toBool(); - bool toInteger(); - bool toDouble(); - bool toString(); - bool toType(TType type); - bool toRGBA(); - // test if the value if a bool, double, or integer - bool isNumerical() const; - /** evaluate a from a string - * \param expr : where to start the evaluation - * \return the position following the token, or NULL if the parsing failed - */ - const char *initFromString(const char *expr); - -///////////////////////////////////////////////////////////////////////////////////////////// -private: - TType _Type; - union - { - bool _BoolValue; - sint64 _IntegerValue; - double _DoubleValue; - CInterfaceExprUserType *_UserTypeValue; - uint32 _RGBAValue; - }; - ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack.. -private: - const char *evalBoolean(const char *expr); - const char *evalNumber(const char *expr); - const char *evalString(const char *expr); -}; - -/** - * Base class for user defined types that are use by the 'CInterfaceExprValue' class - * Derivers should include the 'clone' method - * - * CInterfaceExprValue instances have ownership of this object. - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2003 - */ -struct CInterfaceExprUserType -{ - // cloning method - virtual CInterfaceExprUserType *clone() const = 0; - // dtor - virtual ~CInterfaceExprUserType() {} -}; - - -/** Evaluate expressions used in interface. - * It can retrieve values from the database. - * It can also build a list of database values it depends of. - * - * An expression can be : - * - * - a string : 'toto', 'abcd', 'a\nbcd', 'a\\t', the escape sequences are the one of C - * - a integer 1, 2, 3 - * - a double 1.1, 2.2 - * - a database entry : @ui:interface:toto:truc. If the address is a leaf, it returns the leaf value and put an observer on it. If not a leaf, it returns 0, but put an observer on it. - * - a database indirection @db:value[db:index] is replaced by @db:value0 if db:index == 0 for example - * - a user function call : fct(expr0, epxr1, ...). - * - * NB : The lua language has been integrated since then (2005), and should be more suited - * for most of the tasks. - * - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CInterfaceExpr -{ -public: - // list of argument for a function - typedef std::vector TArgList; - /** prototype of a user callable function - * It should return true if the result is meaningful. If not, the rest of the evaluation is stopped - */ - typedef bool (* TUserFct) (TArgList &args, CInterfaceExprValue &result); -public: - - // release memory - static void release(); - - /** This try to eval the provided expression. - * - This returns a result - * - This eventually fill a vector with a set of database entries it has dependencies on - * \param expr The expression to evaluate - * \param result The result value - * \param nodes If not NULL, will be filled with the database nodes this expression depends on - * Node will only be inserted once, so we end up with a set of node (not ordered) - * \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on. - */ - static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes = NULL, bool noFctCalls = false); - - /** Build a tree from the given expression so that it can be evaluated quickly. - * This is useful for a fixed expression that must be evaluated often - */ - static CInterfaceExprNode *buildExprTree(const std::string &expr); - - - /** Register a function that can have several arguments - * // NB : this is case sensitive - */ - static void registerUserFct(const char *name, TUserFct fct); - // Simple evaluations - static bool evalAsInt(const std::string &expr, sint64 &dest); - static bool evalAsDouble(const std::string &expr, double &dest); - static bool evalAsBool(const std::string &expr, bool &dest); - static bool evalAsString(const std::string &expr, std::string &dest); -///////////////////////////////////////////////////////////////////////////////////////////// -private: - // map of user functions - typedef std::map TUserFctMap; -private: - static TUserFctMap *_UserFct; -private: - /** eval the value of a single expression - * \return position to the next valid character - */ - static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls); - static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector *nodes, bool noFctCalls); - static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector *nodes); -public: - static const char *unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections = NULL); - - /** Build tree of a single expression - * \return position to the next valid character - */ -private: - static const char *buildExprTree(const char *expr, CInterfaceExprNode *&result); - static const char *buildFctNode(const char *expr, CInterfaceExprNode *&result); - static const char *buildDBEntryNode(const char *expr,CInterfaceExprNode *&result); -}; - - -// helper macro to register user functions at startup -#define REGISTER_INTERFACE_USER_FCT(name, fct) \ -const struct __InterUserFctRegister__##fct\ -{\ - __InterUserFctRegister__##fct() { CInterfaceExpr::registerUserFct(name, fct); }\ -} __InterUserFctRegisterInstance__##fct; - - -// helper macro to declare a user function -// the code must follow -// arguments are available in 'args', result should be put in 'result' -#define DECLARE_INTERFACE_USER_FCT(name) \ -bool name(CInterfaceExpr::TArgList &args, CInterfaceExprValue &result) - - -// helper macro to declare a C constant mirroring -#define DECLARE_INTERFACE_CONSTANT(_name, _cconst) \ -static DECLARE_INTERFACE_USER_FCT(_name) \ -{ \ - result.setInteger(_cconst); \ - return true; \ -} \ -REGISTER_INTERFACE_USER_FCT(#_name, _name) - - - -#endif - diff --git a/code/ryzom/client/src/interface_v3/interface_expr_node.cpp b/code/ryzom/client/src/interface_v3/interface_expr_node.cpp deleted file mode 100644 index 0d999f407..000000000 --- a/code/ryzom/client/src/interface_v3/interface_expr_node.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_expr_node.h" -#include "nel/misc/cdb_leaf.h" -#include "nel/misc/cdb_branch.h" - -using NLMISC::ICDBNode; -using NLMISC::CCDBNodeBranch; -using NLMISC::CCDBNodeLeaf; - -// ******************************************************************************************************* -void CInterfaceExprNodeValue::eval(CInterfaceExprValue &result) -{ - result = Value; -} - -void CInterfaceExprNodeValue::evalWithDepends(CInterfaceExprValue &result, std::vector &/* nodes */) -{ - result = Value; -} - -void CInterfaceExprNodeValue::getDepends(std::vector &/* nodes */) -{ -} - - -// ******************************************************************************************************* -void CInterfaceExprNodeValueFnCall::eval(CInterfaceExprValue &result) -{ - nlassert(Func); - uint numParams = (uint)Params.size(); - std::vector params(numParams); - for(uint k = 0; k < numParams; ++k) - { - Params[k]->eval(params[k]); - } - Func(params, result); // do actual call -} - -void CInterfaceExprNodeValueFnCall::evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) -{ - nlassert(Func); - uint numParams = (uint)Params.size(); - std::vector params(numParams); - for(uint k = 0; k < numParams; ++k) - { - Params[k]->evalWithDepends(params[k], nodes); - } - Func(params, result); // do actual call -} - -void CInterfaceExprNodeValueFnCall::getDepends(std::vector &nodes) -{ - uint numParams = (uint)Params.size(); - for(uint k = 0; k < numParams; ++k) - { - Params[k]->getDepends(nodes); - } -} - - -CInterfaceExprNodeValueFnCall::~CInterfaceExprNodeValueFnCall() -{ - for(uint k = 0; k < Params.size(); ++k) - { - delete Params[k]; - } -} - -// ******************************************************************************************************* -void CInterfaceExprNodeDBLeaf::eval(CInterfaceExprValue &result) -{ - nlassert(Leaf); - result.setInteger(Leaf->getValue64()); -} - -void CInterfaceExprNodeDBLeaf::evalWithDepends(CInterfaceExprValue &result,std::vector &nodes) -{ - nlassert(Leaf); - result.setInteger(Leaf->getValue64()); - if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end()) - { - nodes.push_back(Leaf); - } -} - -void CInterfaceExprNodeDBLeaf::getDepends(std::vector &nodes) -{ - nlassert(Leaf); - if (std::find(nodes.begin(), nodes.end(), Leaf) == nodes.end()) - { - nodes.push_back(Leaf); - } -} - - -// ******************************************************************************************************* -void CInterfaceExprNodeDBBranch::eval(CInterfaceExprValue &result) -{ - nlassert(Branch); - result.setInteger(0); -} - -void CInterfaceExprNodeDBBranch::evalWithDepends(CInterfaceExprValue &result,std::vector &nodes) -{ - nlassert(Branch); - result.setInteger(0); - if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end()) - { - nodes.push_back(Branch); - } -} - -void CInterfaceExprNodeDBBranch::getDepends(std::vector &nodes) -{ - nlassert(Branch); - if (std::find(nodes.begin(), nodes.end(), Branch) == nodes.end()) - { - nodes.push_back(Branch); - } -} - - -// ******************************************************************************************************* -void CInterfaceExprNodeDependantDBRead::eval(CInterfaceExprValue &result) -{ - // no gain there, but barely used - CInterfaceExpr::eval(Expr, result); -} - -void CInterfaceExprNodeDependantDBRead::evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) -{ - CInterfaceExpr::eval(Expr, result, &nodes); -} - -void CInterfaceExprNodeDependantDBRead::getDepends(std::vector &nodes) -{ - CInterfaceExprValue dummyResult; - CInterfaceExpr::eval(Expr, dummyResult, &nodes, true); -} - - diff --git a/code/ryzom/client/src/interface_v3/interface_expr_node.h b/code/ryzom/client/src/interface_v3/interface_expr_node.h deleted file mode 100644 index 6dc30f8b8..000000000 --- a/code/ryzom/client/src/interface_v3/interface_expr_node.h +++ /dev/null @@ -1,123 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_INTERFACE_EXPR_NODE_H -#define CL_INTERFACE_EXPR_NODE_H - -#include "interface_expr.h" - -/** Base node of an interface expression parse tree - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2003 - */ -class CInterfaceExprNode -{ -public: - virtual ~CInterfaceExprNode() {} - // eval result of expression, and eventually get the nodes the epression depends on - virtual void eval(CInterfaceExprValue &result) = 0; - // The same, but get db nodes the expression depends on (appended to vector) - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) = 0; - // Get dependencies of the node (appended to vector) - virtual void getDepends(std::vector &nodes) = 0; -}; - - -// ******************************************************************************************************* -/** A constant value already parsed by interface (in a interface expr parse tree) - */ -class CInterfaceExprNodeValue : public CInterfaceExprNode -{ -public: - CInterfaceExprValue Value; -public: - virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); -}; - -// ******************************************************************************************************* -/** A fct call (in a interface expr parse tree) - */ -class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode -{ -public: - CInterfaceExpr::TUserFct Func; - // list of parameters - std::vector Params; -public: - virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); - virtual ~CInterfaceExprNodeValueFnCall(); -}; - -// ******************************************************************************************************* -/** A db leaf read (in a interface expr parse tree) - */ -class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode -{ -public: - class NLMISC::CCDBNodeLeaf *Leaf; -public: - virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); -}; - -// ******************************************************************************************************* -/** A db branch read (in a interface expr parse tree) - */ -class CInterfaceExprNodeDBBranch : public CInterfaceExprNode -{ -public: - class NLMISC::CCDBNodeBranch *Branch; -public: - virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); -}; - -// ******************************************************************************************************* -/** A dependant db read (in a interface expr parse tree) - * This is rarely used so no real optim there.. - */ -class CInterfaceExprNodeDependantDBRead : public CInterfaceExprNode -{ -public: - std::string Expr; -public: - virtual void eval(CInterfaceExprValue &result); - virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes); - virtual void getDepends(std::vector &nodes); -}; - - - - - - - - - - - - - -#endif diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp index dd67699f9..3c16cdd75 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp @@ -20,7 +20,7 @@ #include "stdpch.h" // client -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "ctrl_sheet_selection.h" #include "interface_manager.h" // game_share @@ -519,7 +519,7 @@ static DECLARE_INTERFACE_USER_FCT(userFctGetProp) string sTmp = args[0].getString(); std::vector targetsVector; - CInterfaceParser::splitLinkTargets(sTmp, NULL, targetsVector); + CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector); if (targetsVector.empty()) { diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index e71d37bdc..949e0875d 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" // Interface -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "interface_manager.h" #include "interface_element.h" #include "chat_window.h" diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 0de076f35..aa1f880e8 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -20,7 +20,7 @@ // client #include "../sheet_manager.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "dbctrl_sheet.h" #include "ctrl_sheet_selection.h" #include "dbgroup_list_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index c59b5b01f..8b783d03b 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -19,10 +19,10 @@ #include "stdpch.h" #include "interface_link.h" -#include "interface_expr.h" #include "interface_element.h" #include "interface_manager.h" -#include "interface_expr_node.h" +#include "nel/gui/interface_expr.h" +#include "nel/gui/interface_expr_node.h" #include "nel/gui/reflect.h" #include "nel/gui/db_manager.h" #include "nel/misc/cdb_branch.h" @@ -444,6 +444,88 @@ void CInterfaceLink::removeAllLinks() nlassert(_LinkList.empty()); } +// *************************************************************************** +bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm) +{ + // the last token of the target gives the name of the property + std::string::size_type lastPos = target.find_last_of(':'); + if (lastPos == (target.length() - 1)) + { + // todo hulud interface syntax error + nlwarning("The target should at least contains a path and a property as follow 'path:property'"); + return false; + } + std::string elmPath; + std::string elmProp; + CInterfaceElement *elm = NULL; + if (parentGroup) + { + if (lastPos == std::string::npos) + { + elmProp = target; + elm = parentGroup; + elmPath = "current"; + } + else + { + elmProp = target.substr(lastPos + 1); + elmPath = parentGroup->getId() + ":" + target.substr(0, lastPos); + elm = parentGroup->getElement(elmPath); + } + } + if (!elm) + { + // try the absolute adress of the element + elmPath = target.substr(0, lastPos); + elm = CInterfaceManager::getInstance()->getElementFromId(elmPath); + elmProp = target.substr(lastPos + 1); + } + + if (!elm) + { + // todo hulud interface syntax error + nlwarning(" can't find target link %s", elmPath.c_str()); + return false; + } + targetElm = elm; + propertyName = elmProp; + return true; +} + + +// *************************************************************************** +bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect) +{ + std::vector targetNames; + NLMISC::splitString(targets, ",", targetNames); + targetsVect.clear(); + targetsVect.reserve(targetNames.size()); + bool everythingOk = true; + for (uint k = 0; k < targetNames.size(); ++k) + { + CInterfaceLink::CTargetInfo ti; + std::string::size_type startPos = targetNames[k].find_first_not_of(" "); + if(startPos == std::string::npos) + { + // todo hulud interface syntax error + nlwarning(" empty target encountered"); + continue; + } + std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + + if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) + { + // todo hulud interface syntax error + nlwarning(" Can't get link target"); + everythingOk = false; + continue; + } + targetsVect.push_back(ti); + } + return everythingOk; +} + + //=========================================================== void CInterfaceLink::checkNbRefs() { @@ -470,7 +552,7 @@ void CInterfaceLink::setTargetProperty (const std::string &Target, const CInt if (pIG != NULL) { std::vector vTargets; - CInterfaceParser::splitLinkTargets(Target, pIG, vTargets); + splitLinkTargets(Target, pIG, vTargets); if ((vTargets.size() > 0) && (vTargets[0].Elem)) { vTargets[0].affect(val); diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/ryzom/client/src/interface_v3/interface_link.h index ae88849dd..33561ff0f 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.h +++ b/code/ryzom/client/src/interface_v3/interface_link.h @@ -25,13 +25,14 @@ namespace NLGUI { class CReflectedProperty; + class CInterfaceExprValue; + class CInterfaceExprNode; } class CInterfaceElement; -class CInterfaceExprValue; class CInterfaceGroup; -class CInterfaceExprNode; + using namespace NLGUI; @@ -115,6 +116,16 @@ public: static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val); static bool isUpdatingAllLinks() { return _UpdateAllLinks; } + + /** From a target name of a link, retrieve the target element and its target target property + * \return true if the target is valid + */ + static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm); + + /** From several target names of a link (seprated by ','), retrieve the target elements and their target properties + * \return true if all targets are valid + */ + static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); //////////////////////////////////////////////////////////////////////////////////////////////////////// private: friend struct CRemoveTargetPred; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 89fccdb3e..e2a0f5e10 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -35,7 +35,7 @@ #include "../client_cfg.h" #include "encyclopedia_manager.h" // Expr -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "register_interface_elements.h" // Action / Observers #include "action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index f2534eaab..56e5c961f 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -1403,7 +1403,7 @@ bool CInterfaceParser::parseLink(xmlNodePtr cur, CInterfaceGroup * parentGroup) ptr = (char*) xmlGetProp (cur, (xmlChar*)"target"); if (ptr) { - splitLinkTargets(std::string((const char*)ptr), parentGroup, targets); + CInterfaceLink::splitLinkTargets(std::string((const char*)ptr), parentGroup, targets); } // optional action handler std::string action; @@ -2925,88 +2925,6 @@ bool CInterfaceParser::parseSheetSelection(xmlNodePtr cur) return true; } -// *************************************************************************** -bool CInterfaceParser::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm) -{ - // the last token of the target gives the name of the property - std::string::size_type lastPos = target.find_last_of(':'); - if (lastPos == (target.length() - 1)) - { - // todo hulud interface syntax error - nlwarning("The target should at least contains a path and a property as follow 'path:property'"); - return false; - } - std::string elmPath; - std::string elmProp; - CInterfaceElement *elm = NULL; - if (parentGroup) - { - if (lastPos == std::string::npos) - { - elmProp = target; - elm = parentGroup; - elmPath = "current"; - } - else - { - elmProp = target.substr(lastPos + 1); - elmPath = parentGroup->getId() + ":" + target.substr(0, lastPos); - elm = parentGroup->getElement(elmPath); - } - } - if (!elm) - { - // try the absolute adress of the element - elmPath = target.substr(0, lastPos); - elm = CInterfaceManager::getInstance()->getElementFromId(elmPath); - elmProp = target.substr(lastPos + 1); - } - - if (!elm) - { - // todo hulud interface syntax error - nlwarning(" can't find target link %s", elmPath.c_str()); - return false; - } - targetElm = elm; - propertyName = elmProp; - return true; -} - - -// *************************************************************************** -bool CInterfaceParser::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect) -{ - std::vector targetNames; - NLMISC::splitString(targets, ",", targetNames); - targetsVect.clear(); - targetsVect.reserve(targetNames.size()); - bool everythingOk = true; - for (uint k = 0; k < targetNames.size(); ++k) - { - CInterfaceLink::CTargetInfo ti; - std::string::size_type startPos = targetNames[k].find_first_not_of(" "); - if(startPos == std::string::npos) - { - // todo hulud interface syntax error - nlwarning(" empty target encountered"); - continue; - } - std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); - - if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) - { - // todo hulud interface syntax error - nlwarning(" Can't get link target"); - everythingOk = false; - continue; - } - targetsVect.push_back(ti); - } - return everythingOk; -} - - // *************************************************************************** bool CInterfaceParser::addLink(CInterfaceLink *link, const std::string &id) { diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 0c8b51940..6f318977e 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -214,16 +214,6 @@ public: void setDefine(const std::string &id, const std::string &value); // @} - /** From a target name of a link, retrieve the target element and its target target property - * \return true if the target is valid - */ - static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm); - - /** From several target names of a link (seprated by ','), retrieve the target elements and their target properties - * \return true if all targets are valid - */ - static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); - /// \name Dynamic links mgt // @{ /** Associate the given dynamic link with an ID diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index f6f881a47..2209b9742 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -53,7 +53,7 @@ #include "game_share/people_pd.h" #include "group_tree.h" #include "interface_link.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "people_interraction.h" #include "nel/misc/algo.h" #include "nel/misc/file.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 5aa4c7823..a4eae623c 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -30,7 +30,7 @@ #include "dbgroup_combo_box.h" #include "group_container.h" #include "group_modal_get_key.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" // tmp #include "../r2/editor.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 6a1b54f56..4c2bd1403 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -20,7 +20,7 @@ // client #include "../string_manager_client.h" #include "people_interraction.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "interface_manager.h" #include "action_handler.h" #include "action_handler_misc.h" @@ -30,7 +30,7 @@ #include "group_menu.h" #include "../client_chat_manager.h" #include "../string_manager_client.h" -#include "interface_expr.h" +#include "nel/gui/interface_expr.h" #include "ctrl_button.h" #include "ctrl_text_button.h" #include "filtered_chat_summary.h" @@ -1027,7 +1027,7 @@ class CHandlerChatGroupFilter : public IActionHandler CCtrlTabButton *pTabButton= dynamic_cast(pCaller); if(pTabButton) { - CRGBA stdColor= stringToRGBA(pIM->getDefine("chat_group_tab_color_normal").c_str()); + CRGBA stdColor= CRGBA::stringToRGBA(pIM->getDefine("chat_group_tab_color_normal").c_str()); pTabButton->setTextColorNormal(stdColor); } } diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index 6353029d8..2dd72ad52 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -976,21 +976,6 @@ std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) } -NLMISC::CRGBA stringToRGBA(const char *ptr) -{ - if (!ptr) return NLMISC::CRGBA::White; - int r = 255, g = 255, b = 255, a = 255; - sscanf (ptr, "%d %d %d %d", &r, &g, &b, &a); - NLMISC::clamp (r, 0, 255); - NLMISC::clamp (g, 0, 255); - NLMISC::clamp (b, 0, 255); - NLMISC::clamp (a, 0, 255); - return CRGBA(r,g,b,a); -} - - - - // *************************************************************************** inline bool isSeparator (ucchar c) diff --git a/code/ryzom/client/src/misc.h b/code/ryzom/client/src/misc.h index 77e1df221..1304a1cb1 100644 --- a/code/ryzom/client/src/misc.h +++ b/code/ryzom/client/src/misc.h @@ -166,9 +166,6 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd // Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return "" std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest); -NLMISC::CRGBA stringToRGBA(const char *ptr); - - // Number of shortcut #define RYZOM_MAX_SHORTCUT 20 From c3aff5dc6b1e6a54746e4dd09046792db5070f98 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 27 May 2012 21:52:02 +0200 Subject: [PATCH 035/339] ADDED: #1471 OVQT GUI Editor plugin skeleton code. --- .../src/plugins/CMakeLists.txt | 1 + .../src/plugins/gui_editor/CMakeLists.txt | 43 ++++++++ .../plugins/gui_editor/gui_editor_constants.h | 33 ++++++ .../plugins/gui_editor/gui_editor_context.cpp | 46 ++++++++ .../plugins/gui_editor/gui_editor_context.h | 56 ++++++++++ .../plugins/gui_editor/gui_editor_global.h | 30 +++++ .../plugins/gui_editor/gui_editor_plugin.cpp | 103 ++++++++++++++++++ .../plugins/gui_editor/gui_editor_plugin.h | 79 ++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 86 +++++++++++++++ .../plugins/gui_editor/gui_editor_window.h | 57 ++++++++++ .../plugins/gui_editor/gui_editor_window.ui | 36 ++++++ .../gui_editor/ovqt_plugin_gui_editor.xml | 7 ++ 12 files changed, 577 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt index 467b00876..945e0825f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/CMakeLists.txt @@ -6,6 +6,7 @@ ADD_SUBDIRECTORY(log) ADD_SUBDIRECTORY(disp_sheet_id) ADD_SUBDIRECTORY(object_viewer) ADD_SUBDIRECTORY(georges_editor) +ADD_SUBDIRECTORY(gui_editor) ADD_SUBDIRECTORY(translation_manager) ADD_SUBDIRECTORY(bnp_manager) # Note: Temporarily disabled until development continues. diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt new file mode 100644 index 000000000..769561d34 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -0,0 +1,43 @@ +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${QT_INCLUDES}) + +FILE(GLOB SRC *.cpp *.h) + +SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) + +SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h ) +SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui ) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTOPENGL TRUE) + +QT4_ADD_RESOURCES(OVQT_PLUGIN_GUI_EDITOR_RC_SRCS ${OVQT_PLUGIN_GUI_EDITOR_RCS}) +QT4_WRAP_CPP(OVQT_PLUGIN_GUI_EDITOR_MOC_SRC ${OVQT_PLUGIN_GUI_EDITOR_HDR}) +QT4_WRAP_UI(OVQT_PLUGIN_GUI_EDITOR_UI_HDRS ${OVQT_PLUGIN_GUI_EDITOR_UIS}) + +SOURCE_GROUP(QtResources FILES ${OVQT_PLUGIN_GUI_EDITOR_UIS}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC} OVQT_PLUGIN_GUI_EDITOR_RC_SRCS) +SOURCE_GROUP("GUI Editor Plugin" FILES ${SRC}) +SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC}) + +ADD_LIBRARY(ovqt_plugin_gui_editor MODULE ${SRC} + ${OVQT_PLUGIN_GUI_EDITOR_MOC_SRC} + ${OVQT_EXT_SYS_SRC} + ${OVQT_PLUGIN_GUI_EDITOR_UI_HDRS} + ${OVQT_PLUGIN_GUI_EDITOR_RC_SRCS} + ) + +TARGET_LINK_LIBRARIES(ovqt_plugin_gui_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) + +NL_DEFAULT_PROPS(ovqt_plugin_gui_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: GUI Editor") +NL_ADD_RUNTIME_FLAGS(ovqt_plugin_gui_editor) +NL_ADD_LIB_SUFFIX(ovqt_plugin_gui_editor) + +ADD_DEFINITIONS(-DGUI_EDITOR_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS}) + +INSTALL(TARGETS ovqt_plugin_gui_editor LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h new file mode 100644 index 000000000..2c50d9453 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_constants.h @@ -0,0 +1,33 @@ +// Object Viewer Qt GUI Editor plugin +// 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 GUI_EDITOR_CONSTANTS_H +#define GUI_EDITOR_CONSTANTS_H + +namespace GUIEditor +{ + namespace Constants + { + + const char * const GUI_EDITOR_PLUGIN = "GUIEditor"; + const char * const GUI_EDITOR_SECTION = "GUIEditor"; + + } + +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp new file mode 100644 index 000000000..32dba0e25 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp @@ -0,0 +1,46 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "gui_editor_context.h" +#include "gui_editor_window.h" + +namespace GUIEditor +{ + GUIEditorContext::GUIEditorContext(QObject *parent) : + IContext(parent), + m_guiEditorWindow(0) + { + m_guiEditorWindow = new GUIEditorWindow(); + } + + QUndoStack *GUIEditorContext::undoStack() + { + return m_guiEditorWindow->undoStack(); + } + + void GUIEditorContext::open() + { + m_guiEditorWindow->open(); + } + + QWidget *GUIEditorContext::widget() + { + return m_guiEditorWindow; + } + +} + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h new file mode 100644 index 000000000..39c521cdf --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h @@ -0,0 +1,56 @@ +// Object Viewer Qt GUI Editor plugin +// 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 GUI_EDITOR_CONTEXT_H +#define GUI_EDITOR_CONTEXT_H + +#include "../core/icontext.h" + +#include "nel/misc/app_context.h" + +#include +#include + +namespace GUIEditor +{ + class GUIEditorWindow; + + class GUIEditorContext: public Core::IContext + { + Q_OBJECT + public: + GUIEditorContext(QObject *parent = 0); + virtual ~GUIEditorContext() {} + + virtual QString id() const{ return QLatin1String("GUIEditorContext"); } + + virtual QString trName() const{ return tr("GUI Editor"); } + + virtual QIcon icon() const{ return QIcon(); } + + virtual void open(); + + virtual QUndoStack *undoStack(); + + virtual QWidget *widget(); + + GUIEditorWindow *m_guiEditorWindow; + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h new file mode 100644 index 000000000..82ca563a6 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_global.h @@ -0,0 +1,30 @@ +// Object Viewer Qt GUI Editor plugin +// 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 GUI_EDITOR_GLOBAL_H +#define GUI_EDITOR_GLOBAL_H + +#include + +#if defined( GUI_EDITOR_LIBRARY ) +# define GUI_EDITOR_EXPORT Q_DECL_EXPORT +#else +# define GUI_EDITOR_EXPORT Q_DECL_IMPORT +#endif + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp new file mode 100644 index 000000000..04088f046 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp @@ -0,0 +1,103 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "gui_editor_plugin.h" +#include "gui_editor_window.h" +#include "gui_editor_context.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +#include "nel/misc/debug.h" + +#include + +namespace GUIEditor +{ + GUIEditorPlugin::~GUIEditorPlugin() + { + Q_FOREACH(QObject *obj, m_autoReleaseObjects) + { + m_plugMan->removeObject(obj); + } + + qDeleteAll(m_autoReleaseObjects); + m_autoReleaseObjects.clear(); + } + + bool GUIEditorPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) + { + Q_UNUSED(errorString); + m_plugMan = pluginManager; + addAutoReleasedObject(new GUIEditorContext(this)); + return true; + } + + void GUIEditorPlugin::extensionsInitialized() + { + } + + void GUIEditorPlugin::shutdown() + { + } + + void GUIEditorPlugin::setNelContext(NLMISC::INelContext *nelContext) + { + +#ifdef NL_OS_WINDOWS + // Ensure that a context doesn't exist yet. + // This only applies to platforms without PIC, e.g. Windows. + nlassert(!NLMISC::INelContext::isContextInitialised()); +#endif // NL_OS_WINDOWS + m_libContext = new NLMISC::CLibraryContext(*nelContext); + } + + QString GUIEditorPlugin::name() const + { + return tr("GUIEditor"); + } + + QString GUIEditorPlugin::version() const + { + return "0.0.1"; + } + + QString GUIEditorPlugin::vendor() const + { + return "Ryzom Core"; + } + + QString GUIEditorPlugin::description() const + { + return "GUI Editor ovqt plugin."; + } + + QStringList GUIEditorPlugin::dependencies() const + { + QStringList list; + list.append(Core::Constants::OVQT_CORE_PLUGIN); + return list; + } + + void GUIEditorPlugin::addAutoReleasedObject(QObject *obj) + { + m_plugMan->addObject(obj); + m_autoReleaseObjects.prepend(obj); + } + +} + +Q_EXPORT_PLUGIN(GUIEditor::GUIEditorPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h new file mode 100644 index 000000000..20ec0a96e --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h @@ -0,0 +1,79 @@ +// Object Viewer Qt GUI Editor plugin +// 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 GUI_EDITOR_PLUGIN_H +#define GUI_EDITOR_PLUGIN_H + +#include "gui_editor_constants.h" +#include "../../extension_system/iplugin.h" +#include "../core/icontext.h" + +#include "nel/misc/app_context.h" + +#include +#include + +namespace NLMISC +{ + class CLibraryContext; +} + +namespace ExtensionSystem +{ + class IPluginSpec; +} + +namespace GUIEditor +{ + class GUIEditorWindow; + + class GUIEditorPlugin : public QObject, public ExtensionSystem::IPlugin + { + Q_OBJECT + Q_INTERFACES(ExtensionSystem::IPlugin) + public: + virtual ~GUIEditorPlugin(); + + bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); + + void extensionsInitialized(); + + void shutdown(); + + void setNelContext(NLMISC::INelContext *nelContext); + + QString name() const; + + QString version() const; + + QString vendor() const; + + QString description() const; + + QStringList dependencies() const; + + void addAutoReleasedObject(QObject *obj); + + protected: + NLMISC::CLibraryContext *m_libContext; + + private: + ExtensionSystem::IPluginManager *m_plugMan; + QList m_autoReleaseObjects; + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp new file mode 100644 index 000000000..bd0b97d14 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -0,0 +1,86 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "gui_editor_window.h" +#include "gui_editor_constants.h" + +#include "../core/icore.h" +#include "../core/core_constants.h" + +#include + +#include +#include + +namespace GUIEditor +{ + QString _lastDir; + + GUIEditorWindow::GUIEditorWindow(QWidget *parent) : + QMainWindow(parent) + { + m_ui.setupUi(this); + m_undoStack = new QUndoStack(this); + createMenus(); + readSettings(); + } + + GUIEditorWindow::~GUIEditorWindow() + { + writeSettings(); + } + + QUndoStack *GUIEditorWindow::undoStack() const + { + return m_undoStack; + } + + void GUIEditorWindow::open() + { + QStringList fileNames = QFileDialog::getOpenFileNames(this, + tr("Open GUI XML files"), + _lastDir, + tr("All XML files (*.xml)")); + + setCursor(Qt::WaitCursor); + if(!fileNames.isEmpty()) + { + QStringList list = fileNames; + _lastDir = QFileInfo(list.front()).absolutePath(); + } + setCursor(Qt::ArrowCursor); + } + + void GUIEditorWindow::createMenus() + { + } + + void GUIEditorWindow::readSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::GUI_EDITOR_SECTION); + settings->endGroup(); + } + + void GUIEditorWindow::writeSettings() + { + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Constants::GUI_EDITOR_SECTION); + settings->endGroup(); + settings->sync(); + } + +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h new file mode 100644 index 000000000..943a21655 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -0,0 +1,57 @@ +// Object Viewer Qt GUI Editor plugin +// 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 GUI_EDITOR_WINDOW_H +#define GUI_EDITOR_WINDOW_H + +#include "ui_gui_editor_window.h" + +#include + +namespace GUIEditor +{ + class GUIEditorWindow: public QMainWindow + { + Q_OBJECT +public: + GUIEditorWindow(QWidget *parent = 0); + + ~GUIEditorWindow(); + + QUndoStack *undoStack() const; + + Q_SIGNALS: + +public Q_SLOTS: + void open(); + +private Q_SLOTS: + +private: + void createMenus(); + + void readSettings(); + + void writeSettings(); + + QUndoStack *m_undoStack; + + Ui::GUIEditorWindow m_ui; + }; + +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui new file mode 100644 index 000000000..baf1f01f4 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui @@ -0,0 +1,36 @@ + + + GUIEditorWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml new file mode 100644 index 000000000..9b4efca08 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml @@ -0,0 +1,7 @@ + + ovqt_plugin_gui_editor + GUI Editor + 0.0.1 + Ryzom Core + GUI Editor plugin. + \ No newline at end of file From 4053fe6f8dfa120a6353ebf82387b2e9d965086a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 27 May 2012 23:35:46 +0200 Subject: [PATCH 036/339] CHANGED: #1471 According to dnk-88 these methods are no longer needed, the XML description file is enough for the plugins. --- .../plugins/gui_editor/gui_editor_plugin.cpp | 29 +------------------ .../plugins/gui_editor/gui_editor_plugin.h | 10 ------- .../gui_editor/ovqt_plugin_gui_editor.xml | 3 ++ 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp index 04088f046..d135dde9a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.cpp @@ -64,34 +64,7 @@ namespace GUIEditor #endif // NL_OS_WINDOWS m_libContext = new NLMISC::CLibraryContext(*nelContext); } - - QString GUIEditorPlugin::name() const - { - return tr("GUIEditor"); - } - - QString GUIEditorPlugin::version() const - { - return "0.0.1"; - } - - QString GUIEditorPlugin::vendor() const - { - return "Ryzom Core"; - } - - QString GUIEditorPlugin::description() const - { - return "GUI Editor ovqt plugin."; - } - - QStringList GUIEditorPlugin::dependencies() const - { - QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - return list; - } - + void GUIEditorPlugin::addAutoReleasedObject(QObject *obj) { m_plugMan->addObject(obj); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h index 20ec0a96e..3b9fac2e7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_plugin.h @@ -55,16 +55,6 @@ namespace GUIEditor void setNelContext(NLMISC::INelContext *nelContext); - QString name() const; - - QString version() const; - - QString vendor() const; - - QString description() const; - - QStringList dependencies() const; - void addAutoReleasedObject(QObject *obj); protected: diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml index 9b4efca08..987a43432 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/ovqt_plugin_gui_editor.xml @@ -4,4 +4,7 @@ 0.0.1 Ryzom Core GUI Editor plugin. + + + \ No newline at end of file From 8d2f01fac82b19960a82cff8d9fb5e41048d5235 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 30 May 2012 02:12:37 +0200 Subject: [PATCH 037/339] ADDED: #1471 Added new class CWidgetManager, and started to move code into it from CInterfaceManager. --- code/nel/include/nel/gui/interface_common.h | 11 + code/ryzom/client/src/game_context_menu.cpp | 2 +- code/ryzom/client/src/init.cpp | 3 + .../src/interface_v3/action_handler.cpp | 12 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../src/interface_v3/flying_text_manager.cpp | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 14 +- .../interface_v3/group_in_scene_user_info.cpp | 2 +- .../src/interface_v3/interface_config.cpp | 6 +- .../src/interface_v3/interface_manager.cpp | 112 +-- .../src/interface_v3/interface_parser.cpp | 642 +----------------- .../src/interface_v3/interface_parser.h | 54 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../src/interface_v3/widget_manager.cpp | 366 ++++++++++ .../client/src/interface_v3/widget_manager.h | 84 +++ code/ryzom/client/src/net_manager.cpp | 2 +- code/ryzom/client/src/r2/displayer_visual.cpp | 2 +- code/ryzom/client/src/release.cpp | 1 + 20 files changed, 587 insertions(+), 736 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/widget_manager.cpp create mode 100644 code/ryzom/client/src/interface_v3/widget_manager.h diff --git a/code/nel/include/nel/gui/interface_common.h b/code/nel/include/nel/gui/interface_common.h index 1e28dde58..f0793dd0d 100644 --- a/code/nel/include/nel/gui/interface_common.h +++ b/code/nel/include/nel/gui/interface_common.h @@ -17,6 +17,17 @@ #ifndef INTERFACE_COMMON_H #define INTERFACE_COMMON_H +enum WindowsPriority +{ + WIN_PRIORITY_WORLD_SPACE = 0, + WIN_PRIORITY_LOWEST = 1, + WIN_PRIORITY_LOW = 2, + WIN_PRIORITY_NORMAL = 3, + WIN_PRIORITY_HIGH = 4, + WIN_PRIORITY_HIGHEST = 5, + WIN_PRIORITY_MAX = 8 +}; + enum THotSpot { Hotspot_BL = 36, // 100100, diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index 292158262..ec147a3b9 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -81,7 +81,7 @@ void CGameContextMenu::init(const std::string &srcMenuId) std::string menuId = srcMenuId.empty() ? std::string("game_context_menu") : srcMenuId; CInterfaceManager *pIM= CInterfaceManager::getInstance(); - _GroupMenu = dynamic_cast(pIM->getWindowFromId ("ui:interface:" + menuId + "")); + _GroupMenu = dynamic_cast(CWidgetManager::getInstance()->getWindowFromId ("ui:interface:" + menuId + "")); _ContextVal = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TARGET:CONTEXT_VAL", false); if(_GroupMenu == NULL) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index e64c0df94..531b8ed61 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -69,6 +69,7 @@ #include "sheet_manager.h" #include "interface_v3/sbrick_manager.h" +#include "interface_v3/widget_manager.h" // #include "gabarit.h" #include "hair_set.h" @@ -1072,6 +1073,8 @@ void prelogInit() // resetTextContext ("bremenb.ttf", false); resetTextContext ("ryzom.ttf", false); + + CWidgetManager::getInstance(); CInterfaceManager::create( Driver, TextContext ); // Yoyo: initialize NOW the InputHandler for Event filtering. diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index 07af4a28f..d826a2dea 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -942,10 +942,10 @@ class CAHResetInterface : public IActionHandler { uint32 i; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const vector &rVMG = pIM->getAllMasterGroup(); + const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) { - const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup]; const vector &rV = rMG.Group->getGroups(); // Active all containers (that can be activated) for (i = 0; i < rV.size(); ++i) @@ -962,7 +962,7 @@ class CAHResetInterface : public IActionHandler } pIM->checkCoords(); - pIM->getMasterGroup((uint8)nMasterGroup).centerAllContainers(); + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).centerAllContainers(); // Pop in and close all containers for (i = 0; i < rV.size(); ++i) @@ -980,7 +980,7 @@ class CAHResetInterface : public IActionHandler } } - pIM->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers(); + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers(); } } }; @@ -992,11 +992,11 @@ class CAHUnlockAllContainer : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const vector &rVMG = pIM->getAllMasterGroup(); + const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) { // const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; - pIM->getMasterGroup((uint8)nMasterGroup).unlockAllContainers(); + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers(); } } }; diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 1bbd86d89..446174778 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -153,7 +153,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId) // If root container if (desc.FatherContainer == "ui:interface") { - im->addWindowToMasterGroup("ui:interface", _Chat); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", _Chat); _Chat->setParent(pRoot); _Chat->setMovable(true); _Chat->setActive(false); diff --git a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp index 58e055f22..48bac19ab 100644 --- a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -186,7 +186,7 @@ void CFlyingTextManager::linkToInterface(CGroupInfo &gi) // add to group and window list CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->addWindowToMasterGroup("ui:interface", gi.GroupInScene); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", gi.GroupInScene); gi.GroupInScene->setParent(_Root); _Root->addGroup (gi.GroupInScene); } diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index b29326aeb..3b442ce3b 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -233,7 +233,7 @@ void CGroupInSceneBubbleManager::init () if (group) { // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -538,7 +538,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t pViewSkillMax->setText (toString(pSM->getMaxSkillValue((SKILLS::ESkills)skillId))); // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -587,7 +587,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA } // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -636,7 +636,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, } // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -710,7 +710,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont } // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -903,7 +903,7 @@ void CGroupInSceneBubbleManager::dynChatOpen (uint32 nBotUID, uint32 nBotName, c return; } // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) @@ -1016,7 +1016,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con return; } // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index 20929bf1b..d19c2dcd3 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -741,7 +741,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) info->setActive(true); // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", info); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", info); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); info->setParent(pRoot); if (pRoot) diff --git a/code/ryzom/client/src/interface_v3/interface_config.cpp b/code/ryzom/client/src/interface_v3/interface_config.cpp index b34db79f8..486b05487 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.cpp +++ b/code/ryzom/client/src/interface_v3/interface_config.cpp @@ -522,10 +522,10 @@ void CInterfaceConfig::CDesktopImage::fromCurrentDesktop() // Count number of container to save uint32 nCount = 0, nMasterGroup, i, nCount2; - const vector &rVMG = pIM->getAllMasterGroup(); + const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) { - const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup]; const vector &rV = rMG.Group->getGroups(); for (i = 0; i < rV.size(); ++i) { @@ -541,7 +541,7 @@ void CInterfaceConfig::CDesktopImage::fromCurrentDesktop() // retrieve all containers for (nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) { - const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup]; const vector &rV = rMG.Group->getGroups(); for (i = 0; i < rV.size(); ++i) { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e2a0f5e10..e5d10e45a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -351,11 +351,6 @@ CInterfaceManager::~CInterfaceManager() { reset(); // to flush IDStringWaiters - //delete the interface group - for (uint32 i = 0; i < _MasterGroups.size(); ++i) - { - delete _MasterGroups[i].Group; - } _ParentPositionsMap.clear(); _ParentSizesMap.clear(); _ParentSizesMaxMap.clear(); @@ -1893,6 +1888,7 @@ bool CInterfaceManager::saveConfig (const string &filename) void CInterfaceManager::checkCoords() { H_AUTO ( RZ_Interface_validateCoords ) + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 nMasterGroup; @@ -1902,7 +1898,7 @@ void CInterfaceManager::checkCoords() // checkCoords all the windows for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) @@ -1928,7 +1924,7 @@ void CInterfaceManager::checkCoords() // updateCoords all the needed windows for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) @@ -2071,12 +2067,13 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) To minimize texture swapping, we first sort per Window, then we sort per layer, then we render per Global Texture. Computed String are rendered in on big drawQuads at last part of each layer */ + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); // for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { // Sort world space windows @@ -2231,10 +2228,11 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl() // ---------------------------------------------------------------------------- CInterfaceGroup *CInterfaceManager::getWindowForActiveMasterGroup(const std::string &window) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); // Search for all elements for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - const SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { CInterfaceElement *pEL= getElementFromId( rMG.Group->getId() + ":" + window); @@ -3260,6 +3258,7 @@ void CInterfaceManager::getNewWindowCoordToNewScreenSize(sint32 &x, sint32 &y, s // ------------------------------------------------------------------------------------------------ void CInterfaceManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); // If resolutions correctly setuped, and really different from new setup if( _LastInGameScreenW >0 && _LastInGameScreenH>0 && newScreenW >0 && newScreenH>0 && @@ -3272,7 +3271,7 @@ void CInterfaceManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 // only for ui:interface (not login, nor outgame) for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if(!rMG.Group || rMG.Group->getId()!="ui:interface") continue; @@ -3346,10 +3345,12 @@ void CInterfaceManager::updateAllLocalisedElements() _ViewRenderer.checkNewScreenSize (); _ViewRenderer.getScreenSize (w, h); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + // Update ui:* (limit the master containers to the height of the screen) for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; rMG.Group->setW (w); rMG.Group->setH (h); } @@ -3363,7 +3364,7 @@ void CInterfaceManager::updateAllLocalisedElements() // Invalidate coordinates of all Windows of each MasterGroup for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; rMG.Group->invalidateTexts (false); rMG.Group->invalidateCoords (); @@ -3383,7 +3384,7 @@ void CInterfaceManager::updateAllLocalisedElements() // setup for all for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; bool bActive = rMG.Group->getActive (); rMG.Group->setActive (true); rMG.Group->updateCoords (); @@ -3396,7 +3397,7 @@ void CInterfaceManager::updateAllLocalisedElements() // Action by default (container opening for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; rMG.Group->launch (); } @@ -3489,9 +3490,10 @@ CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y) { H_AUTO (RZ_Interface_Window_Under ) + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) @@ -3516,9 +3518,10 @@ CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y) // ------------------------------------------------------------------------------------------------ CInterfaceGroup* CInterfaceManager::getGroupUnder (sint32 x, sint32 y) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) @@ -3550,11 +3553,13 @@ void CInterfaceManager::getViewsUnder (sint32 x, sint32 y, std::vector &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + uint32 sw, sh; _ViewRenderer.getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) @@ -3586,11 +3591,13 @@ void CInterfaceManager::getCtrlsUnder (sint32 x, sint32 y, std::vector &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + uint32 sw, sh; _ViewRenderer.getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) @@ -3624,11 +3631,13 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vector &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + uint32 sw, sh; _ViewRenderer.getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) @@ -3660,7 +3669,7 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vectorgetMasterGroupFromId (sMasterGroupName); if (pIG != NULL) { pIG->setActive(bActive); @@ -3688,10 +3697,12 @@ CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sEltI if(sEltId == _CtrlLaunchingModalId) return getCtrlLaunchingModal(); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + // Search for all elements for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; CInterfaceElement *pIEL = rMG.Group->getElement (sEltId); if (pIEL != NULL) return pIEL; @@ -3735,10 +3746,11 @@ CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sStar // ------------------------------------------------------------------------------------------------ void CInterfaceManager::setTopWindow (CInterfaceGroup* win) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); //find the window in the window list for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { rMG.setTopWindow(win); @@ -3772,9 +3784,10 @@ void CInterfaceManager::setTopWindow (CInterfaceGroup* win) // ------------------------------------------------------------------------------------------------ void CInterfaceManager::setBackWindow(CInterfaceGroup* win) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { rMG.setBackWindow(win); @@ -3798,9 +3811,10 @@ void CInterfaceManager::setBackWindow(CInterfaceGroup* win) // ------------------------------------------------------------------------------------------------ CInterfaceGroup *CInterfaceManager::getTopWindow (uint8 nPriority) const { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - const SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { // return the first. @@ -3817,9 +3831,10 @@ CInterfaceGroup *CInterfaceManager::getTopWindow (uint8 nPriority) const // ------------------------------------------------------------------------------------------------ CInterfaceGroup *CInterfaceManager::getBackWindow (uint8 nPriority) const { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - const SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { // return the first. @@ -4280,6 +4295,7 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl) void CInterfaceManager::makeWindow(CInterfaceGroup *group) { if (!group) return; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 i = 0; for (i = 0; i < _MasterGroups.size(); ++i) { @@ -4311,6 +4327,7 @@ void CInterfaceManager::makeWindow(CInterfaceGroup *group) void CInterfaceManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) { if (!group) return; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 i = 0; for (i = 0; i < _MasterGroups.size(); ++i) { @@ -4478,15 +4495,15 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) if (_ModalStack.empty()) { // We must be in-game ! - CInterfaceGroup *pMG = getMasterGroupFromId("ui:interface"); + CInterfaceGroup *pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:interface"); // TMP nico : try with login screen: if (!pMG) { - pMG = getMasterGroupFromId("ui:login"); + pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:login"); } if (!pMG) { - pMG = getMasterGroupFromId("ui:outgame"); + pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:outgame"); } if ((pMG != NULL) && (pMG->getActive())) { @@ -4580,10 +4597,12 @@ void CInterfaceManager::setMode(uint8 newMode) if (newMode == _CurrentMode) return; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + // Check if we can change vdesk ! for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) @@ -4653,6 +4672,7 @@ struct CDumpedGroup // *************************************************************************** void CInterfaceManager::dumpUI(bool /* indent */) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); std::vector left; left.resize(_MasterGroups.size()); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) @@ -4727,9 +4747,10 @@ void CInterfaceManager::dumpUI(bool /* indent */) // *************************************************************************** void CInterfaceManager::displayUIViewBBoxs(const std::string &uiFilter) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4745,9 +4766,10 @@ void CInterfaceManager::displayUIViewBBoxs(const std::string &uiFilter) // *************************************************************************** void CInterfaceManager::displayUICtrlBBoxs(const std::string &uiFilter) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4763,9 +4785,10 @@ void CInterfaceManager::displayUICtrlBBoxs(const std::string &uiFilter) // *************************************************************************** void CInterfaceManager::displayUIGroupBBoxs(const std::string &uiFilter) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4870,9 +4893,10 @@ bool CInterfaceManager::saveKeys(const std::string &filename) // *************************************************************************** CInterfaceGroup *CInterfaceManager::getLastEscapableTopWindow() const { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - const SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) @@ -4894,9 +4918,10 @@ CInterfaceGroup *CInterfaceManager::getLastEscapableTopWindow() const // *************************************************************************** void CInterfaceManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority) { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { if (rMG.isWindowPresent(pWin)) @@ -4944,9 +4969,10 @@ void CInterfaceManager::log(const ucstring &str) // *************************************************************************** void CInterfaceManager::clearAllEditBox() { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4964,9 +4990,10 @@ void CInterfaceManager::clearAllEditBox() // *************************************************************************** void CInterfaceManager::restoreAllContainersBackupPosition() { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; for (uint8 nPriority=0; nPriority < WIN_PRIORITY_MAX; ++nPriority) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4983,9 +5010,10 @@ void CInterfaceManager::restoreAllContainersBackupPosition() // *************************************************************************** uint8 CInterfaceManager::getLastTopWindowPriority() const { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - const SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { return rMG.LastTopWindowPriority; @@ -5078,6 +5106,7 @@ void CInterfaceManager::submitEvent (const std::string &event) void CInterfaceManager::visit(CInterfaceElementVisitor *visitor) { nlassert(visitor); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { if (_MasterGroups[nMasterGroup].Group) @@ -5604,9 +5633,10 @@ void CInterfaceManager::notifyForumUpdated() void CInterfaceManager::resetTextIndex() { uint32 nMasterGroup; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; rMG.Group->invalidateTexts (true); for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) @@ -5948,9 +5978,10 @@ void CInterfaceManager::luaGarbageCollect() // *************************************************************************** void CInterfaceManager::hideAllWindows() { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) @@ -5971,9 +6002,10 @@ void CInterfaceManager::hideAllWindows() // *************************************************************************** void CInterfaceManager::hideAllNonSavableWindows() { + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 56e5c961f..fa27fa060 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -292,194 +292,6 @@ private: map _Accel; }; -// ---------------------------------------------------------------------------- -// SMasterGroup -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio) -{ - nlassert(nPrio(pIG)!=NULL)); - - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - // If the element already exists in the list return ! - if (*it == pIG) - return; - it++; - } - } - PrioritizedWindows[nPrio].push_back(pIG); -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::delWindow(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if ((*it) == pIG) - { - PrioritizedWindows[i].erase(it); - return; - } - it++; - } - } -} - -// ---------------------------------------------------------------------------- -CInterfaceGroup* CInterfaceParser::SMasterGroup::getWindowFromId(const std::string &winID) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if ((*it)->getId() == winID) - return *it; - it++; - } - } - return NULL; -} - -// ---------------------------------------------------------------------------- -bool CInterfaceParser::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if ((*it) == pIG) - return true; - it++; - } - } - return false; -} - -// Set a window top in its priority queue -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::setTopWindow(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if (*it == pIG) - { - PrioritizedWindows[i].erase(it); - PrioritizedWindows[i].push_back(pIG); - LastTopWindowPriority= i; - return; - } - it++; - } - } - // todo hulud interface syntax error - nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::setBackWindow(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if (*it == pIG) - { - PrioritizedWindows[i].erase(it); - PrioritizedWindows[i].push_front(pIG); - return; - } - it++; - } - } - // todo hulud interface syntax error - nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::deactiveAllContainers() -{ - vector gcs; - - // Make first a list of all window (Warning: all group container are not window!) - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - CGroupContainer *pGC = dynamic_cast(*it); - if (pGC != NULL) - gcs.push_back(pGC); - it++; - } - } - - // Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows, - // and hence invalidate its. - for (uint32 i = 0; i < gcs.size(); ++i) - { - gcs[i]->setActive(false); - } -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::centerAllContainers() -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - CGroupContainer *pGC = dynamic_cast(*it); - if ((pGC != NULL) && (pGC->getParent() != NULL)) - { - sint32 wParent = pGC->getParent()->getW(false); - sint32 w = pGC->getW(false); - pGC->setXAndInvalidateCoords((wParent - w) / 2); - sint32 hParent = pGC->getParent()->getH(false); - sint32 h = pGC->getH(false); - pGC->setYAndInvalidateCoords(h+(hParent - h) / 2); - } - - it++; - } - } -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::SMasterGroup::unlockAllContainers() -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - CGroupContainer *pGC = dynamic_cast(*it); - if (pGC != NULL) - pGC->setLocked(false); - - it++; - } - } -} - // ---------------------------------------------------------------------------- // CInterfaceParser // ---------------------------------------------------------------------------- @@ -734,7 +546,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) { H_AUTO(parseXMLDocument); - SMasterGroup *curRoot = NULL; + CWidgetManager::SMasterGroup *curRoot = NULL; CInterfaceGroup *rootGroup = NULL; //parse templates xmlNodePtr curNode = root->children; @@ -744,6 +556,8 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) Actions.reserveCategories((uint)Actions.getCategories ().size()+actionCategoryCount); EditActions.reserveCategories(1); + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); + while (curNode) { // first solve define for the xml node and his sons @@ -840,12 +654,12 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) CXMLAutoPtr ptr((const char*)xmlGetProp (root, (xmlChar*)"id")); if (ptr) { - rootGroup = getMasterGroupFromId (string("ui:") + (const char*)ptr); + rootGroup = CWidgetManager::getInstance()->getMasterGroupFromId (string("ui:") + (const char*)ptr); if (rootGroup == NULL) { rootGroup = (CInterfaceGroup*)(new CRootGroup(CViewBase::TCtorParam())); rootGroup->parse (root, NULL); - SMasterGroup mg; + CWidgetManager::SMasterGroup mg; mg.Group = rootGroup; _MasterGroups.push_back (mg); } @@ -982,7 +796,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) { H_AUTO(addWindowToMasterGroup) - SMasterGroup &rMG = _MasterGroups[i]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[i]; // insert all modals for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { @@ -991,7 +805,7 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) if(pIG) { // add to the window list - addWindowToMasterGroup(rMG.Group->getId(), pIG); + CWidgetManager::getInstance()->addWindowToMasterGroup(rMG.Group->getId(), pIG); } } } @@ -1979,9 +1793,10 @@ bool CInterfaceParser::parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGro CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; CInterfaceElement *pEltFound = NULL; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 i = 0; i < _MasterGroups.size(); ++i) { - SMasterGroup &rMG = _MasterGroups[i]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[i]; for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; @@ -2026,10 +1841,11 @@ bool CInterfaceParser::setupTreeNode (xmlNodePtr cur, CGroupContainer * /* paren { CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); CInterfaceElement *pEltFound = NULL; for (uint32 i = 0; i < _MasterGroups.size(); ++i) { - SMasterGroup &rMG = _MasterGroups[i]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[i]; for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; @@ -2119,14 +1935,15 @@ bool CInterfaceParser::setupTreeNode (xmlNodePtr cur, CGroupContainer * /* paren } // ---------------------------------------------------------------------------- -bool CInterfaceParser::setupTree (xmlNodePtr cur, SMasterGroup * /* parentGroup */) +bool CInterfaceParser::setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup * /* parentGroup */) { CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); CInterfaceElement *pEltFound = NULL; for (uint32 i = 0; i < _MasterGroups.size(); ++i) { - SMasterGroup &rMG = _MasterGroups[i]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[i]; for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; @@ -2186,16 +2003,17 @@ bool CInterfaceParser::setupTree (xmlNodePtr cur, SMasterGroup * /* parentGroup // ---------------------------------------------------------------------------- -bool CInterfaceParser::parseTree (xmlNodePtr cur, SMasterGroup *parentGroup) +bool CInterfaceParser::parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup) { H_AUTO(parseTree ) CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"node" )); if (!ptr) return false; + std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); CInterfaceElement *pEltFound = NULL; for (uint32 i = 0; i < _MasterGroups.size(); ++i) { - SMasterGroup &rMG = _MasterGroups[i]; + CWidgetManager::SMasterGroup &rMG = _MasterGroups[i]; for (uint32 j = 0; j < rMG.Group->getGroups().size(); ++j) { CInterfaceGroup *pIG = rMG.Group->getGroups()[j]; @@ -2239,7 +2057,7 @@ bool CInterfaceParser::parseTree (xmlNodePtr cur, SMasterGroup *parentGroup) } // Ok add it. - addWindowToMasterGroup(parentGroup->Group->getId(), pIG); + CWidgetManager::getInstance()->addWindowToMasterGroup(parentGroup->Group->getId(), pIG); CGroupContainer *pIC = dynamic_cast(pEltFound); if (pIC != NULL) @@ -2417,7 +2235,7 @@ bool CInterfaceParser::initCoordsAndLuaScript() parentpos = parent->getElement(EltName); //if the element has no parent, check the windows else - parentpos = getWindowFromId(EltName); + parentpos = CWidgetManager::getInstance()->getWindowFromId(EltName); if (parentpos == NULL) { @@ -2448,7 +2266,7 @@ bool CInterfaceParser::initCoordsAndLuaScript() parentsize = parent->getElement(EltName); //if the element has no parent, check the windows else - parentsize = getWindowFromId(EltName); + parentsize = CWidgetManager::getInstance()->getWindowFromId(EltName); } if (parentsize == NULL) @@ -2481,7 +2299,7 @@ bool CInterfaceParser::initCoordsAndLuaScript() parentsizemax = parent->getElement(EltName); //if the element has no parent, check the windows else - parentsizemax = getWindowFromId(EltName); + parentsizemax = CWidgetManager::getInstance()->getWindowFromId(EltName); } if (parentsizemax == NULL) @@ -2536,60 +2354,6 @@ void CInterfaceParser::addLuaClassAssociation (CInterfaceGroup *group, const std _LuaClassAssociation.insert (std::map::value_type(group, luaScript)); } -// ---------------------------------------------------------------------------- -CInterfaceGroup* CInterfaceParser::getMasterGroupFromId (const std::string &MasterGroupName) -{ - for (uint32 i = 0; i < _MasterGroups.size(); ++i) - { - if (_MasterGroups[i].Group->getId() == MasterGroupName) - return _MasterGroups[i].Group; - } - return NULL; -} - -// ---------------------------------------------------------------------------- -CInterfaceGroup* CInterfaceParser::getWindowFromId (const std::string & groupId) -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - CInterfaceGroup *pIG = rMG.getWindowFromId(groupId); - if (pIG != NULL) - return pIG; - } - return NULL; -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG) -{ - // Warning this function is not smart : its a o(n) ! - if (pIG == NULL) return; - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) - { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getId() == sMasterGroupName) - { - rMG.addWindow(pIG, pIG->getPriority()); - } - } -} - -// ---------------------------------------------------------------------------- -void CInterfaceParser::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG) -{ - // Warning this function is not smart : its a o(n) ! - if (pIG == NULL) return; - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) - { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getId() == sMasterGroupName) - { - rMG.delWindow(pIG); - } - } -} - // *************************************************************************** const std::string &CInterfaceParser::getDefine(const std::string &id) const { @@ -3830,38 +3594,7 @@ void CInterfaceParser::removeAllAnims() } // *************************************************************************** -void unlinkAllContainers (CInterfaceGroup *pIG) -{ - const vector &rG = pIG->getGroups(); - for(uint i = 0; i < rG.size(); ++i) - unlinkAllContainers (rG[i]); - CGroupContainer *pGC = dynamic_cast(pIG); - if (pGC != NULL) - pGC->removeAllContainers(); -} - -// *************************************************************************** -void CInterfaceParser::removeAllMasterGroups() -{ - uint i; - - NLMISC::TTime initStart; - initStart = ryzomGetLocalTime (); - for (i = 0; i < _MasterGroups.size(); ++i) - unlinkAllContainers (_MasterGroups[i].Group); - //nlinfo ("%d seconds for all unlinkAllContainers", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - - initStart = ryzomGetLocalTime (); - // Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback - // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) - while(!_MasterGroups.empty()) - { - delete _MasterGroups.back().Group; - _MasterGroups.pop_back(); - } - //nlinfo ("%d seconds for all delete _MasterGroups", (uint32)(ryzomGetLocalTime ()-initStart)/1000); -} // *************************************************************************** void CInterfaceParser::removeAll() @@ -3886,7 +3619,7 @@ void CInterfaceParser::removeAll() removeAllAnims(); //nlinfo ("%d seconds for removeAllAnims", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); - removeAllMasterGroups(); + CWidgetManager::getInstance()->removeAllMasterGroups(); //nlinfo ("%d seconds for removeAllMasterGroups", (uint32)(ryzomGetLocalTime ()-initStart)/1000); _StyleMap.clear(); _CtrlSheetSelection.deleteGroups(); @@ -4054,141 +3787,7 @@ bool CInterfaceParser::parseCareerGeneratorParams(xmlNodePtr cur, // *************************************************************************** bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */) { - H_AUTO(parseBrickCareerGenerator) - - // No more CAREER / Bricks!!! - // TODO_BRICK: remove this code. return false; - - /* - CBrickManager *pBM= CBrickManager::getInstance(); - - CXMLAutoPtr prop; - - string templateCareer; - string templateJob; - string templateBrick; - string careerWindowBase; - string jobWindowBase; - string brickWindowBase; - xmlNodePtr rootTreeNode; - bool brickTypeFilter; - BRICK_TYPE::EBrickType brickType; - - if(! parseCareerGeneratorParams(cur, templateCareer, templateJob, careerWindowBase, jobWindowBase, rootTreeNode, - brickTypeFilter, brickType) ) - return false; - - if(!brickTypeFilter) - { - nlwarning("'brick_carrer_generator' must be filtered. 'brick_type' must not be 'none'"); - return false; - } - - // Read Brick specials. - prop = xmlGetProp (cur, (xmlChar*)"template_brick"); - if(prop) templateBrick= (const char*)prop; - else - { - nlwarning("prop 'template_brick' not found"); - return false; - } - prop = xmlGetProp (cur, (xmlChar*)"brick_window"); - if(prop) brickWindowBase= (const char*)prop; - else - { - nlwarning("prop 'brick_window' not found"); - return false; - } - // read the XStart for bricks that are in Jobs (not in career). - sint32 xstartCareer=0; - prop = xmlGetProp (cur, (xmlChar*)"xstart_career"); - if(prop) fromString((const char*)prop, xstartCareer); - sint32 xstartJob=0; - prop = xmlGetProp (cur, (xmlChar*)"xstart_job"); - if(prop) fromString((const char*)prop, xstartJob); - - - // **** Create all existing careers - xmlNodePtr nextSibling=cur; - for(uint careerId=0;careerIdgetCareer(brickType, (ROLES::ERole)careerId ); - - // if no filter, then dispplay all careers - if(career) - { - string carreerWindowId= careerWindowBase + toString(careerId); - - // Ok, create the xml node to instanciate the career - xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateCareer.c_str()); - xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str()); - xmlSetProp(node, (xmlChar*)"id", (xmlChar*)carreerWindowId.c_str()); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr careerTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - xmlSetProp(careerTreeNode, (xmlChar*)"node", (xmlChar*)carreerWindowId.c_str()); - // link it to the root - xmlAddChild(rootTreeNode, careerTreeNode); - - // **** create bricks in the career common Job. - string brickWindowId= brickWindowBase + toString(careerId) + "_c_"; - createJobBricks(brickType, nextSibling, careerTreeNode, career->Common, templateBrick, brickWindowId, xstartCareer); - - - // **** create all existing jobs. - sint numJobs; - - // parse jobs of the career - numJobs= career->Jobs.size(); - - // for all jobs to parse - for(sint jobIndex=0;jobIndexJobs[jobIndex].Job ); - - // if the job exist - if(jobId>=0) - { - string jobWindowId= jobWindowBase + toString(careerId) + "_" + toString(jobId); - - // create the xml node to instanciate the job - xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateJob.c_str()); - xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str()); - xmlSetProp(node, (xmlChar*)"jobid", (xmlChar*)toString(jobId).c_str()); - xmlSetProp(node, (xmlChar*)"id", (xmlChar*)jobWindowId.c_str()); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr jobTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - xmlSetProp(jobTreeNode, (xmlChar*)"node", (xmlChar*)jobWindowId.c_str()); - // link it - xmlAddChild(careerTreeNode, jobTreeNode); - - // **** create bricks in the Job. - string brickWindowId= brickWindowBase + toString(careerId) + "_" + toString(jobId) + "_"; - createJobBricks(brickType, nextSibling, jobTreeNode, career->Jobs[jobIndex], templateBrick, brickWindowId, xstartJob); - - } - } - } - } - - return true;*/ } @@ -4196,163 +3795,13 @@ bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */) void CInterfaceParser::createJobBricks(BRICK_TYPE::EBrickType brickType, xmlNodePtr &nextSibling, xmlNodePtr parentTreeNode, const CBrickJob &/* job */, const string &/* templateBrick */, const string &/* baseWindowId */, sint32 /* xstart */) { - // No more CAREER / Bricks!!! - // TODO_BRICK: remove this code. - - /* - uint brickWndIndex=0; - - // Must Parse Family and Special ShopKeeper Family too! - uint numFamilyStd= job.Family.size(); - uint numFamilyTotal= numFamilyStd + job.SpecialShopkeeperFamily.size(); - - // For all the families of brick. - for(uint familyId= 0; familyIdns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str()); - xmlSetProp(node, (xmlChar*)"root_brick", (xmlChar*)toString(brickFamily.Bricks[i].asInt()).c_str()); - xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() ); - xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() ); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" ); - xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it - xmlAddChild(parentTreeNode, brickTreeNode); - } - } - // For Combat-Special, parse only the brickFamily - else - { - string windowId= baseWindowId + toString(brickWndIndex++); - - // create the xml node to instanciate the brick group - xmlNodePtr node= xmlNewNode(nextSibling->ns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str()); - xmlSetProp(node, (xmlChar*)"brick_family", (xmlChar*)toString(brickFamily.Family).c_str()); - xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() ); - xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() ); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" ); - xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it - xmlAddChild(parentTreeNode, brickTreeNode); - } - } - */ } // *************************************************************************** bool CInterfaceParser::parseBrickSuffixGenerator(xmlNodePtr /* cur */) { - H_AUTO(parseBrickSuffixGenerator) - - // No more CAREER / Bricks!!! - // TODO_BRICK: remove this code. return false; - - /* - CBrickManager *pBM= CBrickManager::getInstance(); - - CXMLAutoPtr prop; - - string templateBrick; - string brickWindowBase; - xmlNodePtr rootTreeNode; - BRICK_TYPE::EBrickType brickType; - - - // create or search the root container. - if(!parseGeneratorRootContainer(cur, rootTreeNode)) - return false; - - - // Read Brick specials. - prop = xmlGetProp (cur, (xmlChar*)"template_brick"); - if(prop) templateBrick= (const char*)prop; - else - { - nlwarning("prop 'template_brick' not found"); - return false; - } - prop = xmlGetProp (cur, (xmlChar*)"brick_window"); - if(prop) brickWindowBase= (const char*)prop; - else - { - nlwarning("prop 'brick_window' not found"); - return false; - } - // read the XStart for bricks that are in Jobs (not in career). - sint32 xstart=0; - prop = xmlGetProp (cur, (xmlChar*)"xstart"); - if(prop) fromString((const char*)prop, xstart); - - // Read BrickType - prop = xmlGetProp (cur, (xmlChar*)"brick_type"); - if(prop) - { - brickType= BRICK_TYPE::toBrickType((const char*)prop); - if(brickType == BRICK_TYPE::UNKNOWN) - { - nlwarning("'brick_type' UKNOWN in brick_suffix_generator (NB: none not allowed)"); - return false; - } - } - else - { - nlwarning("prop 'brick_type' not found"); - return false; - } - - - // **** Create All Suffix for the brickType. - const std::vector &bfs= pBM->getBrickSuffixes(brickType); - xmlNodePtr nextSibling=cur; - for(uint i=0;ins, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateBrick.c_str()); - xmlSetProp(node, (xmlChar*)"brick_family", (xmlChar*)toString(bfs[i].Family).c_str()); - xmlSetProp(node, (xmlChar*)"id", (xmlChar*)windowId.c_str() ); - xmlSetProp(node, (xmlChar*)"xstart", (xmlChar*)toString(xstart).c_str() ); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr brickTreeNode= xmlNewNode(nextSibling->ns, (xmlChar*)"tree" ); - xmlSetProp(brickTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it - xmlAddChild(rootTreeNode, brickTreeNode); - } - - return true;*/ } @@ -4501,53 +3950,6 @@ bool CInterfaceParser::solveStyle(xmlNodePtr cur) // *************************************************************************** -class CElementToSort -{ -public: - CInterfaceGroup *pIG; - float Distance; - bool operator< (const CElementToSort& other) const - { - // We want first farest views - return Distance > other.Distance; - } -}; - -void CInterfaceParser::SMasterGroup::sortWorldSpaceGroup () -{ - H_AUTO ( RZ_Interface_sortWorldSpaceGroup ) - - static vector sortTable; - sortTable.clear (); - - // Fill the sort table - list::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); - while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) - { - sortTable.push_back (CElementToSort ()); - CElementToSort &elm = sortTable.back(); - elm.pIG = *it; - elm.Distance = (static_cast(*it))->getDepthForZSort(); - - it++; - } - - // Sort the table - std::sort (sortTable.begin(), sortTable.end()); - - // Fill the final table - uint i = 0; - it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); - while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) - { - *it = sortTable[i].pIG; - - it++; - i++; - } -} - - #ifdef LUA_NEVRAX_VERSION class CLuaDebugBreakScreen : public IDebuggedAppMainLoop diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 6f318977e..81da7731c 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -26,6 +26,7 @@ #include "nel/misc/smart_ptr.h" #include "game_share/brick_types.h" #include "nel/gui/lua_helper.h" +#include "widget_manager.h" using namespace NLGUI; // *************************************************************************** @@ -40,16 +41,6 @@ class CInterfaceLink; class CBrickJob; class CCtrlBase; -// *************************************************************************** - -#define WIN_PRIORITY_MAX 8 -#define WIN_PRIORITY_WORLD_SPACE 0 -#define WIN_PRIORITY_LOWEST 1 -#define WIN_PRIORITY_LOW 2 -#define WIN_PRIORITY_NORMAL 3 -#define WIN_PRIORITY_HIGH 4 -#define WIN_PRIORITY_HIGHEST 5 - // *************************************************************************** /** * class managing the interface parsing @@ -66,34 +57,6 @@ public: CInterfaceParser(); virtual ~CInterfaceParser(); - struct SMasterGroup - { - SMasterGroup() - { - Group= NULL; - LastTopWindowPriority= WIN_PRIORITY_NORMAL; - } - - CInterfaceGroup *Group; - std::list PrioritizedWindows[WIN_PRIORITY_MAX]; - - void addWindow(CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL); - void delWindow(CInterfaceGroup *pIG); - CInterfaceGroup *getWindowFromId(const std::string &winID); - bool isWindowPresent(CInterfaceGroup *pIG); - // Set a window top in its priority queue - void setTopWindow(CInterfaceGroup *pIG); - void setBackWindow(CInterfaceGroup *pIG); - void deactiveAllContainers(); - void centerAllContainers(); - void unlockAllContainers(); - - // Sort the world space group - void sortWorldSpaceGroup (); - - uint8 LastTopWindowPriority; - }; - public: /** @@ -134,7 +97,7 @@ public: bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); - bool parseTree (xmlNodePtr cur, SMasterGroup *parentGroup); + bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool parseDefine(xmlNodePtr cur); @@ -166,7 +129,7 @@ public: bool parseLUAScript (xmlNodePtr cur); - bool setupTree (xmlNodePtr cur, SMasterGroup *parentGroup); + bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); // Called by each parse in parseXMLDocument @@ -197,13 +160,6 @@ public: /** * Accessors */ - - CInterfaceGroup* getMasterGroupFromId (const std::string &MasterGroupName); - const std::vector &getAllMasterGroup() { return _MasterGroups; } - SMasterGroup& getMasterGroup(uint8 i) { return _MasterGroups[i]; } - CInterfaceGroup* getWindowFromId (const std::string & groupId); - void addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG); - void removeWindowFromMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG); // access to control sheet selection CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; } @@ -267,7 +223,6 @@ public: void removeAllDefines(); void removeAllTemplates(); void removeAllAnims(); - void removeAllMasterGroups(); void removeAll(); // @} @@ -295,9 +250,6 @@ protected: CViewPointer *_Pointer; - // Master groups encapsulate all windows - std::vector _MasterGroups; - // Options description std::map > _OptionsMap; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 2209b9742..430f53f0c 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -2554,7 +2554,7 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls) { result->setId("ui:interface:"+string(ls.toString(2))); result->updateCoords(); - im->addWindowToMasterGroup("ui:interface", result); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", result); CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); result->setParent(pRoot); if (pRoot) diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index a4eae623c..ebd96ec5b 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -432,7 +432,7 @@ void CModalContainerEditCmd::create(const std::string &name, bool bDefKey, bool } WinName = "ui:interface:" + name; - pIM->addWindowToMasterGroup("ui:interface", Win); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", Win); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); Win->setParent(pRoot); pRoot->addGroup(Win); diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 395935aab..6664b1418 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -100,7 +100,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha // Root container CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); - im->addWindowToMasterGroup("ui:interface", gc); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", gc); gc->setParent(pRoot); pRoot->addGroup (gc); } diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp new file mode 100644 index 000000000..76ca72a8b --- /dev/null +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -0,0 +1,366 @@ +// Ryzom - MMORPG Framework +// 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 "widget_manager.h" +#include "interface_group.h" +#include "group_container.h" +#include "group_in_scene.h" + +CWidgetManager* CWidgetManager::instance = NULL; + +// ---------------------------------------------------------------------------- +// SMasterGroup +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio) +{ + nlassert(nPrio(pIG)!=NULL)); + + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + // If the element already exists in the list return ! + if (*it == pIG) + return; + it++; + } + } + PrioritizedWindows[nPrio].push_back(pIG); +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::delWindow(CInterfaceGroup *pIG) +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if ((*it) == pIG) + { + PrioritizedWindows[i].erase(it); + return; + } + it++; + } + } +} + +// ---------------------------------------------------------------------------- +CInterfaceGroup* CWidgetManager::SMasterGroup::getWindowFromId(const std::string &winID) +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if ((*it)->getId() == winID) + return *it; + it++; + } + } + return NULL; +} + +// ---------------------------------------------------------------------------- +bool CWidgetManager::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG) +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if ((*it) == pIG) + return true; + it++; + } + } + return false; +} + +// Set a window top in its priority queue +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::setTopWindow(CInterfaceGroup *pIG) +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if (*it == pIG) + { + PrioritizedWindows[i].erase(it); + PrioritizedWindows[i].push_back(pIG); + LastTopWindowPriority= i; + return; + } + it++; + } + } + // todo hulud interface syntax error + nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::setBackWindow(CInterfaceGroup *pIG) +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if (*it == pIG) + { + PrioritizedWindows[i].erase(it); + PrioritizedWindows[i].push_front(pIG); + return; + } + it++; + } + } + // todo hulud interface syntax error + nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::deactiveAllContainers() +{ + std::vector gcs; + + // Make first a list of all window (Warning: all group container are not window!) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainer *pGC = dynamic_cast(*it); + if (pGC != NULL) + gcs.push_back(pGC); + it++; + } + } + + // Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows, + // and hence invalidate its. + for (uint32 i = 0; i < gcs.size(); ++i) + { + gcs[i]->setActive(false); + } +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::centerAllContainers() +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainer *pGC = dynamic_cast(*it); + if ((pGC != NULL) && (pGC->getParent() != NULL)) + { + sint32 wParent = pGC->getParent()->getW(false); + sint32 w = pGC->getW(false); + pGC->setXAndInvalidateCoords((wParent - w) / 2); + sint32 hParent = pGC->getParent()->getH(false); + sint32 h = pGC->getH(false); + pGC->setYAndInvalidateCoords(h+(hParent - h) / 2); + } + + it++; + } + } +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::SMasterGroup::unlockAllContainers() +{ + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainer *pGC = dynamic_cast(*it); + if (pGC != NULL) + pGC->setLocked(false); + + it++; + } + } +} + +class CElementToSort +{ +public: + CInterfaceGroup *pIG; + float Distance; + bool operator< (const CElementToSort& other) const + { + // We want first farest views + return Distance > other.Distance; + } +}; + +void CWidgetManager::SMasterGroup::sortWorldSpaceGroup () +{ + static std::vector sortTable; + sortTable.clear (); + + // Fill the sort table + std::list::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); + while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) + { + sortTable.push_back (CElementToSort ()); + CElementToSort &elm = sortTable.back(); + elm.pIG = *it; + elm.Distance = (static_cast(*it))->getDepthForZSort(); + + it++; + } + + // Sort the table + std::sort (sortTable.begin(), sortTable.end()); + + // Fill the final table + uint i = 0; + it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); + while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) + { + *it = sortTable[i].pIG; + + it++; + i++; + } +} + + +CWidgetManager* CWidgetManager::getInstance() +{ + if( instance == NULL ) + instance = new CWidgetManager; + + return instance; +} + +void CWidgetManager::release() +{ + delete instance; + instance = NULL; +} + +// ---------------------------------------------------------------------------- +CInterfaceGroup* CWidgetManager::getMasterGroupFromId (const std::string &MasterGroupName) +{ + for (uint32 i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group->getId() == MasterGroupName) + return _MasterGroups[i].Group; + } + return NULL; +} + +// ---------------------------------------------------------------------------- +CInterfaceGroup* CWidgetManager::getWindowFromId (const std::string & groupId) +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CInterfaceGroup *pIG = rMG.getWindowFromId(groupId); + if (pIG != NULL) + return pIG; + } + return NULL; +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG) +{ + // Warning this function is not smart : its a o(n) ! + if (pIG == NULL) return; + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getId() == sMasterGroupName) + { + rMG.addWindow(pIG, pIG->getPriority()); + } + } +} + +// ---------------------------------------------------------------------------- +void CWidgetManager::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG) +{ + // Warning this function is not smart : its a o(n) ! + if (pIG == NULL) return; + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getId() == sMasterGroupName) + { + rMG.delWindow(pIG); + } + } +} + +void unlinkAllContainers (CInterfaceGroup *pIG) +{ + const std::vector &rG = pIG->getGroups(); + for(uint i = 0; i < rG.size(); ++i) + unlinkAllContainers (rG[i]); + + CGroupContainer *pGC = dynamic_cast(pIG); + if (pGC != NULL) + pGC->removeAllContainers(); +} + +// *************************************************************************** +void CWidgetManager::removeAllMasterGroups() +{ + uint i; + + for (i = 0; i < _MasterGroups.size(); ++i) + unlinkAllContainers (_MasterGroups[i].Group); + + // Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback + // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) + while(!_MasterGroups.empty()) + { + delete _MasterGroups.back().Group; + _MasterGroups.pop_back(); + } + +} + + + +CWidgetManager::CWidgetManager() +{ +} + +CWidgetManager::~CWidgetManager() +{ + for (uint32 i = 0; i < _MasterGroups.size(); ++i) + { + delete _MasterGroups[i].Group; + } +} \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h new file mode 100644 index 000000000..d70fcc99e --- /dev/null +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -0,0 +1,84 @@ +// Ryzom - MMORPG Framework +// 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 WIDGET_MANAGER_H +#define WIDGET_MANAGER_H + +#include +#include +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_common.h" + +class CInterfaceGroup; + +/// Manages the GUI widgets +class CWidgetManager{ +public: + + + struct SMasterGroup + { + SMasterGroup() + { + Group = NULL; + LastTopWindowPriority = WIN_PRIORITY_NORMAL; + } + + CInterfaceGroup *Group; + std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ]; + + void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL ); + void delWindow( CInterfaceGroup *pIG ); + CInterfaceGroup *getWindowFromId( const std::string &winID ); + bool isWindowPresent( CInterfaceGroup *pIG ); + // Set a window top in its priority queue + void setTopWindow( CInterfaceGroup *pIG ); + void setBackWindow( CInterfaceGroup *pIG ); + void deactiveAllContainers(); + void centerAllContainers(); + void unlockAllContainers(); + + // Sort the world space group + void sortWorldSpaceGroup (); + + uint8 LastTopWindowPriority; + }; + + + static CWidgetManager* getInstance(); + static void release(); + + CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName ); + std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; } + SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; } + CInterfaceGroup* getWindowFromId( const std::string &groupId ); + void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); + void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); + void removeAllMasterGroups(); + +private: + CWidgetManager(); + ~CWidgetManager(); + + static CWidgetManager *instance; + + // Master groups encapsulate all windows + std::vector< SMasterGroup > _MasterGroups; +}; + +#endif + diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 26104a445..467991245 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -1285,7 +1285,7 @@ void impulseBeginTrade(NLMISC::CBitMemStream &impulse) { if (PermanentlyBanned) return; //open trade window - CInterfaceGroup* win = CInterfaceManager::getInstance()->getWindowFromId("ui:interface:trade"); + CInterfaceGroup* win = CWidgetManager::getInstance()->getWindowFromId("ui:interface:trade"); if (!win) { nlwarning("invalid interface ui:interface:trade"); diff --git a/code/ryzom/client/src/r2/displayer_visual.cpp b/code/ryzom/client/src/r2/displayer_visual.cpp index d46607f55..6caa4127f 100644 --- a/code/ryzom/client/src/r2/displayer_visual.cpp +++ b/code/ryzom/client/src/r2/displayer_visual.cpp @@ -441,7 +441,7 @@ void CDisplayerVisual::onPostRender() else { // Link to the interface - pIM->addWindowToMasterGroup("ui:interface", group); + CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 46bfafbac..aad491c3f 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -636,6 +636,7 @@ void release() NLNET::IModuleManager::releaseInstance(); delete &CLuaManager::getInstance(); NLGUI::CDBManager::release(); + CWidgetManager::release(); From 2e9fe265f269f7795580a61f13208548291f8708 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 31 May 2012 04:27:27 +0200 Subject: [PATCH 038/339] CHANGED: #1471 Moved some more code from CInterfaceManager to CWidgetManager ( mostly widget lookup, modal handling, pointer, etc ) --- code/ryzom/client/src/commands.cpp | 8 +- code/ryzom/client/src/connection.cpp | 58 +- code/ryzom/client/src/contextual_cursor.cpp | 2 +- code/ryzom/client/src/continent_manager.cpp | 6 +- code/ryzom/client/src/cursor_functions.cpp | 6 +- code/ryzom/client/src/entities.cpp | 8 +- code/ryzom/client/src/entity_cl.cpp | 4 +- code/ryzom/client/src/far_tp.cpp | 6 +- code/ryzom/client/src/fog_map.cpp | 2 +- code/ryzom/client/src/init_main_loop.cpp | 18 +- code/ryzom/client/src/input.cpp | 12 +- .../src/interface_v3/action_handler.cpp | 30 +- .../src/interface_v3/action_handler_game.cpp | 70 +- .../src/interface_v3/action_handler_help.cpp | 18 +- .../src/interface_v3/action_handler_item.cpp | 116 ++-- .../src/interface_v3/action_handler_misc.cpp | 22 +- .../src/interface_v3/action_handler_move.cpp | 2 +- .../interface_v3/action_handler_outpost.cpp | 4 +- .../interface_v3/action_handler_phrase.cpp | 38 +- .../src/interface_v3/action_handler_ui.cpp | 30 +- .../src/interface_v3/action_phrase_faber.cpp | 58 +- .../client/src/interface_v3/bot_chat_page.cpp | 2 +- .../bot_chat_page_create_guild.cpp | 6 +- .../bot_chat_page_dynamic_mission.cpp | 4 +- .../interface_v3/bot_chat_page_mission.cpp | 6 +- .../bot_chat_page_mission_end.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 76 +-- .../client/src/interface_v3/chat_window.cpp | 14 +- .../src/interface_v3/ctrl_base_button.cpp | 4 +- .../client/src/interface_v3/ctrl_scroll.cpp | 6 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 18 +- .../src/interface_v3/dbgroup_combo_box.cpp | 12 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 16 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 14 +- .../dbgroup_list_sheet_text_share.cpp | 4 +- .../src/interface_v3/encyclopedia_manager.cpp | 30 +- .../client/src/interface_v3/group_compas.cpp | 12 +- .../src/interface_v3/group_container.cpp | 24 +- .../client/src/interface_v3/group_editbox.cpp | 4 +- .../client/src/interface_v3/group_header.cpp | 2 +- .../client/src/interface_v3/group_html.cpp | 8 +- .../src/interface_v3/group_html_qcm.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 6 +- .../interface_v3/group_in_scene_bubble.cpp | 30 +- .../interface_v3/group_in_scene_user_info.cpp | 4 +- .../client/src/interface_v3/group_list.cpp | 6 +- .../client/src/interface_v3/group_map.cpp | 50 +- .../client/src/interface_v3/group_menu.cpp | 16 +- .../src/interface_v3/group_modal_get_key.cpp | 12 +- .../src/interface_v3/group_paragraph.cpp | 6 +- .../group_phrase_skill_filter.cpp | 2 +- .../src/interface_v3/group_quick_help.cpp | 6 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 8 +- .../client/src/interface_v3/guild_manager.cpp | 70 +- .../interface_v3/input_handler_manager.cpp | 4 +- .../src/interface_v3/interface_3d_scene.cpp | 6 +- .../src/interface_v3/interface_config.cpp | 10 +- .../client/src/interface_v3/interface_ddx.cpp | 4 +- .../interface_expr_user_fct_game.cpp | 4 +- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_group.cpp | 2 +- .../src/interface_v3/interface_link.cpp | 4 +- .../src/interface_v3/interface_manager.cpp | 612 ++++-------------- .../src/interface_v3/interface_manager.h | 95 +-- .../src/interface_v3/interface_parser.cpp | 9 +- .../src/interface_v3/interface_parser.h | 2 - .../src/interface_v3/inventory_manager.cpp | 136 ++-- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 22 +- .../client/src/interface_v3/macrocmd_key.cpp | 94 +-- .../src/interface_v3/macrocmd_manager.cpp | 42 +- .../client/src/interface_v3/music_player.cpp | 2 +- .../client/src/interface_v3/obs_huge_list.cpp | 16 +- .../src/interface_v3/people_interraction.cpp | 40 +- .../client/src/interface_v3/people_list.cpp | 12 +- .../client/src/interface_v3/player_trade.cpp | 4 +- .../client/src/interface_v3/skill_manager.cpp | 4 +- .../src/interface_v3/sphrase_manager.cpp | 20 +- .../src/interface_v3/task_bar_manager.cpp | 6 +- .../src/interface_v3/view_bitmap_combo.cpp | 10 +- .../client/src/interface_v3/view_pointer.cpp | 6 +- .../client/src/interface_v3/view_text.cpp | 6 +- .../src/interface_v3/widget_manager.cpp | 351 ++++++++++ .../client/src/interface_v3/widget_manager.h | 115 +++- code/ryzom/client/src/login.cpp | 104 +-- code/ryzom/client/src/main_loop.cpp | 32 +- .../ryzom/client/src/motion/modes/ai_mode.cpp | 2 +- .../ryzom/client/src/motion/user_controls.cpp | 4 +- code/ryzom/client/src/net_manager.cpp | 76 +-- code/ryzom/client/src/outpost_manager.cpp | 6 +- code/ryzom/client/src/player_cl.cpp | 2 +- code/ryzom/client/src/r2/displayer_visual.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 30 +- code/ryzom/client/src/r2/npc_editor.cpp | 2 +- code/ryzom/client/src/r2/tool.cpp | 6 +- .../ryzom/client/src/session_browser_impl.cpp | 2 +- code/ryzom/client/src/user_entity.cpp | 6 +- 97 files changed, 1446 insertions(+), 1470 deletions(-) diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 70d435f6f..3f97ff83d 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -3318,7 +3318,7 @@ NLMISC_COMMAND(loadIntCfg, "load the interface config file","") CInterfaceManager *im = CInterfaceManager::getInstance(); im->loadConfig ("save/interface.icfg"); // reset the compass target - CGroupCompas *gc = dynamic_cast(im->getElementFromId("ui:interface:compass")); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); if (gc && gc->isSavedTargetValid()) { gc->setTarget(gc->getSavedTarget()); @@ -3341,7 +3341,7 @@ NLMISC_COMMAND(harvestDeposit, "harvest a deposit", "") NetMngr.push(out); // open the interface - // CInterfaceManager::getInstance()->getWindowFromId("ui:interface:harvest")->setActive(true); + // CWidgetManager::getInstance()->getWindowFromId("ui:interface:harvest")->setActive(true); } else nlwarning("command : unknown message name : 'HARVEST:DEPOSIT'"); @@ -4960,7 +4960,7 @@ NLMISC_COMMAND(dumpUICoords, "Debug only : dump all coords info of an UI", "uiid return false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *el= pIM->getElementFromId(args[0]); + CInterfaceElement *el= CWidgetManager::getInstance()->getElementFromId(args[0]); if(!el) { pIM->displaySystemInfo(toString("dumpUICoords: '%s' does not exist", args[0].c_str())); @@ -5497,7 +5497,7 @@ NLMISC_COMMAND(clear, "clear content of current char window", "(im->getElementFromId(args[0]))); + cw = getChatWndMgr().getChatWindowFromCaller(dynamic_cast(CWidgetManager::getInstance()->getElementFromId(args[0]))); } else { diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index d2efd56bb..e6017ea6b 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -235,7 +235,7 @@ class CAHOnReloadTestPage: public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // need to reset password and current screen - CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); + CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER)); pGH->browse(ClientCfg.TestBrowserUrl.c_str()); @@ -250,7 +250,7 @@ void initWebBrowser() //NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // start the browser - CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); + CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER)); if (pGH) { @@ -388,7 +388,7 @@ bool connection (const string &cookie, const string &fsaddr) WaitServerAnswer = true; }*/ - pIM->activateMasterGroup ("ui:outgame", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", true); NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(ClientCfg.Local ? 6 : -1); // TMP TMP IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); @@ -552,7 +552,7 @@ bool reconnection() // Start the finite state machine TInterfaceState InterfaceState = GLOBAL_MENU; - pIM->activateMasterGroup ("ui:outgame", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", true); NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(-1); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); @@ -825,7 +825,7 @@ void updateBGDownloaderUI() static NLMISC::CRefPtr bgDownloaderWindow; if (!bgDownloaderWindow) { - bgDownloaderWindow = im->getElementFromId("ui:interface:bg_downloader"); + bgDownloaderWindow = CWidgetManager::getInstance()->getElementFromId("ui:interface:bg_downloader"); } bgWindowVisible = bgDownloaderWindow && bgDownloaderWindow->getActive(); } @@ -992,12 +992,12 @@ TInterfaceState globalMenu() { pIM->uninitOutGame(); pIM->initOutGame(); - pIM->activateMasterGroup ("ui:outgame", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", true); NLGUI::CDBManager::getInstance()->getDbProp ("UI:CURRENT_SCREEN")->setValue32(2); // TMP TMP IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); - pIM->getElementFromId("ui:outgame:charsel")->setActive(false); - pIM->getElementFromId("ui:outgame:charsel")->setActive(true); + CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")->setActive(false); + CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")->setActive(true); // Active inputs Actions.enable(true); EditActions.enable(true); @@ -1024,7 +1024,7 @@ TInterfaceState globalMenu() else { // Display the firewall alert string - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:outgame:connecting:title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title")); if (pVT != NULL) pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); @@ -1229,7 +1229,7 @@ TInterfaceState globalMenu() if ( firewallTimeout ) { // Display the firewall error string instead of the normal failure string - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:outgame:crashing:title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:crashing:title")); if (pVT != NULL) { pVT->setMultiLine( true ); @@ -1300,7 +1300,7 @@ public: for (i = 0; i < CharacterSummaries.size(); ++i) { CCharacterSummary &rCS = CharacterSummaries[i]; - CInterfaceElement *pIE = pIM->getElementFromId(sPath+":text"+NLMISC::toString(i)); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)); CViewText *pVT = dynamic_cast(pIE); if (pVT == NULL) return; @@ -1312,7 +1312,7 @@ public: // 5 slots for (; i < 5; ++i) { - CViewText *pVT = dynamic_cast(pIM->getElementFromId(sPath+":text"+NLMISC::toString(i))); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i))); if (pVT == NULL) return; pVT->setText(CI18N::get("uiEmptySlot")); } @@ -1492,7 +1492,7 @@ public: { string sDBLink = getParam(Params, "dblink"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE = pIM->getElementFromId(pCaller->getId(), sDBLink); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), sDBLink); CInterfaceGroup *pIG = dynamic_cast(pIE); if (pIG == NULL) return; @@ -1662,7 +1662,7 @@ public: string sEditBoxPath = getParam (Params, "name"); ucstring sFirstName = ucstring("NotSet"); ucstring sSurName = ucstring("NotSet"); - CGroupEditBox *pGEB = dynamic_cast(pIM->getElementFromId(sEditBoxPath)); + CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath)); if (pGEB != NULL) sFirstName = pGEB->getInputString(); else @@ -2118,7 +2118,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_MAINLAND)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); if (pList == NULL) { nlwarning("element "GROUP_LIST_MAINLAND" not found probably bad outgame.xml"); @@ -2175,7 +2175,7 @@ public: } } - CCtrlButton *pCB = dynamic_cast(pIM->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(Mainlands[defaultMainland].Id)+":but")); + CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(Mainlands[defaultMainland].Id)+":but")); if (pCB != NULL) { pCB->setPushed(true); @@ -2196,7 +2196,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_MAINLAND)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); pList->clearGroups(); } }; @@ -2216,7 +2216,7 @@ class CAHMainlandSelect : public IActionHandler // Unselect if (MainlandSelected.asInt() != 0) { - pCB = dynamic_cast(pIM->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(MainlandSelected)+":but")); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(MainlandSelected)+":but")); if (pCB != NULL) pCB->setPushed(false); } @@ -2311,7 +2311,7 @@ public: PrevLine = NULL; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - List = dynamic_cast(pIM->getElementFromId(GROUP_LIST_KEYSET)); + List = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); if (List == NULL) { nlwarning("element "GROUP_LIST_KEYSET" not found probably bad outgame.xml"); @@ -2437,7 +2437,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_KEYSET)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); pList->clearGroups(); } }; @@ -2476,7 +2476,7 @@ public: } }; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup * list = dynamic_cast(pIM->getElementFromId(GROUP_LIST_KEYSET)); + CInterfaceGroup * list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); if (list) { CUnpush unpusher; @@ -2635,7 +2635,7 @@ class CAHScenarioControl : public IActionHandler nlinfo("CAHScenarioControl called"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* scenarioWnd = dynamic_cast(pIM->getElementFromId("ui:interface:r2ed_scenario_control")); + CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control")); if(!scenarioWnd) return; // -------- active some groups in function of Ryzom mode or Edition/Animation mode ---- @@ -2846,7 +2846,7 @@ class CAHScenarioInformation : public IActionHandler nlinfo("CAHScenarioDescription called"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* scenarioWnd = dynamic_cast(pIM->getElementFromId("ui:interface:r2ed_scenario_control")); + CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control")); if(!scenarioWnd) return; CInterfaceElement *result = scenarioWnd->findFromShortId(string("scenario_value_text")); @@ -2890,7 +2890,7 @@ class CAHHideCharsFilters : public IActionHandler nlinfo("CAHHideCharsFilters called"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* scenarioWnd = dynamic_cast(pIM->getElementFromId("ui:interface:r2ed_scenario_control")); + CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control")); if(!scenarioWnd) return; bool lookingForPlayers = true; @@ -2937,7 +2937,7 @@ class CAHLoadScenario : public IActionHandler nlinfo("CAHLoadScenario called"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* scenarioWnd = dynamic_cast(pIM->getElementFromId("ui:interface:r2ed_scenario_control")); + CInterfaceGroup* scenarioWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control")); if(!scenarioWnd) return; CInterfaceElement *result = NULL; @@ -3226,7 +3226,7 @@ class CAHLoadScenario : public IActionHandler bool noob = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:IS_NEWBIE")->getValueBool(); if (FreeTrial && noob && (nevraxScenario != "1" || trialAllowed != "1")) { - CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); + CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); @@ -3307,7 +3307,7 @@ class CAHLoadScenario : public IActionHandler if(sessionBrowser._LastInvokeResult == 14) { - CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); + CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); @@ -3336,7 +3336,7 @@ class CAHLoadScenario : public IActionHandler if(sessionBrowser._LastInvokeResult == 14) { - CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); + CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); @@ -3406,7 +3406,7 @@ class CAHOpenRingSessions : public IActionHandler if(!R2::getEditor().isInitialized()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* ringSessionsWnd = dynamic_cast(pIM->getElementFromId("ui:interface:ring_sessions")); + CInterfaceGroup* ringSessionsWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:ring_sessions")); if(!ringSessionsWnd) return; ringSessionsWnd->setActive(true); } diff --git a/code/ryzom/client/src/contextual_cursor.cpp b/code/ryzom/client/src/contextual_cursor.cpp index 27a9f2863..ded0866e6 100644 --- a/code/ryzom/client/src/contextual_cursor.cpp +++ b/code/ryzom/client/src/contextual_cursor.cpp @@ -143,7 +143,7 @@ bool CContextualCursor::context(const std::string &contextName, float dist, cons CInterfaceManager *IM = CInterfaceManager::getInstance(); if(IM) { - CViewPointer *cursor = IM->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { if (!functions.isString) diff --git a/code/ryzom/client/src/continent_manager.cpp b/code/ryzom/client/src/continent_manager.cpp index ec2a03f69..e8ac1f824 100644 --- a/code/ryzom/client/src/continent_manager.cpp +++ b/code/ryzom/client/src/continent_manager.cpp @@ -368,10 +368,10 @@ void CContinentManager::select(const string &name, const CVectorD &pos, NLMISC:: if (pWS->Maps[i].ContinentName == name) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId("ui:interface:map:content:map_content:actual_map")); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap != NULL) pMap->setMap(pWS->Maps[i].Name); - pMap = dynamic_cast(pIM->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); + pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); if (pMap != NULL) pMap->setMap(pWS->Maps[i].Name); break; @@ -549,7 +549,7 @@ void CContinentManager::checkNumberOfUserLandmarks( uint maxNumber ) // Just cut down the last landmarks (in case of hacked file) if ( cont == _Current ) { - CGroupMap *pMap = dynamic_cast(CInterfaceManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if ( pMap ) pMap->removeExceedingUserLandMarks( maxNumber ); } diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 312dd589e..7e64c644e 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -239,7 +239,7 @@ void checkUnderCursor() return; // Get the cursor instance - CViewPointer *cursor = IM->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor == 0) return; @@ -874,8 +874,8 @@ void contextWebPage(bool rightClick, bool dblClick) void contextWebIG(bool rightClick, bool dblClick) { CInterfaceManager *IM = CInterfaceManager::getInstance(); - CInterfaceElement *pGC = IM->getElementFromId("ui:interface:bot_chat_object"); - CInterface3DShape *el= dynamic_cast(IM->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1")); + CInterfaceElement *pGC = CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object"); + CInterface3DShape *el= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1")); if (el != NULL) { el->setName(selectedInstance.getShapeName()); diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp index 37bd0293c..68abecadb 100644 --- a/code/ryzom/client/src/entities.cpp +++ b/code/ryzom/client/src/entities.cpp @@ -132,7 +132,7 @@ public : entity->updateMissionTarget(); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupCompas *gc = dynamic_cast(im->getElementFromId("ui:interface:compass")); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); // if new target title is not NULL, then show the compass and make it blink to indicate new location // please note that the first time the player login, a target has not been saved in his config file, so // we permit the first (and only one) mission that is received to become the new compass direction (chiang the strong ...) @@ -159,7 +159,7 @@ public : if (leaf->getOldValue32() != 0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupCompas *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:compass")); + CGroupCompas *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); if (pGC == NULL) { nlwarning("Can't retrieve compass group"); @@ -198,7 +198,7 @@ public : // { // _AlreadyReceived.insert(name); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupCompas *gc = dynamic_cast(im->getElementFromId("ui:interface:compass")); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); if (!gc) { nlwarning("Can't retrieve compass group"); @@ -223,7 +223,7 @@ public : gc->setTarget(ct); gc->blink(); gc->enableBlink(2); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); } } } diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index 690bb12da..b05c8ae69 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -2331,10 +2331,10 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value) if (_Slot == 0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:interface:player:header_opened:player_title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); if (pVT != NULL) pVT->setText(_Title); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:player")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player")); if (pGC != NULL) pGC->setUCTitle(_EntityName); CSkillManager *pSM = CSkillManager::getInstance(); diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index a7e4ebb94..dec9aed6f 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -861,12 +861,12 @@ retryJoinEdit: // pIM->runActionHandler( "proc", NULL, "charsel_disable_buttons" ); // pIM->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:quit_but:active|value=1" ); - CInterfaceElement *btnOk = pIM->getElementFromId("ui:outgame:charsel:message_box:ok"); + CInterfaceElement *btnOk = CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel:message_box:ok"); if (btnOk) btnOk->setActive( ! requestRetToMainland ); // Hide the black screen i.e. force showing the interface - CInterfaceElement *charSelBlackScreen = pIM->getElementFromId("ui:outgame:charsel:black_screen"); + CInterfaceElement *charSelBlackScreen = CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel:black_screen"); if (charSelBlackScreen) { CViewBase *charSelBlackScreenBitmap = dynamic_cast(charSelBlackScreen); @@ -928,7 +928,7 @@ retryJoinEdit: pIM->runActionHandler( "proc", NULL, "charsel_enable_buttons" ); pIM->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:create_new_but:active|value=0" ); - CInterfaceGroup* charselGroup = dynamic_cast(pIM->getElementFromId("ui:outgame:charsel")); + CInterfaceGroup* charselGroup = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")); if(charselGroup) pIM->runActionHandler( "proc", charselGroup, "charsel_init_buttons" ); } diff --git a/code/ryzom/client/src/fog_map.cpp b/code/ryzom/client/src/fog_map.cpp index 78cd7ecda..e8352e5c3 100644 --- a/code/ryzom/client/src/fog_map.cpp +++ b/code/ryzom/client/src/fog_map.cpp @@ -79,7 +79,7 @@ void CFogMap::getFogParams(float startDist, float endDist, float x, float y, flo float ddMx = x; float ddMy = y; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *gm = dynamic_cast(im->getElementFromId("ui:interface:map:content:map_content:actual_map")); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (gm && gm->isIsland()) { CVector front = MainCam.getMatrix().getJ(); diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index caa765af5..6a79b0de3 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -1187,8 +1187,8 @@ void initMainLoop() ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); //CDebugInit dbg; //dbg.init(&Driver->EventServer); - CInterfaceManager::getInstance()->activateMasterGroup("ui:login", false); - CInterfaceManager::getInstance()->activateMasterGroup("ui:interface", true); + CWidgetManager::getInstance()->activateMasterGroup("ui:login", false); + CWidgetManager::getInstance()->activateMasterGroup("ui:interface", true); } @@ -1485,7 +1485,7 @@ void setLoadingContinent (CContinent *continent) void initWelcomeWindow() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup* welcomeWnd = dynamic_cast(pIM->getElementFromId("ui:interface:welcome_info")); + CInterfaceGroup* welcomeWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:welcome_info")); if(welcomeWnd) { bool welcomeDbProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:WELCOME")->getValueBool(); @@ -1518,11 +1518,11 @@ void initHardwareCursor(bool secondCall) // else, only the first time after this patch, open popup to propose hardare cursor mode else { - CInterfaceGroup * cursorWnd = dynamic_cast(pIM->getElementFromId("ui:interface:hardware_cursor")); + CInterfaceGroup * cursorWnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:hardware_cursor")); if(cursorWnd) { cursorWnd->setActive((sb.CurrentJoinMode!=CFarTP::LaunchEditor) || secondCall); - pIM->setTopWindow(cursorWnd); + CWidgetManager::getInstance()->setTopWindow(cursorWnd); cursorWnd->updateCoords(); cursorWnd->center(); } @@ -1546,25 +1546,25 @@ void initBloomConfigUI() bool supportBloom = Driver->supportBloomEffect(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlBaseButton* button = dynamic_cast(pIM->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:bloom:c")); + CCtrlBaseButton* button = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:bloom:c")); if(button) { button->setFrozen(!supportBloom); } - button = dynamic_cast(pIM->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:square_bloom:c")); + button = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:square_bloom:c")); if(button) { button->setFrozen(!supportBloom); } - CCtrlScroll * scroll = dynamic_cast(pIM->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:density_bloom:c")); + CCtrlScroll * scroll = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_config:content:fx:bloom_gr:density_bloom:c")); if(scroll) { scroll->setFrozen(!supportBloom); } - CInterfaceGroup* group = dynamic_cast(pIM->getElementFromId("ui:interface:game_config:content:fx:bloom_gr")); + CInterfaceGroup* group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_config:content:fx:bloom_gr")); if(!supportBloom) { diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index 0d0e2c4ca..3d67c2455 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -124,7 +124,7 @@ bool InitMouseWithCursor (bool hardware) { Driver->showCursor(true); - CViewPointer *pointer = CInterfaceManager::getInstance()->getPointer(); + CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); if (pointer) { float x = (float)pointer->getX()/(float)Driver->getWindowWidth(); @@ -145,7 +145,7 @@ bool InitMouseWithCursor (bool hardware) else { CInterfaceManager *pIm = CInterfaceManager::getInstance(); - CViewPointer *vp = pIm->getPointer(); + CViewPointer *vp = CWidgetManager::getInstance()->getPointer(); Driver->showCursor(false); SetMousePosFirstTime = false; if (vp) @@ -247,7 +247,7 @@ void SetMouseFreeLook () CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CViewPointer *pointer = im->getPointer(); + CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); if (pointer) pointer->show (false); } @@ -281,7 +281,7 @@ void SetMouseCursor (bool updatePos) if (instance) { // Get the cursor instance - CViewPointer *cursor = instance->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if (cursor) { sint32 ix, iy; @@ -319,7 +319,7 @@ void SetMouseCursor (bool updatePos) if (instance) { // Get the cursor instance - CViewPointer *cursor = instance->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if (cursor) { cursor->setPointerPos(ix, iy); @@ -342,7 +342,7 @@ void SetMouseCursor (bool updatePos) CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CViewPointer *pointer = im->getPointer(); + CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); if (pointer) pointer->show (true); } diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index d826a2dea..7cc097492 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -290,7 +290,7 @@ public: if (ig == NULL) { string elt = property.substr(0,property.rfind(':')); - CInterfaceElement *pIE = pIM->getElementFromId(elt); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); ig = dynamic_cast(pIE); if (ig == NULL && pIE != NULL) ig = pIE->getParent(); @@ -401,7 +401,7 @@ public: sint32 limit; fromString(getParam(Params, "limit"), limit); - CInterfaceElement *pIE = pIM->getElementFromId (pCaller->getId(), elt); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), elt); if (pIE == NULL) return; sint32 newW = pIE->getW(); @@ -432,9 +432,9 @@ public: string target = getParam (Params, "target"); CGroupEditBox *geb; if (pCaller == NULL) - geb = dynamic_cast(pIM->getElementFromId (target)); + geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (target)); else - geb = dynamic_cast(pIM->getElementFromId (pCaller->getId(), target)); + geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), target)); if (geb == NULL) { nlwarning(" Can't get target edit box %s, or bad type", target.c_str()); @@ -514,7 +514,7 @@ class CAHActiveMenu : public IActionHandler // open the menu if (CDBCtrlSheet::getDraggedSheet() == NULL) { - CInterfaceManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu")); + CWidgetManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu")); } } }; @@ -541,9 +541,9 @@ class CAHSetServerString : public IActionHandler string elt = sTarget.substr(0,sTarget.rfind(':')); CInterfaceElement *pIE; if (pCaller != NULL) - pIE = pIM->getElementFromId(pCaller->getId(), elt); + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); else - pIE = pIM->getElementFromId(elt); + pIE = CWidgetManager::getInstance()->getElementFromId(elt); if (pIE == NULL) return; sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); } @@ -581,9 +581,9 @@ class CAHSetServerID : public IActionHandler string elt = sTarget.substr(0,sTarget.rfind(':')); CInterfaceElement *pIE; if (pCaller != NULL) - pIE = pIM->getElementFromId(pCaller->getId(), elt); + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); else - pIE = pIM->getElementFromId(elt); + pIE = CWidgetManager::getInstance()->getElementFromId(elt); if (pIE == NULL) return; sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); } @@ -626,9 +626,9 @@ class CAHResetCamera : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceElement *pIE; if (pCaller != NULL) - pIE = pIM->getElementFromId(pCaller->getId(), sTarget); + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), sTarget); else - pIE = pIM->getElementFromId(sTarget); + pIE = CWidgetManager::getInstance()->getElementFromId(sTarget); CInterface3DCamera *pCam = dynamic_cast(pIE); if (pCam == NULL) return; pCam->reset(); @@ -726,7 +726,7 @@ public: // Enable 'use global alpha' button NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1); // show the modal box - im->enableModalWindow(gc, "ui:interface:define_ui_transparency"); + CWidgetManager::getInstance()->enableModalWindow(gc, "ui:interface:define_ui_transparency"); } @@ -819,7 +819,7 @@ class CAHSetTransparent : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pGC != NULL) { pGC->setUseGlobalAlpha(false); @@ -844,7 +844,7 @@ class CAHSetAlpha : public IActionHandler uint8 alpha; fromString(getParam (Params, "alpha"), alpha); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(ui)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(ui)); if (pGC != NULL) { pGC->setUseGlobalAlpha(false); @@ -1033,7 +1033,7 @@ class CAHPopup : public IActionHandler sCont = eVal.getString(); if (sCont.empty()) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(sCont)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sCont)); if (pGC == NULL) return; if (pGC->isPopuped()) return; pGC->setHighLighted(false); diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 2d6ee545d..cf3f89251 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -227,7 +227,7 @@ class CHandlerContextRingSessions : public IActionHandler // when player go away) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE = pIM->getElementFromId("ui:interface:ring_sessions"); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:ring_sessions"); // check if selection is a Ring terminal CEntityCL * selection = EntitiesMngr.entity(UserEntity->selection()); @@ -1383,11 +1383,11 @@ void CSelectItemSheet::showItemFlags(CInterfaceManager *im,bool canUse,bool canB if (!im) return; CInterfaceGroup *gr; #define BOT_CHAT_TRADE_PATH "ui:interface:bot_chat_trade:header_opened:trade_content:" - gr = dynamic_cast( im->getElementFromId(BOT_CHAT_TRADE_PATH "cant_use_item")); + gr = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(BOT_CHAT_TRADE_PATH "cant_use_item")); if (gr) gr->setActive(!canUse); - gr = dynamic_cast(im->getElementFromId(BOT_CHAT_TRADE_PATH "cant_use_built_item")); + gr = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(BOT_CHAT_TRADE_PATH "cant_use_built_item")); if (gr) gr->setActive(!canUseBuiltItem); - gr = dynamic_cast(im->getElementFromId(BOT_CHAT_TRADE_PATH "cant_build_item")); + gr = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(BOT_CHAT_TRADE_PATH "cant_build_item")); if (gr) gr->setActive(!canBuild); } @@ -1671,7 +1671,7 @@ class CHandlerAnimalOpenInventory : public IActionHandler if(animalIndex>=1 && animalIndex<=MAX_INVENTORY_ANIMAL) { // show/hide the inventory - CInterfaceElement *group= pIM->getElementFromId(toString("ui:interface:inv_pa%d", animalIndex-1) ); + CInterfaceElement *group= CWidgetManager::getInstance()->getElementFromId(toString("ui:interface:inv_pa%d", animalIndex-1) ); if(group) group->setActive(!group->getActive()); } @@ -1687,7 +1687,7 @@ REGISTER_ACTION_HANDLER( CHandlerAnimalOpenInventory, "animal_open_inventory" ); static void closeGroup(const string &groupName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pIG = dynamic_cast(pIM->getElementFromId(groupName)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(groupName)); if (pIG == NULL) return; pIG->setActive(false); } @@ -1883,7 +1883,7 @@ public: helpContainer = "ui:interface:help_browser"; // open the help browser - CInterfaceElement *pIG= pIM->getElementFromId(helpContainer); + CInterfaceElement *pIG= CWidgetManager::getInstance()->getElementFromId(helpContainer); if(pIG) pIG->setActive(true); @@ -1907,9 +1907,9 @@ static bool findInterfacePath(string &sPath, CCtrlBase *pCaller) string elt = sPath.substr(0,sPath.rfind(':')); CInterfaceElement *pIE; if (pCaller != NULL) - pIE = pIM->getElementFromId(pCaller->getId(), elt); + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); else - pIE = pIM->getElementFromId(elt); + pIE = CWidgetManager::getInstance()->getElementFromId(elt); if (pIE == NULL) return false; sPath = pIE->getId() + ":" + sPath.substr(sPath.rfind(':')+1,sPath.size()); } @@ -2071,17 +2071,17 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler // Access UI elements if (sSlot.empty()) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewBitmap *pVBR = dynamic_cast(pIM->getElementFromId(sTargetRegion)); + CViewBitmap *pVBR = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTargetRegion)); if (pVBR == NULL) return; - CViewBitmap *pVBL = dynamic_cast(pIM->getElementFromId(sTargetLevel)); + CViewBitmap *pVBL = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTargetLevel)); if (pVBL == NULL) return; CInterfaceExprValue evValue; if (!CInterfaceExpr::eval(sSlot, evValue, NULL)) return; sint32 nSlot = (sint32)evValue.getInteger(); - CCtrlBase *pTooltip = dynamic_cast(pIM->getElementFromId("ui:interface:target:header_opened:force")); + CCtrlBase *pTooltip = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force")); // Access target entity CEntityCL *pE = NULL; @@ -2167,7 +2167,7 @@ class CActionHandlerSetTargetForceRegionLevel: public IActionHandler pVBL->setTexture(sTexture); // Set tooltip - CCtrlBase *tooltip = dynamic_cast(pIM->getElementFromId("ui:interface:target:header_opened:force")); + CCtrlBase *tooltip = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:header_opened:force")); if (tooltip) { ucstring str; @@ -2750,13 +2750,13 @@ public: }*/ CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:gestion_windows")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows")); if (pGC == NULL) { nlwarning("gestion_windows not found as a container"); return; } - CInterfaceElement *pIE = pIM->getElementFromId("ui:interface:gestion_windows:close"); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows:close"); if (pIE != NULL) pIE->setActive(false); CActionsManager *pAM = &Actions; @@ -2783,7 +2783,7 @@ public: // Show the container pGC->setActive(true); // Yoyo: important to setTopWindow ONLY if needed, else save of the TopWindow doesn't work when you switch it. - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); } } } @@ -2837,7 +2837,7 @@ class CHandlerCloseAllLabosBut : public IActionHandler // if not the excluded one if( Params != laboWindows[i] ) { - CInterfaceElement *pElt= pIM->getElementFromId(laboWindows[i]); + CInterfaceElement *pElt= CWidgetManager::getInstance()->getElementFromId(laboWindows[i]); if(pElt) pElt->setActive(false); } @@ -2866,12 +2866,12 @@ class CHandlerToggleInventory : public IActionHandler // For all labos bool state = false; - CInterfaceElement *pElt= pIM->getElementFromId(inventoryWindows[0]); + CInterfaceElement *pElt= CWidgetManager::getInstance()->getElementFromId(inventoryWindows[0]); if (pElt) state = !pElt->getActive(); for(uint i=0;igetElementFromId(inventoryWindows[i]); + pElt= CWidgetManager::getInstance()->getElementFromId(inventoryWindows[i]); if(pElt) pElt->setActive(state); } @@ -2922,7 +2922,7 @@ public: // Initialize interface combo box CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); + CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB ) { pCB->resetTexts(); @@ -2934,7 +2934,7 @@ public: NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(-1); NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(nFoundMode); - CCtrlBaseButton *pBut = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); if (pBut) { if (ClientCfg.Windowed) @@ -2946,7 +2946,7 @@ public: // **** Init Texture Size Modes // init the combo box, according to Texture Installed or not - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_TEXTURE_MODE_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_TEXTURE_MODE_COMBO )); if( pCB ) { pCB->resetTexts(); @@ -3008,7 +3008,7 @@ class CHandlerGameConfigMode : public IActionHandler sint nVideModeNb = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->getValue32(); if (nVideModeNb == -1) return; - CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); + CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB == NULL ) return; // Get W, H @@ -3046,7 +3046,7 @@ class CHandlerGameConfigMode : public IActionHandler } if (nFoundFreq == -1) nFoundFreq = 0; // Initialize interface combo box - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if( pCB ) { pCB->resetTexts(); @@ -3147,28 +3147,28 @@ class CHandlerGameConfigFullscreen : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); bool bFullscreen = false; { - CCtrlBaseButton *pBut = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); if (pBut) bFullscreen = pBut->getPushed(); } CDBGroupComboBox *pCB; if (bFullscreen) { // show modes combo - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if (pCB) pCB->setActive(true); // show frequencies combo - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if (pCB) pCB->setActive(true); } else { // hide modes combo - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if (pCB) pCB->setActive(false); // hide frequencies combo - pCB= dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if (pCB) pCB->setActive(false); } @@ -3202,7 +3202,7 @@ class CHandlerGameConfigApply : public IActionHandler // Get W, H sint w = 1024, h = 768; { - CDBGroupComboBox *pCB = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB != NULL ) { string vidModeStr = pCB->getText(nVideModeNb).toString(); @@ -3216,7 +3216,7 @@ class CHandlerGameConfigApply : public IActionHandler // Get Frequency sint freq = 60; { - CDBGroupComboBox *pCB = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); if( pCB != NULL ) { string vidFreqStr = pCB->getText(nVideoFreqNb).toString(); @@ -3227,7 +3227,7 @@ class CHandlerGameConfigApply : public IActionHandler // Get Fullscreen bool bFullscreen = false; { - CCtrlBaseButton *pBut = dynamic_cast(pIM->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); if (pBut != NULL) bFullscreen = pBut->getPushed(); } @@ -3823,13 +3823,13 @@ void runMissionProc(sint32 nSelected) else if (nSelected < nNbMission) { string sButtonPath = UI_MISSION_LIST ":b_title"+toString(nSelected); - CCtrlButton *pCB = dynamic_cast(pIM->getElementFromId(sButtonPath)); + CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButtonPath)); pIM->runActionHandler("proc", pCB, "mission_proc_title|"+toString(nSelected)); } else if (nSelected < (nNbMission+nNbGroupMission)) { string sButtonPath = UI_MISSION_LIST ":b_group_title"+toString(nSelected-nNbMission); - CCtrlButton *pCB = dynamic_cast(pIM->getElementFromId(sButtonPath)); + CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButtonPath)); pIM->runActionHandler("proc", pCB, "group_mission_proc_title|"+toString(nSelected-nNbMission)); } return; @@ -3964,7 +3964,7 @@ public: { // hide interface CInterfaceManager* pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pIG = (CInterfaceGroup*)pIM->getElementFromId ("ui:interface:enter_crzone_proposal"); + CInterfaceGroup *pIG = (CInterfaceGroup*)CWidgetManager::getInstance()->getElementFromId ("ui:interface:enter_crzone_proposal"); if(pIG) pIG->setActive(false); diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 16b5c93b5..7004f31c9 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -167,7 +167,7 @@ void CInterfaceHelp::initWindows() for(sint i=0;i(pIM->getElementFromId("ui:interface:sheet_help"+toString(i))); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:sheet_help"+toString(i))); // if the window exist, insert if(group) { @@ -275,7 +275,7 @@ CInterfaceGroup *CInterfaceHelp::activateNextWindow(CDBCtrlSheet *elt, sint forc if(ok) { // then don't neet to open a new window, but make the older top. - pIM->setTopWindow(group); + CWidgetManager::getInstance()->setTopWindow(group); return NULL; } } @@ -356,7 +356,7 @@ CInterfaceGroup *CInterfaceHelp::activateNextWindow(CDBCtrlSheet *elt, sint forc // activate it, set top, copy item watched group->setActive(true); - pIM->setTopWindow(group); + CWidgetManager::getInstance()->setTopWindow(group); _InfoWindows[newIndexWindow].CtrlSheet= elt; // insert in list if(mustAddToActiveWindows) @@ -914,7 +914,7 @@ class CHandlerBrowse : public IActionHandler void execute (CCtrlBase *pCaller, const std::string &sParams) { string container = getParam (sParams, "name"); - CInterfaceElement *element = CInterfaceManager::getInstance()->getElementFromId(container); + CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); CInterfaceGroup *elementGroup = dynamic_cast(element); string urls = getParam (sParams, "url"); @@ -1055,7 +1055,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); - CGroupHTML *groupHtml = dynamic_cast(pIM->getElementFromId(container)); + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(container)); if (groupHtml) { groupHtml->browseUndo(); @@ -1074,7 +1074,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); - CGroupHTML *groupHtml = dynamic_cast(pIM->getElementFromId(container)); + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(container)); if (groupHtml) { groupHtml->browseRedo(); @@ -1093,7 +1093,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); - CGroupHTML *groupHtml = dynamic_cast(pIM->getElementFromId(container)); + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(container)); if (groupHtml) { groupHtml->refresh(); @@ -1118,7 +1118,7 @@ class CHandlerHTMLSubmitForm : public IActionHandler string submit_button = getParam (sParams, "submit_button"); - CInterfaceElement *element = CInterfaceManager::getInstance()->getElementFromId(container); + CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container); { // Group HTML ? CGroupHTML *groupHtml = dynamic_cast(element); @@ -3883,7 +3883,7 @@ public: string dbitem= getParam(Params, "dbitem"); string prefix= getParam(Params, "prefix"); - CInterfaceGroup *wnd= dynamic_cast(pIM->getElementFromId(wndStr)); + CInterfaceGroup *wnd= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(wndStr)); CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbitem); // common method for info and botchat diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index b5fb53fea..16b7cdc68 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -107,13 +107,13 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CInterfaceGroup* group = dynamic_cast( pIM->getElementFromId(WindowName) ); + CInterfaceGroup* group = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(WindowName) ); - CInterfaceGroup* editShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); - CGroupEditBox* editBoxShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); - CInterfaceGroup* editLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); - CGroupEditBox* editBoxLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); - CViewText* display = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_display")) ); + CInterfaceGroup* editShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); + CGroupEditBox* editBoxShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); + CInterfaceGroup* editLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); + CGroupEditBox* editBoxLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); + CViewText* display = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_display")) ); if (group && editShort && editBoxShort && editLarge && editBoxLarge && display) { CClientItemInfo const& itemInfo = getInventory().getItemInfo( ItemSlotId ); @@ -159,7 +159,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() string::size_type delimiter = text.find(' '); if(text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { - CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId("ui:interface:web_transactions:content:html")); + CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) pGH->browse(ucstring(text.substr(4, delimiter-4)).toString().c_str()); if (delimiter == string::npos) @@ -197,16 +197,16 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CGroupContainer* group = dynamic_cast( pIM->getElementFromId(WindowName) ); + CGroupContainer* group = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(WindowName) ); - CInterfaceGroup* editShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); - CGroupEditBox* editBoxShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); - CInterfaceGroup* editLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); - CGroupEditBox* editBoxLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); - CViewText* display = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_display")) ); - CInterfaceGroup* editButtons = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); - CCtrlBaseButton* closeButton = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); - CViewBitmap* background = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_background")) ); + CInterfaceGroup* editShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); + CGroupEditBox* editBoxShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); + CInterfaceGroup* editLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); + CGroupEditBox* editBoxLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); + CViewText* display = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_display")) ); + CInterfaceGroup* editButtons = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); + CCtrlBaseButton* closeButton = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); + CViewBitmap* background = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_background")) ); if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { @@ -297,7 +297,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() string::size_type delimiter = text.find(' '); if(text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B') { - CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId("ui:interface:web_transactions:content:html")); + CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:web_transactions:content:html")); if (pGH) pGH->browse(ucstring(text.substr(4, delimiter-4)).toString().c_str()); if (delimiter == string::npos) @@ -334,16 +334,16 @@ void CInterfaceItemEdition::CItemEditionWindow::end() // hide the dialog CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CInterfaceGroup* group = dynamic_cast( pIM->getElementFromId(windowName) ); + CInterfaceGroup* group = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(windowName) ); - CInterfaceGroup* editShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); - CGroupEditBox* editBoxShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); - CInterfaceGroup* editLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); - CGroupEditBox* editBoxLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); - CViewText* display = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_display")) ); - CInterfaceGroup* editButtons = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); - CCtrlBaseButton* closeButton = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); - CViewBitmap* background = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_background")) ); + CInterfaceGroup* editShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); + CGroupEditBox* editBoxShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); + CInterfaceGroup* editLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); + CGroupEditBox* editBoxLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); + CViewText* display = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_display")) ); + CInterfaceGroup* editButtons = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); + CCtrlBaseButton* closeButton = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); + CViewBitmap* background = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_background")) ); if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { // disable the window @@ -373,16 +373,16 @@ void CInterfaceItemEdition::CItemEditionWindow::validate() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CInterfaceGroup* group = dynamic_cast( pIM->getElementFromId(windowName) ); + CInterfaceGroup* group = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(windowName) ); - CInterfaceGroup* editShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); - CGroupEditBox* editBoxShort = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); - CInterfaceGroup* editLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); - CGroupEditBox* editBoxLarge = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); - CViewText* display = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_display")) ); - CInterfaceGroup* editButtons = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); - CCtrlBaseButton* closeButton = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); - CViewBitmap* background = dynamic_cast( pIM->getElementFromId(pIM->getDefine("edit_custom_background")) ); + CInterfaceGroup* editShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_short")) ); + CGroupEditBox* editBoxShort = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_short")) ); + CInterfaceGroup* editLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_large")) ); + CGroupEditBox* editBoxLarge = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_box_large")) ); + CViewText* display = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_display")) ); + CInterfaceGroup* editButtons = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_edit_buttons")) ); + CCtrlBaseButton* closeButton = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_close_button")) ); + CViewBitmap* background = dynamic_cast( CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("edit_custom_background")) ); if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background) { bool textValid = editShort->getActive(); @@ -479,8 +479,8 @@ static void displayQuantityPopup(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCt { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId("ui:interface:stack_dialog") ); - CGroupEditBox *editBox= dynamic_cast( pIM->getElementFromId("ui:interface:stack_dialog:edit:eb") ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:stack_dialog") ); + CGroupEditBox *editBox= dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:stack_dialog:edit:eb") ); if(group && editBox) { // write all info for the modal @@ -500,7 +500,7 @@ static void displayQuantityPopup(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCt editBox->setInputStringAsInt(availableStack); // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); // Set the Keyboard focus to the editbox (after the enableModalWindow()) pIM->setCaptureKeyboard(editBox); @@ -723,7 +723,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if ((pCSSrc == NULL) || (pCSDst == NULL)) return; @@ -828,7 +828,7 @@ public: { CInterfaceManager *im = CInterfaceManager::getInstance(); CDBCtrlSheet *src = dynamic_cast(pCaller); - CDBCtrlSheet *dest = dynamic_cast(im->getCtrlLaunchingModal()); + CDBCtrlSheet *dest = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (src->getSheetId() == 0) { putExchangedItemToInventory(dest); @@ -866,7 +866,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if (pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item) @@ -887,7 +887,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if (pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item) @@ -933,7 +933,7 @@ public: string src = getParam(Params, "src"); string strTestEmpty= getParam(Params, "test_empty"); bool testEmpty= strTestEmpty=="true"; - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if (!pCSSrc || !pCSDst) return; @@ -1024,7 +1024,7 @@ class CCanDropToExchange : public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if (!pCSSrc || !pCSDst) return; @@ -1489,7 +1489,7 @@ class CHandlerMoveItem : public IActionHandler string sListId = getParam(sParams, "listsheet"+toString(nListIt)); while (!sListId.empty()) { - IListSheetBase *pLS = dynamic_cast(pIM->getElementFromId(sListId)); + IListSheetBase *pLS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sListId)); if (pLS == NULL) return; // search an empty slot where to put sint32 nbelt = pLS->getNbSheet(); @@ -1550,7 +1550,7 @@ class CHandlerMoveItem : public IActionHandler while (!sGrpId.empty()) { uint i; - CInterfaceGroup *pIG = dynamic_cast(pIM->getElementFromId(sGrpId)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sGrpId)); if (pIG != NULL) { // Get all the sheets of the group @@ -1583,7 +1583,7 @@ class CHandlerMoveItem : public IActionHandler while (!sGrpId.empty()) { uint i; - CInterfaceGroup *pIG = dynamic_cast(pIM->getElementFromId(sGrpId)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sGrpId)); if (pIG != NULL) { // Get all the sheets of the group @@ -1626,8 +1626,8 @@ class CHandlerDragNDrop : public IActionHandler string sDst = getParam(sParams,"dst"); string sAH = getParam(sParams,"ah"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCSsrc = dynamic_cast(pIM->getElementFromId(sSrc)); - CDBCtrlSheet *pCSdst = dynamic_cast(pIM->getElementFromId(sDst)); + CDBCtrlSheet *pCSsrc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sSrc)); + CDBCtrlSheet *pCSdst = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sDst)); if ((pCSdst == NULL) || (pCSsrc == NULL) || sAH.empty()) return; pIM->runActionHandler(sAH, pCSdst, "src="+pCSsrc->getId()); } @@ -1668,7 +1668,7 @@ class CHandlerItemCristalReload : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; sendToServerEnchantMessage((uint8)pCS->getInventoryIndex(), (uint16)pCS->getIndexInDB()); @@ -1701,7 +1701,7 @@ void CItemMenuInBagInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet) CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the dialog stack - CInterfaceGroup* pMenu = dynamic_cast( pIM->getElementFromId("ui:interface:item_menu_in_bag") ); + CInterfaceGroup* pMenu = dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:item_menu_in_bag") ); if(!pMenu) return; const CItemSheet *pIS = ctrlSheet->asItemSheet(); @@ -1734,7 +1734,7 @@ class CHandlerItemMenuCheck : public IActionHandler uint i; // Get the ctrl sheet that launched this menu - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; INVENTORIES::TInventory invId= (INVENTORIES::TInventory)pCS->getInventoryIndex(); @@ -2039,7 +2039,7 @@ class CHandlerItemMenuBaseCheck : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Get the ctrl sheet that launched this menu - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; INVENTORIES::TInventory invId= (INVENTORIES::TInventory)pCS->getInventoryIndex(); @@ -2111,7 +2111,7 @@ class CHandlerTeleportUse : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; // use the item @@ -2143,7 +2143,7 @@ class CHandlerItemConsume : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; // use the item @@ -2171,7 +2171,7 @@ class CHandlerItemTextDisplay : public IActionHandler { std::string const& windowName = sParams; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCSItem = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCSItem = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCSItem == NULL || windowName.empty()) return; @@ -2188,7 +2188,7 @@ class CHandlerItemTextEdition : public IActionHandler { std::string const& windowName = sParams; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCSItem = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCSItem = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCSItem == NULL || windowName.empty()) return; @@ -2213,7 +2213,7 @@ class CHandlerXpCatalyserUse : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; // use the item diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 358b94d88..050ac1cd1 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -99,13 +99,13 @@ void CActionHandlerShowOne::execute (CCtrlBase * /* pCaller */, const std::strin // hide all window from the list. for(uint i=0;igetElementFromId(wndList[i]); + CInterfaceElement *wnd= CWidgetManager::getInstance()->getElementFromId(wndList[i]); if(wnd) wnd->setActive(false); } // show the one needed - CInterfaceElement *wnd= mngr->getElementFromId(wndShow); + CInterfaceElement *wnd= CWidgetManager::getInstance()->getElementFromId(wndShow); if(wnd) wnd->setActive(true); } @@ -127,7 +127,7 @@ void CActionHandlerActive::execute (CCtrlBase * /* pCaller */, const std::string return; } CInterfaceManager *mngr = CInterfaceManager::getInstance(); - CInterfaceElement *wnd = mngr->getElementFromId(target); + CInterfaceElement *wnd = CWidgetManager::getInstance()->getElementFromId(target); if(!wnd) { nlwarning(" Can't get window %s", target.c_str()); @@ -158,7 +158,7 @@ void CActionHandlerSetOpen::execute (CCtrlBase * /* pCaller */, const std::strin return; } CInterfaceManager *mngr = CInterfaceManager::getInstance(); - CGroupContainer *wnd = dynamic_cast(mngr->getElementFromId(target)); + CGroupContainer *wnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(target)); if(!wnd) { nlwarning(" Can't get window %s", target.c_str()); @@ -199,7 +199,7 @@ void CActionHandlerHideClose::execute (CCtrlBase * /* pCaller */, const std::str uint i; for(i=0;igetElementFromId(hideList[i]); + CInterfaceElement *wnd= CWidgetManager::getInstance()->getElementFromId(hideList[i]); if(wnd) wnd->setActive(false); } @@ -208,7 +208,7 @@ void CActionHandlerHideClose::execute (CCtrlBase * /* pCaller */, const std::str for(i=0;igetElementFromId(closeList[i]); + CInterfaceElement *wnd= CWidgetManager::getInstance()->getElementFromId(closeList[i]); CGroupContainer *pIC = dynamic_cast(wnd); if(pIC) pIC->close(); @@ -236,13 +236,13 @@ void CActionHandlerEnterModal::execute(CCtrlBase *pCaller, const std::string &pa // get the group from param string groupName= getParam(params, "group"); - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId(groupName) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(groupName) ); if(group) { UserControls.stopFreeLook(); // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); } else { @@ -257,11 +257,11 @@ void CActionHandlerPushModal::execute(CCtrlBase *pCaller, const std::string &par // get the group from param string groupName= getParam(params, "group"); - CInterfaceGroup *group= dynamic_cast( mngr->getElementFromId(groupName) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(groupName) ); if(group) { // enable the modal - mngr->pushModalWindow(pCaller, group); + CWidgetManager::getInstance()->pushModalWindow(pCaller, group); } else { @@ -276,7 +276,7 @@ void CActionHandlerLeaveModal::execute(CCtrlBase * /* pCaller */, const std::str CInterfaceManager *mngr= CInterfaceManager::getInstance(); // quit the modal - mngr->popModalWindow(); + CWidgetManager::getInstance()->popModalWindow(); } diff --git a/code/ryzom/client/src/interface_v3/action_handler_move.cpp b/code/ryzom/client/src/interface_v3/action_handler_move.cpp index 2d52c0d14..67d0c7b72 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -187,7 +187,7 @@ class CAHFreeMouse : public IActionHandler CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId("ui:interface:game_config")); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_config")); if (ig && ig->getActive()) { CInterfaceGroup *igHard = dynamic_cast(ig->getGroup("hard")); diff --git a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp index 34808c9bf..c544594d5 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -207,7 +207,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId(sParams)); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); if (pMap == NULL) return; @@ -313,7 +313,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId(sParams)); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); if (pMap == NULL) return; diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 91a7687d5..551c17f5c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -263,10 +263,10 @@ void launchPhraseComposition(bool creation) CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Launch the composition window - CGroupContainer *window= dynamic_cast( pIM->getElementFromId(PhraseComposition) ); + CGroupContainer *window= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(PhraseComposition) ); if(window) { - CDBGroupBuildPhrase *buildSentenceTarget= dynamic_cast( pIM->getElementFromId(PhraseCompositionGroup) ); + CDBGroupBuildPhrase *buildSentenceTarget= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(PhraseCompositionGroup) ); // if found if(buildSentenceTarget) { @@ -371,7 +371,7 @@ public: } // And hide the modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } public: enum TType {Root, OtherMain, Param, NewOpCredit, FaberPlan}; @@ -418,11 +418,11 @@ public: buildGroup->fillSelectionMain(index); // launch the modal - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); if(group) { // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); } } }; @@ -456,11 +456,11 @@ public: buildGroup->fillSelectionParam(index, paramIndex); // launch the modal - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); if(group) { // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); } } }; @@ -493,11 +493,11 @@ public: buildGroup->fillSelectionNewCredit(); // launch the modal - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); if(group) { // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); } } }; @@ -541,11 +541,11 @@ public: CHandlerPhraseValidateBrick::BrickType= CHandlerPhraseValidateBrick::FaberPlan; // launch the modal - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId( CDBGroupBuildPhrase::BrickSelectionModal ) ); if(group) { // enable the modal - pIM->enableModalWindow(pCaller, group); + CWidgetManager::getInstance()->enableModalWindow(pCaller, group); } } }; @@ -571,7 +571,7 @@ static void updateAllSPhraseInfo() // update all info windows CInterfaceHelp::updateWindowSPhraseTexts(); // If the composition is opened, refresh - CInterfaceGroup *pIG= dynamic_cast(pIM->getElementFromId("ui:interface:phrase_composition")); + CInterfaceGroup *pIG= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:phrase_composition")); if(pIG && pIG->getActive()) { CDBGroupBuildPhrase *buildPhrase= dynamic_cast(pIG->getGroup("header_opened")); @@ -653,7 +653,7 @@ public: CMacroCmdManager *pMM = CMacroCmdManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); // can be a phrase id (comes from memory), a phraseSheet (comes from progression), or a macro, @@ -806,7 +806,7 @@ void CHandlerMemorizePhraseOrMacro::execute (CCtrlBase *pCaller, const string &P } else { - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); pCSSrc = dynamic_cast(pElt); // type check @@ -1265,9 +1265,9 @@ public: // get the control CInterfaceElement *elm; if (shortcut < RYZOM_MAX_SHORTCUT) - elm = pIM->getElementFromId(PhraseMemoryCtrlBase + toString(shortcut) ); + elm = CWidgetManager::getInstance()->getElementFromId(PhraseMemoryCtrlBase + toString(shortcut) ); else - elm = pIM->getElementFromId(PhraseMemoryAltCtrlBase + toString(shortcut-RYZOM_MAX_SHORTCUT) ); + elm = CWidgetManager::getInstance()->getElementFromId(PhraseMemoryAltCtrlBase + toString(shortcut-RYZOM_MAX_SHORTCUT) ); CDBCtrlSheet *ctrl= dynamic_cast(elm); if(ctrl) { @@ -1314,7 +1314,7 @@ public: { // opens the menu CDBCtrlSheet::setCurrSelSheet(pCSDst); - pIM->enableModalWindow (pCSDst, menu); + CWidgetManager::getInstance()->enableModalWindow (pCSDst, menu); } } } @@ -1443,7 +1443,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); CSPhraseManager *pPM = CSPhraseManager::getInstance(); CSBrickManager *pBM = CSBrickManager::getInstance(); - CInterfaceElement *pCristalizeMenuOption = pIM->getElementFromId(sCristalizePath); + CInterfaceElement *pCristalizeMenuOption = CWidgetManager::getInstance()->getElementFromId(sCristalizePath); if (pCristalizeMenuOption == NULL) return; // The default is to not display the cristalize menu option @@ -1452,7 +1452,7 @@ public: // Get the interface control sheet - CDBCtrlSheet *pCS = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS == NULL) return; if (!pCS->isSPhraseIdMemory()) return; diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index 8fcd4726f..745b89d57 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -89,7 +89,7 @@ class CAHUIOpen : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -111,7 +111,7 @@ class CAHUIClose : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -132,7 +132,7 @@ class CAHUIOpenClose : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -154,7 +154,7 @@ class CAHUIPopup : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -185,7 +185,7 @@ class CAHUIPopin : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -220,7 +220,7 @@ class CAHUIPopupPopin : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -256,7 +256,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -307,7 +307,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -316,7 +316,7 @@ public: if (!isContainerAuthorized(pGC)) return; pGC->setActive(true); - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); } }; REGISTER_ACTION_HANDLER( CAHUIShow, "show" ); @@ -338,7 +338,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", Params)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", Params)); if (pGC == NULL) { nlwarning("%s is not a container", Params.c_str()); @@ -388,7 +388,7 @@ class CAHUIShowHide : public IActionHandler } CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface", window)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface", window)); if (pGC == NULL) { nlwarning("%s is not a container", window.c_str()); @@ -410,7 +410,7 @@ class CAHUIShowHide : public IActionHandler } if(!webapp.empty() && pGC->getActive()) { - CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId("ui:interface:webig:content:html")); + CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:webig:content:html")); if (pGH == NULL) { nlwarning("%s is not a group html", window.c_str()); @@ -533,7 +533,7 @@ class CAHTalkUntalk : public IActionHandler cw->getContainer()->setActive(true); cw->getContainer()->setOpen(true); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setTopWindow(cw->getContainer()); + CWidgetManager::getInstance()->setTopWindow(cw->getContainer()); cw->enableBlink(1); im->setCaptureKeyboard(cw->getEditBox()); PeopleInterraction.MainChat.Filter.setTargetPlayer(selection->getName()); @@ -654,8 +654,8 @@ class CAHUISetTopWindow : public IActionHandler { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string sWin = getParam(Params,"win"); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(sWin)); - if (pGC != NULL && isContainerAuthorized(pGC)) pIM->setTopWindow(pGC); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sWin)); + if (pGC != NULL && isContainerAuthorized(pGC)) CWidgetManager::getInstance()->setTopWindow(pGC); } }; REGISTER_ACTION_HANDLER( CAHUISetTopWindow, "set_top_window" ); diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index b48a3a705..b6b797246 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -133,7 +133,7 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn // **** Hide all widgets, MP Ctrls, and reset DB, until the Plan is not selected CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Hide the valid button - CCtrlBaseButton *validButton= dynamic_cast(pIM->getElementFromId(FaberPhraseValidButton)); + CCtrlBaseButton *validButton= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseValidButton)); if(validButton) validButton->setFrozen(true); @@ -150,7 +150,7 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn } // Hide item requirements groups per default - CInterfaceGroup *itemReqLineGroup= dynamic_cast(pIM->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); + CInterfaceGroup *itemReqLineGroup= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); if(itemReqLineGroup) itemReqLineGroup->setActive(false); } @@ -166,13 +166,13 @@ void CActionPhraseFaber::launchFaberCastWindow(sint32 memoryLine, uint memoryIn node->setValue32(0); // Hide the ItemResult group - CInterfaceGroup *groupMp= dynamic_cast(pIM->getElementFromId(FaberPhraseItemResultGroup)); + CInterfaceGroup *groupMp= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseItemResultGroup)); if(groupMp) groupMp->setActive(false); // **** Open the window! - CGroupContainer *window= dynamic_cast(pIM->getElementFromId(FaberPhraseWindow)); + CGroupContainer *window= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseWindow)); if(window) { window->setActive(true); @@ -385,7 +385,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick node->setValue32(itemPlanBrick->FaberPlan.NbItemBuilt); // Show the ItemResult group - CInterfaceGroup *groupMp= dynamic_cast(pIM->getElementFromId(FaberPhraseItemResultGroup)); + CInterfaceGroup *groupMp= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseItemResultGroup)); if(groupMp) groupMp->setActive(true); @@ -471,7 +471,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick // **** show ItemParts according to plan. // Hide the valid button - CCtrlBaseButton *validButton= dynamic_cast(pIM->getElementFromId(FaberPhraseValidButton)); + CCtrlBaseButton *validButton= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseValidButton)); if(validButton) validButton->setFrozen(true); @@ -489,7 +489,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick } // Setup item requirement groups - CInterfaceGroup *itemReqLineGroup= dynamic_cast(pIM->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); + CInterfaceGroup *itemReqLineGroup= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); if(itemReqLineGroup) { if( itemReqLine<_MPBuildNumTotalItemReq ) @@ -556,7 +556,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick } // **** Setup the new window title - CGroupContainer *window= dynamic_cast(pIM->getElementFromId(FaberPhraseWindow)); + CGroupContainer *window= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseWindow)); if(window) { // Setup the Title with the item built @@ -666,7 +666,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) // get the ctrlSlot CDBCtrlSheet *ctrlSlot= NULL; - CInterfaceGroup *itemReqLineGroup= dynamic_cast(pIM->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); + CInterfaceGroup *itemReqLineGroup= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); if(itemReqLineGroup) { CDBGroupListSheet *listSheet= dynamic_cast(itemReqLineGroup->getGroup(FaberPhraseList)); @@ -702,7 +702,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) _MpChangeQuantitySlot= mpSlot; // Setup the text with value by default - CInterfaceGroup *quantityModal= dynamic_cast(pIM->getElementFromId(FaberPhraseMpQuantityModal)); + CInterfaceGroup *quantityModal= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseMpQuantityModal)); if(quantityModal) { CGroupEditBox *eb = dynamic_cast(quantityModal->getGroup("eb")); @@ -715,7 +715,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) } // launch the modal - pIM->enableModalWindow(ctrlSlot, quantityModal); + CWidgetManager::getInstance()->enableModalWindow(ctrlSlot, quantityModal); } // else select new MP else @@ -756,7 +756,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) _MpCurrentSelection= selectMps; // Open the Selection Window. - pIM->enableModalWindow(ctrlSlot, FaberPhraseMpListModal); + CWidgetManager::getInstance()->enableModalWindow(ctrlSlot, FaberPhraseMpListModal); } } @@ -767,7 +767,7 @@ void CActionPhraseFaber::validateMpSelection(uint selectId) if(selectId>=_MpCurrentSelection.size()) { - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return; } @@ -817,7 +817,7 @@ void CActionPhraseFaber::validateMpSelection(uint selectId) // must hide the modal window which had open us. NB: must be done here because next, // we'll open the MP quantity selection - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); // **** when all is correctly ended, open the quantity selection // NB: just enable this code, if you want this feature @@ -882,7 +882,7 @@ void CActionPhraseFaber::validateMpSelectQuantity() updateItemResult(); // hide the Modal Quantity selection - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // *************************************************************************** @@ -931,7 +931,7 @@ void CActionPhraseFaber::validateExecution() // NO more Close the Execution window (allow refaber quick) /*CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceElement *window= pIM->getElementFromId(FaberPhraseWindow); + CInterfaceElement *window= CWidgetManager::getInstance()->getElementFromId(FaberPhraseWindow); if(window) window->setActive(false); */ @@ -981,7 +981,7 @@ void CActionPhraseFaber::updateEmptySlot(uint itemReqLine, CInterfaceGroup *it CInterfaceManager *pIM= CInterfaceManager::getInstance(); if(!itemReqLineGroup) - itemReqLineGroup= dynamic_cast(pIM->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); + itemReqLineGroup= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( toString(FaberPhraseItemReqLine.c_str(), itemReqLine) )); if(!itemReqLineGroup) return; @@ -1085,7 +1085,7 @@ void CActionPhraseFaber::updateValidButton() // unfreeze if valid CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCtrlBaseButton *validButton= dynamic_cast(pIM->getElementFromId(FaberPhraseValidButton)); + CCtrlBaseButton *validButton= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseValidButton)); if(validButton) validButton->setFrozen(!canValid); } @@ -1178,7 +1178,7 @@ public: if(!ctrl) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return; } @@ -1213,7 +1213,7 @@ public: { // get the button CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCtrlBaseButton *button= dynamic_cast(pIM->getElementFromId(FaberPhraseValidButton)); + CCtrlBaseButton *button= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseValidButton)); // Ok, button found. test if active. if( button && !button->getFrozen() ) @@ -1265,7 +1265,7 @@ void validateFaberPlanSelection(CSBrickSheet *itemPlanBrick) void closeFaberCastWindow() { if (ActionPhraseFaber == NULL) return; - CGroupContainer *window= dynamic_cast(CInterfaceManager::getInstance()->getElementFromId(FaberPhraseWindow)); + CGroupContainer *window= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseWindow)); if(window && window->getActive()) window->setActive(false); } @@ -1480,12 +1480,12 @@ void CActionPhraseFaber::onInventoryChange() updateValidButton(); // close selection modals if they are opened - CInterfaceGroup *quantityModal= dynamic_cast(pIM->getElementFromId(FaberPhraseMpQuantityModal)); - if(quantityModal && pIM->getModalWindow()==quantityModal) - pIM->disableModalWindow(); - CInterfaceGroup *listModal= dynamic_cast(pIM->getElementFromId(FaberPhraseMpListModal)); - if(listModal && pIM->getModalWindow()==listModal) - pIM->disableModalWindow(); + CInterfaceGroup *quantityModal= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseMpQuantityModal)); + if(quantityModal && CWidgetManager::getInstance()->getModalWindow()==quantityModal) + CWidgetManager::getInstance()->disableModalWindow(); + CInterfaceGroup *listModal= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseMpListModal)); + if(listModal && CWidgetManager::getInstance()->getModalWindow()==listModal) + CWidgetManager::getInstance()->disableModalWindow(); // update item result updateItemResult(); @@ -1674,7 +1674,7 @@ void CActionPhraseFaber::updateItemResult() // **** change success rate too - CViewText *successView= dynamic_cast(pIM->getElementFromId(FaberPhraseFpSuccessText)); + CViewText *successView= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseFpSuccessText)); if(successView) { ucstring text= CI18N::get("uiPhraseFaberSuccessRate"); @@ -1742,7 +1742,7 @@ void CActionPhraseFaber::updateItemResult() // **** Stats - CInterfaceGroup *groupMp= dynamic_cast(pIM->getElementFromId(FaberPhraseItemResultGroup)); + CInterfaceGroup *groupMp= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(FaberPhraseItemResultGroup)); if(groupMp) { // default: hide all diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page.cpp index 5714afffa..1194c649f 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page.cpp @@ -27,7 +27,7 @@ void CBotChatPage::activateWindow(const char *windowName, bool active) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId(windowName)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(windowName)); if (ig) { ig->setActive(active); diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index e7d4c2d7a..2e7c95ca2 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -59,13 +59,13 @@ class CHandlerGuildCreate : public IActionHandler string IconWin = getParam(Params, "icon"); string guildDescWin = getParam(Params, "desc"); - CGroupEditBox *pGEB = dynamic_cast(pIM->getElementFromId(guildNameWin)); + CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildNameWin)); if (pGEB == NULL) return; - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(IconWin)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(IconWin)); if (pCS == NULL) return; - CGroupEditBox *pDesc = dynamic_cast(pIM->getElementFromId(guildDescWin)); + CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin)); ucstring guildName = pGEB->getInputString(); diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 0d53ef84b..15f3dc6aa 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -87,7 +87,7 @@ void CBotChatPageDynamicMission::begin() } } activateWindow(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION, true); - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION)); if (!ig) { std::fill(_ChoiceCB, _ChoiceCB + DYNAMIC_MISSION_NUM_CHOICES, (CDBGroupComboBox *) NULL); @@ -122,7 +122,7 @@ void CBotChatPageDynamicMission::end() { // if a menu is currently poped, disable it CInterfaceManager *im = CInterfaceManager::getInstance(); - im->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); activateWindow(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION, false); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index 5b2c06083..fc84aedde 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -67,7 +67,7 @@ void CBotChatPageMission::begin() // Select the Mission Aspect according to mission type NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MISSION:MISSION_TYPE")->setValue32(_MType); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_PAGE_MISSION)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_PAGE_MISSION)); if (gc) { // show the ui @@ -96,7 +96,7 @@ void CBotChatPageMission::selectMission(CDBCtrlSheet *missionSheet) if (missionSheet->getGrayed()) return; // show the dialog with good infos CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_ACCEPT_MISSION)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_ACCEPT_MISSION)); // copy text id for title { @@ -123,7 +123,7 @@ void CBotChatPageMission::selectMission(CDBCtrlSheet *missionSheet) } // if (!gc) return; - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->setActive(true); gc->updateCoords(); gc->center(); diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp index 58161417b..acc65410b 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp @@ -40,7 +40,7 @@ void CBotChatPageMissionEnd::begin() CInterfaceManager *im = CInterfaceManager::getInstance(); uint flags = CBotChatManager::getInstance().getChosenMissionFlags(); // reward text - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_PAGE_MISSION_END)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_PAGE_MISSION_END)); if (!ig) return; CInterfaceGroup *rewardText = ig->getGroup("reward_text"); if (rewardText) diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 356845d35..c3b1f2df8 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -97,7 +97,7 @@ public: { CSheetHelpSetup helpSetup; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); fillHelpSetupInfosForTrade(helpSetup, Sheet, ig); refreshItemHelp(helpSetup); } @@ -171,7 +171,7 @@ void CBotChatPageTrade::init() void CBotChatPageTrade::invalidateCoords() { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); if (!gc) return; // invalidate buy group gc->invalidateCoords(); @@ -241,7 +241,7 @@ void CBotChatPageTrade::begin() _DownloadComplete = false; // update interface - CGroupContainer *gc = dynamic_cast(pIM->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); if (gc) { // set the title @@ -323,7 +323,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const itemSheet->Family != ITEMFAMILY::GUILD_OPTION) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return std::numeric_limits::max(); // TODO: edit box in faction points? CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb")); @@ -357,7 +357,7 @@ uint32 CBotChatPageTrade::getCurrItemPriceResale() const // const CItemSheet *itemSheet = _CurrItemSheet->asItemSheet(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the edited resale price - CInterfaceGroup *ig = dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return 0; CGroupEditBox *resaleMarginBox = dynamic_cast(ig->getGroup("header_opened:resell_group:can_resell:choose_resell:edit:eb")); if (!resaleMarginBox) return 0; @@ -506,7 +506,7 @@ uint32 CBotChatPageTrade::getUserFactionPoints(PVP_CLAN::TPVPClan clan) const void CBotChatPageTrade::notifyDownloadComplete(bool completed) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); if (!gc) return; class CDBListVisitor : public CInterfaceElementVisitor { @@ -552,7 +552,7 @@ void CBotChatPageTrade::updateTradeModal() } // get pointers on interface elements CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); CInterfaceGroup *confirmTradeGroup = ig->getGroup("confirm_trade"); CCtrlBase *confirmResellGroup = ig->getCtrl("confirm_trade_resell"); CInterfaceGroup *cantTradeGroup = ig->getGroup("cant_trade"); @@ -841,7 +841,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall { if (!sheet) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return; // don't know why but in some case, the sheetId is 0 @@ -922,7 +922,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall ig->updateCoords(); ig->center(); ig->setModalParentList(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE); - im->setTopWindow(ig); + CWidgetManager::getInstance()->setTopWindow(ig); // _CurrItemSheet = sheet; _CurrItemIndex = sheet->getIndexInDB(); @@ -949,7 +949,7 @@ void CBotChatPageTrade::updateSPhraseBuyDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return; CSheetHelpSetup helpSetup; @@ -963,7 +963,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal nlassert(!_BuyOnly); if (!sheet) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(im->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return; // If this sheet is grayed cause of an "Animal Inventory unavailable" flag, quit @@ -1020,7 +1020,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal ig->updateCoords(); ig->center(); ig->setModalParentList(WIN_BOT_CHAT_PAGE_TRADE); - im->setTopWindow(ig); + CWidgetManager::getInstance()->setTopWindow(ig); // _CurrItemSheet = sheet; _CurrItemIndex = sheet->getIndexInDB(); @@ -1048,7 +1048,7 @@ void CBotChatPageTrade::endTradeModal() // hide the dialog CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *ig = dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CGroupContainer *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (ig) ig->setActive(false); // Hide any confirmation dialog related to trade (important for building MessageBox confirmation) @@ -1056,7 +1056,7 @@ void CBotChatPageTrade::endTradeModal() if(pIM->getCurrentValidMessageBoxOnOk(vmbOnOk)) { if(vmbOnOk=="confirm_trade") - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } @@ -1296,7 +1296,7 @@ void CBotChatPageTrade::confirmTrade( bool enableResale ) if ( _ResaleEdit ) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *ig = dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (ig) { CGroupEditBox *eb = dynamic_cast(ig->getGroup("header_opened:resell_group:can_resell:choose_resell:edit:eb")); @@ -1706,7 +1706,7 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con _FilterBuyDlgMaxValue= maxValue; // change the title - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); if(!ig) return; CViewText *vtitle= dynamic_cast(ig->getView("title")); if(vtitle) @@ -1730,7 +1730,7 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con setFocusOnEditBox(ig->getGroup("edit_min:eb")); // go - pIM->enableModalWindow(NULL, ig); + CWidgetManager::getInstance()->enableModalWindow(NULL, ig); } // *************************************************************************** @@ -1739,7 +1739,7 @@ void CBotChatPageTrade::resetBuyFilterDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get the modal window - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); if(!ig) return; // reset the edited values @@ -1759,7 +1759,7 @@ void CBotChatPageTrade::resetBuyFilterDialog() sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // *************************************************************************** @@ -1768,7 +1768,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get the modal window - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); if(!ig) return; // retrieve the edited values @@ -1792,7 +1792,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterDialog() sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // *************************************************************************** @@ -1801,7 +1801,7 @@ void CBotChatPageTrade::giveFocusToMaxEBChangeBuyFilterDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // get the modal window - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER)); if(!ig) return; // set focus on max @@ -1815,11 +1815,11 @@ void CBotChatPageTrade::startChangeBuyFilterMPDialog() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // show the modal - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_MP)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_MP)); if(!ig) return; // go - pIM->enableModalWindow(NULL, ig); + CWidgetManager::getInstance()->enableModalWindow(NULL, ig); } @@ -1837,7 +1837,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterMPDialog(uint ft) sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } @@ -1915,7 +1915,7 @@ void CBotChatPageTrade::sendCurrentBuyFilterToServer(bool resetBuyList) _TradePagesObs.start(); // update interface - CGroupContainer *gc = dynamic_cast(pIM->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); if (gc) { // unselect just buy list (don't need for sell) @@ -1989,7 +1989,7 @@ void CBotChatPageTrade::refreshResale() _TradePagesObs.start(); // update interface - CGroupContainer *gc = dynamic_cast(pIM->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BuyOnly ? WIN_BOT_CHAT_PAGE_BUY : WIN_BOT_CHAT_PAGE_TRADE)); if (gc) { // unselect just buy list (don't need for sell) @@ -2013,11 +2013,11 @@ void CBotChatPageTrade::startChangeBuyFilterClassDialog() if(dbClassMax) tempClassMax->setValue32(dbClassMax->getValue32()); // show the modal - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_CLASS)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_CLASS)); if(!ig) return; // go - pIM->enableModalWindow(NULL, ig); + CWidgetManager::getInstance()->enableModalWindow(NULL, ig); } @@ -2041,7 +2041,7 @@ void CBotChatPageTrade::resetBuyFilterClassDialog() sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // *************************************************************************** @@ -2066,7 +2066,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterClassDialog() sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } @@ -2091,11 +2091,11 @@ void CBotChatPageTrade::startChangeBuyFilterItemTypeDialog() // the list of possible item type to select is filled when the DB of bitfield change // show the modal - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_ITEM_TYPE)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_CHANGE_BUY_FILTER_ITEM_TYPE)); if(!ig) return; // go - pIM->enableModalWindow(NULL, ig); + CWidgetManager::getInstance()->enableModalWindow(NULL, ig); } // *************************************************************************** @@ -2111,7 +2111,7 @@ void CBotChatPageTrade::confirmChangeBuyFilterItemTypeDialog(ITEM_TYPE::TItemTy sendCurrentBuyFilterToServer(true); // and leave modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // *************************************************************************** @@ -2132,9 +2132,9 @@ void CBotChatPageTrade::startDestroyItemDialog() NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TRADE_ITEM:DESTROY_QUANTITY")->setValue32(quantity); // show the modal - CInterfaceGroup *ig= dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_DESTROY_ITEM)); + CInterfaceGroup *ig= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_DESTROY_ITEM)); if(!ig) return; - pIM->enableModalWindow(NULL, ig); + CWidgetManager::getInstance()->enableModalWindow(NULL, ig); } // *************************************************************************** @@ -2190,7 +2190,7 @@ void CBotChatPageTrade::confirmDestroyItemDialog() } // in all cases, close the modal - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); // if the quantity entered was correct if(quantity!=0 && quantity!=std::numeric_limits::max()) @@ -2551,7 +2551,7 @@ class CAHBotChatChangeResaleMargin : public IActionHandler virtual void execute(CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *ig = dynamic_cast(pIM->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_BOT_CHAT_SELL_BUY_ITEM)); if (!ig) return; CGroupEditBox *resaleMarginBox = dynamic_cast(ig->getGroup("header_opened:resell_group:can_resell:choose_resell:edit:eb")); if (resaleMarginBox) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 446174778..30985718c 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -92,7 +92,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId) { if (desc.FatherContainer != "ui:interface" ) { - fatherContainer = dynamic_cast(im->getElementFromId(desc.FatherContainer)); + fatherContainer = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(desc.FatherContainer)); if (!fatherContainer) { nlwarning(" Can't get father group, or bad type"); @@ -143,7 +143,7 @@ bool CChatWindow::create(const CChatWindowDesc &desc, const std::string &chatId) _EB->setAHOnEnter("chat_box_entry"); } - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); if (fatherContainer) { @@ -289,7 +289,7 @@ void CChatWindow::deleteContainer() proprietaryContainer->detachContainer(_Chat); // just detach } CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->delGroup (_Chat); } else @@ -667,7 +667,7 @@ void CChatGroupWindow::displayTellMessage(const ucstring &msg, NLMISC::CRGBA col gcChat->requireAttention(); - CInterfaceManager::getInstance()->setTopWindow(gcChat); + CWidgetManager::getInstance()->setTopWindow(gcChat); // add the text to this window CGroupList *gl = dynamic_cast(gcChat->getGroup("text_list")); @@ -769,7 +769,7 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c pGC->setSavable(true); pGC->setEscapable(true); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->addGroup (pGC); pGC->setParent(pRoot); // must be done before makeWindow pIM->makeWindow(pGC); @@ -896,7 +896,7 @@ bool CChatGroupWindow::removeFreeTeller(const std::string &containerID) { pIM->removeGroupContainerImage(_FreeTellers[i]->getId(), m); } - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pIM->unMakeWindow(_FreeTellers[i]); pRoot->delGroup (_FreeTellers[i]); _FreeTellers[i] = NULL; @@ -1377,7 +1377,7 @@ public: { CInterfaceManager *im = CInterfaceManager::getInstance(); std::string callerId = getParam(sParams, "id"); - CInterfaceElement *prevCaller = im->getElementFromId(callerId); + CInterfaceElement *prevCaller = CWidgetManager::getInstance()->getElementFromId(callerId); ucstring playerName = ::getFreeTellerName(prevCaller); if (!playerName.empty()) { diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index 7ba05b25c..b0248aa66 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -288,7 +288,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) // Run Menu if (!_ListMenuLeft.empty()) - pIM->enableModalWindow (this, _ListMenuLeft); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft); if (_AHOnLeftDblClick != NULL) { @@ -323,7 +323,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (!_ListMenuRight .empty()) { handled= true; - pIM->enableModalWindow (this, _ListMenuRight); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); } // If not handled here, ret to parent return handled; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 9b313ef75..f77bb4397 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -167,9 +167,9 @@ bool CCtrlScroll::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) if (prop) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceGroup *group = dynamic_cast(pIM->getElementFromId(prop)); + CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); if(group == NULL) - group = dynamic_cast(pIM->getElementFromId(this->getId(), prop)); + group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop)); if(group != NULL) setTarget (group); @@ -210,7 +210,7 @@ int CCtrlScroll::luaSetTarget(CLuaState &ls) std::string targetId = ls.toString(1); CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceGroup *group = dynamic_cast(pIM->getElementFromId(targetId)); + CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(targetId)); if(group != NULL) { setTarget (group); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index f5d68f690..980a8459b 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1858,11 +1858,11 @@ void CDBCtrlSheet::draw() if (_AHOnCanDrop != NULL) if ((pIM->getCapturePointerLeft() != NULL) && (pIM->getCapturePointerLeft() != this)) { - if ((pIM->getPointer()->getX() >= _XReal) && - (pIM->getPointer()->getX() < (_XReal + _WReal))&& - (pIM->getPointer()->getY() > _YReal) && - (pIM->getPointer()->getY() <= (_YReal+ _HReal))) - if (pIM->getCurrentWindowUnder() == pIM->getWindow(this)) + if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && + (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& + (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && + (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) + if (pIM->getCurrentWindowUnder() == CWidgetManager::getInstance()->getWindow(this)) { CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) @@ -2861,7 +2861,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if (getSheetId() != 0) { _CurrMenuSheet = this; - pIM->enableModalWindow (this, _ListMenuLeft); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft); } } // Always return true on LeftClick. @@ -2899,7 +2899,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if(!_ListMenuRight.empty()) { _CurrMenuSheet = this; - pIM->enableModalWindow (this, _ListMenuRight); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); } } // if sheetId==0, then may open the other menu @@ -2908,7 +2908,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if(!_ListMenuRightEmptySlot.empty()) { _CurrMenuSheet = this; - pIM->enableModalWindow (this, _ListMenuRightEmptySlot); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRightEmptySlot); } } } @@ -3638,7 +3638,7 @@ void CDBCtrlSheet::setupInit() { // typically replace "handl" with "handr" or vice versa CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceElement *pElt = pIM->getElementFromId (_Id, _OptString); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId (_Id, _OptString); CDBCtrlSheet *pOtherHand = dynamic_cast(pElt); if( !pOtherHand || pOtherHand ->getType() != CCtrlSheetInfo::SheetType_Item ) { diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 3ccc65b7c..30d25ba22 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -58,7 +58,7 @@ sint32 CDBGroupComboBox::evalContentWidth() const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(pIM->getElementFromId( loginFinished ? WIN_COMBO_BOX_MEASURE_MENU : WIN_COMBO_BOX_MEASURE_MENU_LOGIN )); + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( loginFinished ? WIN_COMBO_BOX_MEASURE_MENU : WIN_COMBO_BOX_MEASURE_MENU_LOGIN )); if( !groupMenu ) { return 0; @@ -551,10 +551,10 @@ public: return; // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(pIM->getElementFromId(loginFinished ? WIN_COMBO_BOX_SELECT_MENU: WIN_COMBO_BOX_SELECT_MENU_LOGIN )); + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(loginFinished ? WIN_COMBO_BOX_SELECT_MENU: WIN_COMBO_BOX_SELECT_MENU_LOGIN )); if( !groupMenu ) { - groupMenu= dynamic_cast(pIM->getElementFromId(WIN_COMBO_BOX_SELECT_MENU_OUTGAME)); + groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_COMBO_BOX_SELECT_MENU_OUTGAME)); } if( !groupMenu ) return; @@ -586,12 +586,12 @@ public: if(dynamic_cast(pCB->getRootWindow())) { groupMenu->setCloseSubMenuUsingPopModal(true); - pIM->pushModalWindow(pCB, groupMenu); + CWidgetManager::getInstance()->pushModalWindow(pCB, groupMenu); } else { groupMenu->setCloseSubMenuUsingPopModal(false); - pIM->enableModalWindow (pCB, groupMenu); + CWidgetManager::getInstance()->enableModalWindow (pCB, groupMenu); } } }; @@ -607,7 +607,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CDBGroupComboBox *pCB = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCB == NULL) return; // set the selection diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index c56b90d9e..f5b920383 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -252,7 +252,7 @@ sint CDBGroupListSheet::getCurScrollValue() // *************************************************************************** CGroupContainer *CDBGroupListSheet::getContainer() { - return dynamic_cast(CInterfaceManager::getInstance()->getWindow(this)); + return dynamic_cast(CWidgetManager::getInstance()->getWindow(this)); /* CGroupContainer *pGC = NULL; CInterfaceGroup *pParent = getParent(); while (pParent != NULL) @@ -326,7 +326,7 @@ void CDBGroupListSheet::updateCoords () if (_DisplayEmptySlot) { // increment num sheet if the empty slot is to be displayed - CDBCtrlSheet *pCS = dynamic_cast(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS != NULL && pCS->isSheetValid()) ++numValidSheets; } _ColumnMax = (uint) (ceil(sqrtf((float) numValidSheets))); @@ -388,7 +388,7 @@ void CDBGroupListSheet::updateCoords () if ( (_DisplayEmptySlot) && (i == 0) ) { _SheetChildren[i]->Valid= true; - CDBCtrlSheet *pCS = dynamic_cast(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS != NULL) { ctrl->setTextureNoItem (pCS->getTextureNoItem()); @@ -716,10 +716,10 @@ void CDBGroupListSheet::draw () CGroupContainer *pGC = getContainer(); if (pIM->getCurrentWindowUnder() == pGC) { - if ((pIM->getPointer()->getX() >= _XReal) && - (pIM->getPointer()->getX() < (_XReal + _WReal))&& - (pIM->getPointer()->getY() > _YReal) && - (pIM->getPointer()->getY() <= (_YReal+ _HReal))) + if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && + (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& + (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && + (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) @@ -942,7 +942,7 @@ sint32 CDBGroupListSheet::getNbElt () const // special display empty slot if ( (_DisplayEmptySlot) && (i == 0) ) { - CDBCtrlSheet *pCS = dynamic_cast(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCS != NULL) { ctrl->setTextureNoItem (pCS->getTextureNoItem()); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index ac3e6e45f..0dfd0c909 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -626,10 +626,10 @@ void CDBGroupListSheetText::draw () CGroupContainer *pGC = getContainer(); if (pIM->getCurrentWindowUnder() == pGC) { - if ((pIM->getPointer()->getX() >= _XReal) && - (pIM->getPointer()->getX() < (_XReal + _WReal))&& - (pIM->getPointer()->getY() > _YReal) && - (pIM->getPointer()->getY() <= (_YReal+ _HReal))) + if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && + (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& + (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && + (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) @@ -1008,7 +1008,7 @@ void CDBGroupListSheetText::CSheetChild::hide(CDBGroupListSheetText * /* pFather // *************************************************************************** CGroupContainer *CDBGroupListSheetText::getContainer() { - return dynamic_cast(CInterfaceManager::getInstance()->getWindow(this)); + return dynamic_cast(CWidgetManager::getInstance()->getWindow(this)); } // *************************************************************************** @@ -1184,7 +1184,7 @@ class CHandlerListSheetTextRightClick : public IActionHandler { if ( CDBCtrlSheet::getDraggedSheet() == NULL) { - pIM->enableModalWindow (ctrlSheet, listSheetTrade->_CtrlInfo._ListMenuRight); + CWidgetManager::getInstance()->enableModalWindow (ctrlSheet, listSheetTrade->_CtrlInfo._ListMenuRight); } } @@ -1201,7 +1201,7 @@ class CHandlerListSheetTextResetSelection : public IActionHandler { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CDBGroupListSheetText *listSheetTrade = dynamic_cast(pIM->getElementFromId(Params)); + CDBGroupListSheetText *listSheetTrade = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (listSheetTrade == NULL) return; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index c2633d567..d43d8e2f8 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -264,7 +264,7 @@ class CHandlerTeamShareChoose : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); CBitMemStream out; - CCtrlTextButton *pTB = dynamic_cast(pIM->getElementFromId("ui:interface:team_share:content:ok")); + CCtrlTextButton *pTB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share:content:ok")); if (pTB == NULL) return; if (pTB->getActive() == false) return; @@ -317,7 +317,7 @@ class CHandlerTeamShareValid : public IActionHandler CBitMemStream out; string strMsgName = "TEAM:SHARE_VALID"; - CCtrlTextButton *pTB = dynamic_cast(pIM->getElementFromId("ui:interface:team_share:content:ok")); + CCtrlTextButton *pTB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share:content:ok")); if (pTB != NULL) pTB->setActive(false); diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 7ec68afab..8bdac6a34 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -162,7 +162,7 @@ void CEncyclopediaManager::updateThema(uint32 nAlbumName, const CEncyMsgThema &t _AlbumNameSelected = nAlbumName; _ThemaNameSelected = t.Name; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pContainer = dynamic_cast(pIM->getElementFromId(CONT_ENCY)); + CInterfaceElement *pContainer = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CONT_ENCY)); if (pContainer != NULL) pContainer->setActive(true); } @@ -186,7 +186,7 @@ void CEncyclopediaManager::rebuildAlbumList() CInterfaceManager *pIM = CInterfaceManager::getInstance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); - CGroupTree *pTree = dynamic_cast(pIM->getElementFromId(LIST_ENCY_ALBUM)); + CGroupTree *pTree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ENCY_ALBUM)); nlassert(pTree != NULL); CGroupTree::SNode *pRoot = new CGroupTree::SNode; @@ -281,22 +281,22 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName) CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Hide and show good group - CInterfaceElement *pIE = pIM->getElementFromId(PAGE_ENCY_ALBUM); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_ALBUM); nlassert(pIE != NULL); pIE->setActive(true); - pIE = pIM->getElementFromId(PAGE_ENCY_HELP); + pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_HELP); pIE->setActive(false); - pIE = pIM->getElementFromId(PAGE_ENCY_THEMA); + pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_THEMA); pIE->setActive(false); // Setup title - CViewTextID *pVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_ALBUM ":title")); + CViewTextID *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_ALBUM ":title")); nlassert(pVT != NULL); pVT->setTextId(pAlbum->Name); // Setup brick reward NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:ALBUMBRICK:SHEET")->setValue32(pAlbum->RewardBrick); - CViewText *pRBVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_ALBUM ":reward:desc")); + CViewText *pRBVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_ALBUM ":reward:desc")); if (pRBVT != NULL) { STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); @@ -328,27 +328,27 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Hide and show good group - CInterfaceElement *pIE = pIM->getElementFromId(PAGE_ENCY_ALBUM); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_ALBUM); nlassert(pIE != NULL); pIE->setActive(false); - pIE = pIM->getElementFromId(PAGE_ENCY_HELP); + pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_HELP); pIE->setActive(false); - pIE = pIM->getElementFromId(PAGE_ENCY_THEMA); + pIE = CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_THEMA); pIE->setActive(true); // Setup title - CViewTextID *pVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_THEMA ":title")); + CViewTextID *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_THEMA ":title")); nlassert(pVT != NULL); pVT->setTextId(pThema->Name); // Setup rewards - pVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_THEMA ":reward_text:desc")); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_THEMA ":reward_text:desc")); nlassert(pVT != NULL); pVT->setTextId(pThema->RewardText); // Setup brick reward NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ENCY:REWARDBRICK:SHEET")->setValue32(pThema->RewardSheet); - CViewText *pRBVT = dynamic_cast(pIM->getElementFromId(PAGE_ENCY_THEMA ":reward:desc")); + CViewText *pRBVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PAGE_ENCY_THEMA ":reward:desc")); nlassert(pRBVT != NULL); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); CEntitySheet *pES = SheetMngr.get(CSheetId(pThema->RewardSheet)); @@ -392,7 +392,7 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) sTmp = PAGE_ENCY_THEMA ":todo:task" + toString(i); // setup task description - CViewTextID *pText = dynamic_cast(pIM->getElementFromId(sTmp+":desc")); + CViewTextID *pText = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTmp+":desc")); nlassert(pText != NULL); pText->setTextId(pThema->TaskName[i]); @@ -407,7 +407,7 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName) pText->setAlpha(160); // If the task is finished toggle it - CViewBitmap *pBitmap = dynamic_cast(pIM->getElementFromId(sTmp+":done")); + CViewBitmap *pBitmap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTmp+":done")); nlassert(pBitmap != NULL); if (pThema->getTaskState((uint8)i) == 2) pBitmap->setActive(true); diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index 6d28b7ec7..356393fe2 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -926,9 +926,9 @@ class CHandlerSetCompas : public IActionHandler std::string compassID = getParam(sParams, "compass"); std::string menuID = getParam(sParams, "menu"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupCompas *gc = dynamic_cast(im->getElementFromId(compassID)); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(compassID)); if (!gc) return; - CGroupCompasMenu *gcm = dynamic_cast(im->getElementFromId(menuID)); + CGroupCompasMenu *gcm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(menuID)); if (!gcm) return; int index; std::string id = getParam(sParams, "id"); @@ -938,7 +938,7 @@ class CHandlerSetCompas : public IActionHandler gc->setTarget(gcm->Targets[index]); gc->setActive(true); gc->blink(); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); } } }; @@ -967,13 +967,13 @@ class CHandlerSetTeamCompas : public IActionHandler CCompassTarget ct; if(buildCompassTargetFromTeamMember(ct, peopleIndex)) { - CGroupCompas *gc= dynamic_cast(pIM->getElementFromId(compassID)); + CGroupCompas *gc= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(compassID)); if(gc) { gc->setTarget(ct); gc->setActive(true); gc->blink(); - pIM->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); } } } @@ -989,7 +989,7 @@ class CHandlerSetCompassNorth : public IActionHandler { std::string compassID = getParam(sParams, "compass"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupCompas *gc = dynamic_cast(im->getElementFromId(compassID)); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(compassID)); if (!gc) return; gc->setTarget(CCompassTarget()); } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 8ea72a0df..19e3891f9 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -712,7 +712,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) _MoveDeltaYReal= _Parent->getYReal() - _Parent->getY(); _Moving= true; // set the window at top. - CInterfaceManager::getInstance()->setTopWindow(_Parent); + CWidgetManager::getInstance()->setTopWindow(_Parent); if (gc->getAHOnBeginMovePtr()) { CInterfaceManager *im = CInterfaceManager::getInstance(); @@ -2086,7 +2086,7 @@ void CGroupContainer::draw () { CRGBA c = CRGBA(255,255,255,255); // Display the header in white if we are the last clicked window - if (pIM->getTopWindow(pIM->getLastTopWindowPriority()) != this) + if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != this) { if (_HeaderColor.getNodePtr() != NULL) c = _HeaderColor.getRGBA(); @@ -2194,7 +2194,7 @@ void CGroupContainer::draw () // manage rollover - CViewPointer *mousePointer = pIM->getPointer(); + CViewPointer *mousePointer = CWidgetManager::getInstance()->getPointer(); if (mousePointer) { bool dontFade = false; @@ -3204,9 +3204,9 @@ void CGroupContainer::setActive (bool state) if(state != getActive() && getLayer()==0) { if (state) - pIM->setTopWindow(this); + CWidgetManager::getInstance()->setTopWindow(this); else - pIM->setBackWindow(this); + CWidgetManager::getInstance()->setBackWindow(this); } pIM->submitEvent((state?"show:":"hide:")+getId()); @@ -3290,7 +3290,7 @@ void CGroupContainer::popupCurrentPos() CInterfaceManager *im = CInterfaceManager::getInstance(); im->makeWindow(this); - im->setTopWindow(this); + CWidgetManager::getInstance()->setTopWindow(this); im->clearViewUnders(); im->clearCtrlsUnders(); @@ -3512,7 +3512,7 @@ public: { im->runActionHandler(pIC->getAHOnCloseButton(), pCaller, pIC->getAHOnCloseButtonParams()); } - CInterfaceManager::getInstance()->setBackWindow(pIC); + CWidgetManager::getInstance()->setBackWindow(pIC); pIC->setActive(false); } } @@ -3641,7 +3641,7 @@ void CGroupContainer::setOpenable(bool openable) void CGroupContainer::rollOverAlphaUp() { CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewPointer *vp = im->getPointer(); + CViewPointer *vp = CWidgetManager::getInstance()->getPointer(); float speed = im->getAlphaRolloverSpeed(); if (!isIn(vp->getX(), vp->getY())) { @@ -3741,9 +3741,9 @@ void CGroupContainer::setModalParentList (const std::string &name) // add each of them (if possible) for(uint i=0;i(pIM->getElementFromId(modalParents[i])); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(modalParents[i])); if (pGC == NULL) - pGC = dynamic_cast(pIM->getElementFromId("ui:interface:"+modalParents[i])); + pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+modalParents[i])); if (pGC == NULL) nlwarning(" not found %s",modalParents[i].c_str()); else @@ -3944,7 +3944,7 @@ CRGBA CGroupContainer::getDrawnHeaderColor () const CRGBA c = CRGBA(255,255,255,255); // Display the header in white if we are the last clicked window - if (pIM->getTopWindow(pIM->getLastTopWindowPriority()) != static_cast(this)) + if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != static_cast(this)) { if (_HeaderColor.getNodePtr() != NULL) c = _HeaderColor.getRGBA(); @@ -3974,7 +3974,7 @@ void CGroupContainer::requireAttention() // Window have headers opened => blink it if is not the top window if (isOpen()) { - if (getId() != CInterfaceManager::getInstance()->getTopWindow()->getId()) + if (getId() != CWidgetManager::getInstance()->getTopWindow()->getId()) { enableBlink(3); } diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 0afbe81b5..478bb73a2 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -885,7 +885,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) if (CDBCtrlSheet::getDraggedSheet() == NULL) { _MenuFather = this; - pIM->enableModalWindow (this, _ListMenuRight); + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); stopParentBlink(); } } @@ -1307,7 +1307,7 @@ void CGroupEditBox::makeTopWindow() CInterfaceGroup *root = getRootWindow(); if (root) { - im->setTopWindow(root); + CWidgetManager::getInstance()->setTopWindow(root); } } diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index 93f418a65..964f6ca82 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -418,7 +418,7 @@ bool CGroupHeaderEntry::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) CInterfaceGroup *CGroupHeaderEntry::getTargetColumn() const { CInterfaceManager *im = CInterfaceManager::getInstance(); - return dynamic_cast(im->getElementFromId(_TargetColumnId)); + return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_TargetColumnId)); } // ***************************************************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 82a8d3828..c566fd477 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -2221,7 +2221,7 @@ void CGroupHTML::doBrowse(const char *url) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupTree *groupTree=dynamic_cast(pIM->getElementFromId(_BrowseTree)); + CGroupTree *groupTree=dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseTree)); if(groupTree) { string nodeId= selectTreeNodeRecurs(groupTree->getRootNode(), url); @@ -3634,8 +3634,8 @@ void CGroupHTML::browseRedo() void CGroupHTML::updateUndoRedoButtons() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCtrlBaseButton *butUndo= dynamic_cast(pIM->getElementFromId(_BrowseUndoButton)); - CCtrlBaseButton *butRedo= dynamic_cast(pIM->getElementFromId(_BrowseRedoButton)); + CCtrlBaseButton *butUndo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton)); + CCtrlBaseButton *butRedo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton)); // gray according to list size if(butUndo) @@ -3648,7 +3648,7 @@ void CGroupHTML::updateUndoRedoButtons() void CGroupHTML::updateRefreshButton() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CCtrlBaseButton *butRefresh = dynamic_cast(pIM->getElementFromId(_BrowseRefreshButton)); + CCtrlBaseButton *butRefresh = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton)); bool enabled = !_Browsing && !_Connecting; if(butRefresh) diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp index 4414556b0..426c6dbd5 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp @@ -56,7 +56,7 @@ void CGroupHTMLQCM::addText (const char * buf, int len) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->runActionHandler("quit_ryzom", NULL); - CInterfaceElement *pIE = pIM->getElementFromId("ui:interface:web_on_quit"); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:web_on_quit"); pIE->setActive(false); } diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 0b84f7749..1ab1f40bc 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -38,7 +38,7 @@ public: { CInterfaceManager *pIM= CInterfaceManager::getInstance(); string container = getParam (sParams, "name"); - CGroupHTML *groupHtml = dynamic_cast(pIM->getElementFromId(container)); + CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(container)); if (groupHtml) { groupHtml->browse(groupHtml->Home.c_str()); @@ -199,7 +199,7 @@ struct CWebigNotificationThread : public NLMISC::IRunnable if(_CheckMailNode) { _CheckMailNode->setValue32(nbmail==0?0:1); - CInterfaceElement *elm = pIM->getElementFromId("ui:interface:compass:mail:mail_nb"); + CInterfaceElement *elm = CWidgetManager::getInstance()->getElementFromId("ui:interface:compass:mail:mail_nb"); if (elm) { CViewText *vt = dynamic_cast(elm); @@ -226,7 +226,7 @@ struct CWebigNotificationThread : public NLMISC::IRunnable if(_CheckForumNode) { _CheckForumNode->setValue32(nbforum==0?0:1); - CInterfaceElement *elm = pIM->getElementFromId("ui:interface:compass:forum:forum_nb"); + CInterfaceElement *elm = CWidgetManager::getInstance()->getElementFromId("ui:interface:compass:forum:forum_nb"); if (elm) { CViewText *vt = dynamic_cast(elm); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 3b442ce3b..be8d1a950 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -61,7 +61,7 @@ void contextHelp (const std::string &name) string target = pIM->getDefine(defineTarget); string url = pIM->getDefine(defineUrl); - CInterfaceElement *elementTarget = pIM->getElementFromId(target); + CInterfaceElement *elementTarget = CWidgetManager::getInstance()->getElementFromId(target); if (elementTarget && elementTarget->getActive()) { // Add the context help @@ -165,7 +165,7 @@ void CGroupInSceneBubbleManager::alignMessagePopup (vector &rList, bool // First message must be aligned from the screen if (!rList.empty()) { - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); if (pRoot) { sint i = (sint)rList.size ()-1; @@ -234,7 +234,7 @@ void CGroupInSceneBubbleManager::init () { // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -359,7 +359,7 @@ void CGroupInSceneBubbleManager::update () if (!_BubblePopup[i].Target.empty()) { // Get the target - CInterfaceElement *target = pIM->getElementFromId(_BubblePopup[i].Target); + CInterfaceElement *target = CWidgetManager::getInstance()->getElementFromId(_BubblePopup[i].Target); if (target) { // Target is good ? @@ -539,7 +539,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -588,7 +588,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -637,7 +637,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -663,7 +663,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont string v="m"; string h="m"; - target = CInterfaceManager::getInstance()->getElementFromId(targetName); + target = CWidgetManager::getInstance()->getElementFromId(targetName); if (target) { // Find a position @@ -711,7 +711,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -904,7 +904,7 @@ void CGroupInSceneBubbleManager::dynChatOpen (uint32 nBotUID, uint32 nBotName, c } // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -1017,7 +1017,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con } // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); @@ -1468,7 +1468,7 @@ void CGroupInSceneBubble::setRawText (const ucstring &text) { _CanBeShown = !text.empty(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pVTIE = pIM->getElementFromId(getId()+":header_opened:window:text"); + CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text"); CViewText *pVT= dynamic_cast(pVTIE); if (pVT != NULL) pVT->setText(text); @@ -1479,11 +1479,11 @@ void CGroupInSceneBubble::setRawText (const ucstring &text) void CGroupInSceneBubble::displayNextAndSkip(bool show) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE = pIM->getElementFromId(getId()+":header_opened:window:but_next"); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:but_next"); if (pIE != NULL) pIE->setActive(show); - pIE = pIM->getElementFromId(getId()+":header_opened:window:but_skip"); + pIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:but_skip"); if (pIE != NULL) pIE->setActive(show); - pIE = pIM->getElementFromId(getId()+":header_opened:window:text"); + pIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text"); if (pIE != NULL) { if (show) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index d19c2dcd3..7d0253978 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -742,7 +742,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity) // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", info); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); info->setParent(pRoot); if (pRoot) pRoot->addGroup (info); @@ -1156,7 +1156,7 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::newGroupInScene(const std::string { // NB : only use the fast version during edition because duplication of CCDBCtrlSheet not implemented now, but we don't // use it for the edition !!!! - CInterfaceElement *prototype = im->getElementFromId("ui:interface:" + templateName + "_proto"); + CInterfaceElement *prototype = CWidgetManager::getInstance()->getElementFromId("ui:interface:" + templateName + "_proto"); if (prototype && dynamic_cast(prototype)) { extern bool NoOpForCCtrlSheetInfo_Serial; // CCDBCtrlSheet::serial not implemented, but prevent an assert in its serial because diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 91c245851..c8d45b576 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -573,10 +573,10 @@ void CGroupList::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = pIM->getViewRenderer(); - if (pIM->getModalWindow() == NULL) + if (CWidgetManager::getInstance()->getModalWindow() == NULL) { - sint32 x = pIM->getPointer()->getX(); - sint32 y = pIM->getPointer()->getY(); + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); CInterfaceGroup *pIG = pIM->getWindowUnder(x, y); CInterfaceGroup *pParent = this; diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 6cdd08bbc..f2bf62aff 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -98,13 +98,13 @@ static void popupLandMarkNameDialog() { // pop the rename dialog CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(WIN_LANDMARK_NAME)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_LANDMARK_NAME)); if (!gc) return; gc->setActive(true); gc->updateCoords(); gc->center(); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->enableBlink(1); CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); @@ -133,7 +133,7 @@ static void popupLandMarkNameDialog() static void closeLandMarkNameDialog() { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(WIN_LANDMARK_NAME)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_LANDMARK_NAME)); if (!gc) return; gc->setActive(false); } @@ -721,7 +721,7 @@ bool CGroupMap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) _RespawnSelectedBitmap->setPosRef(Hotspot_MM); addView(_RespawnSelectedBitmap); - //CCtrlBaseButton *pCB = dynamic_cast(CInterfaceManager::getInstance()->getElementFromId(_RespawnButton)); + //CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_RespawnButton)); //if (pCB != NULL) pCB->setActive(false); } nlassert(!_FrustumView); @@ -1578,13 +1578,13 @@ void CGroupMap::draw() _FrustumView->setQuad(fruQuad); _FrustumView->updateCoords(); // handle mouse over - if (im->getPointer()) + if (CWidgetManager::getInstance()->getPointer()) { sint32 originX, originY; getCorner(originX, originY, getPosRef()); CVector delta((float) originX, (float) originY, 0.f); fruTri = CTriangle(fruQuad.V0, fruQuad.V1, fruQuad.V2); - CVector mousePos((float) im->getPointer()->getXReal(), (float) im->getPointer()->getYReal(), 0.f); + CVector mousePos((float) CWidgetManager::getInstance()->getPointer()->getXReal(), (float) CWidgetManager::getInstance()->getPointer()->getYReal(), 0.f); mousePos -= delta; CVector dummyHit; float deltaBlend = DT / (0.001f * (float) _FrustumViewBlendTimeInMs); @@ -2396,13 +2396,13 @@ static void hideTeleportButtonsInPopupMenuIfNotEnoughPriv() bool showTeleport = (hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeVG() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeEG()); CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *ie = im->getElementFromId("ui:interface:map_menu:teleport"); + CInterfaceElement *ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:map_menu:teleport"); if(ie) ie->setActive(showTeleport); - ie = im->getElementFromId("ui:interface:land_mark_menu:lmteleport"); + ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:land_mark_menu:lmteleport"); if(ie) ie->setActive(showTeleport); - ie = im->getElementFromId("ui:interface:user_land_mark_menu:lmteleport"); + ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:user_land_mark_menu:lmteleport"); if(ie) ie->setActive(showTeleport); } @@ -2878,7 +2878,7 @@ void CGroupMap::targetLandmark(CCtrlButton *lm) { NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_RESPAWN_PT")->setValue32(_RespawnSelected); // Close window containing the map - CInterfaceGroup *pGrp = pIM->getWindow(this); + CInterfaceGroup *pGrp = CWidgetManager::getInstance()->getWindow(this); if (pGrp != NULL) pGrp->setActive(false); } invalidateCoords(); @@ -2936,13 +2936,13 @@ void CGroupMap::targetLandmark(CCtrlButton *lm) if (found) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupCompas *gc = dynamic_cast(im->getElementFromId(_CompassId)); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_CompassId)); if (gc) { gc->setActive(true); gc->setTarget(ct); gc->blink(); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); } } } @@ -3197,7 +3197,7 @@ class CAHValidateUserLandMarkName : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* params */) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *ig = dynamic_cast(im->getElementFromId(WIN_LANDMARK_NAME)); + CInterfaceGroup *ig = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_LANDMARK_NAME)); if (!ig) return; CGroupEditBox *eb = dynamic_cast(ig->getGroup("eb")); if (!eb) return; @@ -3241,7 +3241,7 @@ void createUserLandMark(CCtrlBase * /* pCaller */, const string &/* params */) { CInterfaceManager *im = CInterfaceManager::getInstance(); // pop the rename dialog - LastClickedMap = dynamic_cast(im->getCtrlLaunchingModal()); + LastClickedMap = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (LastClickedMap->isInDeathMode()) return; if (LastClickedMap->getNumUserLandMarks() >= CContinent::getMaxNbUserLandMarks() ) { @@ -3284,7 +3284,7 @@ class CAHMapZoomIn : public IActionHandler { std::string map = getParam(params, "map"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *gm = dynamic_cast(im->getElementFromId(map)); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (!gm) return; NLMISC::CVector2f center; gm->windowToMap(center, gm->getWReal() / 2, gm->getHReal() / 2); @@ -3301,7 +3301,7 @@ class CAHMapZoomOut : public IActionHandler { std::string map = getParam(params, "map"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *gm = dynamic_cast(im->getElementFromId(map)); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (!gm) return; NLMISC::CVector2f center; gm->windowToMap(center, gm->getWReal() / 2, gm->getHReal() / 2); @@ -3318,7 +3318,7 @@ class CAHMapCenter : public IActionHandler { std::string map = getParam(params, "map"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *gm = dynamic_cast(im->getElementFromId(map)); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (!gm) return; gm->centerOnPlayer(); } @@ -3333,7 +3333,7 @@ class CAHMapBack : public IActionHandler { std::string map = getParam(params, "map"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *pGM = dynamic_cast(im->getElementFromId(map)); + CGroupMap *pGM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (pGM == NULL) return; SMap *pMap = pGM->getParentMap(pGM->getCurMap()); if (pMap != NULL) @@ -3350,7 +3350,7 @@ class CAHRespawnMapValid : public IActionHandler { std::string map = getParam(params, "map"); CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *gm = dynamic_cast(im->getElementFromId(map)); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (!gm) return; if (gm->getRespawnSelected() == -1) return; @@ -3406,7 +3406,7 @@ class CAHWorldMapRightClick : public IActionHandler hideTeleportButtonsInPopupMenuIfNotEnoughPriv(); - CGroupMap *gm = dynamic_cast(im->getElementFromId(map)); + CGroupMap *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(map)); if (!gm) return; if (!gm->isIsland()) { @@ -3457,7 +3457,7 @@ class CAHMapTeleport : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* params */) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMap *clickedMap = dynamic_cast(im->getCtrlLaunchingModal()); + CGroupMap *clickedMap = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); closeLandMarkNameDialog(); NLMISC::CVector2f pos = clickedMap->getRightClickLastPos(); clickedMap->mapToWorld(pos, pos); @@ -3512,7 +3512,7 @@ class CUpdateLandMarksColor : public IActionHandler{public: virtual void execute - CGroupMap *pGM = dynamic_cast(pIM->getElementFromId("ui:interface:map:content:map_content:actual_map")); + CGroupMap *pGM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pGM == NULL) return; pGM->updateUserLandMarks(); @@ -3555,7 +3555,7 @@ NLMISC_COMMAND( testRespawn, "Debug : test respawn map", "" ) rpm.RespawnPoints.push_back(CRespawnPointsMsg::SRespawnPoint(4050*1000,-4200*1000)); rpm.RespawnPoints.push_back(CRespawnPointsMsg::SRespawnPoint(4200*1000,-4150*1000)); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); if (pMap == NULL) { nlwarning("problem cannot find ui:interface:respawn_map:content:map_content:actual_map"); @@ -3564,7 +3564,7 @@ NLMISC_COMMAND( testRespawn, "Debug : test respawn map", "" ) pMap->addRespawnPoints(rpm); - pMap = dynamic_cast(pIM->getElementFromId("ui:interface:map:content:map_content:actual_map")); + pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap == NULL) { nlwarning("problem cannot find ui:interface:map:content:map_content:actual_map"); @@ -3584,7 +3584,7 @@ NLMISC_COMMAND( setMap, "Debug : test respawn map", "" ) if (args.size() != 1) return false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId("ui:interface:map:content:map_content:actual_map")); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap != NULL) pMap->setMap(args[0]); diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index dcadb3e82..9f8bbf3aa 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -867,8 +867,8 @@ void CGroupSubMenu::checkCoords() // if the mouse goes out the window, unselect all (because handleEvent may not be called) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - sint xMouse= pIM->getPointer()->getX(); - sint yMouse= pIM->getPointer()->getY(); + sint xMouse= CWidgetManager::getInstance()->getPointer()->getX(); + sint yMouse= CWidgetManager::getInstance()->getPointer()->getY(); if (!((xMouse >= _XReal) && (xMouse < (_XReal + _WReal))&& (yMouse > _YReal) && @@ -984,7 +984,7 @@ bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); pIM->runActionHandler ( _Lines[_Selected].AHName, - pIM->getCtrlLaunchingModal(), + CWidgetManager::getInstance()->getCtrlLaunchingModal(), _Lines[_Selected].AHParams ); if (_SubMenus[_Selected] != NULL) @@ -994,12 +994,12 @@ bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) else { // if the menu hasn't triggered a new modal window, disable it - if (pIM->getModalWindow() == _GroupMenu) + if (CWidgetManager::getInstance()->getModalWindow() == _GroupMenu) { if(_GroupMenu && _GroupMenu->getCloseSubMenuUsingPopModal()) - pIM->popModalWindow(); + CWidgetManager::getInstance()->popModalWindow(); else - pIM->disableModalWindow (); + CWidgetManager::getInstance()->disableModalWindow (); } } } @@ -1936,10 +1936,10 @@ bool CGroupMenu::parse (xmlNodePtr in, CInterfaceGroup *parentGroup) if (prop) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupMenu *gm = dynamic_cast(im->getElementFromId(prop)); + CGroupMenu *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); if (!gm) { - gm = dynamic_cast(im->getElementFromId("ui:interface:" + std::string((const char*)prop))); + gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop))); } if (gm) { diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp index adf817b8d..6ca9541d4 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -57,11 +57,11 @@ void CGroupModalGetKey::setActive (bool state) else pIM->setCaptureKeyboard (NULL); - CViewText *pVT= dynamic_cast(pIM->getElementFromId( VIEW_TEXT_KEY )); + CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); if (pVT != NULL) pVT->setText(string("")); - pVT= dynamic_cast(pIM->getElementFromId( VIEW_TEXT_INUSE )); + pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_INUSE )); if (pVT != NULL) pVT->setText(string("")); - CCtrlBaseButton *pCB= dynamic_cast(pIM->getElementFromId( CTRL_BUTTON_OK )); + CCtrlBaseButton *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CTRL_BUTTON_OK )); if (pCB != NULL) pCB->setFrozen(true); CGroupModal::setActive(state); @@ -85,7 +85,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) // Setup the text ! CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT= dynamic_cast(pIM->getElementFromId( VIEW_TEXT_KEY )); + CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); if (pVT != NULL) pVT->setText(Combo.toUCString()); // Check if in use @@ -101,7 +101,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) { const CActionsManager::TComboActionMap &keyShortcut = pCurAM->getComboActionMap(); CActionsManager::TComboActionMap::const_iterator it = keyShortcut.find(Combo); - pVT = dynamic_cast(pIM->getElementFromId( VIEW_TEXT_INUSE )); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_INUSE )); if (it != keyShortcut.end()) { const CBaseAction *baseAction = pCurAM->getBaseAction(it->second); @@ -118,7 +118,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event) } // Show the ok button - CCtrlBaseButton *pCB= dynamic_cast(pIM->getElementFromId( CTRL_BUTTON_OK )); + CCtrlBaseButton *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CTRL_BUTTON_OK )); if (pCB != NULL) pCB->setFrozen(false); } // } diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index 5cc17105e..e600638a4 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -773,10 +773,10 @@ void CGroupParagraph::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = pIM->getViewRenderer(); - if (pIM->getModalWindow() == NULL) + if (CWidgetManager::getInstance()->getModalWindow() == NULL) { - sint32 x = pIM->getPointer()->getX(); - sint32 y = pIM->getPointer()->getY(); + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); CInterfaceGroup *pIG = pIM->getWindowUnder(x,y); CInterfaceGroup *pParent = this; diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index 775a0acf2..10f23bb9a 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -153,7 +153,7 @@ void CGroupPhraseSkillFilter::rebuild() // get the tree if (_Tree == NULL) { - _Tree = dynamic_cast(pIM->getElementFromId(getId(),"sbtree:tree_list")); + _Tree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(getId(),"sbtree:tree_list")); if (_Tree == NULL) { diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 3f829c8ef..26245433a 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -359,7 +359,7 @@ class CHandlerSubmitQuickHelp : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { - CInterfaceElement *element = CInterfaceManager::getInstance()->getElementFromId("ui:interface:quick_help:content:html"); + CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId("ui:interface:quick_help:content:html"); if (element) { // Group HTML ? @@ -370,7 +370,7 @@ class CHandlerSubmitQuickHelp : public IActionHandler groupQH->submitEvent (sParams.c_str()); } } - element = CInterfaceManager::getInstance()->getElementFromId("ui:interface:help_browser:content:html"); + element = CWidgetManager::getInstance()->getElementFromId("ui:interface:help_browser:content:html"); if (element) { // Group HTML ? @@ -400,7 +400,7 @@ class CHandlerRunQuickHelp : public IActionHandler if (!buttonId.empty()) { // Get the button id - CInterfaceElement *element = pIM->getElementFromId(buttonId+":"+sParams); + CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(buttonId+":"+sParams); if (element) { // Button Ctrl ? diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 619438f12..8fc17fac5 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -124,7 +124,7 @@ void CGroupSkills::rebuild() // **** first time bind? if(!_Tree) { - _Tree = dynamic_cast(pIM->getElementFromId(getId(),WIN_TREE_LIST)); + _Tree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(getId(),WIN_TREE_LIST)); if (_Tree == NULL) { nlwarning("cant find tree"); diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 6eb9159e3..9797f0844 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -571,10 +571,10 @@ void CGroupTree::draw() bDisplayOver = false; } else - if (pIM->getModalWindow() == NULL) + if (CWidgetManager::getInstance()->getModalWindow() == NULL) { - sint32 x = pIM->getPointer()->getX(); - sint32 y = pIM->getPointer()->getY(); + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); CInterfaceGroup *pIG = pIM->getWindowUnder(x, y); CInterfaceGroup *pParent = this; @@ -1331,7 +1331,7 @@ public: void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupTree *pTree = dynamic_cast(pIM->getElementFromId(sParams)); + CGroupTree *pTree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); if (pTree != NULL) pTree->reset(); } diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 79a39c56d..7092cd903 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -325,12 +325,12 @@ void CGuildManager::update() // Open the guild info if we are not in the init phase if (!IngameDbMngr.initInProgress()) { - pElt = pIM->getElementFromId(WIN_GUILD); + pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD); if (pElt != NULL) pElt->setActive(true); } // Browse the forum - pElt = pIM->getElementFromId(WIN_GUILD_FORUM":content:html"); + pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM":content:html"); if (pElt != NULL) { CGroupHTML *html = dynamic_cast(pElt); @@ -423,17 +423,17 @@ void CGuildManager::update() NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade); // update the guild display - CGroupContainer *pGuild = dynamic_cast(pIM->getElementFromId(WIN_GUILD)); + CGroupContainer *pGuild = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD)); if (pGuild != NULL) { // if the guild window is visible if (pGuild->isOpen() && pGuild->getActive()) { // Close the modal window if the member list will change - if(pIM->getModalWindow()!=NULL && _NeedUpdateMembers) + if(CWidgetManager::getInstance()->getModalWindow()!=NULL && _NeedUpdateMembers) { - if (pIM->getModalWindow()->getId() == MENU_GUILD_MEMBER ) - pIM->disableModalWindow(); + if (CWidgetManager::getInstance()->getModalWindow()->getId() == MENU_GUILD_MEMBER ) + CWidgetManager::getInstance()->disableModalWindow(); } // Rebuild interface. Rebuild members only if needed @@ -456,15 +456,15 @@ void CGuildManager::update() if (bAllValid) { _JoinPropUpdate = false; - CGroupContainer *pJoinProp = dynamic_cast(pIM->getElementFromId(WIN_JOIN_PROPOSAL)); + CGroupContainer *pJoinProp = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_JOIN_PROPOSAL)); if (pJoinProp != NULL) { - CViewText *pJoinPropPhraseView = dynamic_cast(pIM->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE)); + CViewText *pJoinPropPhraseView = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE)); if (pJoinPropPhraseView != NULL) pJoinPropPhraseView->setText(_JoinPropPhrase); pJoinProp->setActive(true); - pIM->setTopWindow(pJoinProp); + CWidgetManager::getInstance()->setTopWindow(pJoinProp); pJoinProp->updateCoords(); pJoinProp->center(); pJoinProp->enableBlink(2); @@ -498,10 +498,10 @@ void CGuildManager::launchAscensor() // Start Ascensor Interface CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pAC = dynamic_cast(pIM->getElementFromId(WIN_ASCENSOR)); + CGroupContainer *pAC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_ASCENSOR)); if (pAC == NULL) return; pAC->setActive(true); - pIM->setTopWindow(pAC); + CWidgetManager::getInstance()->setTopWindow(pAC); } // TEMP TEMP TEMP @@ -550,7 +550,7 @@ NLMISC_COMMAND(testAscensorPage, "Temp : Simulate the server that fills the data void CGuildManager::quitAscensor() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pAC = dynamic_cast(pIM->getElementFromId(WIN_ASCENSOR)); + CGroupContainer *pAC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_ASCENSOR)); if (pAC == NULL) return; pAC->setActive(false); } @@ -566,7 +566,7 @@ void CGuildManager::launchJoinProposal(uint32 phraseID) void CGuildManager::quitJoinProposal() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pJoinProp = dynamic_cast(pIM->getElementFromId(WIN_JOIN_PROPOSAL)); + CGroupContainer *pJoinProp = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_JOIN_PROPOSAL)); if (pJoinProp != NULL) pJoinProp->setActive(false); } @@ -575,13 +575,13 @@ void CGuildManager::quitJoinProposal() void CGuildManager::closeAllInterfaces() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGuild = dynamic_cast(pIM->getElementFromId(WIN_GUILD)); + CGroupContainer *pGuild = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD)); if (pGuild != NULL) pGuild->setActive(false); - CGroupContainer *pGuildForum = dynamic_cast(pIM->getElementFromId(WIN_GUILD_FORUM)); + CGroupContainer *pGuildForum = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM)); if (pGuildForum != NULL) pGuildForum->setActive(false); - CGroupContainer *pGuildChat = dynamic_cast(pIM->getElementFromId(WIN_GUILD_CHAT)); + CGroupContainer *pGuildChat = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_CHAT)); if (pGuildChat != NULL) pGuildChat->setActive(false); } @@ -598,13 +598,13 @@ void CGuildManager::openGuildWindow() // node->setValue64(1); // // CInterfaceElement *pElt; -// pElt = pIM->getElementFromId(WIN_GUILD); +// pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD); // if (pElt != NULL) // { // pElt->setActive(true); // } // // Browse the forum -// pElt = pIM->getElementFromId(WIN_GUILD_FORUM":content:html"); +// pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM":content:html"); // if (pElt != NULL) // { // CGroupHTML *html = dynamic_cast(pElt); @@ -785,7 +785,7 @@ class CAHGuildSheetOpen : public IActionHandler const SGuild &rGuild = pGM->getGuild(); // Freeze / unfreeze quit button - CCtrlBaseButton *control = dynamic_cast(pIM->getElementFromId(VIEW_TEXT_GUILD_QUIT)); + CCtrlBaseButton *control = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TEXT_GUILD_QUIT)); if (control) control->setFrozen (!rGuild.QuitGuildAvailable || pGM->isProxy()); @@ -799,12 +799,12 @@ class CAHGuildSheetOpen : public IActionHandler // update member count view const vector &rGuildMembers = pGM->getGuildMembers(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId(VIEW_TEXT_GUILD_MEMBER_COUNT)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TEXT_GUILD_MEMBER_COUNT)); if (pVT) pVT->setText(toString(rGuildMembers.size())); // rebuild guild member list - CGroupList *pParent = dynamic_cast(pIM->getElementFromId(LIST_GUILD_MEMBERS)); + CGroupList *pParent = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_MEMBERS)); if (pParent == NULL) return; pParent->clearGroups(); pParent->setDynamicDisplaySize(false); @@ -892,19 +892,19 @@ static void setRights(bool lead, bool hioff, bool offi, bool recr, bool bear, bo { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewTextMenu *pVTM; - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":lead"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":lead"))); if (pVTM != NULL) pVTM->setGrayed(!lead); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":hiof"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":hiof"))); if (pVTM != NULL) pVTM->setGrayed(!hioff); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":offi"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":offi"))); if (pVTM != NULL) pVTM->setGrayed(!offi); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":recr"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":recr"))); if (pVTM != NULL) pVTM->setGrayed(!recr); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":bear"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":bear"))); if (pVTM != NULL) pVTM->setGrayed(!bear); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":memb"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":memb"))); if (pVTM != NULL) pVTM->setGrayed(!memb); - pVTM = dynamic_cast(pIM->getElementFromId(string(MENU_GUILD_MEMBER":kick"))); + pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER":kick"))); if (pVTM != NULL) pVTM->setGrayed(!kick); } @@ -918,11 +918,11 @@ class CAHGuildSheetMenuOpen : public IActionHandler const vector &rGuildMembers = pGM->getGuildMembers(); // *** Check and retrieve the current member index (index in the member list) - CCtrlBase *ctrlLaunchingModal= pIM->getCtrlLaunchingModal(); + CCtrlBase *ctrlLaunchingModal= CWidgetManager::getInstance()->getCtrlLaunchingModal(); if (pCaller == NULL || ctrlLaunchingModal == NULL) { // Error -> Close - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return; } string sId = ctrlLaunchingModal->getId(); @@ -932,7 +932,7 @@ class CAHGuildSheetMenuOpen : public IActionHandler if ((nLineNb < 0) || (nLineNb >= (sint32)rGuildMembers.size())) { // Error -> Close - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return; } MemberIndexSelected= nLineNb; @@ -942,7 +942,7 @@ class CAHGuildSheetMenuOpen : public IActionHandler if(MemberNameSelected.empty()) { // Error -> Close - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return; } @@ -1052,7 +1052,7 @@ public: CGuildManager *pGM = CGuildManager::getInstance(); const vector &rGuildMembers = pGM->getGuildMembers(); // *** Check and retrieve the current member index (index in the member list) - CCtrlBase *ctrlLaunchingModal= pIM->getCtrlLaunchingModal(); + CCtrlBase *ctrlLaunchingModal= CWidgetManager::getInstance()->getCtrlLaunchingModal(); if (pCaller == NULL) { // Error -> Close @@ -1355,7 +1355,7 @@ class CHandlerGuildInvGetMoney : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { sendMoneyServerMessage("GUILD:TAKE_MONEY"); - CInterfaceManager::getInstance()->popModalWindow(); + CWidgetManager::getInstance()->popModalWindow(); } }; REGISTER_ACTION_HANDLER (CHandlerGuildInvGetMoney, "guild_inv_get_money"); @@ -1367,7 +1367,7 @@ class CHandlerGuildInvPutMoney : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { sendMoneyServerMessage("GUILD:PUT_MONEY"); - CInterfaceManager::getInstance()->popModalWindow(); + CWidgetManager::getInstance()->popModalWindow(); } }; REGISTER_ACTION_HANDLER (CHandlerGuildInvPutMoney, "guild_inv_put_money"); diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 18420ef82..3332e33ac 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -258,7 +258,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) } } // **** Event Mouse - else if(pIM->getPointer() && _Focus /* && pIM->isMouseHandlingEnabled() */ && + else if(CWidgetManager::getInstance()->getPointer() && _Focus /* && pIM->isMouseHandlingEnabled() */ && ( event == EventMouseMoveId || event == EventMouseDownId || event == EventMouseUpId || @@ -268,7 +268,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) { - CViewPointer &rIP = *pIM->getPointer(); + CViewPointer &rIP = *CWidgetManager::getInstance()->getPointer(); NLGUI::CEventDescriptorMouse eventDesc; diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 52186b823..fc0582d19 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -162,7 +162,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) _Ref3DScene = NULL; if (ptr) { - CInterfaceElement *pIE = pIM->getElementFromId(this->getId(), ptr); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(this->getId(), ptr); _Ref3DScene = dynamic_cast(pIE); } if (_Ref3DScene != NULL) @@ -705,7 +705,7 @@ void CInterface3DScene::setCurrentCamera (const string &name) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterface3DScene *pI3DS = (_Ref3DScene != NULL) ? _Ref3DScene : this; - CInterfaceElement *pIE = pIM->getElementFromId(pI3DS->getId(), name); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(pI3DS->getId(), name); CInterface3DCamera *pI3DCam = dynamic_cast(pIE); if (pI3DCam != NULL) { @@ -732,7 +732,7 @@ void CInterface3DScene::setCurrentClusterSystem(const string &sCSName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterface3DScene *pI3DS = (_Ref3DScene != NULL) ? _Ref3DScene : this; - CInterfaceElement *pIE = pIM->getElementFromId(pI3DS->getId(), sCSName); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(pI3DS->getId(), sCSName); CInterface3DIG *pI3DIG = dynamic_cast(pIE); if (pI3DIG != NULL) { diff --git a/code/ryzom/client/src/interface_v3/interface_config.cpp b/code/ryzom/client/src/interface_v3/interface_config.cpp index 486b05487..34fb9d52e 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.cpp +++ b/code/ryzom/client/src/interface_v3/interface_config.cpp @@ -565,7 +565,7 @@ void CInterfaceConfig::CDesktopImage::fromCurrentDesktop() f.resetPtrTable(); f.seek(0, NLMISC::IStream::begin); // Save the Top Window for this config. - CInterfaceGroup *topWindow= pIM->getTopWindow(pIM->getLastTopWindowPriority()); + CInterfaceGroup *topWindow= CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()); string topWindowName; if (topWindow) { @@ -595,7 +595,7 @@ void CInterfaceConfig::CDesktopImage::toCurrentDesktop() for(uint k = 0; k < GCImages.size(); ++k) { - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(GCImages[k].Id)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GCImages[k].Id)); if (pGC != NULL) GCImages[k].setTo(pGC); } @@ -617,9 +617,9 @@ void CInterfaceConfig::CDesktopImage::toCurrentDesktop() f.serial(topWindowName); if(!topWindowName.empty()) { - CInterfaceGroup *window= dynamic_cast(pIM->getElementFromId(topWindowName)); + CInterfaceGroup *window= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(topWindowName)); if(window && window->getActive()) - pIM->setTopWindow(window); + CWidgetManager::getInstance()->setTopWindow(window); } } uint32 numElemWithConfig; @@ -632,7 +632,7 @@ void CInterfaceConfig::CDesktopImage::toCurrentDesktop() f.serial(chunkSize); uint startPos = f.getPos(); CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *elem = im->getElementFromId(elemID); + CInterfaceElement *elem = CWidgetManager::getInstance()->getElementFromId(elemID); if (!elem) { nlwarning("Element %s not found while loading config, skipping datas", elemID.c_str()); diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index c22c5204a..73f4873b4 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -627,7 +627,7 @@ bool CInterfaceDDX::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) else if( stricmp((char*)cur->name,"apply") == 0 ) { CXMLAutoPtr ptrUI((const char*)xmlGetProp (cur, (xmlChar*)"ui")); - _ApplyButton = dynamic_cast(pIM->getElementFromId(_Parent->getId(),(const char*)ptrUI)); + _ApplyButton = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_Parent->getId(),(const char*)ptrUI)); } cur = cur->next; @@ -1083,7 +1083,7 @@ public: CDDXManager *pDM = CDDXManager::getInstance(); if (pCaller == NULL) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlBase *pCB = pIM->getCtrlLaunchingModal(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCtrlLaunchingModal(); // Search for a ddx in the parents CInterfaceGroup *pIG = pCB->getParent(); bool found = false; diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 949e0875d..091c941cd 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -120,7 +120,7 @@ static DECLARE_INTERFACE_USER_FCT(isOpen) { if (args.size() != 1) return false; if (!args[0].toString()) return false; - CGroupContainer *elm = dynamic_cast(CInterfaceManager::getInstance()->getElementFromId(args[0].getString())); + CGroupContainer *elm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(args[0].getString())); if (!elm) { nlwarning(" : can't find element %s", args[0].getString().c_str()); @@ -733,7 +733,7 @@ static DECLARE_INTERFACE_USER_FCT(isCtrlLaunchModalMacro) } CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CDBCtrlSheet *ctrl= dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *ctrl= dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); result.setBool( ctrl->isMacro() ); diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index aa1f880e8..356ca8c38 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -157,7 +157,7 @@ static DECLARE_INTERFACE_USER_FCT(getSheetFromId) { if (args.size() != 1 || !args[0].toString()) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - CDBCtrlSheet *sheet = dynamic_cast(im->getElementFromId(args[0].getString())); + CDBCtrlSheet *sheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(args[0].getString())); if (!sheet) { nlwarning("Sheet %s not found", args[0].getString().c_str()); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 24fd256f3..814560331 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -246,7 +246,7 @@ void CInterfaceGroup::setPriority(uint8 nprio) { if (nprio != _Priority) { - CInterfaceManager::getInstance()->setWindowPriority(this, nprio); + CWidgetManager::getInstance()->setWindowPriority(this, nprio); } } diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 8b783d03b..4a7315ef0 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -477,7 +477,7 @@ bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup { // try the absolute adress of the element elmPath = target.substr(0, lastPos); - elm = CInterfaceManager::getInstance()->getElementFromId(elmPath); + elm = CWidgetManager::getInstance()->getElementFromId(elmPath); elmProp = target.substr(lastPos + 1); } @@ -544,7 +544,7 @@ void CInterfaceLink::setTargetProperty (const std::string &Target, const CInt // Eval target ! string elt = Target.substr(0,Target.rfind(':')); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE = pIM->getElementFromId(elt); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceGroup *pIG = dynamic_cast(pIE); if (pIG == NULL) pIG = pIE->getParent(); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e5d10e45a..41f678289 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -181,10 +181,6 @@ CChatDisplayer * ChatDisplayer = NULL; void initActions(); void uninitActions(); -// ------------------------------------------------------------------------------------------------ -string CInterfaceManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; - - // ------------------------------------------------------------------------------------------------ static const uint DOUBLE_CLICK_MIN = 50; static const uint DOUBLE_CLICK_MAX = 750; @@ -268,7 +264,6 @@ _ViewRenderer( driver, textcontext ) interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; - _Pointer = NULL; _DescTextTarget = NULL; _GlobalColor = CRGBA(255,255,255,255); _GlobalColorForContent = _GlobalColor; @@ -294,7 +289,7 @@ _ViewRenderer( driver, textcontext ) _EmotesInitialized = false; // context help - _DeltaTimeStopingContextHelp= 0; + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; _MaxTimeStopingContextHelp= 0.2f; _LastXContextHelp= -10000; _LastYContextHelp= -10000; @@ -377,7 +372,7 @@ void CInterfaceManager::reset() { _ViewRenderer.reset(); _CtrlsUnderPointer.clear(); - _CurCtrlContextHelp = ""; + CWidgetManager::getInstance()->setCurContextHelp( NULL ); _ViewsUnderPointer.clear(); _GroupsUnderPointer.clear(); _CaptureKeyboard = NULL; @@ -421,7 +416,7 @@ void CInterfaceManager::resetShardSpecificData() CSPhraseManager *pPM= CSPhraseManager::getInstance(); pPM->setEquipInvalidation(0, 0); - CGroupContainer *pGC = dynamic_cast(getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); if (pGC != NULL) pGC->setActive(false); } @@ -484,7 +479,7 @@ void CInterfaceManager::initLogin() updateAllLocalisedElements(); - activateMasterGroup ("ui:login", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:login", true); { initActions(); @@ -495,12 +490,12 @@ void CInterfaceManager::initLogin() void CInterfaceManager::uninitLogin() { - activateMasterGroup ("ui:login", false); + CWidgetManager::getInstance()->activateMasterGroup ("ui:login", false); removeAll(); reset(); - _Pointer = NULL; + CWidgetManager::getInstance()->setPointer( NULL ); CInterfaceLink::removeAllLinks(); @@ -574,7 +569,7 @@ void CInterfaceManager::initOutGame() updateAllLocalisedElements(); - activateMasterGroup ("ui:outgame", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", true); // if (!ClientCfg.FSHost.empty()) // { @@ -598,7 +593,7 @@ void CInterfaceManager::uninitOutGame() if (ClientCfg.SelectCharacter != -1) return; - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); //_Database->display(""); CBotChatManager::getInstance()->setCurrPage(NULL); @@ -615,7 +610,7 @@ void CInterfaceManager::uninitOutGame() //nlinfo ("%d seconds for uninitOutGame", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); - activateMasterGroup ("ui:outgame", false); + CWidgetManager::getInstance()->activateMasterGroup ("ui:outgame", false); //nlinfo ("%d seconds for activateMasterGroup", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); removeAll(); @@ -624,7 +619,7 @@ void CInterfaceManager::uninitOutGame() reset(); //nlinfo ("%d seconds for reset", (uint32)(ryzomGetLocalTime ()-initStart)/1000); // reset the mouse pointer to avoid invalid pointer access - _Pointer = NULL; + CWidgetManager::getInstance()->setPointer( NULL ); initStart = ryzomGetLocalTime (); CInterfaceLink::removeAllLinks(); //nlinfo ("%d seconds for removeAllLinks", (uint32)(ryzomGetLocalTime ()-initStart)/1000); @@ -787,7 +782,7 @@ void CInterfaceManager::initInGame() //CBotChatUI::refreshActiveWindows(); // bot chat windows are saved too.. - activateMasterGroup ("ui:interface", true); + CWidgetManager::getInstance()->activateMasterGroup ("ui:interface", true); // Update the time in the ui database _CheckMailNode = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:MAIL_WAITING"); @@ -826,7 +821,7 @@ void CInterfaceManager::initInGame() nlinfo ("%d seconds for initInGame", (uint32)(ryzomGetLocalTime ()-initStart)/1000); // reset the compass target - CGroupCompas *gc = dynamic_cast(getElementFromId("ui:interface:compass")); + CGroupCompas *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); if (gc && gc->isSavedTargetValid()) { gc->setTarget(gc->getSavedTarget()); @@ -887,7 +882,7 @@ void CInterfaceManager::configureQuitDialogBox() CInterfaceManager *pIM = CInterfaceManager::getInstance(); string quitDialogMainStr = "ui:interface:quit_dialog"; string quitDialogStr = quitDialogMainStr + ":indent_middle"; - CInterfaceGroup *quitDlg = dynamic_cast(pIM->getElementFromId(quitDialogStr)); + CInterfaceGroup *quitDlg = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(quitDialogStr)); if (quitDlg) { CInterfaceElement *eltRet, *eltQuit, *eltQuitNow; @@ -976,7 +971,7 @@ void CInterfaceManager::configureQuitDialogBox() } // Make all controls have the same size - CInterfaceGroup *quitDlgMain = dynamic_cast(pIM->getElementFromId(quitDialogMainStr)); + CInterfaceGroup *quitDlgMain = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(quitDialogMainStr)); if ( quitDlgMain ) { @@ -1148,10 +1143,10 @@ void CInterfaceManager::uninitInGame1 () } // disable the game_quitting modal window - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); // Remove all interface objects (containers, groups, variables, defines, ...) - activateMasterGroup ("ui:interface", false); + CWidgetManager::getInstance()->activateMasterGroup ("ui:interface", false); removeAll(); reset(); CInterfaceLink::removeAllLinks(); @@ -1287,7 +1282,7 @@ void CInterfaceManager::updateFrameEvents() CI18N::get (WeatherManager.getCurrWeatherState().LocalizedName); - CViewText *pVT = dynamic_cast(getElementFromId("ui:interface:map:content:map_content:weather")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather")); if (pVT != NULL) pVT->setText(str); @@ -1311,13 +1306,13 @@ void CInterfaceManager::updateFrameEvents() str += CI18N::get("uiAtysianCycle" + toString(RT.getRyzomCycle()+1) + "Ordinal") + " " + CI18N::get("uiAtysianCycle") + " "; str += toString("%04d", RT.getRyzomYear()); - pVT = dynamic_cast(getElementFromId("ui:interface:map:content:map_content:time")); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time")); if (pVT != NULL) pVT->setText(str); str.clear(); // Update the clock in the compass if enabled. - pVT = dynamic_cast(getElementFromId("ui:interface:compass:clock:time")); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass:clock:time")); if (pVT != NULL) { if (pVT->getActive()) @@ -1962,10 +1957,8 @@ void CInterfaceManager::checkCoords() } } - if (_Pointer != NULL) - { - _Pointer->updateCoords(); - } + if ( CWidgetManager::getInstance()->getPointer() != NULL) + CWidgetManager::getInstance()->getPointer()->updateCoords(); } @@ -1973,10 +1966,10 @@ void CInterfaceManager::checkCoords() if (bRecomputeCtrlUnderPtr) { H_AUTO ( RZ_Interface_RecomputeCtrlUnderPtr ) - if (_Pointer) + if ( CWidgetManager::getInstance()->getPointer() != NULL ) { - sint32 mx = _Pointer->getX(); - sint32 my = _Pointer->getY(); + sint32 mx = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 my = CWidgetManager::getInstance()->getPointer()->getY(); getViewsUnder (mx, my, _ViewsUnderPointer); getCtrlsUnder (mx, my, _CtrlsUnderPointer); getGroupsUnder (mx, my, _GroupsUnderPointer); @@ -2130,17 +2123,17 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) drawContextHelp (); // Draw the pointer and DND Item - if (_Pointer != NULL) + if ( CWidgetManager::getInstance()->getPointer() != NULL) { //_Pointer->updateCoords(); - if (_Pointer->show()) + if ( CWidgetManager::getInstance()->getPointer()->show()) { CDBCtrlSheet *pCS = dynamic_cast((CCtrlBase*)_CapturePointerLeft); if ((pCS != NULL) && (pCS->isDraging())) { - sint x= _Pointer->getX() - pCS->getDeltaDragX(); - sint y= _Pointer->getY() - pCS->getDeltaDragY(); + sint x= CWidgetManager::getInstance()->getPointer()->getX() - pCS->getDeltaDragX(); + sint y= CWidgetManager::getInstance()->getPointer()->getY() - pCS->getDeltaDragY(); pCS->drawSheet (x, y, false, false); // if the control support CopyDrag, and if copy key pressed, display a tiny "+" @@ -2158,8 +2151,8 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // Even if hardware, Force draw if the cursor is a string (ATTACK etc...) /*if (_Pointer->getActive() && (!IsMouseCursorHardware () || _Pointer->getStringMode()) ) _Pointer->draw ();*/ - if (_Pointer->getActive()) - _Pointer->draw (); + if (CWidgetManager::getInstance()->getPointer()->getActive()) + CWidgetManager::getInstance()->getPointer()->draw (); } // flush layers @@ -2188,9 +2181,9 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl() { if ((pICL->getActive()) && (!pICL->emptyContextHelp())) { - if (!_Pointer) return pICL; + if (!CWidgetManager::getInstance()->getPointer()) return pICL; sint32 mx, my; - _Pointer->getPointerPos(mx, my); + CWidgetManager::getInstance()->getPointer()->getPointerPos(mx, my); if (pICL->preciseHitTest(mx, my)) { best = pICL; @@ -2210,9 +2203,9 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl() { if ((pICL->getActive()) && (!pICL->emptyContextHelp())) { - if (!_Pointer) return pICL; + if (!CWidgetManager::getInstance()->getPointer()) return pICL; sint32 mx, my; - _Pointer->getPointerPos(mx, my); + CWidgetManager::getInstance()->getPointer()->getPointerPos(mx, my); if (pICL->preciseHitTest(mx, my)) { best = pICL; @@ -2235,7 +2228,7 @@ CInterfaceGroup *CInterfaceManager::getWindowForActiveMasterGroup(const std::str const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { - CInterfaceElement *pEL= getElementFromId( rMG.Group->getId() + ":" + window); + CInterfaceElement *pEL= CWidgetManager::getInstance()->getElementFromId( rMG.Group->getId() + ":" + window); if(pEL && pEL->isGroup()) return (CInterfaceGroup*)pEL; } @@ -2248,7 +2241,7 @@ CInterfaceGroup *CInterfaceManager::getWindowForActiveMasterGroup(const std::str // ---------------------------------------------------------------------------- void CInterfaceManager::updateTooltipCoords() { - updateTooltipCoords(_CurCtrlContextHelp); + updateTooltipCoords( CWidgetManager::getInstance()->getCurContextHelp() ); } // ---------------------------------------------------------------------------- @@ -2271,8 +2264,8 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) CCtrlBase::TToolTipParentType parentType= newCtrl->getToolTipParent(); CInterfaceGroup *win= NULL; // adjust to the mouse by default - sint32 xParent= _Pointer->getX(); - sint32 yParent= _Pointer->getY(); + sint32 xParent= CWidgetManager::getInstance()->getPointer()->getX(); + sint32 yParent= CWidgetManager::getInstance()->getPointer()->getY(); sint32 wParent= 0; sint32 hParent= 0; // adjust to the window @@ -2281,7 +2274,7 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) if(parentType==CCtrlBase::TTWindow) win= newCtrl->getRootWindow(); else - win= dynamic_cast(getElementFromId(newCtrl->getToolTipSpecialParent())); + win= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(newCtrl->getToolTipSpecialParent())); if(win) { xParent = win->getXReal(); @@ -2336,19 +2329,20 @@ void CInterfaceManager::updateTooltipCoords(CCtrlBase *newCtrl) // ---------------------------------------------------------------------------- void CInterfaceManager::drawContextHelp () { - if (!_Pointer || !_ContextHelpActive) + if (!CWidgetManager::getInstance()->getPointer() || !_ContextHelpActive) return; - sint32 x = _Pointer->getX(); - sint32 y = _Pointer->getY(); + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); // *************** // **** try to disable // *************** // test disable first, so can recheck asap if another present. see below - if(_CurCtrlContextHelp) + CCtrlBase *_CurCtrlContextHelp = CWidgetManager::getInstance()->getCurContextHelp(); + if( _CurCtrlContextHelp) { if(x!=_LastXContextHelp || y!=_LastYContextHelp) { @@ -2393,12 +2387,12 @@ void CInterfaceManager::drawContextHelp () CCtrlBase *newCtrl= getNewContextHelpCtrl(); if(x==_LastXContextHelp && y==_LastYContextHelp) - _DeltaTimeStopingContextHelp+= DT; + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp+= DT; else - _DeltaTimeStopingContextHelp= 0; + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; // If reach the time limit - if( _DeltaTimeStopingContextHelp > _MaxTimeStopingContextHelp || (newCtrl && newCtrl->wantInstantContextHelp())) + if( CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp > _MaxTimeStopingContextHelp || (newCtrl && newCtrl->wantInstantContextHelp())) { // if present, get the ctx help text. if(newCtrl) @@ -2419,11 +2413,11 @@ void CInterfaceManager::drawContextHelp () // not present? wait furthermore to move the mouse. if(!newCtrl) - _DeltaTimeStopingContextHelp= 0; + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp= 0; else { // enable - _CurCtrlContextHelp = newCtrl->getId(); + CWidgetManager::getInstance()->setCurContextHelp( newCtrl ); newCtrl->invalidateCoords(); } } @@ -2443,9 +2437,9 @@ void CInterfaceManager::drawContextHelp () /** If there's a modal box around, should be sure that the context help doesn't intersect it. * If this is the case, we just disable it, unless the tooltip was generated by the current modal window */ - if (!_ModalStack.empty()) + if ( CWidgetManager::getInstance()->hasModal() ) { - CInterfaceGroup *mw = _ModalStack.back().ModalWindow; + CInterfaceGroup *mw = CWidgetManager::getInstance()->getModal().ModalWindow; if (mw && mw->isIn(*groupContextHelp)) { if (_CurCtrlContextHelp->isSonOf(mw)) @@ -2674,6 +2668,7 @@ uint CInterfaceManager::getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentW bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool handled= false; + CViewPointer *_Pointer = CWidgetManager::getInstance()->getPointer(); if( event.getType() == NLGUI::CEventDescriptor::system ) { @@ -2712,11 +2707,11 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // Hide menu (or popup menu) is ESCAPE pressed if( eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) { - if(_ModalStack.size() > 0) + if( CWidgetManager::getInstance()->hasModal() ) { - CModalWndInfo mwi = _ModalStack.back(); + CWidgetManager::SModalWndInfo mwi = CWidgetManager::getInstance()->getModal(); if (mwi.ModalExitKeyPushed) - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } @@ -2724,7 +2719,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if( eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyESCAPE ) { // Get the last escapable active top window. NB: this is ergonomically better. - CInterfaceGroup *win= getLastEscapableTopWindow(); + CInterfaceGroup *win= CWidgetManager::getInstance()->getLastEscapableTopWindow(); if( win ) { // If the window is a modal, must pop it. @@ -2732,7 +2727,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { if(!win->getAHOnEscape().empty()) runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); - popModalWindow(); + CWidgetManager::getInstance()->popModalWindow(); handled= true; } // else just disable it. @@ -2751,7 +2746,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keychar && eventDesc.getChar() == KeyRETURN) { // If the top window has Enter AH - CInterfaceGroup *tw= getTopWindow(); + CInterfaceGroup *tw= CWidgetManager::getInstance()->getTopWindow(); if(tw && !tw->getAHOnEnter().empty()) { // if the captured keyboard is in this Modal window, then must handle him in priority @@ -2804,7 +2799,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } if (lastContainer) { - setTopWindow(lastContainer); + CWidgetManager::getInstance()->setTopWindow(lastContainer); lastContainer->enableBlink(1); } handled= true; @@ -2868,9 +2863,9 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) NLMISC::CRefPtr clickedOutModalWindow; // modal special features - if (!_ModalStack.empty()) + if ( CWidgetManager::getInstance()->hasModal() ) { - CModalWndInfo mwi = _ModalStack.back(); + CWidgetManager::SModalWndInfo mwi = CWidgetManager::getInstance()->getModal(); if(mwi.ModalWindow) { // If we are not in "click out" mode so we dont handle controls other than those of the modal @@ -2898,22 +2893,12 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { clickedOutModalWindow = dynamic_cast((CInterfaceGroup*)mwi.ModalWindow); // disable the modal - popModalWindow(); - if (!_ModalStack.empty()) + CWidgetManager::getInstance()->popModalWindow(); + if ( CWidgetManager::getInstance()->hasModal() ) { // don't handle event unless it is a previous modal window - uint k = 0; - for(k = 0; k < _ModalStack.size(); ++k) - { - if (_ModalStack[k].ModalWindow == pNewCurrentWnd) - { - break; - } - } - if (k == _ModalStack.size()) - { + if( !CWidgetManager::getInstance()->isPreviousModal( pNewCurrentWnd ) ) pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows - } } movePointer (0,0); // Reget controls under pointer } @@ -2925,16 +2910,16 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // Manage LeftClick. if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { - if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) + if ((pNewCurrentWnd != NULL) && (!CWidgetManager::getInstance()->hasModal()) && (pNewCurrentWnd->getOverlappable())) { CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); if (pGC != NULL) { - if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); + if (!pGC->isGrayed()) CWidgetManager::getInstance()->setTopWindow(pNewCurrentWnd); } else { - setTopWindow(pNewCurrentWnd); + CWidgetManager::getInstance()->setTopWindow(pNewCurrentWnd); } } @@ -2977,16 +2962,16 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // Manage RightClick if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { - if ((pNewCurrentWnd != NULL) && (_ModalStack.empty()) && (pNewCurrentWnd->getOverlappable())) + if ((pNewCurrentWnd != NULL) && (!CWidgetManager::getInstance()->hasModal()) && (pNewCurrentWnd->getOverlappable())) { CGroupContainer *pGC = dynamic_cast(pNewCurrentWnd); if (pGC != NULL) { - if (!pGC->isGrayed()) setTopWindow(pNewCurrentWnd); + if (!pGC->isGrayed()) CWidgetManager::getInstance()->setTopWindow(pNewCurrentWnd); } else { - setTopWindow(pNewCurrentWnd); + CWidgetManager::getInstance()->setTopWindow(pNewCurrentWnd); } } @@ -3037,7 +3022,8 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // window handling. if not handled by a control if (!handled) { - if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))) + if (((pNewCurrentWnd != NULL) && !CWidgetManager::getInstance()->hasModal()) || + ((CWidgetManager::getInstance()->hasModal() && CWidgetManager::getInstance()->getModal().ModalWindow == pNewCurrentWnd))) { NLGUI::CEventDescriptorMouse ev2 = eventDesc; sint32 x= eventDesc.getX(), y = eventDesc.getY(); @@ -3069,17 +3055,17 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // If the current window is the modal, may Modal quit. Do it after standard event handle - if(!_ModalStack.empty() && pNewCurrentWnd == _ModalStack.back().ModalWindow) + if(CWidgetManager::getInstance()->hasModal() && pNewCurrentWnd == CWidgetManager::getInstance()->getModal().ModalWindow) { // NB: don't force handle==true because to quit a modal does not avoid other actions - CModalWndInfo mwi = _ModalStack.back(); + CWidgetManager::SModalWndInfo mwi = CWidgetManager::getInstance()->getModal(); // and if must quit on click right if(mwi.ModalExitClickR) { // quit if click right if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) // disable the modal - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } // and if must quit on click left @@ -3088,7 +3074,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // quit if click right if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) // disable the modal - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } @@ -3111,8 +3097,8 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve uint32 screenW, screenH; _ViewRenderer.getScreenSize( screenW, screenH ); - sint32 oldX = _Pointer->getX(); - sint32 oldY = _Pointer->getY(); + sint32 oldX = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 oldY = CWidgetManager::getInstance()->getPointer()->getY(); sint32 x = e.getX(); sint32 y = e.getY(); @@ -3126,8 +3112,8 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve { movePointerAbs( newX, newY ); NLGUI::CEventDescriptorMouse &ve = const_cast< NLGUI::CEventDescriptorMouse& >( e ); - ve.setX( _Pointer->getX() ); - ve.setY( _Pointer->getY() ); + ve.setX( CWidgetManager::getInstance()->getPointer()->getX() ); + ve.setY( CWidgetManager::getInstance()->getPointer()->getY() ); } return true; @@ -3136,7 +3122,8 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve // ------------------------------------------------------------------------------------------------ void CInterfaceManager::movePointer (sint32 dx, sint32 dy) { - if (!_Pointer) return; + if (!CWidgetManager::getInstance()->getPointer()) return; + CViewPointer *_Pointer = CWidgetManager::getInstance()->getPointer(); uint32 nScrW, nScrH; sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; @@ -3173,14 +3160,14 @@ void CInterfaceManager::movePointer (sint32 dx, sint32 dy) // ------------------------------------------------------------------------------------------------ void CInterfaceManager::movePointerAbs(sint32 px, sint32 py) { - if (!_Pointer) return; + if (!CWidgetManager::getInstance()->getPointer()) return; uint32 nScrW, nScrH; _ViewRenderer.getScreenSize (nScrW, nScrH); clamp(px, 0, (sint32) nScrW); clamp(py, 0, (sint32) nScrH); // - _Pointer->setPointerPos (px, py); - _Pointer->setPointerDispPos (px, py); + CWidgetManager::getInstance()->getPointer()->setPointerPos (px, py); + CWidgetManager::getInstance()->getPointer()->setPointerDispPos (px, py); // getViewsUnder (px, py, _ViewsUnderPointer); getCtrlsUnder (px, py, _CtrlsUnderPointer); @@ -3609,7 +3596,7 @@ void CInterfaceManager::getCtrlsUnder (sint32 x, sint32 y, std::vectorhasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || CWidgetManager::getInstance()->getModal().ModalExitClickOut) if (pIG->getActive() && pIG->getUseCursor()) { if (pIG->getCtrlsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vICL)) @@ -3649,7 +3636,8 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vectorhasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || + CWidgetManager::getInstance()->getModal().ModalExitClickOut) if (pIG->getActive() && pIG->getUseCursor()) { if (pIG->isIn(x, y)) @@ -3666,323 +3654,10 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vectorgetMasterGroupFromId (sMasterGroupName); - if (pIG != NULL) - { - pIG->setActive(bActive); - pIG->invalidateCoords(); - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceManager::getWindow(CInterfaceElement *pIE) -{ - CInterfaceGroup *pIG = pIE->getParent(); - if (pIG == NULL) return NULL; - if (pIG->getParent() == NULL) return NULL; - while (pIG->getParent()->getParent() != NULL) - { - pIG = pIG->getParent(); - } - return pIG; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sEltId) -{ - // System special - if(sEltId == _CtrlLaunchingModalId) - return getCtrlLaunchingModal(); - - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - - // Search for all elements - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - CInterfaceElement *pIEL = rMG.Group->getElement (sEltId); - if (pIEL != NULL) - return pIEL; - } - return NULL; -} - // ------------------------------------------------------------------------------------------------ CInterfaceElement* CInterfaceManager::getElementFromDefine (const std::string &defineId) { - return getElementFromId(getDefine(defineId)); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CInterfaceManager::getElementFromId (const std::string &sStart, const std::string &sEltId) -{ - CInterfaceElement *pIEL = getElementFromId (sEltId); - if (pIEL == NULL) - { - string sZeStart = sStart, sTmp; - if (sZeStart[sZeStart.size()-1] == ':') - sZeStart = sZeStart.substr(0, sZeStart.size()-1); - - while (sZeStart != "") - { - if (sEltId[0] == ':') - sTmp = sZeStart + sEltId; - else - sTmp = sZeStart + ":" + sEltId; - pIEL = getElementFromId (sTmp); - if (pIEL != NULL) - return pIEL; - string::size_type nextPos = sZeStart.rfind(':'); - if (nextPos == string::npos) break; - sZeStart = sZeStart.substr(0, nextPos); - } - } - return pIEL; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::setTopWindow (CInterfaceGroup* win) -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - //find the window in the window list - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - rMG.setTopWindow(win); -/* - for (list::iterator it = rMG.Windows.begin(); it != rMG.Windows.end() ;it++) - { - if (win == *it) - { - CInterfaceGroup* buf = *it; - - CInterfaceGroup* pIGLast = rMG.Windows.back(); - if (pIGLast != NULL) - { - CGroupContainer *pGC = dynamic_cast(pIGLast); - if (pGC != NULL) - { - pGC->setHighLighted(false,0); - } - } - - rMG.Windows.erase(it); - rMG.Windows.push_back(buf); - break; - } - } -*/ - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::setBackWindow(CInterfaceGroup* win) -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - rMG.setBackWindow(win); -/* - //find the window in the window list - for (list::iterator it = rMG.Windows.begin(); it != rMG.Windows.end() ;it++) - { - if (win == *it) - { - CInterfaceGroup* buf = *it; - rMG.Windows.erase(it); - rMG.Windows.push_front(buf); - break; - } - } -*/ - } - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup *CInterfaceManager::getTopWindow (uint8 nPriority) const -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - // return the first. - if(rMG.PrioritizedWindows[nPriority].empty()) - return NULL; - else - return rMG.PrioritizedWindows[nPriority].back(); - } - } - return NULL; -} - - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup *CInterfaceManager::getBackWindow (uint8 nPriority) const -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - // return the first. - if(rMG.PrioritizedWindows[nPriority].empty()) - return NULL; - else - return rMG.PrioritizedWindows[nPriority].front(); - } - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) -{ - // disable any modal before. release keyboard - disableModalWindow(); - pushModalWindow(ctrlLaunchingModal, pIG); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::enableModalWindow (CCtrlBase *CtrlLaunchingModal, const std::string &groupName) -{ - CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); - if(group) - { - // enable the modal - enableModalWindow(CtrlLaunchingModal, group); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::disableModalWindow () -{ - while (!_ModalStack.empty()) - { - CModalWndInfo winInfo = _ModalStack.back(); - _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash - // disable old modal window - if(winInfo.ModalWindow) - { - setBackWindow(winInfo.ModalWindow); - winInfo.ModalWindow->setActive(false); - } - } - - // disable any context help - _CurCtrlContextHelp = ""; - _DeltaTimeStopingContextHelp = 0; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) -{ - // enable the wanted modal - if(pIG) - { - CModalWndInfo mwi; - mwi.ModalWindow = pIG; - mwi.CtrlLaunchingModal = ctrlLaunchingModal; - // setup special group - CGroupModal *groupModal= dynamic_cast(pIG); - if(groupModal) - { - mwi.ModalExitClickOut = groupModal->ExitClickOut; - mwi.ModalExitClickL = groupModal->ExitClickL; - mwi.ModalExitClickR = groupModal->ExitClickR; - mwi.ModalHandlerClickOut = groupModal->OnClickOut; - mwi.ModalClickOutParams = groupModal->OnClickOutParams; - mwi.ModalExitKeyPushed = groupModal->ExitKeyPushed; - // update coords of the modal - if(groupModal->SpawnOnMousePos) - { - groupModal->SpawnMouseX = _Pointer->getX(); - groupModal->SpawnMouseY = _Pointer->getY(); - - } - } - else - { - // default for group not modal. Backward compatibility - mwi.ModalExitClickOut = false; - mwi.ModalExitClickL = false; - mwi.ModalExitClickR = false; - mwi.ModalExitKeyPushed = false; - } - - _ModalStack.push_back(mwi); - - // update coords and activate the modal - mwi.ModalWindow->invalidateCoords(); - mwi.ModalWindow->setActive(true); - setTopWindow(mwi.ModalWindow); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, const std::string &groupName) -{ - CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); - if(group) - { - // enable the modal - enableModalWindow(ctrlLaunchingModal, group); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::popModalWindow() -{ - if (!_ModalStack.empty()) - { - CModalWndInfo winInfo = _ModalStack.back(); - _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash - if(winInfo.ModalWindow) - { - setBackWindow(winInfo.ModalWindow); - winInfo.ModalWindow->setActive(false); - } - if (!_ModalStack.empty()) - { - if(_ModalStack.back().ModalWindow) - { - _ModalStack.back().ModalWindow->setActive(true); - setTopWindow(_ModalStack.back().ModalWindow); - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::popModalWindowCategory(const std::string &category) -{ - for(;;) - { - if (_ModalStack.empty()) break; - if (!_ModalStack.back().ModalWindow) break; - CGroupModal *gm = dynamic_cast((CInterfaceGroup*)(_ModalStack.back().ModalWindow)); - if (gm && gm->Category == category) - { - _ModalStack.back().ModalWindow->setActive(false); - _ModalStack.pop_back(); - } - else - { - break; - } - } + return CWidgetManager::getInstance()->getElementFromId(getDefine(defineId)); } // ------------------------------------------------------------------------------------------------ @@ -4163,14 +3838,14 @@ void CInterfaceManager::stopAnim (const string &animId) // ------------------------------------------------------------------------------------------------ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucstring &text, const string &masterGroup, TCaseMode caseMode) { - CInterfaceGroup *group= dynamic_cast(getElementFromId(masterGroup+":" + msgBoxGroup)); - CViewText *viewText= dynamic_cast(getElementFromId(masterGroup+":" + msgBoxGroup + ":text")); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup)); + CViewText *viewText= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + msgBoxGroup + ":text")); if (group && viewText) { viewText->setCaseMode(caseMode); viewText->setText(text); - enableModalWindow(NULL, group); + CWidgetManager::getInstance()->enableModalWindow(NULL, group); // don't understand why but need to update coords here group->updateCoords(); group->updateCoords(); @@ -4196,7 +3871,7 @@ void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::stri // clicking 'ok' do not have any consequence, so allow exiting the message box by clicking // outside of it (this behavior is wanted on the login page, to allow to reclick on 'login' without // having to click 'ok' in the message box each time) - CInterfaceGroup *group= dynamic_cast(getElementFromId(masterGroup+":" + mbName)); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":" + mbName)); CGroupModal *gm = dynamic_cast(group); if (gm) { @@ -4210,9 +3885,9 @@ void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::stri void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &text, const std::string &ahOnOk, const std::string ¶msOnOk, const std::string &ahOnCancel, const std::string ¶msOnCancel, const string &masterGroup) { - CInterfaceGroup *group= dynamic_cast(getElementFromId(masterGroup+":valid_message_box")); - CViewText *viewText= dynamic_cast(getElementFromId(masterGroup+":valid_message_box:text")); - CViewBitmap *viewBitmap= dynamic_cast(getElementFromId(masterGroup+":valid_message_box:icon_group:icon")); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box")); + CViewText *viewText= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box:text")); + CViewBitmap *viewBitmap= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box:icon_group:icon")); if (group && viewText) { @@ -4238,7 +3913,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring & } // Go - enableModalWindow(NULL, group); + CWidgetManager::getInstance()->enableModalWindow(NULL, group); // don't understand why but need to update coords here group->updateCoords(); group->updateCoords(); @@ -4250,12 +3925,12 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring & bool CInterfaceManager::getCurrentValidMessageBoxOnOk(string &ahOnOk, const std::string &masterGroup) { // any modal window opened? - CInterfaceGroup *mw= getModalWindow(); + CInterfaceGroup *mw= CWidgetManager::getInstance()->getModalWindow(); if(!mw) return false; // Is this modal window the valid_message_box window? - CInterfaceGroup *group= dynamic_cast(getElementFromId(masterGroup+":valid_message_box")); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(masterGroup+":valid_message_box")); if(mw==group) { // Ok, get the current procedure OnOk action @@ -4278,8 +3953,8 @@ void CInterfaceManager::setContextHelpText(const ucstring &text) // ------------------------------------------------------------------------------------------------ void CInterfaceManager::disableContextHelp() { - _CurCtrlContextHelp = ""; - _DeltaTimeStopingContextHelp = 0; + CWidgetManager::getInstance()->setCurContextHelp( NULL ); + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; } // ------------------------------------------------------------------------------------------------ @@ -4287,7 +3962,7 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl) { if(!pCtrl) return; - if(_CurCtrlContextHelp == pCtrl ) + if( CWidgetManager::getInstance()->getCurContextHelp() == pCtrl ) disableContextHelp(); } @@ -4387,7 +4062,7 @@ void CInterfaceManager::enableMouseHandling(bool handle) _MouseHandlingEnabled= handle; if(!handle) { - if(!_Pointer) + if(!CWidgetManager::getInstance()->getPointer()) return; // If Left captured, reset @@ -4403,7 +4078,7 @@ void CInterfaceManager::enableMouseHandling(bool handle) } // Avoid any problem with modals - disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } @@ -4492,7 +4167,7 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) // Launch the context menu in-game: can't appear while dragging an item if (CDBCtrlSheet::getDraggedSheet() == NULL) { - if (_ModalStack.empty()) + if ( !CWidgetManager::getInstance()->hasModal() ) { // We must be in-game ! CInterfaceGroup *pMG = CWidgetManager::getInstance()->getMasterGroupFromId("ui:interface"); @@ -4507,11 +4182,11 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) } if ((pMG != NULL) && (pMG->getActive())) { - CInterfaceElement *pIE = getElementFromId(nameOfCM); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(nameOfCM); CInterfaceGroup *pIG = dynamic_cast(pIE); if (pIG != NULL) { - enableModalWindow (NULL, pIG); + CWidgetManager::getInstance()->enableModalWindow (NULL, pIG); } } } @@ -4617,7 +4292,7 @@ void CInterfaceManager::setMode(uint8 newMode) // if this GC is a Full modal window, or if it is a modal son of another GC, if (pGC->isModal() || pGC->isModalSon()) { - setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); pGC->enableBlink(2); return; } @@ -4890,49 +4565,6 @@ bool CInterfaceManager::saveKeys(const std::string &filename) return ret; } -// *************************************************************************** -CInterfaceGroup *CInterfaceManager::getLastEscapableTopWindow() const -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator it; - it= rList.rbegin(); - for(;it!=rList.rend();it++) - { - if((*it)->getActive() && (*it)->getEscapable()) - return *it; - } - } - } - } - return NULL; -} - -// *************************************************************************** -void CInterfaceManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority) -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - if (rMG.isWindowPresent(pWin)) - { - rMG.delWindow(pWin); - rMG.addWindow(pWin, nNewPriority); - } - } - } -} - // *************************************************************************** bool CInterfaceManager::deletePlayerConfig (const std::string &playerFileIdent) { @@ -5007,27 +4639,11 @@ void CInterfaceManager::restoreAllContainersBackupPosition() } -// *************************************************************************** -uint8 CInterfaceManager::getLastTopWindowPriority() const -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - return rMG.LastTopWindowPriority; - } - } - return 0; -} - - // *************************************************************************** void CInterfaceManager::removeRefOnCtrl (CCtrlBase *ctrlBase) { - if (_CurCtrlContextHelp == ctrlBase) - _CurCtrlContextHelp = ""; + if ( CWidgetManager::getInstance()->getCurContextHelp() == ctrlBase) + CWidgetManager::getInstance()->setCurContextHelp( NULL ); if (getCapturePointerLeft() == ctrlBase) setCapturePointerLeft(NULL); if (getCapturePointerRight() == ctrlBase) @@ -5264,7 +4880,7 @@ NLMISC_COMMAND(loadui, "Load an interface file", "") // *************************************************************************** void CInterfaceManager::displayWebWindow(const string & name, const string & url) { - CInterfaceGroup *pIG = dynamic_cast(getElementFromId(name)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(name)); if (pIG != NULL) { pIG->setActive(true); @@ -5413,7 +5029,7 @@ void CInterfaceManager::initEmotes() if (sName[i] == '|') nbToken++; - CGroupMenu *pRootMenu = dynamic_cast(pIM->getElementFromId("ui:interface:user_chat_emote_menu")); + CGroupMenu *pRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:user_chat_emote_menu")); nlassert(pRootMenu); CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); @@ -5539,7 +5155,7 @@ void CInterfaceManager::uninitEmotes() // get the emotes menu CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMenu *pRootMenu = dynamic_cast(pIM->getElementFromId("ui:interface:game_context_menu")); + CGroupMenu *pRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_context_menu")); if( pRootMenu ) { CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); @@ -5656,7 +5272,7 @@ void CInterfaceManager::resetTextIndex() CInterfaceElement *getInterfaceResource(const std::string &key) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - return pIM->getElementFromId (key); + return CWidgetManager::getInstance()->getElementFromId (key); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 66c7a7987..ac8e9b408 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -247,42 +247,8 @@ public: * NB: "ctrl_launch_modal" is a special Id which return the last ctrl which has launch a modal. NULL if modal closed. * \param groupId : the Id of the window group */ - CInterfaceElement* getElementFromId (const std::string &sEltId); - CInterfaceElement* getElementFromId (const std::string &sStart, const std::string &sEltId); - void activateMasterGroup (const std::string &sMasterGroupName, bool bActive); /// get an element from a define ID. shortcut for getElementFromId(getDefine(define)) CInterfaceElement* getElementFromDefine (const std::string &defineId); - /// Get the window from an element (ui:interface:###) - CInterfaceGroup* getWindow(CInterfaceElement*); - /** - * set the top window - * \param win : pointer to the window to be set on top - */ - void setTopWindow (CInterfaceGroup *pWin); - - /** - * set the back window - * \param win : pointer to the window to be set on top - */ - void setBackWindow (CInterfaceGroup *pWin); - - /** get the top window in the first activated masterGroup - */ - CInterfaceGroup *getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; - - /** get the back window in the first activated masterGroup - */ - CInterfaceGroup *getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; - - /** get the last escapable top window in the first activated masterGroup - */ - CInterfaceGroup *getLastEscapableTopWindow() const; - - void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority); - - /** return the priority of the Last Window setTopWindow()-ed. - */ - uint8 getLastTopWindowPriority() const; /// Control specific @@ -305,30 +271,6 @@ public: * NB : the keyboard capture is released on both calls. * NB : cascaded modal windows are disabled by the call */ - void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); - void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); - // Disable all modals windows - void disableModalWindow (); - - /** Push a modal window that becomes the current modal window - */ - void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); - void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); - void popModalWindow(); - // pop all top modal windows with the given category (a string stored in the modal) - void popModalWindowCategory(const std::string &category); - - CCtrlBase *getCtrlLaunchingModal () - { - if (_ModalStack.empty()) return NULL; - return _ModalStack.back().CtrlLaunchingModal; - } - /// get the currently active modal window, or NULL if none - CInterfaceGroup *getModalWindow() const - { - if (_ModalStack.empty()) return NULL; - return _ModalStack.back().ModalWindow; - } /// Handle The Event. return true if the interfaceManager catch it and if must not send to the Game Action Manager @@ -379,9 +321,6 @@ public: uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } - /// Pointer - CViewPointer *getPointer () { return _Pointer; } - // Relative move of pointer void movePointer (sint32 dx, sint32 dy); // Set absolute coordinates of pointer @@ -770,33 +709,6 @@ private: void buildRecursLocalLeaves(NLMISC::CCDBNodeBranch *branch, std::vector &leaves); }; - // Infos about a modal window. - class CModalWndInfo - { - public: - // Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after) - NLMISC::CRefPtr ModalWindow; // the current modal window - NLMISC::CRefPtr CtrlLaunchingModal; - bool ModalClip; - bool ModalExitClickOut; - bool ModalExitClickL; - bool ModalExitClickR; - bool ModalExitKeyPushed; - std::string ModalHandlerClickOut; - std::string ModalClickOutParams; - public: - CModalWndInfo() - { - ModalWindow = NULL; - CtrlLaunchingModal= NULL; - ModalExitClickOut= false; - ModalExitClickL= false; - ModalExitClickR= false; - ModalExitKeyPushed= false; - } - }; - - // Database management stuff class CDBLandmarkObs : public NLMISC::ICDBNode::IPropertyObserver { @@ -883,10 +795,6 @@ private: NLMISC::CRefPtr _CapturePointerRight; bool _MouseOverWindow; - std::vector _ModalStack; - static std::string _CtrlLaunchingModalId; - - // view that should be notified from clock msg std::vector _ClockMsgTargets; @@ -898,8 +806,7 @@ private: // Context Help bool _ContextHelpActive; - CCtrlBasePtr _CurCtrlContextHelp; - float _DeltaTimeStopingContextHelp; + //CCtrlBasePtr _CurCtrlContextHelp; //Delay before displaying ContextHelp on a ctrl having wantInstantContextHelp set to false (in seconds) float _MaxTimeStopingContextHelp; sint _LastXContextHelp; diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index fa27fa060..4c225ddf5 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -299,17 +299,12 @@ private: // ---------------------------------------------------------------------------- CInterfaceParser::CInterfaceParser() { - _Pointer= NULL; - // LUA _LuaState= NULL; } CInterfaceParser::~CInterfaceParser() { -// delete _Pointer; - _Pointer = NULL; - //delete _LuaState; _LuaState = NULL; } /** Convert a string into a memstream @@ -1745,7 +1740,7 @@ bool CInterfaceParser::parseView(xmlNodePtr cur, CInterfaceGroup * parentGroup, if ( !strcmp(ptr,"pointer")) { - _Pointer = dynamic_cast(view); + CWidgetManager::getInstance()->setPointer( dynamic_cast(view) ); } //nlinfo("view type %s mem : %d",ptr,view->getMemory()); @@ -3491,7 +3486,7 @@ CInterfaceElement *CInterfaceParser::createUIElement(const std::string &template } CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceElement *pIE= pIM->getElementFromId(parentID); + CInterfaceElement *pIE= CWidgetManager::getInstance()->getElementFromId(parentID); CInterfaceGroup * parentGroup = dynamic_cast(pIE); if(!parentGroup) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 81da7731c..650e60cb9 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -248,8 +248,6 @@ protected: * Data of initialized interface */ - CViewPointer *_Pointer; - // Options description std::map > _OptionsMap; diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 7069d2a12..bb959f0ba 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -331,44 +331,44 @@ void CInventoryManager::init() DNDCurrentItem = NULL; DNDFrom = Nowhere; // Initialize interface part - UIHands[0] = dynamic_cast(im->getElementFromId(CTRL_HAND_RIGHT)); - UIHands[1] = dynamic_cast(im->getElementFromId(CTRL_HAND_LEFT)); + UIHands[0] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_RIGHT)); + UIHands[1] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); - UIEquip[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_HEADDRESS)); - UIEquip[SLOT_EQUIPMENT::EARL] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_EARING_LEFT)); - UIEquip[SLOT_EQUIPMENT::EARR] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_EARING_RIGHT)); - UIEquip[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_NECK)); - UIEquip[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_BRACELET_LEFT)); - UIEquip[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_BRACELET_RIGHT)); - UIEquip[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_RING_LEFT)); - UIEquip[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_RING_RIGHT)); - UIEquip[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_ANKLET_LEFT)); - UIEquip[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(im->getElementFromId(CTRL_JEWEL_ANKLET_RIGHT)); + UIEquip[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_HEADDRESS)); + UIEquip[SLOT_EQUIPMENT::EARL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_EARING_LEFT)); + UIEquip[SLOT_EQUIPMENT::EARR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_EARING_RIGHT)); + UIEquip[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_NECK)); + UIEquip[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_BRACELET_LEFT)); + UIEquip[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_BRACELET_RIGHT)); + UIEquip[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_RING_LEFT)); + UIEquip[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_RING_RIGHT)); + UIEquip[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_ANKLET_LEFT)); + UIEquip[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWEL_ANKLET_RIGHT)); - UIEquip[SLOT_EQUIPMENT::HEAD] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_HEAD)); - UIEquip[SLOT_EQUIPMENT::CHEST] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_CHEST)); - UIEquip[SLOT_EQUIPMENT::ARMS] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_ARMS)); - UIEquip[SLOT_EQUIPMENT::FEET] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_FEET)); - UIEquip[SLOT_EQUIPMENT::LEGS] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_LEGS)); - UIEquip[SLOT_EQUIPMENT::HANDS] = dynamic_cast(im->getElementFromId(CTRL_ARMOR_HANDS)); + UIEquip[SLOT_EQUIPMENT::HEAD] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_HEAD)); + UIEquip[SLOT_EQUIPMENT::CHEST] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_CHEST)); + UIEquip[SLOT_EQUIPMENT::ARMS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_ARMS)); + UIEquip[SLOT_EQUIPMENT::FEET] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_FEET)); + UIEquip[SLOT_EQUIPMENT::LEGS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_LEGS)); + UIEquip[SLOT_EQUIPMENT::HANDS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMOR_HANDS)); - UIEquip2[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_HEADDRESS)); - UIEquip2[SLOT_EQUIPMENT::EARL] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_EARING_LEFT)); - UIEquip2[SLOT_EQUIPMENT::EARR] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_EARING_RIGHT)); - UIEquip2[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_NECK)); - UIEquip2[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_BRACELET_LEFT)); - UIEquip2[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_BRACELET_RIGHT)); - UIEquip2[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_RING_LEFT)); - UIEquip2[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_RING_RIGHT)); - UIEquip2[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_ANKLET_LEFT)); - UIEquip2[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(im->getElementFromId(CTRL_JEWL2_ANKLET_RIGHT)); + UIEquip2[SLOT_EQUIPMENT::HEADDRESS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_HEADDRESS)); + UIEquip2[SLOT_EQUIPMENT::EARL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_LEFT)); + UIEquip2[SLOT_EQUIPMENT::EARR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_EARING_RIGHT)); + UIEquip2[SLOT_EQUIPMENT::NECKLACE] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_NECK)); + UIEquip2[SLOT_EQUIPMENT::WRISTL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_BRACELET_LEFT)); + UIEquip2[SLOT_EQUIPMENT::WRISTR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_BRACELET_RIGHT)); + UIEquip2[SLOT_EQUIPMENT::FINGERL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_RING_LEFT)); + UIEquip2[SLOT_EQUIPMENT::FINGERR] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_RING_RIGHT)); + UIEquip2[SLOT_EQUIPMENT::ANKLEL] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_ANKLET_LEFT)); + UIEquip2[SLOT_EQUIPMENT::ANKLER] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_JEWL2_ANKLET_RIGHT)); - UIEquip2[SLOT_EQUIPMENT::HEAD] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_HEAD)); - UIEquip2[SLOT_EQUIPMENT::CHEST] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_CHEST)); - UIEquip2[SLOT_EQUIPMENT::ARMS] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_ARMS)); - UIEquip2[SLOT_EQUIPMENT::FEET] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_FEET)); - UIEquip2[SLOT_EQUIPMENT::LEGS] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_LEGS)); - UIEquip2[SLOT_EQUIPMENT::HANDS] = dynamic_cast(im->getElementFromId(CTRL_ARMR2_HANDS)); + UIEquip2[SLOT_EQUIPMENT::HEAD] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_HEAD)); + UIEquip2[SLOT_EQUIPMENT::CHEST] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_CHEST)); + UIEquip2[SLOT_EQUIPMENT::ARMS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_ARMS)); + UIEquip2[SLOT_EQUIPMENT::FEET] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_FEET)); + UIEquip2[SLOT_EQUIPMENT::LEGS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_LEGS)); + UIEquip2[SLOT_EQUIPMENT::HANDS] = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_ARMR2_HANDS)); // Init ItemInfoObservers @@ -662,7 +662,7 @@ static void grayItem (const std::string &listname, sint32 bagEntryIndex, bool gr { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - IListSheetBase *pList = dynamic_cast(pIM->getElementFromId(listname)); + IListSheetBase *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(listname)); if (pList != NULL) { @@ -787,7 +787,7 @@ void CInventoryManager::equip(const std::string &bagPath, const std::string &inv sint16 oldRightIndexInBag = NLGUI::CDBManager::getInstance()->getDbProp(invPath + ":INDEX_IN_BAG")->getValue16(); if (inventory == INVENTORIES::handling && invSlot == 0) { - CDBCtrlSheet *pCSLeftHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_LEFT)); + CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); if (pCSLeftHand == NULL) { return; @@ -919,7 +919,7 @@ void CInventoryManager::unequip(const std::string &invPath) // Hands management : check if we have to unequip left hand because of incompatibility with right hand item if (inventory == INVENTORIES::handling && invSlot == 0) { - CDBCtrlSheet *pCSLeftHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_LEFT)); + CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); if (pCSLeftHand == NULL) { return; @@ -1073,8 +1073,8 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) else return; // Set database for wearing the right item - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(sIE)); - CDBCtrlSheet *pCS2 = dynamic_cast(pIM->getElementFromId(sIE2)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sIE)); + CDBCtrlSheet *pCS2 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sIE2)); // Remove Last reference and update database sint16 oldVal = pNL->getOldValue16(); @@ -1105,7 +1105,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) if (sIE == CTRL_HAND_RIGHT) { // if nothing in left hand -> return - CDBCtrlSheet *pCSLeftHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_LEFT)); + CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); if (pCSLeftHand == NULL) { return; @@ -1184,7 +1184,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) // left hand item is changing if (sIE == CTRL_HAND_LEFT) { - CDBCtrlSheet *pCSLeftHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_LEFT)); + CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); if ( pCSLeftHand ) { CViewRenderer &rVR = pIM->getViewRenderer(); @@ -1196,7 +1196,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) { // check if we clear display (have to manage 2 hands weapons for instance) bool clearLeftHandDisplay = true; - CDBCtrlSheet * pCSRightHand = dynamic_cast(pIM->getElementFromId(CTRL_HAND_RIGHT)); + CDBCtrlSheet * pCSRightHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_RIGHT)); if ( pCSRightHand && pCSRightHand->getSheetId() ) { CCDBNodeLeaf *pNL3 = NLGUI::CDBManager::getInstance()->getDbProp(LOCAL_INVENTORY ":HAND:0:INDEX_IN_BAG", false); @@ -1272,7 +1272,7 @@ bool CInventoryManager::autoEquip(sint bagEntryIndex, bool allowReplace) uint i; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - IListSheetBase *pList = dynamic_cast(pIM->getElementFromId(LIST_BAG_TEXT)); + IListSheetBase *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_TEXT)); CDBCtrlSheet *pCSSrc = NULL; if (pList == NULL) return false; @@ -1705,7 +1705,7 @@ void CTempInvManager::update() _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); if (pGC == NULL) return; @@ -1774,7 +1774,7 @@ void CTempInvManager::updateType() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); _Mode = (TEMP_INV_MODE::TInventoryMode)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:INVENTORY:TEMP:TYPE")->getValue8(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); // Something arrived, change text switch(_Mode) { @@ -1837,7 +1837,7 @@ void CTempInvManager::updateForageQQ( uint whichOne ) ucstring title = CI18N::get( WIN_TEMPINV_TITLE_FORAGING ); strFindReplace( title, "%qt", toString( "%.1f", qt ) ); strFindReplace( title, "%ql", toString( "%.1f", ql ) ); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); pGC->setUCTitle( title ); } @@ -1849,7 +1849,7 @@ void CTempInvManager::open(TEMP_INV_MODE::TInventoryMode m) { _Mode = m; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); // In Foraging mode, we can call open() on the inventory with the same contents (e.g. when changing Forage action) if ( _Mode != TEMP_INV_MODE::Forage ) @@ -1902,7 +1902,7 @@ void CTempInvManager::close() pNL->setValue32(0); } - CInterfaceGroup *pIG = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); if (pIG != NULL) { pIG->setActive(false); @@ -1914,7 +1914,7 @@ void CTempInvManager::close() bool CTempInvManager::isOpened() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_TEMPINV)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_TEMPINV)); if (pGC != NULL) return pGC->getActive(); return false; @@ -2313,7 +2313,7 @@ bool CDBGroupListSheetFilterCLMSlot::CSheetChildFilter::isSheetValid(CDBGroupLis Plus the ChildControl must not be locked */ CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBCtrlSheet *clmCtrl = dynamic_cast(pIM->getCtrlLaunchingModal()); + CDBCtrlSheet *clmCtrl = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (!clmCtrl || !Ctrl) return false; if (clmCtrl->getInventoryIndex() == INVENTORIES::exchange && Ctrl->getInventoryIndex() == INVENTORIES::exchange) @@ -2467,7 +2467,7 @@ class CHandlerInvCanDropTo : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); if (pCSSrc == NULL) return; // Cannot do anything if the incoming sheet is not a sheet @@ -2618,14 +2618,14 @@ class CHandlerInvDropTo : public IActionHandler // To prevent other things to happens if (!getInventory().isDragging()) { - CInterfaceGroup *pIG = pIM->getModalWindow(); + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getModalWindow(); if (pIG == NULL) return; if (pIG->getId() != "ui:interface:bag_choose") return; getInventory().beginDrag(NULL, CInventoryManager::TextList); // Special case for choose in bag dialog string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); @@ -2642,7 +2642,7 @@ class CHandlerInvDropTo : public IActionHandler } string src = getParam(Params, "src"); - CInterfaceElement *pElt = pIM->getElementFromId(src); + CInterfaceElement *pElt = CWidgetManager::getInstance()->getElementFromId(src); CDBCtrlSheet *pCSSrc = dynamic_cast(pElt); CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); if (pCSSrc == NULL) return; @@ -3309,39 +3309,39 @@ void CInventoryManager::sortBag() CDBGroupIconListBag *pIconList; CDBGroupListSheetBag *pList; - pIconList = dynamic_cast(pIM->getElementFromId(LIST_BAG_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_BAG_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_BAG_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_ROOM_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_ROOM_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_ROOM_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_GUILD_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_GUILD_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_PA0_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_PA0_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA0_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_PA1_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_PA1_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA1_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_PA2_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_PA2_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA2_TEXT)); if (pList != NULL) pList->needToSort(); - pIconList = dynamic_cast(pIM->getElementFromId(LIST_PA3_ICONS)); + pIconList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_ICONS)); if (pIconList != NULL) pIconList->needToSort(); - pList = dynamic_cast(pIM->getElementFromId(LIST_PA3_TEXT)); + pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(LIST_PA3_TEXT)); if (pList != NULL) pList->needToSort(); } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 430f53f0c..6c9ebb167 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1019,7 +1019,7 @@ int CLuaIHMRyzom::getUI(CLuaState &ls) // return the element CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceElement *pIE= pIM->getElementFromId(eltStr); + CInterfaceElement *pIE= CWidgetManager::getInstance()->getElementFromId(eltStr); if(!pIE) { ls.pushNil(); @@ -1504,7 +1504,7 @@ int CLuaIHMRyzom::setTopWindow(CLuaState &ls) CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); } CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setTopWindow(wnd); + CWidgetManager::getInstance()->setTopWindow(wnd); return 0; } @@ -1739,7 +1739,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT); - CGroupMenu *pInitRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); + CGroupMenu *pInitRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(emoteMenu)); pInitRootMenu->reset(); for (std::list::const_iterator it = entries.begin(); it != entries.end(); it++) @@ -1768,7 +1768,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) if (sName[i] == '|') nbToken++; - CGroupMenu *pRootMenu = dynamic_cast(pIM->getElementFromId(emoteMenu)); + CGroupMenu *pRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(emoteMenu)); CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); for (i = 0; i < nbToken; ++i) @@ -1999,13 +1999,13 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) if(ctrl) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceGroup *group= dynamic_cast( pIM->getElementFromId(modalId) ); + CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(modalId) ); if(group) { UserControls.stopFreeLook(); // enable the modal - pIM->enableModalWindow(ctrl, group); + CWidgetManager::getInstance()->enableModalWindow(ctrl, group); } else { @@ -2024,7 +2024,7 @@ int CLuaIHMRyzom::disableModalWindow(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_disableModalWindow) CLuaIHM::checkArgCount(ls, "disableModalWindow", 0); CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); return 0; } @@ -2555,7 +2555,7 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls) result->setId("ui:interface:"+string(ls.toString(2))); result->updateCoords(); CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", result); - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); result->setParent(pRoot); if (pRoot) pRoot->addGroup(result); @@ -3271,7 +3271,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string { //H_AUTO(Lua_CLuaIHM_browseNpcWebPage) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); + CGroupHTML *groupHtml= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId)); if(groupHtml) { // if true, it means that we want to display a web page that use webig auth @@ -3343,7 +3343,7 @@ void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId) { //H_AUTO(Lua_CLuaIHM_clearHtmlUndoRedo) CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupHTML *groupHtml= dynamic_cast(pIM->getElementFromId(htmlId)); + CGroupHTML *groupHtml= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId)); if(groupHtml) groupHtml->clearUndoRedo(); } @@ -3609,7 +3609,7 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg) if (w->getContainer()) { w->getContainer()->setActive(true); - im->setTopWindow(w->getContainer()); + CWidgetManager::getInstance()->setTopWindow(w->getContainer()); } } } diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index ebd96ec5b..4103026e1 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -237,7 +237,7 @@ public: for (uint i = 0; i < rCats.size(); ++i) { string contName = string(WIN_KEYS_GAME)+rCats[i].Name; - pGC = dynamic_cast(pIM->getElementFromId(contName)); + pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(contName)); if(pGC != NULL) { pGC->setX(0); @@ -259,8 +259,8 @@ public: for (uint i = 0; i < rCats.size(); ++i) { string contName = string(WIN_KEYS_GAME)+rCats[i].Name; - CInterfaceGroup *pCategory = dynamic_cast(pIM->getElementFromId(contName)); - CGroupList *pList = dynamic_cast(pIM->getElementFromId(contName + ":content")); + CInterfaceGroup *pCategory = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(contName)); + CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(contName + ":content")); if (pCategory != NULL && pList != NULL) { pList->clearGroups(); @@ -317,9 +317,9 @@ public: pMCM->NewKey->CurrentEditCmdLine = pMCM->NewKey->AllLines[nLineNb]; pMCM->NewKey->CurAM = pMCM->ActionManagers[pMCM->NewKey->AllLines[nLineNb].ComboAM]; - CGroupModalGetKey*pGetKey = dynamic_cast(pIM->getElementFromId(WIN_MODAL_GET_KEY)); + CGroupModalGetKey*pGetKey = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_MODAL_GET_KEY)); pGetKey->Caller = "editkey"; - pIM->enableModalWindow(pCaller, WIN_MODAL_GET_KEY); + CWidgetManager::getInstance()->enableModalWindow(pCaller, WIN_MODAL_GET_KEY); } }; REGISTER_ACTION_HANDLER( CHandlerKeysAssign, "keys_assign"); @@ -433,11 +433,11 @@ void CModalContainerEditCmd::create(const std::string &name, bool bDefKey, bool WinName = "ui:interface:" + name; CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", Win); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); Win->setParent(pRoot); pRoot->addGroup(Win); - CInterfaceGroup *pIG = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_KEY_GROUP)); + CInterfaceGroup *pIG = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_KEY_GROUP)); if (pIG != NULL) pIG->setActive (CanDefineKey); } @@ -458,7 +458,7 @@ void CModalContainerEditCmd::activate() Win->launch(); // Initialisation of category combo box CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( WinName+WIN_EDITCMD_COMBO_CATEGORY )); + CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+WIN_EDITCMD_COMBO_CATEGORY )); if (pCB != NULL) { CurrentEditCmdCategories.clear(); @@ -493,7 +493,7 @@ void CModalContainerEditCmd::activate() } } // Clean up all actions - pCB= dynamic_cast(pIM->getElementFromId( WinName+WIN_EDITCMD_COMBO_ACTION )); + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+WIN_EDITCMD_COMBO_ACTION )); if (pCB != NULL) pCB->resetTexts(); // Clean up CurAM = NULL; @@ -504,9 +504,9 @@ void CModalContainerEditCmd::activate() NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp1P )->setValue32(-1); NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params - CViewText *pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); + CViewText *pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); - pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); invalidCurrentCommand(); } @@ -579,13 +579,13 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std // Set category : Search the right category CDBGroupComboBox *pCB; - pCB = dynamic_cast(pIM->getElementFromId(WinName+WIN_EDITCMD_COMBO_CATEGORY)); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+WIN_EDITCMD_COMBO_CATEGORY)); pCB->setSelection(catCBIndex); onChangeCategory(); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); //pIM->runActionHandler("editcmd_change_category",NULL); - pCB = dynamic_cast(pIM->getElementFromId(WinName+WIN_EDITCMD_COMBO_ACTION)); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+WIN_EDITCMD_COMBO_ACTION)); pCB->setSelection(actCBIndex); onChangeAction(); IngameDbMngr.flushObserverCalls(); @@ -658,7 +658,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std string sCombo; if (noParam == 0) sCombo = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_LIST; else sCombo = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_LIST; - pCB = dynamic_cast(pIM->getElementFromId(sCombo)); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sCombo)); pCB->setSelection(nPinCB); } } @@ -670,7 +670,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std string sEditBox; if (noParam == 0) sEditBox = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX; else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; - CGroupEditBox *pEB = dynamic_cast(pIM->getElementFromId(sEditBox)); + CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBox)); // sTmp is utf8 pEB->setInputStringAsUtf8(sTmp); } @@ -681,7 +681,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std string sText; if (noParam == 0) sText = WinName+VIEW_EDITCMD_FIRST_PARAM_NAME; else sText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME; - CViewText *pVT = dynamic_cast(pIM->getElementFromId(sText)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sText)); if (pVT != NULL) pVT->setText(CI18N::get(pBA->Parameters[i].LocalizedName)); noParam++; } @@ -693,7 +693,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CActionsManager::TActionComboMap::const_iterator it = actionCombo.find(CurrentEditCmdLine.ActionName); // Deactive the key definition (we are in edit key mode) - CCtrlBaseButton *pBut = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); if (pBut != NULL) pBut->setActive(false); if (it != actionCombo.end()) @@ -701,13 +701,13 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std CurrentEditCmdLine.Combo = it->second; // Activate the key definer text - CViewText *pVT = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // setup the text of the key pVT->setText(it->second.toUCString()); // There is already a shortcut so we can display ok button - pBut = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pBut != NULL) pBut->setFrozen (false); } } @@ -770,20 +770,20 @@ void CModalContainerEditCmd::invalidCurrentCommand() if (CurrentEditCmdNb == -1) { // Dont display key shortcut if we are in creation mode - pVT= dynamic_cast(pIM->getElementFromId( WinName+VIEW_EDITCMD_TEXT_KEY )); + pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+VIEW_EDITCMD_TEXT_KEY )); if (pVT != NULL) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); // Deactivate the key definer text - pVT = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(false); } // Deactivate the key definer button - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); if (pCB != NULL) pCB->setActive(false); // Deactivate ok button - pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (true); } @@ -853,7 +853,7 @@ void CModalContainerEditCmd::validCurrentCommand() string sWin; if (noParam == 0) sWin = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX; else sWin = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; - CGroupEditBox *pEB= dynamic_cast(pIM->getElementFromId( sWin )); + CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); // convert to utf8 if (pEB != NULL) CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8(); @@ -868,10 +868,10 @@ void CModalContainerEditCmd::validCurrentCommand() if (CurrentEditCmdNb == -1) { // Activate the key definer button - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_KEY)); if (pCB != NULL) pCB->setActive(true); // Activate the key definer text - CViewText *pVT = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setActive(true); // Does the command already exists ? const CActionsManager::TActionComboMap &actionCombo = pAM->getActionComboMap(); @@ -882,7 +882,7 @@ void CModalContainerEditCmd::validCurrentCommand() // Yes ok let setup the text of the key pVT->setText(it->second.toUCString()); // There is already a shortcut so we can display ok button - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); } else @@ -892,13 +892,13 @@ void CModalContainerEditCmd::validCurrentCommand() // Display not assigned text pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT)); // Do not display the ok button - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (true); } } else { - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); } } @@ -906,7 +906,7 @@ void CModalContainerEditCmd::validCurrentCommand() // If we are in mode new command (from macro) just turn on the ok button if (WinName == "ui:interface:editcmd") { - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen(false); } } @@ -932,8 +932,8 @@ bool CModalContainerEditCmd::isParamValid (sint32 nParamIndex) else if (paramType == 1) { CGroupEditBox *pEB; - if (nParamIndex == 0) pEB = dynamic_cast(pIM->getElementFromId( WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX )); - else pEB = dynamic_cast(pIM->getElementFromId( WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX )); + if (nParamIndex == 0) pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX )); + else pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX )); if (pEB == NULL) return false; // no need to translate utf8 or not here @@ -1008,7 +1008,7 @@ void CModalContainerEditCmd::onChangeCategory() return; // Update the combo box of actions - CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( WinName+WIN_EDITCMD_COMBO_ACTION )); + CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+WIN_EDITCMD_COMBO_ACTION )); if( pCB ) { pCB->resetTexts(); @@ -1040,9 +1040,9 @@ void CModalContainerEditCmd::onChangeCategory() NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1); // reset name of params CViewText *pViewParamName; - pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); - pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); // Reset key invalidCurrentCommand(); @@ -1078,9 +1078,9 @@ void CModalContainerEditCmd::onChangeAction() NLGUI::CDBManager::getInstance()->getDbProp( DbComboSel2P )->setValue32(-1); // reset name of params CViewText *pViewParamName; - pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); - pViewParamName = dynamic_cast(pIM->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME)); if (pViewParamName != NULL) pViewParamName->setText (string("")); uint noParam = 0; @@ -1102,7 +1102,7 @@ void CModalContainerEditCmd::onChangeAction() if (noParam == 0) sViewText = WinName+VIEW_EDITCMD_FIRST_PARAM_NAME; else sViewText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME; - pViewParamName = dynamic_cast(pIM->getElementFromId(sViewText)); + pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sViewText)); if (pViewParamName != NULL) pViewParamName->setText (CI18N::get(rP.LocalizedName)); } @@ -1112,7 +1112,7 @@ void CModalContainerEditCmd::onChangeAction() string sWin; if (noParam == 0) sWin = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_LIST; else sWin = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_LIST; - CDBGroupComboBox *pCB= dynamic_cast(pIM->getElementFromId( sWin )); + CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); if( pCB ) { pCB->resetTexts(); @@ -1138,7 +1138,7 @@ void CModalContainerEditCmd::onChangeAction() string sWin; if (noParam == 0) sWin = WinName+WIN_EDITCMD_COMBO_FIRST_PARAM_EDITBOX; else sWin = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX; - CGroupEditBox *pEB= dynamic_cast(pIM->getElementFromId( sWin )); + CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin )); if( pEB ) { pEB->setInputString(ucstring("")); @@ -1270,9 +1270,9 @@ public: { //checkCurrentCommandValidity(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupModalGetKey*pGetKey = dynamic_cast(pIM->getElementFromId(WIN_MODAL_GET_KEY)); + CGroupModalGetKey*pGetKey = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_MODAL_GET_KEY)); pGetKey->Caller = Params; - pIM->enableModalWindow(pCaller, WIN_MODAL_GET_KEY); + CWidgetManager::getInstance()->enableModalWindow(pCaller, WIN_MODAL_GET_KEY); } }; REGISTER_ACTION_HANDLER( CHandlerEditCmdDefineKey, "editcmd_cmd_def_key"); @@ -1326,8 +1326,8 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pIM->disableModalWindow(); - CGroupModalGetKey*pGetKey = dynamic_cast(pIM->getElementFromId(WIN_MODAL_GET_KEY)); + CWidgetManager::getInstance()->disableModalWindow(); + CGroupModalGetKey*pGetKey = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_MODAL_GET_KEY)); if (pGetKey == NULL) return; @@ -1346,10 +1346,10 @@ public: { pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo; - CViewText *pVT = dynamic_cast(pIM->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY)); if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString()); - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK)); if (pCB != NULL) pCB->setFrozen (false); } @@ -1358,7 +1358,7 @@ public: { pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo; pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo; - CViewText *pVT = dynamic_cast(pIM->getElementFromId(VIEW_NEWMACRO_KEY)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString()); } } diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 3effb37cd..47b770a10 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -580,7 +580,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); string sTP = getParam(Params, "target"); if (sTP.empty()) return; - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(sTP)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTP)); sint32 nb; fromString(getParam(Params, "value"), nb); if (pCS != NULL) pCS->setMacroBack((uint8)nb); @@ -597,7 +597,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); string sTP = getParam(Params, "target"); if (sTP.empty()) return; - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(sTP)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTP)); sint32 nb; fromString(getParam(Params, "value"), nb); if (pCS != NULL) pCS->setMacroIcon((uint8)nb); @@ -614,7 +614,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); string sTP = getParam(Params, "target"); if (sTP.empty()) return; - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(sTP)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sTP)); sint32 nb; fromString(getParam(Params, "value"), nb); if (pCS != NULL) pCS->setMacroOver((uint8)nb); @@ -632,7 +632,7 @@ public: CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(Params)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pCS == NULL) return; pCS->setMacroText(pEB->getInputStringAsStdString()); } @@ -649,13 +649,13 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(CTRL_MACROICONCREATION_ICON)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); if (pCS != NULL) pCS->writeToMacro(pMCM->CurrentEditMacro); - pCS = dynamic_cast(pIM->getElementFromId(CTRL_NEWMACRO_ICON)); + pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_NEWMACRO_ICON)); if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro); - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } }; REGISTER_ACTION_HANDLER( CHandlerMacroIconCreation, "macro_icon_creation_ok"); @@ -678,7 +678,7 @@ public: if (back != 0xff) { string sButton = string(GROUP_MACROICONCREATION_BACK) + CTRL_MACROICONCREATION_BUTTON + toString(back+1); - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(sButton)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButton)); if (pCB != NULL) pCB->setPushed(true); } @@ -686,7 +686,7 @@ public: if (icon != 0xff) { string sButton = string(GROUP_MACROICONCREATION_ICON) + CTRL_MACROICONCREATION_BUTTON + toString(icon+1); - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(sButton)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButton)); if (pCB != NULL) pCB->setPushed(true); } @@ -694,15 +694,15 @@ public: if (over != 0xff) { string sButton = string(GROUP_MACROICONCREATION_OVER) + CTRL_MACROICONCREATION_BUTTON + toString(over+1); - CCtrlBaseButton *pCB = dynamic_cast(pIM->getElementFromId(sButton)); + CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButton)); if (pCB != NULL) pCB->setPushed(true); } - CGroupEditBox *pEB = dynamic_cast(pIM->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); + CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT)); if (pEB != NULL) { pEB->setInputStringAsStdString(pMCM->CurrentEditMacro.DispText); - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(CTRL_MACROICONCREATION_ICON)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON)); if (pCS != NULL) pCS->setMacroText(pEB->getInputStringAsStdString()); } @@ -836,7 +836,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pCaller == NULL) - pCaller = dynamic_cast(pIM->getElementFromId("ui:interface:new_macro:content:edit_name")); + pCaller = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:new_macro:content:edit_name")); CGroupEditBox *pEB = dynamic_cast(pCaller); if (pEB == NULL) return; @@ -861,16 +861,16 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); // Icon - CDBCtrlSheet *pCS = dynamic_cast(pIM->getElementFromId(CTRL_NEWMACRO_ICON)); + CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_NEWMACRO_ICON)); if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro); // Name - CGroupEditBox *pEB = dynamic_cast(pIM->getElementFromId(GROUP_NEWMACRO_EDIT_NAME)); + CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME)); if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name); // Commands - CGroupList *pList = dynamic_cast(pIM->getElementFromId(GROUP_NEWMACRO_COMMANDS)); + CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS)); if (pList == NULL) return; // Key Shortcut - CViewText *pVT = dynamic_cast(pIM->getElementFromId(VIEW_NEWMACRO_KEY)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY)); if (pVT != NULL) { if (pMCM->CurrentEditMacro.Combo.Key == KeyCount) @@ -936,7 +936,7 @@ public: pMCM->addMacro(pMCM->CurrentEditMacro); } - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_NEWMACRO)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_NEWMACRO)); if (pGC != NULL) pGC->setActive (false); pIM->runActionHandler("macros_open",NULL); @@ -1001,7 +1001,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - CGroupList *pList = dynamic_cast(pIM->getElementFromId(WIN_MACRO_CONTENT)); + CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_MACRO_CONTENT)); if (pList == NULL) return; pList->clearGroups(); @@ -1037,7 +1037,7 @@ public: mc.BitmapOver = 0; pMCM->CurrentEditMacro = mc; - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_NEWMACRO)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_NEWMACRO)); if (pGC != NULL) { pGC->setTitle(NEWMACRO_TITLE_NEW); @@ -1077,7 +1077,7 @@ public: CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); pMCM->CurrentEditMacro = pMCM->getMacros()[nMacNb]; pMCM->CurrentEditMacroNb = nMacNb; - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId(WIN_NEWMACRO)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_NEWMACRO)); if (pGC != NULL) { pGC->setTitle(NEWMACRO_TITLE_EDIT); diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 3f5782c92..1aeabb9cb 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -81,7 +81,7 @@ void CMusicPlayer::play () /* Show the song title */ CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:interface:mp3_player:screen:text")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text")); if (pVT) pVT->setText (_Songs[_CurrentSong].Title); } diff --git a/code/ryzom/client/src/interface_v3/obs_huge_list.cpp b/code/ryzom/client/src/interface_v3/obs_huge_list.cpp index 6d7121a88..1af0044b5 100644 --- a/code/ryzom/client/src/interface_v3/obs_huge_list.cpp +++ b/code/ryzom/client/src/interface_v3/obs_huge_list.cpp @@ -511,12 +511,12 @@ void CHugeListObs::updateUIItemPage(uint index) if (BotChatPageAll->Trade->getBuyOnly()) { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":"; - listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY_BUY_ONLY)); + listSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY_BUY_ONLY)); } else { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":"; - listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY)); + listSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY)); } if (!listSheet) return; itemListCategoryLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TYPE_OF_ITEMS_TO_BUY", false); @@ -525,32 +525,32 @@ void CHugeListObs::updateUIItemPage(uint index) case ItemForMissions: { dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":"; - listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MISSION)); + listSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(UI_LIST_OF_ITEMS_FOR_MISSION)); if (!listSheet) return; itemListCategoryLeaf = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:TYPE_OF_ITEMS_FOR_MISSION", false); if (!itemListCategoryLeaf) return; // display the group for mission items - CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_MISSION); + CInterfaceElement *elm = CWidgetManager::getInstance()->getElementFromId(UI_GROUP_OF_ITEMS_FOR_MISSION); if (elm) elm->setActive(true); } break; case Ascensor: { dbPath = DB_LOCAL_BRANCH_FOR_ASCENSOR ":"; - listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_ASCENSOR)); + listSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(UI_LIST_OF_ITEMS_FOR_ASCENSOR)); if (!listSheet) return; // display the group for mission items - CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_ASCENSOR); + CInterfaceElement *elm = CWidgetManager::getInstance()->getElementFromId(UI_GROUP_OF_ITEMS_FOR_ASCENSOR); if (elm) elm->setActive(true); } break; case Missions: { dbPath = DB_LOCAL_BRANCH_FOR_MISSIONS ":"; - listSheet = dynamic_cast(im->getElementFromId(UI_LIST_OF_MISSIONS)); + listSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(UI_LIST_OF_MISSIONS)); if (!listSheet) return; // display the group for mission items - CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_MISSIONS); + CInterfaceElement *elm = CWidgetManager::getInstance()->getElementFromId(UI_GROUP_OF_MISSIONS); if (elm) elm->setActive(true); } break; diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 4c2bd1403..c357505cc 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -1087,7 +1087,7 @@ bool CPeopleInterraction::getPeopleFromCurrentMenu(CPeopleList *&peopleList, uin { CInterfaceManager *im = CInterfaceManager::getInstance(); // the group that launched the modal window (the menu) must be the header of the group container that represent a people entry - CInterfaceGroup *header = dynamic_cast(im->getCtrlLaunchingModal()); + CInterfaceGroup *header = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (!header) return false; // get the parent container CGroupContainer *gc = dynamic_cast(header->getParent()); @@ -1100,7 +1100,7 @@ CPeopleList *CPeopleInterraction::getPeopleListFromCurrentMenu() { CInterfaceManager *im = CInterfaceManager::getInstance(); // the group that launched the modal window (the menu) must be the header of the group container that represent a people entry - CInterfaceGroup *header = dynamic_cast(im->getCtrlLaunchingModal()); + CInterfaceGroup *header = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (!header) return NULL; // get the parent container CGroupContainer *gc = dynamic_cast(header->getParent()); @@ -2230,7 +2230,7 @@ public: { CInterfaceManager *pIM = CInterfaceManager::getInstance(); string groupName= getParam(sParams, "group"); - CInterfaceGroup *gc = dynamic_cast(pIM->getElementFromId(groupName)); + CInterfaceGroup *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(groupName)); if (gc) { CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb")); @@ -2416,9 +2416,9 @@ public: nlwarning("Deactivated for now!"); return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(NEW_PARTY_CHAT_WINDOW)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(NEW_PARTY_CHAT_WINDOW)); if (!gc) return; - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); // Set the keyboard focus CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); if (eb) @@ -2447,7 +2447,7 @@ class CHandlerValidatePartyChatName : public IActionHandler void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId(NEW_PARTY_CHAT_WINDOW)); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(NEW_PARTY_CHAT_WINDOW)); if (!gc) return; CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); if (!eb) return; @@ -2484,7 +2484,7 @@ class CHandlerRemovePartyChat : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { - CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); + CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (chat) PeopleInterraction.removePartyChat(chat); } }; @@ -2523,7 +2523,7 @@ class CHandlerAddAllTeamMembersToPartyChat : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { -// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); +// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // TODO GAMEDEV : add all team members } }; @@ -2536,7 +2536,7 @@ class CHandlerRemoveAllTeamMembersToPartyChat : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { -// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); +// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // TODO GAMEDEV : remove all team members } }; @@ -2549,7 +2549,7 @@ class CHandlerAddAllGuildMembersToPartyChat : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { -// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); +// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // TODO GAMEDEV : add all guild members } }; @@ -2562,7 +2562,7 @@ class CHandlerRemoveAllGuildMembersToPartyChat : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { -// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CInterfaceManager::getInstance()->getCtrlLaunchingModal()); +// CChatWindow *chat = getChatWndMgr().getChatWindowFromCaller(CWidgetManager::getInstance()->getCtrlLaunchingModal()); // TODO_GAMEDEV : remove all guild members } }; @@ -2594,7 +2594,7 @@ public: partyChats = nlstricmp("true", strPartyChats.c_str()) == 0; } // get the menu - CGroupMenu *menu = dynamic_cast(im->getElementFromId(menuName)); + CGroupMenu *menu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(menuName)); if (!menu) return; // remove all party chat from the previous list uint lastTargetSelectedIndex = 0; @@ -2639,7 +2639,7 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); cw = PeopleInterraction.TheUserChat.Window; // CChatStdInput &ci = PeopleInterraction.ChatInput; - CGroupMenu *pMenu = dynamic_cast(pIM->getElementFromId("ui:interface:user_chat_target_menu")); + CGroupMenu *pMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:user_chat_target_menu")); CViewTextMenu *pMenuAround = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:around")); CViewTextMenu *pMenuRegion = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:region")); CViewTextMenu *pMenuUniverse = dynamic_cast(pMenu->getElement("ui:interface:user_chat_target_menu:universe")); @@ -2681,7 +2681,7 @@ public: } // activate the menu - CInterfaceManager::getInstance()->enableModalWindow(pCaller, menuName); + CWidgetManager::getInstance()->enableModalWindow(pCaller, menuName); } }; REGISTER_ACTION_HANDLER( CHandlerSelectChatTarget, "select_chat_target"); @@ -2844,13 +2844,13 @@ class CHandlerSelectChatSource : public IActionHandler if (cw == pi.ChatGroup.Window) { // select main chat menu - menu = dynamic_cast(im->getElementFromId(MAIN_CHAT_SOURCE_MENU)); + menu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(MAIN_CHAT_SOURCE_MENU)); // Remove all unused dynamic channels and set the names for (uint i = 0; i < CChatGroup::MaxDynChanPerPlayer; i++) { string s = toString(i); - CViewTextMenu *pVTM = dynamic_cast(im->getElementFromId(MAIN_CHAT_SOURCE_MENU+":tab:dyn"+s)); + CViewTextMenu *pVTM = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(MAIN_CHAT_SOURCE_MENU+":tab:dyn"+s)); if (pVTM) { uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(i); @@ -2885,7 +2885,7 @@ class CHandlerSelectChatSource : public IActionHandler if (cw == pi.TheUserChat.Window) { // select user chat menu - menu = dynamic_cast(im->getElementFromId(USER_CHAT_SOURCE_MENU)); + menu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(USER_CHAT_SOURCE_MENU)); addUserChatEntries= true; } // Simple menu @@ -2895,7 +2895,7 @@ class CHandlerSelectChatSource : public IActionHandler // Just open the STD chat menu, and quit NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); - CInterfaceManager::getInstance()->enableModalWindow(pCaller, STD_CHAT_SOURCE_MENU); + CWidgetManager::getInstance()->enableModalWindow(pCaller, STD_CHAT_SOURCE_MENU); return; } } @@ -2997,7 +2997,7 @@ class CHandlerSelectChatSource : public IActionHandler // *** active the menu NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(cw->getContainer()->isPopuped() || cw->getContainer()->getLayerSetup() == 0 ? 1 : 0); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(!cw->getContainer()->getHelpPage().empty()); - im->enableModalWindow(pCaller, menu); + CWidgetManager::getInstance()->enableModalWindow(pCaller, menu); } }; REGISTER_ACTION_HANDLER(CHandlerSelectChatSource, "select_chat_source"); @@ -3116,7 +3116,7 @@ class CHandlerToggleChatEBVis : public IActionHandler { void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { - CCtrlBase *clm = CInterfaceManager::getInstance()->getCtrlLaunchingModal(); + CCtrlBase *clm = CWidgetManager::getInstance()->getCtrlLaunchingModal(); if (!clm) return; CInterfaceGroup *ig = clm->getParent(); do diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 6664b1418..1b904bbeb 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -63,7 +63,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha CGroupContainer *fatherContainer = NULL; if (!desc.FatherContainer.empty()) { - fatherContainer = dynamic_cast(im->getElementFromId(desc.FatherContainer)); + fatherContainer = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(desc.FatherContainer)); if (!fatherContainer) { nlwarning(" Can't get father group, or bad type"); @@ -99,7 +99,7 @@ bool CPeopleList::create(const CPeopleListDesc &desc, const CChatWindowDesc *cha { // Root container - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", gc); gc->setParent(pRoot); pRoot->addGroup (gc); @@ -384,7 +384,7 @@ sint CPeopleList::addPeople(const ucstring &name, uint teamMateIndex /*= 0*/) _BaseContainer->attachContainer(gc); } - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->addGroup (gc); _Peoples.push_back(CPeople()); @@ -416,7 +416,7 @@ void CPeopleList::removePeople(uint index) _BaseContainer->detachContainer(_Peoples[index].Container); } CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->delGroup (_Peoples[index].Container); _Peoples.erase(_Peoples.begin() + index); @@ -528,7 +528,7 @@ void CPeopleList::displayMessage(uint index, const ucstring &msg, NLMISC::CRGBA gcChat->requireAttention(); - CInterfaceManager::getInstance()->setTopWindow(gcChat); + CWidgetManager::getInstance()->setTopWindow(gcChat); CGroupList *gl = dynamic_cast(gcChat->getGroup("text_list")); if (gl == NULL) @@ -582,7 +582,7 @@ void CPeopleList::reset() else // detach from root { CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *pRoot = dynamic_cast(im->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->delGroup(_BaseContainer); } _BaseContainer = ""; diff --git a/code/ryzom/client/src/interface_v3/player_trade.cpp b/code/ryzom/client/src/interface_v3/player_trade.cpp index 47d8bfecc..1e4c4a172 100644 --- a/code/ryzom/client/src/interface_v3/player_trade.cpp +++ b/code/ryzom/client/src/interface_v3/player_trade.cpp @@ -152,7 +152,7 @@ void CPlayerTrade::restoreItem(CDBCtrlSheet *exchangeSlot) CDBCtrlSheet *CPlayerTrade::getExchangeItem(uint index) { CInterfaceManager *im = CInterfaceManager::getInstance(); - return dynamic_cast(im->getElementFromId(NLMISC::toString("ui:interface:player_trade:header_opened:give:given_items:slot%d", (int) index))); + return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(NLMISC::toString("ui:interface:player_trade:header_opened:give:given_items:slot%d", (int) index))); } @@ -225,7 +225,7 @@ class CPlayerTradeLeftClickOnSlotHandler : public IActionHandler } } CInterfaceManager *im = CInterfaceManager::getInstance(); - im->pushModalWindow(pCaller, "ui:interface:exchange_choose_in_bag"); + CWidgetManager::getInstance()->pushModalWindow(pCaller, "ui:interface:exchange_choose_in_bag"); } }; REGISTER_ACTION_HANDLER(CPlayerTradeLeftClickOnSlotHandler, "exchange_left_click_on_slot"); diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index e72ab80c6..0df3a071e 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -1084,7 +1084,7 @@ public: pSM->tryToUnblockTitleFromItems(false); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBGroupComboBox *pCB = dynamic_cast(pIM->getElementFromId(GROUP_TITLE_COMBO)); + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_TITLE_COMBO)); if (pCB != NULL) { pCB->resetTexts(); @@ -1116,7 +1116,7 @@ public: uint8 nNewTitle = 0; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CDBGroupComboBox *pCB = dynamic_cast(pIM->getElementFromId(GROUP_TITLE_COMBO)); + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_TITLE_COMBO)); if (pCB == NULL) return; if ((pCB->getSelection() < 0) || (pCB->getSelection() >= (sint32)pSM->_UIUnblockedTitles.size())) return; diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp index 26245b2c5..749bd00ea 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.cpp +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.cpp @@ -1629,7 +1629,7 @@ float CSPhraseManager::getPhraseSumBrickProp(const CSPhraseCom &phrase, uint { CInterfaceManager *im = CInterfaceManager::getInstance(); uint32 weight = (uint32) NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:DEFAULT_WEIGHT_HANDS")->getValue32() / 10; // weight must be in dg here - CDBCtrlSheet *ctrlSheet = dynamic_cast(im->getElementFromId("ui:interface:gestionsets:hands:handr")); + CDBCtrlSheet *ctrlSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestionsets:hands:handr")); if (ctrlSheet) { const CItemSheet *itemSheet = ctrlSheet->asItemSheet(); @@ -1638,7 +1638,7 @@ float CSPhraseManager::getPhraseSumBrickProp(const CSPhraseCom &phrase, uint weight = (uint32) ctrlSheet->getItemWeight(); } } - ctrlSheet = dynamic_cast(im->getElementFromId("ui:interface:gestionsets:hands:handl")); + ctrlSheet = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestionsets:hands:handl")); if (ctrlSheet) { const CItemSheet *itemSheet = ctrlSheet->asItemSheet(); @@ -1838,12 +1838,12 @@ void CSPhraseManager::updateExecutionDisplay() displayNext= false; // DisplayCycleSelectionOnActionBar - CInterfaceElement *viewCycle= pIM->getElementFromId(PhraseMemoryViewCycleAction); + CInterfaceElement *viewCycle= CWidgetManager::getInstance()->getElementFromId(PhraseMemoryViewCycleAction); if(viewCycle) { CInterfaceElement *ctrl= NULL; if(displayCycle) - ctrl= pIM->getElementFromId(PhraseMemoryViewSlotBase + toString(_CurrentExecuteSlotCycle)); + ctrl= CWidgetManager::getInstance()->getElementFromId(PhraseMemoryViewSlotBase + toString(_CurrentExecuteSlotCycle)); if(displayCycle && ctrl) { viewCycle->setParentPos(ctrl); @@ -1857,12 +1857,12 @@ void CSPhraseManager::updateExecutionDisplay() } // DisplayNextSelectionOnActionBar - CInterfaceElement *viewNext= pIM->getElementFromId(PhraseMemoryViewNextAction); + CInterfaceElement *viewNext= CWidgetManager::getInstance()->getElementFromId(PhraseMemoryViewNextAction); if(viewNext) { CInterfaceElement *ctrl= NULL; if(displayNext) - ctrl= pIM->getElementFromId(PhraseMemoryViewSlotBase + toString(_CurrentExecuteSlotNext)); + ctrl= CWidgetManager::getInstance()->getElementFromId(PhraseMemoryViewSlotBase + toString(_CurrentExecuteSlotNext)); if(displayNext && ctrl) { viewNext->setParentPos(ctrl); @@ -3037,13 +3037,13 @@ void CSPhraseManager::updateAllMemoryCtrlState() for(uint i=0;i(pIM->getElementFromId(PhraseMemoryCtrlBase + toString(i)) ); + CDBCtrlSheet *ctrl= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PhraseMemoryCtrlBase + toString(i)) ); if(ctrl) { // update the valid state. updateMemoryCtrlState(i, ctrl, itemSkill); } - CDBCtrlSheet *ctrlAlt= dynamic_cast(pIM->getElementFromId(PhraseMemoryAltCtrlBase + toString(i)) ); + CDBCtrlSheet *ctrlAlt= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PhraseMemoryAltCtrlBase + toString(i)) ); if(ctrlAlt) updateMemoryCtrlState(i, ctrlAlt, itemSkill); } @@ -3069,7 +3069,7 @@ CDBCtrlSheet *CSPhraseManager::getMemorySlotCtrl(uint memorySlot) // Get the ctrl CInterfaceManager *pIM= CInterfaceManager::getInstance(); - return dynamic_cast(pIM->getElementFromId(PhraseMemoryCtrlBase + toString(memorySlot))); + return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PhraseMemoryCtrlBase + toString(memorySlot))); } // *************************************************************************** @@ -3080,7 +3080,7 @@ CDBCtrlSheet *CSPhraseManager::getMemoryAltSlotCtrl(uint memorySlot) // Get the ctrl CInterfaceManager *pIM= CInterfaceManager::getInstance(); - return dynamic_cast(pIM->getElementFromId(PhraseMemoryAltCtrlBase + toString(memorySlot))); + return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PhraseMemoryAltCtrlBase + toString(memorySlot))); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp index 99d573381..de19fbdca 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -137,7 +137,7 @@ public: virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainerWindows *pGCW = dynamic_cast(pIM->getElementFromId("ui:interface:windows")); + CGroupContainerWindows *pGCW = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:windows")); if (pGCW == NULL) return; pGCW->setShowDesktops(!pGCW->getShowDesktops()); } @@ -154,7 +154,7 @@ public: virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:gestion_windows")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:gestion_windows")); if (pGC == NULL) return; CActionsManager *pAM = &Actions; const CActionsManager::TActionComboMap &acmap = pAM->getActionComboMap(); @@ -171,7 +171,7 @@ public: CActionsManager::TActionComboMap::const_iterator it = acmap.find(CAction::CName("show_hide",sWin.c_str())); string sFullTxt = string("ui:interface:gestion_windows:") + sTxt + ":key"; - CViewText *pVT = dynamic_cast(pIM->getElementFromId(sFullTxt)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sFullTxt)); if (pVT != NULL) { if (it != acmap.end()) diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index d9eb19957..a44dcf509 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -278,8 +278,8 @@ void CViewBitmapCombo::draw() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = pIM->getViewRenderer(); const std::vector &rVB = pIM->getViewsUnderPointer(); - if (!pIM->getPointer()) return; - pIM->getPointer()->getPointerDispPos(mx, my); + if (!CWidgetManager::getInstance()->getPointer()) return; + CWidgetManager::getInstance()->getPointer()->getPointerDispPos(mx, my); bool over = false; uint32 i; for (i = 0; i < rVB.size(); ++i) @@ -361,7 +361,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh) { overItem = true; - if (pIM->getPointer()->getButtonState() & NLMISC::leftButton) + if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, texIndex); color = getCol(_ColPushed, texIndex); @@ -416,7 +416,7 @@ void CViewBitmapCombo::draw() // if (_CD.Unrolled.getBool()) { - if (overItem && pIM->getPointer()->getButtonState() & NLMISC::leftButton) + if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsId, selectedTexIndex); color = getCol(_Col, selectedTexIndex); @@ -436,7 +436,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh ) { - if (pIM->getPointer()->getButtonState() & NLMISC::leftButton) + if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, selectedTexIndex); color = getCol(_ColPushed, selectedTexIndex); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 195977a6b..941f5ffb1 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -181,13 +181,13 @@ void CViewPointer::draw () _StringCursor = pIM->createGroupInstance("string_cursor", "", templateParams); if (_StringCursor) - _StringCursor->setParentPos(pIM->getElementFromId("ui:interface")); + _StringCursor->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); templateParams.clear(); templateParams.push_back (std::pair("id", "string_cursor_hardware")); _StringCursorHardware = pIM->createGroupInstance("string_cursor_hardware", "", templateParams); if (_StringCursorHardware) - _StringCursorHardware->setParentPos(pIM->getElementFromId("ui:interface")); + _StringCursorHardware->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); } CRGBA col; @@ -305,7 +305,7 @@ void CViewPointer::draw () // is the cursor currently over a modal window ? - CInterfaceGroup *currModal = pIM->getModalWindow(); + CInterfaceGroup *currModal = CWidgetManager::getInstance()->getModalWindow(); if (currModal) { sint32 xPos = _XReal + _OffsetX; diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 969691ac1..6167fd5f9 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -615,11 +615,11 @@ void CViewText::draw () TextContext->resetStringSelection(_Index); // if single line clamped, may allow to draw an over - if(isSingleLineTextClamped() && _OverExtendViewText && pIM->getPointer()) + if(isSingleLineTextClamped() && _OverExtendViewText && CWidgetManager::getInstance()->getPointer()) { // but must check first if mouse is over - sint32 x = pIM->getPointer()->getX(); - sint32 y = pIM->getPointer()->getY(); + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); bool mouseIn; // use parent clip or self clip? if(_OverExtendViewTextUseParentRect) diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 76ca72a8b..2bf490e13 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -18,8 +18,10 @@ #include "interface_group.h" #include "group_container.h" #include "group_in_scene.h" +#include "view_pointer.h" CWidgetManager* CWidgetManager::instance = NULL; +std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; // ---------------------------------------------------------------------------- // SMasterGroup @@ -351,10 +353,356 @@ void CWidgetManager::removeAllMasterGroups() } +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::activateMasterGroup (const std::string &sMasterGroupName, bool bActive) +{ + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getMasterGroupFromId (sMasterGroupName); + if (pIG != NULL) + { + pIG->setActive(bActive); + pIG->invalidateCoords(); + } +} + +// ------------------------------------------------------------------------------------------------ +CInterfaceGroup* CWidgetManager::getWindow(CInterfaceElement *pIE) +{ + CInterfaceGroup *pIG = pIE->getParent(); + if (pIG == NULL) return NULL; + if (pIG->getParent() == NULL) return NULL; + while (pIG->getParent()->getParent() != NULL) + { + pIG = pIG->getParent(); + } + return pIG; +} + + +// ------------------------------------------------------------------------------------------------ +CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sEltId) +{ + // System special + if(sEltId == _CtrlLaunchingModalId) + return getCtrlLaunchingModal(); + + // Search for all elements + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CInterfaceElement *pIEL = rMG.Group->getElement (sEltId); + if (pIEL != NULL) + return pIEL; + } + return NULL; +} + +// ------------------------------------------------------------------------------------------------ +CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sStart, const std::string &sEltId) +{ + CInterfaceElement *pIEL = getElementFromId (sEltId); + if (pIEL == NULL) + { + std::string sZeStart = sStart, sTmp; + if (sZeStart[sZeStart.size()-1] == ':') + sZeStart = sZeStart.substr(0, sZeStart.size()-1); + + while (sZeStart != "") + { + if (sEltId[0] == ':') + sTmp = sZeStart + sEltId; + else + sTmp = sZeStart + ":" + sEltId; + pIEL = getElementFromId (sTmp); + if (pIEL != NULL) + return pIEL; + std::string::size_type nextPos = sZeStart.rfind(':'); + if (nextPos == std::string::npos) break; + sZeStart = sZeStart.substr(0, nextPos); + } + } + return pIEL; +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::setTopWindow (CInterfaceGroup* win) +{ + //find the window in the window list + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + rMG.setTopWindow(win); + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::setBackWindow(CInterfaceGroup* win) +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + rMG.setBackWindow(win); + } +} + +// ------------------------------------------------------------------------------------------------ +CInterfaceGroup* CWidgetManager::getTopWindow (uint8 nPriority) const +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + // return the first. + if(rMG.PrioritizedWindows[nPriority].empty()) + return NULL; + else + return rMG.PrioritizedWindows[nPriority].back(); + } + } + return NULL; +} + + +// ------------------------------------------------------------------------------------------------ +CInterfaceGroup* CWidgetManager::getBackWindow (uint8 nPriority) const +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + // return the first. + if(rMG.PrioritizedWindows[nPriority].empty()) + return NULL; + else + return rMG.PrioritizedWindows[nPriority].front(); + } + } + return NULL; +} + +// *************************************************************************** +CInterfaceGroup* CWidgetManager::getLastEscapableTopWindow() const +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator it; + it= rList.rbegin(); + for(;it!=rList.rend();it++) + { + if((*it)->getActive() && (*it)->getEscapable()) + return *it; + } + } + } + } + return NULL; +} + +// *************************************************************************** +void CWidgetManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority) +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + if (rMG.isWindowPresent(pWin)) + { + rMG.delWindow(pWin); + rMG.addWindow(pWin, nNewPriority); + } + } + } +} + +// *************************************************************************** +uint8 CWidgetManager::getLastTopWindowPriority() const +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + return rMG.LastTopWindowPriority; + } + } + return 0; +} + +bool CWidgetManager::hasModal() const +{ + if( !_ModalStack.empty() ) + return true; + else + return false; +} + +CWidgetManager::SModalWndInfo& CWidgetManager::getModal() +{ + return _ModalStack.back(); +} + +bool CWidgetManager::isPreviousModal( CInterfaceGroup *wnd ) const +{ + std::vector< SModalWndInfo >::size_type s = _ModalStack.size(); + for( std::vector< SModalWndInfo >::size_type i = 0; i < s; i++ ) + if( _ModalStack[ i ].ModalWindow == wnd ) + return true; + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) +{ + // disable any modal before. release keyboard + disableModalWindow(); + pushModalWindow(ctrlLaunchingModal, pIG); +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::enableModalWindow (CCtrlBase *CtrlLaunchingModal, const std::string &groupName) +{ + CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); + if(group) + { + // enable the modal + enableModalWindow(CtrlLaunchingModal, group); + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::disableModalWindow () +{ + while (!_ModalStack.empty()) + { + SModalWndInfo winInfo = _ModalStack.back(); + _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash + // disable old modal window + if(winInfo.ModalWindow) + { + setBackWindow(winInfo.ModalWindow); + winInfo.ModalWindow->setActive(false); + } + } + + // disable any context help + setCurContextHelp( NULL ); + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) +{ + // enable the wanted modal + if(pIG) + { + SModalWndInfo mwi; + mwi.ModalWindow = pIG; + mwi.CtrlLaunchingModal = ctrlLaunchingModal; + // setup special group + CGroupModal *groupModal= dynamic_cast(pIG); + if(groupModal) + { + mwi.ModalExitClickOut = groupModal->ExitClickOut; + mwi.ModalExitClickL = groupModal->ExitClickL; + mwi.ModalExitClickR = groupModal->ExitClickR; + mwi.ModalHandlerClickOut = groupModal->OnClickOut; + mwi.ModalClickOutParams = groupModal->OnClickOutParams; + mwi.ModalExitKeyPushed = groupModal->ExitKeyPushed; + // update coords of the modal + if(groupModal->SpawnOnMousePos) + { + groupModal->SpawnMouseX = _Pointer->getX(); + groupModal->SpawnMouseY = _Pointer->getY(); + } + } + else + { + // default for group not modal. Backward compatibility + mwi.ModalExitClickOut = false; + mwi.ModalExitClickL = false; + mwi.ModalExitClickR = false; + mwi.ModalExitKeyPushed = false; + } + + _ModalStack.push_back(mwi); + + // update coords and activate the modal + mwi.ModalWindow->invalidateCoords(); + mwi.ModalWindow->setActive(true); + setTopWindow(mwi.ModalWindow); + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, const std::string &groupName) +{ + CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); + if(group) + { + // enable the modal + enableModalWindow(ctrlLaunchingModal, group); + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::popModalWindow() +{ + if (!_ModalStack.empty()) + { + SModalWndInfo winInfo = _ModalStack.back(); + _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash + if(winInfo.ModalWindow) + { + setBackWindow(winInfo.ModalWindow); + winInfo.ModalWindow->setActive(false); + } + if (!_ModalStack.empty()) + { + if(_ModalStack.back().ModalWindow) + { + _ModalStack.back().ModalWindow->setActive(true); + setTopWindow(_ModalStack.back().ModalWindow); + } + } + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::popModalWindowCategory(const std::string &category) +{ + for(;;) + { + if (_ModalStack.empty()) break; + if (!_ModalStack.back().ModalWindow) break; + CGroupModal *gm = dynamic_cast((CInterfaceGroup*)(_ModalStack.back().ModalWindow)); + if (gm && gm->Category == category) + { + _ModalStack.back().ModalWindow->setActive(false); + _ModalStack.pop_back(); + } + else + { + break; + } + } +} CWidgetManager::CWidgetManager() { + _Pointer = NULL; + curContextHelp = NULL; } CWidgetManager::~CWidgetManager() @@ -363,4 +711,7 @@ CWidgetManager::~CWidgetManager() { delete _MasterGroups[i].Group; } + + _Pointer = NULL; + curContextHelp = NULL; } \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index d70fcc99e..76d03b514 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -23,13 +23,16 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_common.h" +class CInterfaceElement; +class CCtrlBase; class CInterfaceGroup; +class CViewPointer; /// Manages the GUI widgets class CWidgetManager{ public: - + // Master groups encapsulate all windows struct SMasterGroup { SMasterGroup() @@ -59,6 +62,32 @@ public: }; + // Infos about a modal window. + struct SModalWndInfo + { + // Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after) + NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window + NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal; + bool ModalClip; + bool ModalExitClickOut; + bool ModalExitClickL; + bool ModalExitClickR; + bool ModalExitKeyPushed; + std::string ModalHandlerClickOut; + std::string ModalClickOutParams; + + SModalWndInfo() + { + ModalWindow = NULL; + CtrlLaunchingModal = NULL; + ModalExitClickOut = false; + ModalExitClickL = false; + ModalExitClickR = false; + ModalExitKeyPushed = false; + } + }; + + static CWidgetManager* getInstance(); static void release(); @@ -70,14 +99,94 @@ public: void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); void removeAllMasterGroups(); + void activateMasterGroup (const std::string &sMasterGroupName, bool bActive); + + CInterfaceElement* getElementFromId( const std::string &sEltId ); + CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId ); + + /// Get the window from an element (ui:interface:###) + CInterfaceGroup* getWindow(CInterfaceElement*); + + + /** + * set the top window + * \param win : pointer to the window to be set on top + */ + void setTopWindow (CInterfaceGroup *pWin); + + /** + * set the back window + * \param win : pointer to the window to be set on top + */ + void setBackWindow (CInterfaceGroup *pWin); + + /** get the top window in the first activated masterGroup + */ + CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; + + /** get the back window in the first activated masterGroup + */ + CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; + + /** get the last escapable top window in the first activated masterGroup + */ + CInterfaceGroup* getLastEscapableTopWindow() const; + + void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority); + + /** return the priority of the Last Window setTopWindow()-ed. + */ + uint8 getLastTopWindowPriority() const; + + bool hasModal() const; + + SModalWndInfo& getModal(); + + bool isPreviousModal( CInterfaceGroup *wnd ) const; + + void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); + void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); + // Disable all modals windows + void disableModalWindow (); + + /** Push a modal window that becomes the current modal window + */ + void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); + void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); + void popModalWindow(); + // pop all top modal windows with the given category (a string stored in the modal) + void popModalWindowCategory(const std::string &category); + + CCtrlBase *getCtrlLaunchingModal () + { + if (_ModalStack.empty()) return NULL; + return _ModalStack.back().CtrlLaunchingModal; + } + /// get the currently active modal window, or NULL if none + CInterfaceGroup *getModalWindow() const + { + if (_ModalStack.empty()) return NULL; + return _ModalStack.back().ModalWindow; + } + + void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; } + CCtrlBase* getCurContextHelp(){ return curContextHelp; } + + float _DeltaTimeStopingContextHelp; + + CViewPointer* getPointer(){ return _Pointer; } + void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } + private: CWidgetManager(); ~CWidgetManager(); static CWidgetManager *instance; - - // Master groups encapsulate all windows std::vector< SMasterGroup > _MasterGroups; + std::vector< SModalWndInfo > _ModalStack; + static std::string _CtrlLaunchingModalId; + NLMISC::CRefPtr< CCtrlBase > curContextHelp; + CViewPointer *_Pointer; }; #endif diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index ef014f6bc..1457aa396 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -162,7 +162,7 @@ static void errorMessageBox(const ucstring &msg) void createOptionalCatUI() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_CAT)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); if (pList == NULL) { nlwarning("element "GROUP_LIST_CAT" not found probably bad login_main.xml"); @@ -229,7 +229,7 @@ void initEula() static void setDataScanLog(const ucstring &text) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:datascan:content:log_txt:log")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log")); if (pVT != NULL) { pVT->setText(text); @@ -240,10 +240,10 @@ static void setDataScanLog(const ucstring &text) static void setDataScanState(const ucstring &text, ucstring progress= ucstring()) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:datascan:content:state")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state")); if (pVT != NULL) pVT->setText(text); - pVT = dynamic_cast(pIM->getElementFromId("ui:login:datascan:content:progress")); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress")); if (pVT != NULL) pVT->setText(progress); } @@ -280,7 +280,7 @@ void initReboot() static void setPatcherStateText(const std::string &baseUIPath, const ucstring &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId(baseUIPath + ":content:state")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state")); if (pVT != NULL) { pVT->setText(str); @@ -291,7 +291,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s static void setPatcherProgressText(const std::string &baseUIPath, const ucstring &str) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId(baseUIPath + ":content:progress")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress")); if (pVT != NULL) { pVT->setText(str); @@ -657,7 +657,7 @@ void loginMainLoop() } } - CViewText *pVT = dynamic_cast(pIM->getElementFromId(VIEW_TOTAL_SIZE_PATCH)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE_PATCH)); ucstring sTmp; sTmp = BGDownloader::getWrittenSize(currentPatchingSize); sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize); @@ -672,7 +672,7 @@ void loginMainLoop() uint32 nNonOptSize = 0; TotalPatchSize = 0; vector ReqCat; - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_CAT)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); if (pList != NULL) { for(uint i = 0; i < InfoOnPatch.OptCat.size(); i++) @@ -709,10 +709,10 @@ void loginMainLoop() TotalPatchSize += nNonOptSize; // Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat - CViewText *pVT = dynamic_cast(pIM->getElementFromId(VIEW_TOTAL_SIZE)); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE)); if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize)); - pVT = dynamic_cast(pIM->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE)); if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize)); } } @@ -739,7 +739,7 @@ void initLoginScreen() if(!l.empty()) { - CGroupEditBox *pGEB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); + CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); if (pGEB != NULL && (pGEB->getInputString().empty())) { pGEB->setInputString(l); @@ -752,7 +752,7 @@ void initLoginScreen() } - CCtrlTextButton *pCB = dynamic_cast(pIM->getElementFromId(CTRL_BUTTON_CONNECT)); + CCtrlTextButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CONNECT)); if (pCB != NULL) pCB->setActive(false); loginFinished = false; @@ -762,8 +762,8 @@ void initLoginScreen() void initAutoLogin() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupEditBox *pGEBLog = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); - CGroupEditBox *pGEBPwd = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_PASSWORD)); + CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); + CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); pGEBLog->setInputString(LoginLogin); pGEBPwd->setInputString(LoginPassword); pIM->runActionHandler("on_login", NULL, ""); @@ -831,17 +831,17 @@ bool login() // NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // // // hide 'back to login' button -// CInterfaceElement *backToLogin = pIM->getElementFromId(CTRL_BUTTON_BACKTOLOGIN); +// CInterfaceElement *backToLogin = CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_BACKTOLOGIN); // if (backToLogin) // backToLogin->setActive(false); // // // show 'reload test page' button -// CInterfaceElement *reloadTest = pIM->getElementFromId(CTRL_BUTTON_RELOADTESTPAGE); +// CInterfaceElement *reloadTest = CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_RELOADTESTPAGE); // if (reloadTest) // reloadTest->setActive(true); // // // start the browser -// CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); +// CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER)); // // pGH->browse(ClientCfg.TestBrowserUrl.c_str()); // @@ -866,7 +866,7 @@ bool login() // // if(!l.empty()) // { -// CGroupEditBox *pGEB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); +// CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); // if (pGEB != NULL) // pGEB->setInputString(l); // pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); @@ -877,7 +877,7 @@ bool login() // } ShardSelected = -1; -// CCtrlTextButton *pCB = dynamic_cast(pIM->getElementFromId(CTRL_BUTTON_CONNECT)); +// CCtrlTextButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CONNECT)); // if (pCB != NULL) pCB->setActive(false); // // loginFinished = false; @@ -887,8 +887,8 @@ bool login() // if (!LoginLogin.empty()) // { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CGroupEditBox *pGEBLog = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); -// CGroupEditBox *pGEBPwd = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_PASSWORD)); +// CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); +// CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); // pGEBLog->setInputString(LoginLogin); // pGEBPwd->setInputString(LoginPassword); // pIM->runActionHandler("on_login", NULL, ""); @@ -1031,7 +1031,7 @@ void initShardDisplay() CInterfaceManager *pIM = CInterfaceManager::getInstance(); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD)); if (pList == NULL) { nlwarning("element "GROUP_LIST_SHARD" not found probably bad login_main.xml"); @@ -1087,7 +1087,7 @@ void initShardDisplay() // UI Patch if (!Shards.empty()) { - CCtrlButton *pCB = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD ":s0:but")); + CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); if (pCB != NULL) pCB->setPushed(true); pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); @@ -1147,7 +1147,7 @@ void onlogin(bool vanishScreen = true) // // CInterfaceManager *pIM = CInterfaceManager::getInstance(); // // start the browser -// CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); +// CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER)); // // pGH->browse(RingMainURL.c_str()); // } @@ -1158,7 +1158,7 @@ void onlogin(bool vanishScreen = true) // NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_SHARDDISP); } -// CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD)); +// CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD)); // if (pList == NULL) // { // nlwarning("element "GROUP_LIST_SHARD" not found probably bad login_main.xml"); @@ -1214,7 +1214,7 @@ void onlogin(bool vanishScreen = true) // // UI Patch // if (!Shards.empty()) // { -// CCtrlButton *pCB = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD ":s0:but")); +// CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); // if (pCB != NULL) // pCB->setPushed(true); // pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); @@ -1248,8 +1248,8 @@ class CAHOnLogin : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupEditBox *pGEBLog = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); - CGroupEditBox *pGEBPwd = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_PASSWORD)); + CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); + CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); if ((pGEBLog == NULL) || (pGEBPwd == NULL)) { nlwarning("element "CTRL_EDITBOX_LOGIN" or "CTRL_EDITBOX_PASSWORD" not found probably bad login_main.xml"); @@ -1325,9 +1325,9 @@ class CAHLoginTab : public IActionHandler CCtrlBase *pNewCB; string sID = pCB->getId(); if (sID == CTRL_EDITBOX_LOGIN) - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_PASSWORD)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); else - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); pIM->setCaptureKeyboard(pNewCB); } } @@ -1339,13 +1339,13 @@ class CAHLoginTab : public IActionHandler CCtrlBase *pNewCB; string sID = pCB->getId(); if (sID == CTRL_EDITBOX_CREATEACCOUNT_LOGIN) - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_PASSWORD)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_PASSWORD)); else if (sID == CTRL_EDITBOX_CREATEACCOUNT_PASSWORD) - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_CONFIRMPASSWORD)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_CONFIRMPASSWORD)); else if (sID == CTRL_EDITBOX_CREATEACCOUNT_CONFIRMPASSWORD) - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_EMAIL)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_EMAIL)); else - pNewCB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_LOGIN)); + pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_LOGIN)); pIM->setCaptureKeyboard(pNewCB); } } @@ -1367,7 +1367,7 @@ class CAHShardSelect : public IActionHandler // Unselect if (ShardSelected != -1) { - pCB = dynamic_cast(pIM->getElementFromId(GROUP_LIST_SHARD ":s"+toString(ShardSelected)+":but")); + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s"+toString(ShardSelected)+":but")); if (pCB != NULL) pCB->setPushed(false); } @@ -1383,7 +1383,7 @@ class CAHShardSelect : public IActionHandler pCB->setPushed(true); } - CCtrlTextButton *pCTB = dynamic_cast(pIM->getElementFromId(CTRL_BUTTON_CONNECT)); + CCtrlTextButton *pCTB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CONNECT)); if (pCTB != NULL) pCTB->setActive(true); } @@ -1533,7 +1533,7 @@ void initPatch() // Get the list of optional categories to patch vector vCategories; - CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_CAT)); + CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); if (pList == NULL) { nlwarning("element "GROUP_LIST_CAT" not found probably bad login_main.xml"); @@ -1573,7 +1573,7 @@ void initPatch() } NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_PATCHING); - CInterfaceElement *closeBtn = pIM->getElementFromId(CTRL_BUTTON_CLOSE_PATCH); + CInterfaceElement *closeBtn = CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CLOSE_PATCH); if (closeBtn) closeBtn->setActive(false); @@ -1597,7 +1597,7 @@ class CAHLoginPatch : public IActionHandler // // Get the list of optional categories to patch // vector vCategories; // -// CInterfaceGroup *pList = dynamic_cast(pIM->getElementFromId(GROUP_LIST_CAT)); +// CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_CAT)); // if (pList == NULL) // { // nlwarning("element "GROUP_LIST_CAT" not found probably bad login_main.xml"); @@ -1666,7 +1666,7 @@ class CAHSetReleaseNote : public IActionHandler string sShard = getParam(sParams, "shard"); string sGroupHtml = getParam(sParams, "group"); - CGroupHTML *pQH = dynamic_cast(pIM->getElementFromId(sGroupHtml)); + CGroupHTML *pQH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sGroupHtml)); if (pQH == NULL) return; @@ -1761,7 +1761,7 @@ class CAHAcceptEula : public IActionHandler // NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_WEBSTART); // // // start the browser -// CGroupHTML *pGH = dynamic_cast(pIM->getElementFromId(GROUP_BROWSER)); +// CGroupHTML *pGH = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_BROWSER)); // // pGH->browse(RingMainURL.c_str()); // } @@ -1912,7 +1912,7 @@ class CAHInitResLod : public IActionHandler CurrentMode = 1; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:res_value")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:res_value")); if (pVT != NULL) pVT->setHardText(StringModeList[CurrentMode]); @@ -1989,7 +1989,7 @@ class CAHInitResLod : public IActionHandler else if (nPreset&8) CurrentPreset = 3; } - pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:lod_value")); + pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:lod_value")); if (pVT != NULL) pVT->setHardText(StringPresetList[CurrentPreset]); } @@ -2005,7 +2005,7 @@ class CAHMoreRes : public IActionHandler if (CurrentMode < ((sint)StringModeList.size()-1)) CurrentMode++; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:res_value")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:res_value")); if (pVT != NULL) pVT->setHardText(StringModeList[CurrentMode]); } @@ -2021,7 +2021,7 @@ class CAHLessRes : public IActionHandler if (CurrentMode > 0) CurrentMode--; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:res_value")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:res_value")); if (pVT != NULL) pVT->setHardText(StringModeList[CurrentMode]); } @@ -2037,7 +2037,7 @@ class CAHMoreLod : public IActionHandler if (CurrentPreset < ((sint)StringPresetList.size()-1)) CurrentPreset++; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:lod_value")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:lod_value")); if (pVT != NULL) pVT->setHardText(StringPresetList[CurrentPreset]); } @@ -2053,7 +2053,7 @@ class CAHLessLod : public IActionHandler if (CurrentPreset > 0) CurrentPreset--; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewText *pVT = dynamic_cast(pIM->getElementFromId("ui:login:checkpass:content:lod_value")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:checkpass:content:lod_value")); if (pVT != NULL) pVT->setHardText(StringPresetList[CurrentPreset]); } @@ -2168,7 +2168,7 @@ class CAHOnScanDataClose : public IActionHandler // // // Give focus to password if some login entered // string loginEB; -// CGroupEditBox *pGEB = dynamic_cast(pIM->getElementFromId(CTRL_EDITBOX_LOGIN)); +// CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); // if(pGEB) // loginEB= pGEB->getInputStringAsStdString(); // // if none entered @@ -2234,7 +2234,7 @@ bool initCreateAccount() CInterfaceManager *pIM = CInterfaceManager::getInstance(); // reset UI - CInterfaceGroup *createAccountUI = dynamic_cast(pIM->getElementFromId("ui:login:create_account")); + CInterfaceGroup *createAccountUI = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:create_account")); if(createAccountUI) { // show "submit interface", hide "login interface" @@ -2372,7 +2372,7 @@ class CAHCreateAccountRules : public IActionHandler nlinfo("CAHCreateAccountRules called"); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *createAccountUI = dynamic_cast(pIM->getElementFromId("ui:login:create_account")); + CInterfaceGroup *createAccountUI = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:create_account")); if(createAccountUI) { CInterfaceGroup * rulesGr = dynamic_cast(createAccountUI->findFromShortId("rules_gr")); @@ -2426,7 +2426,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *createAccountUI = dynamic_cast(pIM->getElementFromId("ui:login:create_account")); + CInterfaceGroup *createAccountUI = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:create_account")); if(createAccountUI) { // recover data from UI @@ -2589,7 +2589,7 @@ class CAHCreateAccountLogin : public IActionHandler CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *createAccountUI = dynamic_cast(pIM->getElementFromId("ui:login:create_account")); + CInterfaceGroup *createAccountUI = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:create_account")); if(createAccountUI) { CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb")); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 4989b3f71..1abf1dc28 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1310,44 +1310,44 @@ void updateGameQuitting() // update the window CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CInterfaceGroup *group= dynamic_cast(pIM->getElementFromId("ui:interface:free_trial_game_quitting")); + CInterfaceGroup *group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:free_trial_game_quitting")); if(group) { // if Free trial if(paying_account_request) { // if no current modal window, or if not the quit window - if(group != pIM->getModalWindow()) + if(group != CWidgetManager::getInstance()->getModalWindow()) { // disable - pIM->disableModalWindow(); - pIM->enableModalWindow(NULL, group); + CWidgetManager::getInstance()->disableModalWindow(); + CWidgetManager::getInstance()->enableModalWindow(NULL, group); } } else { // if the current modal window is the quit window, disable - if(group == pIM->getModalWindow()) + if(group == CWidgetManager::getInstance()->getModalWindow()) { // disable - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } } - group= dynamic_cast(pIM->getElementFromId("ui:interface:game_quitting")); + group= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:game_quitting")); if(group) { // if exit request if(game_exit_request && !paying_account_request) { // if no current modal window, or if not the quit window - if(group != pIM->getModalWindow()) + if(group != CWidgetManager::getInstance()->getModalWindow()) { // disable - pIM->disableModalWindow(); - pIM->enableModalWindow(NULL, group); + CWidgetManager::getInstance()->disableModalWindow(); + CWidgetManager::getInstance()->enableModalWindow(NULL, group); bool farTPing = FarTP.isFarTPInProgress(); // Far TP: skipping not allowed (because we can't duplicate the avatar...), anyway the quit button would quit the game (no far tp) @@ -1370,10 +1370,10 @@ void updateGameQuitting() else { // if the current modal window is the quit window, disable - if(group == pIM->getModalWindow()) + if(group == CWidgetManager::getInstance()->getModalWindow()) { // disable - pIM->disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); } } } @@ -1738,7 +1738,7 @@ bool mainLoop() if(!pIMinstance->getViewRenderer().isMinimized()) { // Get the cursor instance - CViewPointer *cursor = pIMinstance->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { // Get the pointer position (in pixel) @@ -1778,7 +1778,7 @@ bool mainLoop() { // When database received, activate allegiance buttons (for neutral state) in fame window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *group = dynamic_cast(pIM->getElementFromId("ui:interface:fame:content:you")); + CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:fame:content:you")); if (group) group->updateAllLinks(); // send a msg to lua for specific ui update @@ -4552,11 +4552,11 @@ void inGamePatchUncompleteWarning() im->executeLuaScript("bgdownloader:inGamePatchUncompleteWarning()"); /* CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast(im->getElementFromId("ui:interface:bg_downloader")); + CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:bg_downloader")); if (gc) { gc->setActive(true); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->enableBlink(2); } im->messageBoxWithHelp(CI18N::get("uiBGD_InGamePatchIncomplete")); diff --git a/code/ryzom/client/src/motion/modes/ai_mode.cpp b/code/ryzom/client/src/motion/modes/ai_mode.cpp index 779072e21..775aff68c 100644 --- a/code/ryzom/client/src/motion/modes/ai_mode.cpp +++ b/code/ryzom/client/src/motion/modes/ai_mode.cpp @@ -150,7 +150,7 @@ void CUserControls::aiMode() IM->enableMouseHandling(false); EventsListener.enableMouseSmoothing(true); // Get the cursor instance and hide. - CViewPointer *cursor = IM->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { // Freelook mode. diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index 158465420..4697a0d5e 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -507,7 +507,7 @@ void CUserControls::freeLook(bool fullMode) // disable interface mouse handling. IM->enableMouseHandling(false); // Get the cursor instance - CViewPointer *cursor = IM->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { // Hide the Cursor. @@ -590,7 +590,7 @@ void CUserControls::cameraLook(bool fullMode) // disable interface mouse handling. IM->enableMouseHandling(false); // Get the cursor instance - CViewPointer *cursor = IM->getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { // Hide the Cursor. diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 467991245..5ca5219d4 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -1073,7 +1073,7 @@ void setFakeNews () iname += table[i]; iname += "_friendly_main"; - CInterfaceGroup *inter = CInterfaceManager::getInstance()->getWindowFromId(iname); + CInterfaceGroup *inter = CWidgetManager::getInstance()->getWindowFromId(iname); if (inter == NULL) { nlwarning ("cant find interface 's%'", iname.c_str()); @@ -1098,7 +1098,7 @@ void setFakeNews () iname += table[i]; iname += "_neutral_main"; - CInterfaceGroup *inter = CInterfaceManager::getInstance()->getWindowFromId(iname); + CInterfaceGroup *inter = CWidgetManager::getInstance()->getWindowFromId(iname); if (inter == NULL) { nlwarning ("cant find interface 's%'", iname.c_str()); @@ -1119,7 +1119,7 @@ void setFakeNews () iname += table[i]; iname += "_more_news"; - CInterfaceGroup *inter = CInterfaceManager::getInstance()->getWindowFromId(iname); + CInterfaceGroup *inter = CWidgetManager::getInstance()->getWindowFromId(iname); if (inter == NULL) { nlwarning ("cant find interface 's%'", iname.c_str()); @@ -1230,7 +1230,7 @@ void impulseBotChatSetInterface(NLMISC::CBitMemStream &impulse) */ // TEMP FOR THE DEMO, DON'T USE THE NETWORK NEW BUT SELECT A NEWS HERE /* - CInterfaceGroup *inter = CInterfaceManager::getInstance()->getWindowFromId("ui:interface:bot_chat_intro"); + CInterfaceGroup *inter = CWidgetManager::getInstance()->getWindowFromId("ui:interface:bot_chat_intro"); nlassert (inter != NULL); inter->setActive(true); @@ -1254,7 +1254,7 @@ void impulseBotChatSetInterface(NLMISC::CBitMemStream &impulse) } else { - CInterfaceGroup *inter = CInterfaceManager::getInstance()->getWindowFromId(interfaceName); + CInterfaceGroup *inter = CWidgetManager::getInstance()->getWindowFromId(interfaceName); if (inter == NULL) { nlwarning ("Can't find interface name '%s' %d", interfaceName.c_str(), interfaceId); @@ -1715,10 +1715,10 @@ void impulseTeamShareOpen(NLMISC::CBitMemStream &impulse) { if (PermanentlyBanned) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast( im->getElementFromId("ui:interface:team_share")); + CGroupContainer *gc = dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share")); if (!gc) return; gc->setActive(true); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->updateCoords(); gc->center(); }// impulseTeamShareOpen // @@ -1734,7 +1734,7 @@ void impulseTeamShareInvalid(NLMISC::CBitMemStream &impulse) { if (PermanentlyBanned) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlTextButton *pTB = dynamic_cast(pIM->getElementFromId("ui:interface:team_share:content:ok")); + CCtrlTextButton *pTB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share:content:ok")); if (pTB != NULL) pTB->setActive(true); }// impulseTeamShareInvalid // @@ -1748,10 +1748,10 @@ void impulseTeamShareClose(NLMISC::CBitMemStream &impulse) if (PermanentlyBanned) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupContainer - *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:team_share")); + *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share")); if (pGC != NULL) pGC->setActive(false); - CCtrlTextButton *pTB = dynamic_cast(pIM->getElementFromId("ui:interface:team_share:content:ok")); + CCtrlTextButton *pTB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:team_share:content:ok")); if (pTB != NULL) pTB->setActive(true); }// impulseTeamShareClose // @@ -1932,13 +1932,13 @@ void impulseGuildJoinProposal(NLMISC::CBitMemStream &impulse) CGuildManager::getInstance()->launchJoinProposal(phraseID); /*//activate the pop up window CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast( im->getElementFromId("ui:interface:join_guild_proposal")); + CGroupContainer *gc = dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:join_guild_proposal")); if (!gc) return; CViewText *vt = dynamic_cast(gc->getView("invitor_name")); if (vt == NULL) return; vt->setText(invitor); gc->setActive(true); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->updateCoords(); gc->center(); gc->enableBlink(2);*/ @@ -1975,13 +1975,13 @@ void impulseEnterCrZoneProposal(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *im = CInterfaceManager::getInstance(); - CGroupContainer *gc = dynamic_cast( im->getElementFromId("ui:interface:enter_crzone_proposal")); + CGroupContainer *gc = dynamic_cast( CWidgetManager::getInstance()->getElementFromId("ui:interface:enter_crzone_proposal")); if (!gc) return; CViewTextID *vti = dynamic_cast(gc->getView("phrase")); if (!vti) return; vti->setTextId(phraseID); gc->setActive(true); - im->setTopWindow(gc); + CWidgetManager::getInstance()->setTopWindow(gc); gc->updateCoords(); gc->center(); gc->enableBlink(2); @@ -1995,7 +1995,7 @@ void impulseCloseEnterCrZoneProposal(NLMISC::CBitMemStream &impulse) { // hide interface CInterfaceManager* pIM = CInterfaceManager::getInstance(); - CInterfaceGroup *pIG = (CInterfaceGroup*)pIM->getElementFromId ("ui:interface:enter_crzone_proposal"); + CInterfaceGroup *pIG = (CInterfaceGroup*)CWidgetManager::getInstance()->getElementFromId ("ui:interface:enter_crzone_proposal"); if(pIG) pIG->setActive(false); }// impulseCloseEnterCrZoneProposal // @@ -2012,14 +2012,14 @@ void impulseExchangeInvitation(NLMISC::CBitMemStream &impulse) CInterfaceManager* iMngr = CInterfaceManager::getInstance(); // show the modal window that allow the player to accept / decline the invitation - CGroupContainer *wnd = dynamic_cast(iMngr->getElementFromId(PLAYER_EXCHANGE_INVITATION_DIALOG)); + CGroupContainer *wnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PLAYER_EXCHANGE_INVITATION_DIALOG)); if (wnd) { wnd->setActive(true); wnd->updateCoords(); wnd->center(); wnd->enableBlink(2); - iMngr->setTopWindow(wnd); + CWidgetManager::getInstance()->setTopWindow(wnd); } CViewTextID *vti = dynamic_cast(wnd->getView("invite_phrase")); @@ -2038,7 +2038,7 @@ void impulseExchangeCloseInvitation(NLMISC::CBitMemStream &impulse) if (PermanentlyBanned) return; CInterfaceManager* iMngr = CInterfaceManager::getInstance(); // hide the modal window that allow the player to accept / decline the invitation - CInterfaceGroup *wnd = dynamic_cast(iMngr->getElementFromId(PLAYER_EXCHANGE_INVITATION_DIALOG)); + CInterfaceGroup *wnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(PLAYER_EXCHANGE_INVITATION_DIALOG)); if (wnd) wnd->setActive(false); } @@ -2310,7 +2310,7 @@ void impulseBotChatForceEnd(NLMISC::CBitMemStream &impulse) CGroupContainer *getMissionCompletedContainer() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE = pIM->getElementFromId(MC_M_CONTAINER); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(MC_M_CONTAINER); CGroupContainer *pGCM = dynamic_cast(pIE); if (pGCM == NULL) return NULL; @@ -2899,7 +2899,7 @@ void impulseDeathRespawnPoint (NLMISC::CBitMemStream &impulse) impulse.serial(msg); if (PermanentlyBanned) return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupMap *pMap = dynamic_cast(pIM->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:respawn_map:content:map_content:actual_map")); if (pMap == NULL) { nlwarning("problem cannot find ui:interface:respawn_map:content:map_content:actual_map"); @@ -2908,7 +2908,7 @@ void impulseDeathRespawnPoint (NLMISC::CBitMemStream &impulse) pMap->addRespawnPoints(msg); - pMap = dynamic_cast(pIM->getElementFromId("ui:interface:map:content:map_content:actual_map")); + pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap == NULL) { nlwarning("problem cannot find ui:interface:map:content:map_content:actual_map"); @@ -2938,13 +2938,13 @@ void impulseDuelInvitation(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_duel_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_duel_proposal")); if (pGC == NULL) return; CViewTextID *pVTID = dynamic_cast(pGC->getView("invitor_name")); if (pVTID == NULL) return; pVTID->setTextId(textID); pGC->setActive(true); - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); pGC->updateCoords(); pGC->center(); pGC->enableBlink(2); @@ -2961,7 +2961,7 @@ void impulseDuelCancelInvitation(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_duel_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_duel_proposal")); if (pGC == NULL) return; pGC->setActive(false); @@ -2981,13 +2981,13 @@ void impulsePVPChallengeInvitation(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_challenge_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_challenge_proposal")); if (pGC == NULL) return; CViewTextID *pVTID = dynamic_cast(pGC->getView("invitor_name")); if (pVTID == NULL) return; pVTID->setTextId(textID); pGC->setActive(true); - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); pGC->updateCoords(); pGC->center(); pGC->enableBlink(2); @@ -3003,7 +3003,7 @@ void impulsePVPChallengeCancelInvitation(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_challenge_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_challenge_proposal")); if (pGC == NULL) return; pGC->setActive(false); @@ -3075,16 +3075,16 @@ void impulsePVPChooseClan(NLMISC::CBitMemStream &impulse) //activate the pop up window CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_clan_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal")); if (pGC == NULL) return; pGC->setActive(true); - CCtrlTextButton * butClan1 = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan1")); + CCtrlTextButton * butClan1 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan1")); if( butClan1 == NULL ) return; butClan1->setText( ucstring(EGSPD::CPeople::toString( clan1 )) ); - CCtrlTextButton * butClan2 = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan2")); + CCtrlTextButton * butClan2 = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_clan_proposal:content:clan2")); if( butClan2 == NULL ) return; butClan2->setText( ucstring(EGSPD::CPeople::toString( clan2 )) ); @@ -3137,7 +3137,7 @@ void impulseItemCloseRoomInventory(NLMISC::CBitMemStream &impulse) NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:INVENTORY_ROOM_OPENED")->setValue32(0); // deactivate the pop up window - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:inv_room")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:inv_room")); if (pGC == NULL) return; pGC->setActive(false); } @@ -3297,16 +3297,16 @@ private: string group = titleStr.toString(); // group = group.substr(9, group.size()-10); - groupHtml = dynamic_cast(pIM->getElementFromId("ui:interface:"+group+":content:html")); + groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+group+":content:html")); if (!groupHtml) { - groupHtml = dynamic_cast(pIM->getElementFromId("ui:interface:webig:content:html")); + groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:webig:content:html")); group = "webig"; } if (groupHtml) { - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:"+group)); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+group)); if (pGC) { if (contentStr.empty()) @@ -3320,14 +3320,14 @@ private: string url = contentStr.toString(); addWebIGParams(url, true); groupHtml->browse(url.c_str()); - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); } } } } else { - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:server_message_box")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:server_message_box")); if (pGC) { // show the window with correct width @@ -3335,12 +3335,12 @@ private: pGC->setActive(true); // must set the text by hand - CViewText *vt= dynamic_cast(pIM->getElementFromId(pIM->getDefine("server_message_box_content_view_text"))); + CViewText *vt= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pIM->getDefine("server_message_box_content_view_text"))); if(vt) vt->setTextFormatTaged(contentStr); // open - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); pGC->invalidateCoords(); // Yoyo: because of buggued group container, I found that 6 times is a good number.... for(uint i=0;i<6;i++) diff --git a/code/ryzom/client/src/outpost_manager.cpp b/code/ryzom/client/src/outpost_manager.cpp index 01b073cc9..1f6deb320 100644 --- a/code/ryzom/client/src/outpost_manager.cpp +++ b/code/ryzom/client/src/outpost_manager.cpp @@ -58,11 +58,11 @@ void COutpostManager::startPvpJoinProposal(bool playerGuildInConflict, bool play if(node) node->setValue32(_EndTickForPvpJoinProposal); // open Popup - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_outpost_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal")); if (pGC) { pGC->setActive(true); - pIM->setTopWindow(pGC); + CWidgetManager::getInstance()->setTopWindow(pGC); pGC->updateCoords(); pGC->updateCoords(); pGC->center(); @@ -108,7 +108,7 @@ void COutpostManager::update() pIM->runActionHandler("outpost_pvp_join", NULL, "neutral"); // close the window - CGroupContainer *pGC = dynamic_cast(pIM->getElementFromId("ui:interface:join_pvp_outpost_proposal")); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal")); if (pGC) pGC->setActive(false); diff --git a/code/ryzom/client/src/player_cl.cpp b/code/ryzom/client/src/player_cl.cpp index 69755bab2..fb1c4fbe0 100644 --- a/code/ryzom/client/src/player_cl.cpp +++ b/code/ryzom/client/src/player_cl.cpp @@ -683,7 +683,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle * // display the new title in player interface if (_Slot == 0) { - CViewText *pVT = dynamic_cast(IM->getElementFromId("ui:interface:player:header_opened:player_title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title")); if (pVT != NULL) pVT->setText(_Title); } diff --git a/code/ryzom/client/src/r2/displayer_visual.cpp b/code/ryzom/client/src/r2/displayer_visual.cpp index 6caa4127f..3e49d57fa 100644 --- a/code/ryzom/client/src/r2/displayer_visual.cpp +++ b/code/ryzom/client/src/r2/displayer_visual.cpp @@ -442,7 +442,7 @@ void CDisplayerVisual::onPostRender() { // Link to the interface CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group); - CInterfaceGroup *pRoot = dynamic_cast(pIM->getElementFromId("ui:interface")); + CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); group->setParent(pRoot); if (pRoot) pRoot->addGroup (group); diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 567a9a864..24b0cd302 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -615,7 +615,7 @@ void CEditor::clearDebugWindow() //H_AUTO(R2_CEditor_clearDebugWindow) CHECK_EDITOR getUI().flushDebugWindow(); - CGroupList *gl = dynamic_cast(getUI().getElementFromId("ui:interface:debug_info:content:cb:text_list")); + CGroupList *gl = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:debug_info:content:cb:text_list")); if (gl) { gl->deleteAllChildren(); @@ -1648,11 +1648,11 @@ void CEditor::waitScenarioScreen() setMode(GoingToEditionMode); } getUI().hideAllWindows(); - CInterfaceGroup *waitScreen = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_connecting")); + CInterfaceGroup *waitScreen = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting")); if (waitScreen) { waitScreen->setActive(true); - getUI().setTopWindow(waitScreen); + CWidgetManager::getInstance()->setTopWindow(waitScreen); } // enum TState { WaitingScenario, WaitingTP, DoExit }; @@ -1669,7 +1669,7 @@ void CEditor::waitScenarioScreen() loadBackgroundBitmap (StartBackground); // patch for the 'sys info that pop' prb (cause unknown for now ...) - CInterfaceElement *sysInfo = getUI().getElementFromId("ui:interface:system_info"); + CInterfaceElement *sysInfo = CWidgetManager::getInstance()->getElementFromId("ui:interface:system_info"); bool sysInfoActive = false; if (sysInfo) sysInfoActive = sysInfo->getActive(); @@ -1718,7 +1718,7 @@ void CEditor::waitScenarioScreen() else { // Display the firewall alert string - CViewText *pVT = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_connecting:title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); if (pVT != NULL) pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("...")); @@ -1767,7 +1767,7 @@ void CEditor::waitScenarioScreen() if (waitScreen) { - getUI().setTopWindow(waitScreen); + CWidgetManager::getInstance()->setTopWindow(waitScreen); } if (sysInfo) sysInfo->setActive(false); @@ -1807,7 +1807,7 @@ void CEditor::waitScenarioScreen() if ( firewallTimeout ) { // Display the firewall error string instead of the normal failure string - CViewText *pVT = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_connecting:title")); + CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title")); if (pVT != NULL) { pVT->setMultiLine( true ); @@ -2350,7 +2350,7 @@ void CEditor::setMode(TMode mode) ContextCur.release(); _Mode = mode; loadKeySet(getKeySetPrefix(_Mode)); - getUI().disableModalWindow(); + CWidgetManager::getInstance()->disableModalWindow(); getUI().setCapturePointerLeft(NULL); getUI().setCapturePointerRight(NULL); getUI().setCaptureKeyboard(NULL); @@ -2578,7 +2578,7 @@ void CEditor::hideRingWindows() for (uint k = 0; k < sizeofarray(ringWindows); ++k) { std::string id = "ui:interface:" + std::string(ringWindows[k]); - CInterfaceElement *grp = getUI().getElementFromId(id); + CInterfaceElement *grp = CWidgetManager::getInstance()->getElementFromId(id); if (grp) { grp->setActive(false); @@ -5191,7 +5191,7 @@ void CEditor::onEditionModeConnected( uint32 userSlotId, uint32 adventureId, COb { setMode(EditionMode); } - CInterfaceGroup *currentSessionGroup = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_current_session")); + CInterfaceGroup *currentSessionGroup = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_current_session")); if (currentSessionGroup) { CViewText *text = dynamic_cast(currentSessionGroup->getView("current_session")); @@ -5242,7 +5242,7 @@ void CEditor::onAnimationModeConnected(const CClientMessageAdventureUserConnecti } - CInterfaceGroup *currentSessionGroup = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_current_session")); + CInterfaceGroup *currentSessionGroup = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_current_session")); if (currentSessionGroup) { CViewText *text = dynamic_cast(currentSessionGroup->getView("current_session")); @@ -6386,7 +6386,7 @@ void CEditor::connexionMsg(const std::string &stringId) // ignore if current ui desktop is not the third if (getUI().getMode() != 3) return; // show the connection window - CInterfaceGroup *r2ConnectWindow = dynamic_cast(getUI().getElementFromId("ui:interface:r2ed_connect")); + CInterfaceGroup *r2ConnectWindow = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connect")); if (!r2ConnectWindow) return; if (stringId.empty()) { @@ -7330,9 +7330,9 @@ class CAHOpenScenarioControl : public IActionHandler CInterfaceGroup* wnd = NULL; if(!R2::getEditor().isInitialized()) - wnd = dynamic_cast(pIM->getElementFromId("ui:interface:ring_scenario_loading_window")); + wnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:ring_scenario_loading_window")); else - wnd = dynamic_cast(pIM->getElementFromId("ui:interface:r2ed_scenario_control")); + wnd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_scenario_control")); if(wnd) { @@ -7425,7 +7425,7 @@ class CAHInviteCharacter : public IActionHandler if(sessionBrowser._LastInvokeResult == 14) { - CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); + CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); diff --git a/code/ryzom/client/src/r2/npc_editor.cpp b/code/ryzom/client/src/r2/npc_editor.cpp index 8317f92d7..5522b2014 100644 --- a/code/ryzom/client/src/r2/npc_editor.cpp +++ b/code/ryzom/client/src/r2/npc_editor.cpp @@ -52,7 +52,7 @@ CNPCEditor::~CNPCEditor() void CNPCEditor::updateNPCView(uint slot) { _NPCWindow = dynamic_cast( - CEditor::getUI().getElementFromId("ui:interface:r2ed_npc")); + CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_npc")); if (!_NPCWindow) { nlwarning(" can't retrieve npc window, or bad type"); diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index eb5083806..4d3e890e2 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -155,7 +155,7 @@ uint32 CTool::getScreenHeight() void CTool::getMousePos(sint32 &x, sint32 &y) { //H_AUTO(R2_CTool_getMousePos) - CViewPointer *cursor = getUI().getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor == NULL) { x = y = -1; @@ -198,7 +198,7 @@ CGroupMap *CTool::getWorldMap() static volatile bool cacheTest = true; if (!mapPtr || !cacheTest) { - mapPtr = dynamic_cast(getUI().getElementFromId("ui:interface:map:content:map_content:actual_map")); + mapPtr = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); } return mapPtr; } @@ -752,7 +752,7 @@ bool CTool::isMouseCaptured() void CTool::setMouseCursor(const char *cursorTexture) { //H_AUTO(R2_CTool_setMouseCursor) - CViewPointer *cursor = getUI().getPointer(); + CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); if(cursor) { cursor->setCursor(cursorTexture); diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index 7828ed52a..b408686aa 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -219,7 +219,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls) if(sessionBrowser._LastJoinSessionResult == 20) { - CViewText* pVT = dynamic_cast(pIM->getElementFromId("ui:interface:warning_free_trial:text")); + CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); pIM->runActionHandler("enter_modal", NULL, "group=ui:interface:warning_free_trial"); diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index 2a713554e..08d12fd0d 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -510,7 +510,7 @@ void CUserEntity::updateVisualPropertyName(const NLMISC::TGameCycle &gameCycle, /* if (oldNameId != _NameId) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *element = pIM->getElementFromId("ui:interface:mailbox:content:html"); + CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId("ui:interface:mailbox:content:html"); if (element) { CGroupHTML *html = dynamic_cast(element); @@ -2667,7 +2667,7 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual if (pPlayer) { /*// Pvp Mode - CViewBitmap * tagMode = dynamic_cast(pIM->getElementFromId("ui:interface:target:pvp_tags:mode")); + CViewBitmap * tagMode = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:pvp_tags:mode")); if (tagMode) { if (pPlayer->getPvpMode()&PVP_MODE::PvpFaction) @@ -2679,7 +2679,7 @@ void CUserEntity::selection(const CLFECOMMON::TCLEntityId &slot) // virtual } */ /*// Pvp available actions (attack, heal, both) - CViewBitmap * tagMode = dynamic_cast(pIM->getElementFromId("ui:interface:target:pvp_tags:actions")); + CViewBitmap * tagMode = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:target:pvp_tags:actions")); if (tagMode) { if (pPlayer->getPvpMode()&PVP_MODE::PvpFaction) From 51a515fded7de94872a1dba0b3ef76e7d85f8b7a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 1 Jun 2012 00:19:53 +0200 Subject: [PATCH 039/339] CHANGED: #1471 Renamed the action handler factory manager to CAHManager and moved some global functions into it as instance methods. Also broke up an action handler file to AH and Ryzom related files. --- code/ryzom/client/src/far_tp.cpp | 1 + .../src/interface_v3/action_handler.cpp | 445 +----------------- .../client/src/interface_v3/action_handler.h | 98 ++-- .../src/interface_v3/action_handler_base.cpp | 430 +++++++++++++++++ .../src/interface_v3/action_handler_base.h | 28 ++ .../src/interface_v3/action_handler_game.cpp | 1 + .../src/interface_v3/ctrl_base_button.cpp | 12 +- .../src/interface_v3/ctrl_base_button.h | 8 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 24 +- .../client/src/interface_v3/dbctrl_sheet.h | 16 +- .../src/interface_v3/group_container.cpp | 16 +- .../client/src/interface_v3/group_container.h | 16 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../client/src/interface_v3/group_tab.cpp | 2 +- .../client/src/interface_v3/group_wheel.cpp | 4 +- .../src/interface_v3/interface_element.cpp | 4 +- .../src/interface_v3/interface_group.cpp | 16 +- .../client/src/interface_v3/interface_group.h | 20 +- .../src/interface_v3/interface_manager.cpp | 6 +- .../src/interface_v3/interface_parser.cpp | 4 +- code/ryzom/client/src/net_manager.cpp | 1 + 21 files changed, 590 insertions(+), 564 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/action_handler_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/action_handler_base.h diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index dec9aed6f..cb3387873 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -44,6 +44,7 @@ #include "client_chat_manager.h" #include "bg_downloader_access.h" #include "login_progress_post_thread.h" +#include "interface_v3/action_handler_base.h" using namespace NLMISC; using namespace NLNET; diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index 7cc097492..b1aa1fa79 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -14,32 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "action_handler.h" -#include "action_handler_misc.h" - +#include "group_container.h" #include "nel/gui/interface_expr.h" -#include "interface_manager.h" - -#include "group_container.h" -#include "group_editbox.h" -#include "dbctrl_sheet.h" -#include "interface_3d_scene.h" -#include "character_3d.h" -#include "group_container.h" -#include "people_interraction.h" - -#include "../r2/editor.h" - +#include "nel/gui/db_manager.h" +#include "interface_link.h" +#include "widget_manager.h" using namespace std; using namespace NLMISC; // ------------------------------------------------------------------------------------------------ -CActionHandlerFactoryManager *CActionHandlerFactoryManager::_GlobalInstance = NULL; +CAHManager *CAHManager::_GlobalInstance = NULL; // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -119,7 +105,7 @@ void IActionHandler::getAllParams (const string &Params, vector< pairgetActionHandler(ahName); + return getActionHandler(ahName); } // standalone form else - return CActionHandlerFactoryManager::getInstance()->getActionHandler(name); + return getActionHandler(name); } // ------------------------------------------------------------------------------------------------ -IActionHandler *getAH(const std::string &name, CStringShared ¶ms) +IActionHandler* CAHManager::getAH(const std::string &name, CStringShared ¶ms) { // Special AH form? string::size_type i= name.find(':'); @@ -143,15 +129,15 @@ IActionHandler *getAH(const std::string &name, CStringShared ¶ms) { string ahName= name.substr(0, i); params= name.substr(i+1); - return CActionHandlerFactoryManager::getInstance()->getActionHandler(ahName); + return getActionHandler(ahName); } // standalone form else - return CActionHandlerFactoryManager::getInstance()->getActionHandler(name); + return getActionHandler(name); } // ------------------------------------------------------------------------------------------------ -void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶mRet) +void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶mRet) { CXMLAutoPtr prop; @@ -183,7 +169,7 @@ void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandl } } -void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared ¶mRet) +void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared ¶mRet) { CXMLAutoPtr prop; @@ -221,7 +207,6 @@ class CAHSet : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const string &Params) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dblink = getParam (Params, "dblink"); string property = getParam (Params, "target_property"); string propertyToEval = getParam (Params, "target"); @@ -321,7 +306,6 @@ class CAHCopy : public IActionHandler public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); string dbdst = getParam (Params, "dbdst"); string dbsrc = getParam (Params, "dbsrc"); CCDBNodeBranch *pNBdst = NLGUI::CDBManager::getInstance()->getDbBranch(dbdst); @@ -391,8 +375,6 @@ class CAHResizeW : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const string &Params) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string elt = getParam (Params, "elt"); sint32 value; @@ -422,220 +404,6 @@ public: }; REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w"); -// ------------------------------------------------------------------------------------------------ -class CAHSetKeyboardFocus : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string target = getParam (Params, "target"); - CGroupEditBox *geb; - if (pCaller == NULL) - geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (target)); - else - geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), target)); - if (geb == NULL) - { - nlwarning(" Can't get target edit box %s, or bad type", target.c_str()); - return; - } - pIM->setCaptureKeyboard(geb); - string selectAllStr = getParam (Params, "select_all"); - bool selectAll = CInterfaceElement::convertBool(selectAllStr.c_str()); - if (selectAll) - { - geb->setSelectionAll(); - } - } -}; -REGISTER_ACTION_HANDLER (CAHSetKeyboardFocus, "set_keyboard_focus"); - -// ------------------------------------------------------------------------------------------------ -class CAHResetKeyboardFocus : public IActionHandler -{ -public: - virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->resetCaptureKeyboard(); - } -}; -REGISTER_ACTION_HANDLER (CAHResetKeyboardFocus, "reset_keyboard_focus"); - -// ------------------------------------------------------------------------------------------------ -class CAHSetEditBoxCommand : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &Params) - { - CGroupEditBox *menuEB = CGroupEditBox::getMenuFather(); - if (menuEB) menuEB->setCommand(getParam(Params, "value"), nlstricmp(getParam(Params, "execute"), "true") ? true : false); - } -}; -REGISTER_ACTION_HANDLER (CAHSetEditBoxCommand, "set_edit_box_command"); - -// ------------------------------------------------------------------------------------------------ -class CAHActiveMenu : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - CInterfaceManager *im = CInterfaceManager::getInstance(); - - // get the parent container - CGroupContainer *gc = NULL; - CCtrlBase *cb = pCaller; - while (cb) - { - gc = dynamic_cast(cb); - if (gc) break; - cb = cb->getParent(); - } - - // update GC_POPUP flag - if (gc) - { - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64((gc->isPopuped() || gc->getLayerSetup() == 0) ? 1 : 0); - } - else - { - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(0); - } - - // update GC_HAS_HELP flag - if(gc && !gc->getHelpPage().empty()) - { - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(1); - } - else - { - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(0); - } - - // open the menu - if (CDBCtrlSheet::getDraggedSheet() == NULL) - { - CWidgetManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu")); - } - } -}; -REGISTER_ACTION_HANDLER (CAHActiveMenu, "active_menu"); - -// ------------------------------------------------------------------------------------------------ -class CAHSetServerString : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - string sValue = getParam(Params,"value"); - string sTarget = getParam(Params,"target"); - - if (sTarget.empty()) return; - - if (sTarget.rfind(':') == string::npos) - { - if (pCaller == NULL) return; - sTarget = pCaller->getId() + ":" + sTarget; - } - else - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string elt = sTarget.substr(0,sTarget.rfind(':')); - CInterfaceElement *pIE; - if (pCaller != NULL) - pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); - else - pIE = CWidgetManager::getInstance()->getElementFromId(elt); - if (pIE == NULL) return; - sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); - } - - CInterfaceExprValue evValue; - if (CInterfaceExpr::eval(sValue, evValue, NULL)) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (evValue.toInteger()) - pIM->addServerString (sTarget, (uint32)evValue.getInteger()); - } - } -}; -REGISTER_ACTION_HANDLER (CAHSetServerString, "set_server_string"); - -// ------------------------------------------------------------------------------------------------ -class CAHSetServerID : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - string sValue = getParam(Params,"value"); - string sTarget = getParam(Params,"target"); - string sRemoveTitle = getParam(Params,"remove_title"); - - if (sTarget.empty()) return; - - if (sTarget.rfind(':') == string::npos) - { - if (pCaller == NULL) return; - sTarget = pCaller->getId() + ":" + sTarget; - } - else - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string elt = sTarget.substr(0,sTarget.rfind(':')); - CInterfaceElement *pIE; - if (pCaller != NULL) - pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); - else - pIE = CWidgetManager::getInstance()->getElementFromId(elt); - if (pIE == NULL) return; - sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); - } - - CInterfaceExprValue evValue; - if (CInterfaceExpr::eval(sValue, evValue, NULL)) - { - bool bRemoveTitle = false; - if (!sRemoveTitle.empty()) - fromString(sRemoveTitle, bRemoveTitle); - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - - if (bRemoveTitle) - { - CStringPostProcessRemoveTitle *pSPPRT = new CStringPostProcessRemoveTitle; - - if (evValue.toInteger()) - pIM->addServerID (sTarget, (uint32)evValue.getInteger(), pSPPRT); - } - else - { - if (evValue.toInteger()) - pIM->addServerID (sTarget, (uint32)evValue.getInteger(), NULL); - } - } - } -}; -REGISTER_ACTION_HANDLER (CAHSetServerID, "set_server_id"); - -// ------------------------------------------------------------------------------------------------ -class CAHResetCamera : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - string sTarget = getParam(Params,"target"); - - if (sTarget.empty()) return; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceElement *pIE; - if (pCaller != NULL) - pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), sTarget); - else - pIE = CWidgetManager::getInstance()->getElementFromId(sTarget); - CInterface3DCamera *pCam = dynamic_cast(pIE); - if (pCam == NULL) return; - pCam->reset(); - } -}; -REGISTER_ACTION_HANDLER (CAHResetCamera, "reset_camera"); - //////////////////////////////// // EDITION OF CONTAINER ALPHA // //////////////////////////////// @@ -678,7 +446,6 @@ class CAHChooseUIAlpha : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CGroupContainer *gc = NULL; CCtrlBase *cb = pCaller; while (cb) @@ -784,7 +551,6 @@ class CAHUseGlobalAlphaSettings : public IActionHandler if (AlphaChooserTarget) { AlphaChooserTarget->setUseGlobalAlpha(!AlphaChooserTarget->isUsingGlobalAlpha()); - CInterfaceManager *im = CInterfaceManager::getInstance(); NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1); } } @@ -797,7 +563,6 @@ class CAHLockUnlock : public IActionHandler { virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { -// CInterfaceManager *im = CInterfaceManager::getInstance(); CGroupContainer *gc = NULL; CCtrlBase *cb = pCaller; while (cb) @@ -818,7 +583,6 @@ class CAHSetTransparent : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); if (pGC != NULL) { @@ -837,8 +601,6 @@ class CAHSetAlpha : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string ui = getParam (Params, "target"); uint8 alpha; @@ -857,141 +619,11 @@ class CAHSetAlpha : public IActionHandler }; REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha"); -/////////////////////////////// -// VIRTUAL DESKTOP MANAGMENT // -/////////////////////////////// - - -// ------------------------------------------------------------------------------------------------ -class CAHSetVirtualDesktop : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &Params) - { - string sVDesk = getParam(Params,"vdesk"); - - if (sVDesk.empty()) return; - sint32 nVDesk; - fromString(sVDesk, nVDesk); - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->setMode((uint8)nVDesk); - - PeopleInterraction.refreshActiveUserChats(); - } -}; -REGISTER_ACTION_HANDLER (CAHSetVirtualDesktop, "set_virtual_desktop"); - -// ------------------------------------------------------------------------------------------------ -class CAHResetVirtualDesktop : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &Params) - { - string sVDesk = getParam(Params,"vdesk"); - - if (sVDesk.empty()) return; - sint32 nVDesk; - fromString(sVDesk, nVDesk); - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->resetMode((uint8)nVDesk); - - PeopleInterraction.refreshActiveUserChats(); - } -}; -REGISTER_ACTION_HANDLER (CAHResetVirtualDesktop, "reset_virtual_desktop"); - -// ------------------------------------------------------------------------------------------------ -class CAHMilkoMenuResetInterface : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string sParam("mode="); - if(R2::getEditor().getMode() == R2::CEditor::TestMode) - sParam = "R2TestMode"; - - pIM->validMessageBox(CInterfaceManager::QuestionIconMsg, CI18N::get("uiQResetUI"), "milko_menu_do_reset_interface", sParam); - } -}; -REGISTER_ACTION_HANDLER (CAHMilkoMenuResetInterface, "milko_menu_reset_interface"); - -// ------------------------------------------------------------------------------------------------ -class CAHMilkoMenuDoResetInterface : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string& Params) - { - // get param - string mode; - fromString(getParam(Params, "mode"), mode); - - // run procedure - vector v; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (mode == "R2TestMode") - pIM->runProcedure ("proc_reset_r2ed_interface", NULL, v); - else - pIM->runProcedure("proc_reset_interface", NULL, v); - } -}; -REGISTER_ACTION_HANDLER(CAHMilkoMenuDoResetInterface, "milko_menu_do_reset_interface"); - -// ------------------------------------------------------------------------------------------------ -class CAHResetInterface : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) - { - uint32 i; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup]; - const vector &rV = rMG.Group->getGroups(); - // Active all containers (that can be activated) - for (i = 0; i < rV.size(); ++i) - { - CGroupContainer *pGC = dynamic_cast(rV[i]); - if (pGC == NULL) continue; - if (pGC->isSavable()) - { - // Yoyo: DO NOT force activation of containers who don't want to save their Active state. - // Usually driven by server. - if(pGC->isActiveSavable()) - pGC->setActive(true); - } - } - - pIM->checkCoords(); - CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).centerAllContainers(); - - // Pop in and close all containers - for (i = 0; i < rV.size(); ++i) - { - CGroupContainer *pGC = dynamic_cast(rV[i]); - if (pGC == NULL) continue; - if (pGC->isSavable()) - { - if (pGC->isPopable()&&pGC->isPopuped()) - pGC->popin(); - - // Can close ? - if (pGC->isOpenable()&&pGC->isOpen()) - pGC->close(); - } - } - - CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers(); - } - } -}; -REGISTER_ACTION_HANDLER (CAHResetInterface, "reset_interface"); - // ------------------------------------------------------------------------------------------------ class CAHUnlockAllContainer : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) { @@ -1001,54 +633,3 @@ class CAHUnlockAllContainer : public IActionHandler } }; REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container"); - -// ------------------------------------------------------------------------------------------------ -class CAHConvertServerEntities : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &Params) - { - string sDstPath = getParam(Params, "dest"); - if (sDstPath.empty()) return; - string sEntityNb = getParam(Params, "entity"); - uint32 nEntityNb = 0; - if (!sEntityNb.empty()) - fromString(sEntityNb, nEntityNb); - - CCharacterSummary cs; - SCharacter3DSetup::setupCharacterSummaryFromSERVERDB(cs, (uint8)nEntityNb); - SCharacter3DSetup::setupDBFromCharacterSummary(sDstPath, cs); - - } -}; -REGISTER_ACTION_HANDLER (CAHConvertServerEntities, "convert_server_entities"); - -/*// ------------------------------------------------------------------------------------------------ -class CAHPopup : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - string sCont = getParam(Params,"cont"); - CInterfaceExprValue eVal; - if (!CInterfaceExpr::eval(sCont, eVal, NULL)) return; - sCont = eVal.getString(); - if (sCont.empty()) return; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sCont)); - if (pGC == NULL) return; - if (pGC->isPopuped()) return; - pGC->setHighLighted(false); - // pop the window - pGC->popupCurrentPos(); - if (pGC->getPopupW() != -1) - { - pGC->setX(pGC->getPopupX()); - pGC->setY(pGC->getPopupY()); - pGC->setW(pGC->getPopupW()); - // must resize the children to get correct height - pGC->setChildrenH(pGC->getPopupChildrenH()); - } - pGC->invalidateCoords(2); - } -}; -REGISTER_ACTION_HANDLER (CAHPopup, "popup"); -*/ diff --git a/code/ryzom/client/src/interface_v3/action_handler.h b/code/ryzom/client/src/interface_v3/action_handler.h index e578c4959..e86471a58 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.h +++ b/code/ryzom/client/src/interface_v3/action_handler.h @@ -14,8 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - #ifndef NL_ACTION_HANDLER_H #define NL_ACTION_HANDLER_H @@ -26,15 +24,6 @@ #include "nel/misc/xml_auto_ptr.h" #include -extern bool game_exit; -extern bool ryzom_exit; -extern bool game_exit_request; -extern bool ryzom_exit_request; -extern bool paying_account_request; -extern bool paying_account_already_request; -extern bool game_exit_after_paying_account_request; - - /** * interface for action handlers * \author Nicolas Brigand @@ -42,7 +31,6 @@ extern bool game_exit_after_paying_account_request; * \date 2002 */ -class IInputControl; class CCtrlBase; class IActionHandler @@ -61,23 +49,19 @@ public: /** - * interface for action handlers factory - * no release in this factory : a handler must be destroyed by the control that created it - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 + interface for action handlers factory + no release in this factory : a handler must be destroyed by the control that created it */ - -class CActionHandlerFactoryManager +class CAHManager { public: typedef std::map< std::string, IActionHandler* > TFactoryMap; typedef std::map< IActionHandler*, std::string > TNameMap; - static CActionHandlerFactoryManager* getInstance() + static CAHManager* getInstance() { if (_GlobalInstance == NULL) - _GlobalInstance = new CActionHandlerFactoryManager; + _GlobalInstance = new CAHManager; return _GlobalInstance; } @@ -96,41 +80,41 @@ public: } /// map of action handler factories - TFactoryMap FactoryMap; - TNameMap NameMap; - std::string EmptyName; + TFactoryMap FactoryMap; + TNameMap NameMap; + std::string EmptyName; + + /// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed) + IActionHandler *getAH(const std::string &name, std::string ¶ms); + IActionHandler *getAH(const std::string &name, class CStringShared ¶ms); + + /** common method to parse Action Handler from a xml node + * \param ahId eg: "onclick_l" + * \param paramId eg: "params_l". + * \param params returned parameters. + * NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book") + * is taken + * NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed + */ + void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶ms); + void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); + + /// Get the AH name from ptr + const std::string &getAHName(IActionHandler *pAH) { return getActionHandlerName(pAH); } private: - CActionHandlerFactoryManager(){} - static CActionHandlerFactoryManager *_GlobalInstance; + CAHManager(){} + static CAHManager *_GlobalInstance; }; -/// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed) -IActionHandler *getAH(const std::string &name, std::string ¶ms); -IActionHandler *getAH(const std::string &name, class CStringShared ¶ms); - -/** common method to parse Action Handler from a xml node - * \param ahId eg: "onclick_l" - * \param paramId eg: "params_l". - * \param params returned parameters. - * NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book") - * is taken - * NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed - */ -void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶ms); -void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); - -/// Get the AH name from ptr -inline const std::string &getAHName(IActionHandler *pAH) { return CActionHandlerFactoryManager::getInstance()->getActionHandlerName(pAH); } - /// Ah name must all be lower case -#define REGISTER_ACTION_HANDLER(handler ,name) \ -class handler##Factory : public handler\ -{\ -public:\ - handler##Factory ()\ - {\ +#define REGISTER_ACTION_HANDLER(handler ,name) \ +class handler##Factory : public handler \ +{ \ +public: \ + handler##Factory () \ + { \ nlassert(name!=NULL); \ const char *c= name; \ while(*c!='\0') \ @@ -138,12 +122,12 @@ public:\ nlassert(islower(*c) || !isalpha(*c)); \ c++; \ } \ - CActionHandlerFactoryManager *pAHFM = CActionHandlerFactoryManager::getInstance(); \ - pAHFM->FactoryMap.insert(CActionHandlerFactoryManager::TFactoryMap::value_type(name,this));\ - pAHFM->NameMap.insert(CActionHandlerFactoryManager::TNameMap::value_type(this,name));\ - };\ -}; \ - handler##Factory handler##FactoryInstance ;\ -\ + CAHManager *pAHFM = CAHManager::getInstance(); \ + pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \ + pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \ + }; \ +}; \ + handler##Factory handler##FactoryInstance ; \ + \ #endif //NL_ACTION_HANDLER_H diff --git a/code/ryzom/client/src/interface_v3/action_handler_base.cpp b/code/ryzom/client/src/interface_v3/action_handler_base.cpp new file mode 100644 index 000000000..c7acaf3f2 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/action_handler_base.cpp @@ -0,0 +1,430 @@ +// Ryzom - MMORPG Framework +// 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 "action_handler_base.h" +#include "action_handler_misc.h" + +#include "nel/gui/interface_expr.h" +#include "interface_manager.h" + +#include "group_container.h" +#include "group_editbox.h" +#include "dbctrl_sheet.h" +#include "interface_3d_scene.h" +#include "character_3d.h" +#include "group_container.h" +#include "people_interraction.h" + +#include "../r2/editor.h" + +using namespace std; +using namespace NLMISC; + +// ------------------------------------------------------------------------------------------------ +class CAHActiveMenu : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + CInterfaceManager *im = CInterfaceManager::getInstance(); + + // get the parent container + CGroupContainer *gc = NULL; + CCtrlBase *cb = pCaller; + while (cb) + { + gc = dynamic_cast(cb); + if (gc) break; + cb = cb->getParent(); + } + + // update GC_POPUP flag + if (gc) + { + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64((gc->isPopuped() || gc->getLayerSetup() == 0) ? 1 : 0); + } + else + { + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_POPUP")->setValue64(0); + } + + // update GC_HAS_HELP flag + if(gc && !gc->getHelpPage().empty()) + { + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(1); + } + else + { + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:GC_HAS_HELP")->setValue64(0); + } + + // open the menu + if (CDBCtrlSheet::getDraggedSheet() == NULL) + { + CWidgetManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu")); + } + } +}; +REGISTER_ACTION_HANDLER (CAHActiveMenu, "active_menu"); + +// ------------------------------------------------------------------------------------------------ +class CAHSetKeyboardFocus : public IActionHandler +{ +public: + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string target = getParam (Params, "target"); + CGroupEditBox *geb; + if (pCaller == NULL) + geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (target)); + else + geb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), target)); + if (geb == NULL) + { + nlwarning(" Can't get target edit box %s, or bad type", target.c_str()); + return; + } + pIM->setCaptureKeyboard(geb); + string selectAllStr = getParam (Params, "select_all"); + bool selectAll = CInterfaceElement::convertBool(selectAllStr.c_str()); + if (selectAll) + { + geb->setSelectionAll(); + } + } +}; +REGISTER_ACTION_HANDLER (CAHSetKeyboardFocus, "set_keyboard_focus"); + +// ------------------------------------------------------------------------------------------------ +class CAHResetKeyboardFocus : public IActionHandler +{ +public: + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->resetCaptureKeyboard(); + } +}; +REGISTER_ACTION_HANDLER (CAHResetKeyboardFocus, "reset_keyboard_focus"); + +// ------------------------------------------------------------------------------------------------ +class CAHSetEditBoxCommand : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + CGroupEditBox *menuEB = CGroupEditBox::getMenuFather(); + if (menuEB) menuEB->setCommand(getParam(Params, "value"), nlstricmp(getParam(Params, "execute"), "true") ? true : false); + } +}; +REGISTER_ACTION_HANDLER (CAHSetEditBoxCommand, "set_edit_box_command"); + +// ------------------------------------------------------------------------------------------------ +class CAHSetServerString : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + string sValue = getParam(Params,"value"); + string sTarget = getParam(Params,"target"); + + if (sTarget.empty()) return; + + if (sTarget.rfind(':') == string::npos) + { + if (pCaller == NULL) return; + sTarget = pCaller->getId() + ":" + sTarget; + } + else + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string elt = sTarget.substr(0,sTarget.rfind(':')); + CInterfaceElement *pIE; + if (pCaller != NULL) + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); + else + pIE = CWidgetManager::getInstance()->getElementFromId(elt); + if (pIE == NULL) return; + sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); + } + + CInterfaceExprValue evValue; + if (CInterfaceExpr::eval(sValue, evValue, NULL)) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + if (evValue.toInteger()) + pIM->addServerString (sTarget, (uint32)evValue.getInteger()); + } + } +}; +REGISTER_ACTION_HANDLER (CAHSetServerString, "set_server_string"); + +// ------------------------------------------------------------------------------------------------ +class CAHSetServerID : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + string sValue = getParam(Params,"value"); + string sTarget = getParam(Params,"target"); + string sRemoveTitle = getParam(Params,"remove_title"); + + if (sTarget.empty()) return; + + if (sTarget.rfind(':') == string::npos) + { + if (pCaller == NULL) return; + sTarget = pCaller->getId() + ":" + sTarget; + } + else + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string elt = sTarget.substr(0,sTarget.rfind(':')); + CInterfaceElement *pIE; + if (pCaller != NULL) + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), elt); + else + pIE = CWidgetManager::getInstance()->getElementFromId(elt); + if (pIE == NULL) return; + sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size()); + } + + CInterfaceExprValue evValue; + if (CInterfaceExpr::eval(sValue, evValue, NULL)) + { + bool bRemoveTitle = false; + if (!sRemoveTitle.empty()) + fromString(sRemoveTitle, bRemoveTitle); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + + if (bRemoveTitle) + { + CStringPostProcessRemoveTitle *pSPPRT = new CStringPostProcessRemoveTitle; + + if (evValue.toInteger()) + pIM->addServerID (sTarget, (uint32)evValue.getInteger(), pSPPRT); + } + else + { + if (evValue.toInteger()) + pIM->addServerID (sTarget, (uint32)evValue.getInteger(), NULL); + } + } + } +}; +REGISTER_ACTION_HANDLER (CAHSetServerID, "set_server_id"); + +// ------------------------------------------------------------------------------------------------ +class CAHResetCamera : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + string sTarget = getParam(Params,"target"); + + if (sTarget.empty()) return; + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CInterfaceElement *pIE; + if (pCaller != NULL) + pIE = CWidgetManager::getInstance()->getElementFromId(pCaller->getId(), sTarget); + else + pIE = CWidgetManager::getInstance()->getElementFromId(sTarget); + CInterface3DCamera *pCam = dynamic_cast(pIE); + if (pCam == NULL) return; + pCam->reset(); + } +}; +REGISTER_ACTION_HANDLER (CAHResetCamera, "reset_camera"); + +/////////////////////////////// +// VIRTUAL DESKTOP MANAGMENT // +/////////////////////////////// + + +// ------------------------------------------------------------------------------------------------ +class CAHSetVirtualDesktop : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + string sVDesk = getParam(Params,"vdesk"); + + if (sVDesk.empty()) return; + sint32 nVDesk; + fromString(sVDesk, nVDesk); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->setMode((uint8)nVDesk); + + PeopleInterraction.refreshActiveUserChats(); + } +}; +REGISTER_ACTION_HANDLER (CAHSetVirtualDesktop, "set_virtual_desktop"); + +// ------------------------------------------------------------------------------------------------ +class CAHResetVirtualDesktop : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + string sVDesk = getParam(Params,"vdesk"); + + if (sVDesk.empty()) return; + sint32 nVDesk; + fromString(sVDesk, nVDesk); + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + pIM->resetMode((uint8)nVDesk); + + PeopleInterraction.refreshActiveUserChats(); + } +}; +REGISTER_ACTION_HANDLER (CAHResetVirtualDesktop, "reset_virtual_desktop"); + +// ------------------------------------------------------------------------------------------------ +class CAHMilkoMenuResetInterface : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string sParam("mode="); + if(R2::getEditor().getMode() == R2::CEditor::TestMode) + sParam = "R2TestMode"; + + pIM->validMessageBox(CInterfaceManager::QuestionIconMsg, CI18N::get("uiQResetUI"), "milko_menu_do_reset_interface", sParam); + } +}; +REGISTER_ACTION_HANDLER (CAHMilkoMenuResetInterface, "milko_menu_reset_interface"); + +// ------------------------------------------------------------------------------------------------ +class CAHMilkoMenuDoResetInterface : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string& Params) + { + // get param + string mode; + fromString(getParam(Params, "mode"), mode); + + // run procedure + vector v; + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + if (mode == "R2TestMode") + pIM->runProcedure ("proc_reset_r2ed_interface", NULL, v); + else + pIM->runProcedure("proc_reset_interface", NULL, v); + } +}; +REGISTER_ACTION_HANDLER(CAHMilkoMenuDoResetInterface, "milko_menu_do_reset_interface"); + +// ------------------------------------------------------------------------------------------------ +class CAHResetInterface : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + uint32 i; + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); + for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = rVMG[nMasterGroup]; + const vector &rV = rMG.Group->getGroups(); + // Active all containers (that can be activated) + for (i = 0; i < rV.size(); ++i) + { + CGroupContainer *pGC = dynamic_cast(rV[i]); + if (pGC == NULL) continue; + if (pGC->isSavable()) + { + // Yoyo: DO NOT force activation of containers who don't want to save their Active state. + // Usually driven by server. + if(pGC->isActiveSavable()) + pGC->setActive(true); + } + } + + pIM->checkCoords(); + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).centerAllContainers(); + + // Pop in and close all containers + for (i = 0; i < rV.size(); ++i) + { + CGroupContainer *pGC = dynamic_cast(rV[i]); + if (pGC == NULL) continue; + if (pGC->isSavable()) + { + if (pGC->isPopable()&&pGC->isPopuped()) + pGC->popin(); + + // Can close ? + if (pGC->isOpenable()&&pGC->isOpen()) + pGC->close(); + } + } + + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).deactiveAllContainers(); + } + } +}; +REGISTER_ACTION_HANDLER (CAHResetInterface, "reset_interface"); + +// ------------------------------------------------------------------------------------------------ +class CAHConvertServerEntities : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + string sDstPath = getParam(Params, "dest"); + if (sDstPath.empty()) return; + string sEntityNb = getParam(Params, "entity"); + uint32 nEntityNb = 0; + if (!sEntityNb.empty()) + fromString(sEntityNb, nEntityNb); + + CCharacterSummary cs; + SCharacter3DSetup::setupCharacterSummaryFromSERVERDB(cs, (uint8)nEntityNb); + SCharacter3DSetup::setupDBFromCharacterSummary(sDstPath, cs); + + } +}; +REGISTER_ACTION_HANDLER (CAHConvertServerEntities, "convert_server_entities"); + +/*// ------------------------------------------------------------------------------------------------ +class CAHPopup : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + string sCont = getParam(Params,"cont"); + CInterfaceExprValue eVal; + if (!CInterfaceExpr::eval(sCont, eVal, NULL)) return; + sCont = eVal.getString(); + if (sCont.empty()) return; + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sCont)); + if (pGC == NULL) return; + if (pGC->isPopuped()) return; + pGC->setHighLighted(false); + // pop the window + pGC->popupCurrentPos(); + if (pGC->getPopupW() != -1) + { + pGC->setX(pGC->getPopupX()); + pGC->setY(pGC->getPopupY()); + pGC->setW(pGC->getPopupW()); + // must resize the children to get correct height + pGC->setChildrenH(pGC->getPopupChildrenH()); + } + pGC->invalidateCoords(2); + } +}; +REGISTER_ACTION_HANDLER (CAHPopup, "popup"); +*/ + + diff --git a/code/ryzom/client/src/interface_v3/action_handler_base.h b/code/ryzom/client/src/interface_v3/action_handler_base.h new file mode 100644 index 000000000..67af6e634 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/action_handler_base.h @@ -0,0 +1,28 @@ +// Ryzom - MMORPG Framework +// 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 ACTION_HANDLER_BASE_H +#define ACTION_HANDLER_BASE_H + +extern bool game_exit; +extern bool ryzom_exit; +extern bool game_exit_request; +extern bool ryzom_exit_request; +extern bool paying_account_request; +extern bool paying_account_already_request; +extern bool game_exit_after_paying_account_request; + +#endif diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index cf3f89251..6d5ea3f5d 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -22,6 +22,7 @@ // Interface includes #include "interface_manager.h" #include "action_handler.h" +#include "action_handler_base.h" #include "action_handler_misc.h" #include "bot_chat_manager.h" #include "bot_chat_page_all.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index b0248aa66..4584ac003 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -149,12 +149,12 @@ bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) // *** Read Action handlers - parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams); - parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); - parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams); - parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); - parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams); - parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams); + CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams); + CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); + CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams); + CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); + CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams); + CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams); // Context menu association prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.h b/code/ryzom/client/src/interface_v3/ctrl_base_button.h index eb7438e8b..25d3dddf7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.h @@ -114,16 +114,16 @@ public: /// \name Handlers // @{ // Event part - void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = getAH(actionHandlerName, _AHLeftClickParams); } + void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; } - void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = getAH(actionHandlerName, _AHRightClickParams); } - void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = getAH(ahName, _AHClockTickParams); } + void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } + void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; } void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; } void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } // get Event part - std::string _getActionOnLeftClick() const { return getAHName(_AHOnLeftClick); } + std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 980a8459b..c42e1699b 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -383,13 +383,13 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr if (prop) _Dragable = CInterfaceElement::convertBool(prop); // Read Action handlers - parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); - parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); - parseAH(cur, "oncandrop", "params_candrop", _AHOnCanDrop, _AHCanDropParams); - parseAH(cur, "ondrop", "params_drop", _AHOnDrop, _AHDropParams); - parseAH(cur, "oncannotdrop", "params_cannotdrop", _AHOnCannotDrop, _AHCannotDropParams); - parseAH(cur, "oncandrag", "params_candrag", _AHOnCanDrag, _AHCanDragParams); - parseAH(cur, "ondrag", "params_drag", _AHOnDrag, _AHDragParams); + CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); + CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); + CAHManager::getInstance()->parseAH(cur, "oncandrop", "params_candrop", _AHOnCanDrop, _AHCanDropParams); + CAHManager::getInstance()->parseAH(cur, "ondrop", "params_drop", _AHOnDrop, _AHDropParams); + CAHManager::getInstance()->parseAH(cur, "oncannotdrop", "params_cannotdrop", _AHOnCannotDrop, _AHCannotDropParams); + CAHManager::getInstance()->parseAH(cur, "oncandrag", "params_candrag", _AHOnCanDrag, _AHCanDragParams); + CAHManager::getInstance()->parseAH(cur, "ondrag", "params_drag", _AHOnDrag, _AHDragParams); prop = (char*) xmlGetProp( cur, (xmlChar*)"selection_group" ); if (prop) @@ -1870,7 +1870,7 @@ void CDBCtrlSheet::draw() string params = string("src=") + pCSSrc->getId(); if (!_AHCanDropParams.empty()) { - if (getAHName(_AHOnCanDrop) == "lua") + if ( CAHManager::getInstance()->getAHName(_AHOnCanDrop) == "lua") { params = _AHCanDropParams; strFindReplace(params, "%src", pCSSrc->getId()); @@ -2687,7 +2687,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) string params = string("src=") + _Id; if (!pCSdest->_AHCanDropParams.empty()) { - if (getAHName(pCSdest->_AHOnCanDrop) == "lua") + if (CAHManager::getInstance()->getAHName(pCSdest->_AHOnCanDrop) == "lua") { params = pCSdest->_AHCanDropParams; strFindReplace(params, "%src", _Id); @@ -2707,7 +2707,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) string params = string("src=") + _Id; if (!pCSdest->_AHDropParams.empty()) { - if (getAHName(pCSdest->_AHOnDrop) == "lua") + if (CAHManager::getInstance()->getAHName(pCSdest->_AHOnDrop) == "lua") { params = pCSdest->_AHDropParams; strFindReplace(params, "%src", _Id); @@ -2752,7 +2752,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) string params = string("src=") + _Id; if (!pList->getCtrlSheetInfo()._AHCanDropParams.empty()) { - if (getAHName(pList->getCtrlSheetInfo()._AHOnCanDrop) == "lua") + if (CAHManager::getInstance()->getAHName(pList->getCtrlSheetInfo()._AHOnCanDrop) == "lua") { params = pList->getCtrlSheetInfo()._AHCanDropParams; strFindReplace(params, "%src", _Id); @@ -2772,7 +2772,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) string params = string("src=") + _Id; if (!pList->getCtrlSheetInfo()._AHDropParams.empty()) { - if (getAHName(pList->getCtrlSheetInfo()._AHOnDrop) == "lua") + if (CAHManager::getInstance()->getAHName(pList->getCtrlSheetInfo()._AHOnDrop) == "lua") { params = pList->getCtrlSheetInfo()._AHDropParams; strFindReplace(params, "%src", _Id); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index ed6abde2b..29b6d21ad 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -191,19 +191,19 @@ public: virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - void setActionOnLeftClick (const std::string &ActionHandlerName) { _AHOnLeftClick = getAH(ActionHandlerName, _AHLeftClickParams); } - void setActionOnRightClick (const std::string &ActionHandlerName) { _AHOnRightClick = getAH(ActionHandlerName, _AHRightClickParams); } - void setActionOnDrop (const std::string &ActionHandlerName) { _AHOnDrop = getAH(ActionHandlerName, _AHDropParams); } - void setActionOnCanDrop (const std::string &ActionHandlerName) { _AHOnCanDrop = getAH(ActionHandlerName, _AHCanDropParams); } + void setActionOnLeftClick (const std::string &ActionHandlerName) { _AHOnLeftClick = CAHManager::getInstance()->getAH(ActionHandlerName, _AHLeftClickParams); } + void setActionOnRightClick (const std::string &ActionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(ActionHandlerName, _AHRightClickParams); } + void setActionOnDrop (const std::string &ActionHandlerName) { _AHOnDrop = CAHManager::getInstance()->getAH(ActionHandlerName, _AHDropParams); } + void setActionOnCanDrop (const std::string &ActionHandlerName) { _AHOnCanDrop = CAHManager::getInstance()->getAH(ActionHandlerName, _AHCanDropParams); } void setParamsOnLeftClick (const std::string &ParamsHandlerName) { _AHLeftClickParams = ParamsHandlerName; } void setParamsOnRightClick (const std::string &ParamsHandlerName) { _AHRightClickParams = ParamsHandlerName; } void setParamsOnDrop (const std::string &ParamsHandlerName) { _AHDropParams = ParamsHandlerName; } void setParamsOnCanDrop (const std::string &ParamsHandlerName) { _AHCanDropParams = ParamsHandlerName; } - const std::string &getActionOnLeftClick () const { return getAHName(_AHOnLeftClick); } - const std::string &getActionOnRightClick () const { return getAHName(_AHOnRightClick); } - const std::string &getActionOnDrop () const { return getAHName(_AHOnDrop); } - const std::string &getActionOnCanDrop () const { return getAHName(_AHOnCanDrop); } + const std::string &getActionOnLeftClick () const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } + const std::string &getActionOnRightClick () const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); } + const std::string &getActionOnDrop () const { return CAHManager::getInstance()->getAHName(_AHOnDrop); } + const std::string &getActionOnCanDrop () const { return CAHManager::getInstance()->getAHName(_AHOnCanDrop); } const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } const std::string &getParamsOnDrop () const { return _AHDropParams; } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 19e3891f9..629dba6fe 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -1426,14 +1426,14 @@ bool CGroupContainer::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if (ptr) fromString((const char*)ptr, _ResizerTopSize); - parseAH(cur, "on_open", "on_open_params", _AHOnOpen, _AHOnOpenParams); - parseAH(cur, "on_close", "on_close_params", _AHOnClose, _AHOnCloseParams); - parseAH(cur, "on_close_button", "on_close_button_params", _AHOnCloseButton, _AHOnCloseButtonParams); - parseAH(cur, "on_move", "on_move_params", _AHOnMove, _AHOnMoveParams); - parseAH(cur, "on_deactive_check", "on_deactive_check_params", _AHOnDeactiveCheck, _AHOnDeactiveCheckParams); - parseAH(cur, "on_resize", "on_resize_params", _AHOnResize, _AHOnResizeParams); - parseAH(cur, "on_alpha_settings_changed", "on_alpha_settings_changed_params", _AHOnAlphaSettingsChanged, _AHOnAlphaSettingsChangedParams); - parseAH(cur, "on_begin_move", "on_begin_move_params", _AHOnBeginMove, _AHOnBeginMoveParams); + CAHManager::getInstance()->parseAH(cur, "on_open", "on_open_params", _AHOnOpen, _AHOnOpenParams); + CAHManager::getInstance()->parseAH(cur, "on_close", "on_close_params", _AHOnClose, _AHOnCloseParams); + CAHManager::getInstance()->parseAH(cur, "on_close_button", "on_close_button_params", _AHOnCloseButton, _AHOnCloseButtonParams); + CAHManager::getInstance()->parseAH(cur, "on_move", "on_move_params", _AHOnMove, _AHOnMoveParams); + CAHManager::getInstance()->parseAH(cur, "on_deactive_check", "on_deactive_check_params", _AHOnDeactiveCheck, _AHOnDeactiveCheckParams); + CAHManager::getInstance()->parseAH(cur, "on_resize", "on_resize_params", _AHOnResize, _AHOnResizeParams); + CAHManager::getInstance()->parseAH(cur, "on_alpha_settings_changed", "on_alpha_settings_changed_params", _AHOnAlphaSettingsChanged, _AHOnAlphaSettingsChangedParams); + CAHManager::getInstance()->parseAH(cur, "on_begin_move", "on_begin_move_params", _AHOnBeginMove, _AHOnBeginMoveParams); ptr = xmlGetProp (cur, (xmlChar*)"max_w"); diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index ae899f9b9..94b00f9f3 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -415,33 +415,33 @@ public: // to be called by the 'deactive check' handler static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } - const std::string &getAHOnDeactiveCheck() const { return getAHName(_AHOnDeactiveCheck); } + const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); } const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; } // - const std::string &getAHOnCloseButton() const { return getAHName(_AHOnCloseButton); } + const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); } const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; } // IActionHandler *getAHOnMovePtr() const { return _AHOnMove; } - const std::string &getAHOnMove() const { return getAHName(_AHOnMove); } + const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); } const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; } // IActionHandler *getAHOnResizePtr() const { return _AHOnResize; } - const std::string &getAHOnResize() const { return getAHName(_AHOnResize); } + const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); } const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } // IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; } - const std::string &getAHOnBeginMove() const { return getAHName(_AHOnBeginMove); } + const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); } const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; } // - void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = getAH(h,_AHOnCloseButtonParams); } + void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } - std::string getAHOnAlphaSettingsChanged() const { return getAHName(_AHOnAlphaSettingsChanged); } + std::string getAHOnAlphaSettingsChanged() const { return CAHManager::getInstance()->getAHName(_AHOnAlphaSettingsChanged); } std::string getAHOnAlphaSettingsChangedParams() const { return _AHOnAlphaSettingsChangedParams; } - void setAHOnAlphaSettingsChanged(const std::string &h) { _AHOnAlphaSettingsChanged = getAH(h, _AHOnAlphaSettingsChangedParams); } + void setAHOnAlphaSettingsChanged(const std::string &h) { _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH(h, _AHOnAlphaSettingsChangedParams); } void setAHOnAlphaSettingsChangedParams(const std::string &p) { _AHOnAlphaSettingsChangedParams = p; } diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 478bb73a2..c42878ef8 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -119,7 +119,7 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) } // NB: use InterfaceGroup "OnEnter" data. Different script params for an historic reason - parseAH(cur, "onenter", "params", _AHOnEnter, _AHOnEnterParams); + CAHManager::getInstance()->parseAH(cur, "onenter", "params", _AHOnEnter, _AHOnEnterParams); prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange" ); if (prop) _AHOnChange = (const char *) prop; diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 38a971890..8c189ae11 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -752,7 +752,7 @@ bool CCtrlTabButton::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) // if left click not setuped, set default _AHOnLeftClick2 = _AHOnLeftClick; string dummy; - _AHOnLeftClick= getAH("tab_select", dummy); + _AHOnLeftClick= CAHManager::getInstance()->getAH("tab_select", dummy); // read the associated group to show/hide CXMLAutoPtr prop; diff --git a/code/ryzom/client/src/interface_v3/group_wheel.cpp b/code/ryzom/client/src/interface_v3/group_wheel.cpp index 91cc53dd2..78bd079b5 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.cpp +++ b/code/ryzom/client/src/interface_v3/group_wheel.cpp @@ -37,8 +37,8 @@ CInterfaceGroupWheel::CInterfaceGroupWheel(const TCtorParam ¶m) : CInterface bool CInterfaceGroupWheel::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { if (!CInterfaceGroup::parse(cur, parentGroup)) return false; - parseAH(cur, "on_wheel_up", "on_wheel_up_params", _AHWheelUp, _AHWheelUpParams); - parseAH(cur, "on_wheel_down", "on_wheel_down_params", _AHWheelDown, _AHWheelDownParams); + CAHManager::getInstance()->parseAH(cur, "on_wheel_up", "on_wheel_up_params", _AHWheelUp, _AHWheelUpParams); + CAHManager::getInstance()->parseAH(cur, "on_wheel_down", "on_wheel_down_params", _AHWheelDown, _AHWheelDownParams); return true; } diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index bca3816af..ff9977ce6 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -1254,11 +1254,11 @@ void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah) if (f.isReading()) { f.serial(ahName); - ah = CActionHandlerFactoryManager::getInstance()->getActionHandler(ahName); + ah = CAHManager::getInstance()->getActionHandler(ahName); } else { - ahName = CActionHandlerFactoryManager::getInstance()->getActionHandlerName(ah); + ahName = CAHManager::getInstance()->getActionHandlerName(ah); f.serial(ahName); } } diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 814560331..1a4a380b6 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -292,8 +292,8 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { NLMISC::fromString((const char*)ptr, _ResizeFromChildHMargin); } - parseAH(cur, "on_active", "on_active_params", _AHOnActive, _AHOnActiveParams); - parseAH(cur, "on_deactive", "on_deactive_params", _AHOnDeactive, _AHOnDeactiveParams); + CAHManager::getInstance()->parseAH(cur, "on_active", "on_active_params", _AHOnActive, _AHOnActiveParams); + CAHManager::getInstance()->parseAH(cur, "on_deactive", "on_deactive_params", _AHOnDeactive, _AHOnDeactiveParams); // Read user max size ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_w" ); @@ -327,11 +327,11 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) } // left & right clicks - parseAH(cur, "group_onclick_r", "group_params_r", _AHOnRightClick, _AHOnRightClickParams); - parseAH(cur, "group_onclick_l", "group_params_l", _AHOnLeftClick, _AHOnLeftClickParams); + CAHManager::getInstance()->parseAH(cur, "group_onclick_r", "group_params_r", _AHOnRightClick, _AHOnRightClickParams); + CAHManager::getInstance()->parseAH(cur, "group_onclick_l", "group_params_l", _AHOnLeftClick, _AHOnLeftClickParams); // Each window (modal and groupContainer) can be validated by Enter. if "" => no op. - parseAH(cur, "on_enter", "on_enter_params", _AHOnEnter, _AHOnEnterParams); + CAHManager::getInstance()->parseAH(cur, "on_enter", "on_enter_params", _AHOnEnter, _AHOnEnterParams); ptr = (char*) xmlGetProp( cur, (xmlChar*)"win_priority" ); if(ptr) NLMISC::fromString((const char*)ptr, _Priority); @@ -341,7 +341,7 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) // Each window (modal and groupContainer) can be escaped if "escapable" set // they can add an action handler before the hide - parseAH(cur, "on_escape", "on_escape_params", _AHOnEscape, _AHOnEscapeParams); + CAHManager::getInstance()->parseAH(cur, "on_escape", "on_escape_params", _AHOnEscape, _AHOnEscapeParams); // LuaClass script @@ -1559,13 +1559,13 @@ void CInterfaceGroup::setAlpha (sint32 a) // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::setLeftClickHandler(const std::string &handler) { - _AHOnLeftClick = getAH(handler, _AHOnLeftClickParams); + _AHOnLeftClick = CAHManager::getInstance()->getAH(handler, _AHOnLeftClickParams); } // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::setRightClickHandler(const std::string &handler) { - _AHOnRightClick = getAH(handler, _AHOnRightClickParams); + _AHOnRightClick = CAHManager::getInstance()->getAH(handler, _AHOnRightClickParams); } // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index f9bc949eb..ee9357749 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -134,13 +134,13 @@ public: // escapable void setEscapable(bool b) { _Escapable= b; } bool getEscapable() const { return _Escapable; } - void setAHOnEscape(const std::string &ah) { _AHOnEscape = getAH(ah, _AHOnEscapeParams); } - const std::string &getAHOnEscape() const { return getAHName(_AHOnEscape); } + void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); } + const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); } void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; } const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; } // enterable - void setAHOnEnter(const std::string &ah) { _AHOnEnter = getAH(ah, _AHOnEnterParams); } - const std::string &getAHOnEnter() const { return getAHName(_AHOnEnter); } + void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); } + const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); } void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; } const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; } uint8 getPriority() const { return _Priority; } @@ -174,18 +174,18 @@ public: void setRightClickHandler(const std::string &handler); void setLeftClickHandlerParams(const std::string ¶ms) { _AHOnLeftClickParams = params; } void setRightClickHandlerParams(const std::string ¶ms) { _AHOnRightClickParams = params; } - void setOnActiveHandler(const std::string &h) { _AHOnActive = getAH(h,_AHOnActiveParams); } + void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); } void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; } - void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = getAH(h,_AHOnDeactiveParams); } + void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); } void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; } - const std::string &getLeftClickHandler() const { return getAHName(_AHOnLeftClick); } + const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; } - const std::string &getRightClickHandler() const { return getAHName(_AHOnRightClick); } + const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); } const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; } - const std::string &getOnActiveHandler() const { return getAHName(_AHOnActive); } + const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); } const std::string &getOnActiveParams() const { return _AHOnActiveParams; } - const std::string &getOnDeactiveHandler() const { return getAHName(_AHOnDeactive); } + const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); } const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; } // find a sub view/ctrl/group in this group from its id diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 41f678289..9872b5962 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1410,7 +1410,7 @@ void CInterfaceManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pC ahParams= ahUserParams; // Execute the action handler - CActionHandlerFactoryManager *pAHFM = CActionHandlerFactoryManager::getInstance(); + CAHManager *pAHFM = CAHManager::getInstance(); map::iterator it = pAHFM->FactoryMap.find (ahName); if (it == pAHFM->FactoryMap.end()) { @@ -1442,11 +1442,11 @@ void CInterfaceManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCalle return; } pAH->execute (pCaller, Params); - string AHName = getAHName(pAH); + string AHName = CAHManager::getInstance()->getAHName(pAH); // Quick Help const string submitQuickHelp = "submit_quick_help"; - CActionHandlerFactoryManager *pAHFM = CActionHandlerFactoryManager::getInstance(); + CAHManager *pAHFM = CAHManager::getInstance(); map::iterator it = pAHFM->FactoryMap.find (AHName); it = pAHFM->FactoryMap.find(submitQuickHelp); if(it == pAHFM->FactoryMap.end()) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 4c225ddf5..db5f1dc7d 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -3173,11 +3173,11 @@ bool CInterfaceParser::parseActionCategory(xmlNodePtr cur) else { // Remove thoses actions from the manager - CActionHandlerFactoryManager *pAHFM = CActionHandlerFactoryManager::getInstance(); + CAHManager *pAHFM = CAHManager::getInstance(); uint i; for (i=0; iFactoryMap.find (category.BaseActions[i].Name); + CAHManager::TFactoryMap::iterator ite = pAHFM->FactoryMap.find (category.BaseActions[i].Name); if (ite != pAHFM->FactoryMap.end()) { IActionHandler *ah = ite->second; diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 5ca5219d4..21662969d 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -84,6 +84,7 @@ #include "game_share/r2_share_itf.h" #include "game_share/r2_types.h" #include "npc_icon.h" +#include "interface_v3/action_handler_base.h" // Std. #include From 41134639db8648fd476cc984926f08965f1a7d54 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 1 Jun 2012 01:22:05 +0200 Subject: [PATCH 040/339] CHANGED: #1471 Moved CInterface::runActionHandler methods to CAHManager. --- code/ryzom/client/src/actions.cpp | 2 +- code/ryzom/client/src/commands.cpp | 18 ++-- code/ryzom/client/src/connection.cpp | 12 +-- code/ryzom/client/src/cursor_functions.cpp | 2 +- code/ryzom/client/src/far_tp.cpp | 12 +-- .../src/interface_v3/action_handler.cpp | 72 +++++++++++++ .../client/src/interface_v3/action_handler.h | 5 +- .../src/interface_v3/action_handler_edit.cpp | 4 +- .../src/interface_v3/action_handler_game.cpp | 24 ++--- .../src/interface_v3/action_handler_help.cpp | 8 +- .../src/interface_v3/action_handler_item.cpp | 10 +- .../interface_v3/action_handler_outpost.cpp | 4 +- .../interface_v3/action_handler_phrase.cpp | 14 +-- .../src/interface_v3/action_handler_ui.cpp | 12 +-- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../src/interface_v3/ctrl_base_button.cpp | 12 +-- .../client/src/interface_v3/ctrl_button.cpp | 2 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 24 ++--- .../src/interface_v3/dbgroup_combo_box.cpp | 4 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 6 +- .../src/interface_v3/group_container.cpp | 22 ++-- .../client/src/interface_v3/group_editbox.cpp | 10 +- .../client/src/interface_v3/group_header.cpp | 2 +- .../src/interface_v3/group_html_qcm.cpp | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 4 +- .../client/src/interface_v3/group_map.cpp | 4 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../src/interface_v3/group_quick_help.cpp | 4 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_tab.cpp | 10 +- .../client/src/interface_v3/group_tree.cpp | 10 +- .../client/src/interface_v3/group_wheel.cpp | 4 +- .../client/src/interface_v3/guild_manager.cpp | 4 +- .../src/interface_v3/interface_anim.cpp | 2 +- .../src/interface_v3/interface_group.cpp | 10 +- .../src/interface_v3/interface_link.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 102 +++--------------- .../src/interface_v3/interface_manager.h | 4 - .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/inventory_manager.cpp | 18 ++-- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 6 +- .../src/interface_v3/macrocmd_manager.cpp | 34 +++--- .../src/interface_v3/people_interraction.cpp | 8 +- .../client/src/interface_v3/skill_manager.cpp | 8 +- code/ryzom/client/src/light_cycle_manager.cpp | 2 +- code/ryzom/client/src/login.cpp | 38 +++---- code/ryzom/client/src/net_manager.cpp | 6 +- code/ryzom/client/src/outpost_manager.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 8 +- .../client/src/r2/tool_create_entity.cpp | 6 +- .../ryzom/client/src/session_browser_impl.cpp | 4 +- code/ryzom/client/src/user_entity.cpp | 34 +++--- 57 files changed, 316 insertions(+), 319 deletions(-) diff --git a/code/ryzom/client/src/actions.cpp b/code/ryzom/client/src/actions.cpp index f6b24f5c5..599f7a637 100644 --- a/code/ryzom/client/src/actions.cpp +++ b/code/ryzom/client/src/actions.cpp @@ -59,7 +59,7 @@ void CAction::runAction () CInterfaceManager *IM = CInterfaceManager::getInstance (); if (IM) { - IM->runActionHandler (Name.Name, NULL, Name.Argu); + CAHManager::getInstance()->runActionHandler (Name.Name, NULL, Name.Argu); } } diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 3f97ff83d..6b6c2b01b 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -1340,11 +1340,11 @@ NLMISC_COMMAND(ah, "Launch an action handler", " ") CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (args.size() == 1) { - pIM->runActionHandler(args[0], NULL); + CAHManager::getInstance()->runActionHandler(args[0], NULL); } else { - pIM->runActionHandler(args[0], NULL, args[1]); + CAHManager::getInstance()->runActionHandler(args[0], NULL, args[1]); } return true; @@ -4016,14 +4016,14 @@ NLMISC_COMMAND(browse, "Browse a HTML document with the internal help web browse { if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler("browse", NULL, "name=ui:interface:help_browser:content:html|url="+args[0]); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name=ui:interface:help_browser:content:html|url="+args[0]); return true; } NLMISC_COMMAND(openRingWindow, "Browse the main page in the ring web browser.", "") { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler("browse", NULL, "name=ui:interface:r2ed_web_admin:content:admin_web_page|url="+RingMainURL); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name=ui:interface:r2ed_web_admin:content:admin_web_page|url="+RingMainURL); return true; } @@ -4031,7 +4031,7 @@ NLMISC_COMMAND(browseRingAdmin, "Browse a HTML document with the ring web browse { if (args.size() != 1) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler("browse", NULL, "name=ui:interface:r2ed_web_admin:content:admin_web_page|url="+args[0]); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name=ui:interface:r2ed_web_admin:content:admin_web_page|url="+args[0]); return true; } @@ -4129,13 +4129,13 @@ NLMISC_COMMAND(GUKick, "kick a member", "") NLMISC_COMMAND(GUAccept, "accept an invitation", "") { - CInterfaceManager::getInstance()->runActionHandler("accept_guild_invitation",NULL); + CAHManager::getInstance()->runActionHandler("accept_guild_invitation",NULL); return true; } NLMISC_COMMAND(GURefuse, "refuse an invitation", "") { - CInterfaceManager::getInstance()->runActionHandler("refuse_guild_invitation",NULL); + CAHManager::getInstance()->runActionHandler("refuse_guild_invitation",NULL); return true; } @@ -5296,7 +5296,7 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std: } // Run the action handler - pIM->runActionHandler (mode->Action, pIM->getOldCaptureKeyboard(), finalArgs); + CAHManager::getInstance()->runActionHandler (mode->Action, pIM->getOldCaptureKeyboard(), finalArgs); } else { @@ -5763,7 +5763,7 @@ NLMISC_COMMAND(em, "emote command", "") emotePhrase += " "; emotePhrase += args[i]; } - pIM->runActionHandler("emote", NULL, "nb=0|behav=255|custom_phrase="+emotePhrase); + CAHManager::getInstance()->runActionHandler("emote", NULL, "nb=0|behav=255|custom_phrase="+emotePhrase); return true; } return false; diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index e6017ea6b..86f26961f 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -1161,7 +1161,7 @@ TInterfaceState globalMenu() } // Auto-selection for fast launching (dev only) - pIM->runActionHandler("launch_game", NULL, toString("slot=%d|edit_mode=0", ClientCfg.SelectCharacter)); + CAHManager::getInstance()->runActionHandler("launch_game", NULL, toString("slot=%d|edit_mode=0", ClientCfg.SelectCharacter)); } } @@ -2179,7 +2179,7 @@ public: if (pCB != NULL) { pCB->setPushed(true); - pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); + CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); } } pList->invalidateCoords(); @@ -2419,7 +2419,7 @@ public: if (pCB != NULL) { pCB->setPushed(true); - pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); + CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); } } } @@ -3229,7 +3229,7 @@ class CAHLoadScenario : public IActionHandler CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); - pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); return; } @@ -3310,7 +3310,7 @@ class CAHLoadScenario : public IActionHandler CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); - pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } @@ -3339,7 +3339,7 @@ class CAHLoadScenario : public IActionHandler CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); - pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } } } diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 7e64c644e..ef9c5fcb3 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -890,7 +890,7 @@ void contextWebIG(bool rightClick, bool dblClick) { if (pGC != NULL) pGC->setActive(false); - IM->runActionHandler("browse", NULL, "name=ui:interface:webig:content:html|url="+selectedInstanceURL); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name=ui:interface:webig:content:html|url="+selectedInstanceURL); } }// contextWebIG // diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index cb3387873..5b4b28c99 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -519,7 +519,7 @@ void CLoginStateMachine::run() // Far TP part 1.1: From the ingame main loop, the admin html box gives us an event ev_connect for the destination shard. // Note: the admin html box is run by CInputHandlerManager::getInstance()->pumpEvents() in the main loop. // Tip: to see where a co-task is resumed from, just add a breakpoint on the end of CCoTask::resume(). - CInterfaceManager::getInstance()->runActionHandler("quit_ryzom", NULL, ""); + CAHManager::getInstance()->runActionHandler("quit_ryzom", NULL, ""); if (!FarTP.isIngame()) // assumes there is no Far TP starting between char selection and main loop, see below { @@ -859,8 +859,8 @@ retryJoinEdit: if ( letReturnToCharSelect ) { // // Hide all buttons except Quit. If !requestRetToMainland, we will show them back at the end of connectToNewShard(). -// pIM->runActionHandler( "proc", NULL, "charsel_disable_buttons" ); -// pIM->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:quit_but:active|value=1" ); +// CAHManager::getInstance()->runActionHandler( "proc", NULL, "charsel_disable_buttons" ); +// CAHManager::getInstance()->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:quit_but:active|value=1" ); CInterfaceElement *btnOk = CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel:message_box:ok"); if (btnOk) @@ -926,12 +926,12 @@ retryJoinEdit: else if ( letReturnToCharSelect ) { // Show all buttons except 'New character' so that the character can retry entering game or choose another character. - pIM->runActionHandler( "proc", NULL, "charsel_enable_buttons" ); - pIM->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:create_new_but:active|value=0" ); + CAHManager::getInstance()->runActionHandler( "proc", NULL, "charsel_enable_buttons" ); + CAHManager::getInstance()->runActionHandler( "set", NULL, "target_property=ui:outgame:charsel:create_new_but:active|value=0" ); CInterfaceGroup* charselGroup = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:charsel")); if(charselGroup) - pIM->runActionHandler( "proc", charselGroup, "charsel_init_buttons" ); + CAHManager::getInstance()->runActionHandler( "proc", charselGroup, "charsel_init_buttons" ); } return false; diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index b1aa1fa79..6ec889ca4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -201,6 +201,78 @@ void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, } } +// ------------------------------------------------------------------------------------------------ +void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams) +{ + if (ahCmdLine.empty()) return; + + // Special AH form ("ah:params") ? + string::size_type i = ahCmdLine.find(':'); + string ahName; + string ahParams; + if(i!=string::npos) + { + ahName= ahCmdLine.substr(0, i); + ahParams= ahCmdLine.substr(i+1); + } + else + { + ahName= ahCmdLine; + } + + // Replace params if defined + if(!ahUserParams.empty()) + ahParams= ahUserParams; + + // Execute the action handler + map::iterator it = FactoryMap.find (ahName); + if (it == FactoryMap.end()) + { + nlwarning ("not found action handler : %s",ahName.c_str()); + return; + } + IActionHandler *pAH = it->second; + pAH->execute (pCaller, ahParams); + + // Quick Help + const string submitQuickHelp = "submit_quick_help"; + it = FactoryMap.find(submitQuickHelp); + if(it == FactoryMap.end()) + { + nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); + return; + } + pAH = it->second; + const std::string event = ahName + ":" + ahParams; + pAH->execute(NULL, event); +} + +// ------------------------------------------------------------------------------------------------ +void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params) +{ + if (pAH == NULL) + { + nlwarning ("no action handler"); + return; + } + pAH->execute (pCaller, Params); + string AHName = CAHManager::getInstance()->getAHName(pAH); + + // Quick Help + const string submitQuickHelp = "submit_quick_help"; + map::iterator it = FactoryMap.find (AHName); + it = FactoryMap.find(submitQuickHelp); + if(it == FactoryMap.end()) + { + nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); + return; + } + pAH = it->second; + const std::string event = AHName + ":" + Params; + pAH->execute(NULL, event); +} + + // ------------------------------------------------------------------------------------------------ class CAHSet : public IActionHandler { diff --git a/code/ryzom/client/src/interface_v3/action_handler.h b/code/ryzom/client/src/interface_v3/action_handler.h index e86471a58..b4234335c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.h +++ b/code/ryzom/client/src/interface_v3/action_handler.h @@ -100,7 +100,10 @@ public: void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); /// Get the AH name from ptr - const std::string &getAHName(IActionHandler *pAH) { return getActionHandlerName(pAH); } + const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); } + + void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") ); private: CAHManager(){} diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index dc1c64f4f..042f2788b 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -511,7 +511,7 @@ protected: if (!_GroupEdit->getAHOnChange().empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_GroupEdit->getAHOnChange(), _GroupEdit, _GroupEdit->getParamsOnChange()); + CAHManager::getInstance()->runActionHandler(_GroupEdit->getAHOnChange(), _GroupEdit, _GroupEdit->getParamsOnChange()); } } // else cut forwards @@ -524,7 +524,7 @@ protected: if (!_GroupEdit->getAHOnChange().empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_GroupEdit->getAHOnChange(), _GroupEdit, _GroupEdit->getParamsOnChange()); + CAHManager::getInstance()->runActionHandler(_GroupEdit->getAHOnChange(), _GroupEdit, _GroupEdit->getParamsOnChange()); } } // must stop selection in all case diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 6d5ea3f5d..39fff2c6d 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -185,7 +185,7 @@ public: { ucstring name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName()); if (name.empty()) return; - im->runActionHandler("enter_tell", pCaller, "player=" + name.toString()); + CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name.toString()); } } protected: @@ -942,7 +942,7 @@ public: { // directly launch the quit_team AH. CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->runActionHandler("quit_team",pCaller, sParams); + CAHManager::getInstance()->runActionHandler("quit_team",pCaller, sParams); } protected: }; @@ -1026,7 +1026,7 @@ public: (typeProp != NULL) && (typeProp->getValue32() == ANIMAL_TYPE::Mount)) { beastOrder("mount", toString(i+1)); // why +1 ? : dixit sendAnimalCommand in EGS : index 0 = all animals, 1 = animal 0 etc - pIM->runActionHandler("animal_target", NULL, toString(i+1)); + CAHManager::getInstance()->runActionHandler("animal_target", NULL, toString(i+1)); UserEntity->moveTo(UserEntity->selection(),2.0,CUserEntity::None); } } @@ -1181,7 +1181,7 @@ public: if(!FreeTrial) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->runActionHandler("quit_ryzom", NULL); + CAHManager::getInstance()->runActionHandler("quit_ryzom", NULL); } } }; @@ -1232,7 +1232,7 @@ public: { // send a message to server, thru cancel cast CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->runActionHandler("phrase_cancel_cast", NULL); + CAHManager::getInstance()->runActionHandler("phrase_cancel_cast", NULL); } paying_account_request = false; paying_account_already_request = false; @@ -1260,10 +1260,10 @@ public: else { paying_account_already_request = true; - pIM->runActionHandler("quit_ryzom", NULL); + CAHManager::getInstance()->runActionHandler("quit_ryzom", NULL); } - pIM->runActionHandler("leave_modal", NULL); + CAHManager::getInstance()->runActionHandler("leave_modal", NULL); } }; REGISTER_ACTION_HANDLER( CAHCloseFreeTrialQuitting, "close_free_trial_game_quitting"); @@ -1509,7 +1509,7 @@ public: string beastIndex; if( CInterfaceExpr::evalAsString(getParam(Params,"beast_index"), beastIndex) ) { - pIM->runActionHandler("animal_target", NULL, beastIndex); + CAHManager::getInstance()->runActionHandler("animal_target", NULL, beastIndex); } // move to the beast UserEntity->moveTo(UserEntity->selection(),3.0,CUserEntity::Mount); @@ -1889,7 +1889,7 @@ public: pIG->setActive(true); // browse the url - pIM->runActionHandler("browse", NULL, "name="+helpContainer+":content:html|url="+url); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name="+helpContainer+":content:html|url="+url); } }; REGISTER_ACTION_HANDLER( CAHLaunchHelp, "launch_help"); @@ -2943,7 +2943,7 @@ public: else pBut->setPushed(true); } - pIM->runActionHandler("game_config_change_vid_fullscreen",NULL); + CAHManager::getInstance()->runActionHandler("game_config_change_vid_fullscreen",NULL); // **** Init Texture Size Modes // init the combo box, according to Texture Installed or not @@ -3825,13 +3825,13 @@ void runMissionProc(sint32 nSelected) { string sButtonPath = UI_MISSION_LIST ":b_title"+toString(nSelected); CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButtonPath)); - pIM->runActionHandler("proc", pCB, "mission_proc_title|"+toString(nSelected)); + CAHManager::getInstance()->runActionHandler("proc", pCB, "mission_proc_title|"+toString(nSelected)); } else if (nSelected < (nNbMission+nNbGroupMission)) { string sButtonPath = UI_MISSION_LIST ":b_group_title"+toString(nSelected-nNbMission); CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sButtonPath)); - pIM->runActionHandler("proc", pCB, "group_mission_proc_title|"+toString(nSelected-nNbMission)); + CAHManager::getInstance()->runActionHandler("proc", pCB, "group_mission_proc_title|"+toString(nSelected-nNbMission)); } return; } diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 7004f31c9..6a93a9da3 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -656,7 +656,7 @@ class CHandlerOpenTitleHelp : public IActionHandler ucstring name = peopleList->getName(index); if ( ! name.empty()) { - CInterfaceManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)CEntityCL::Player)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)CEntityCL::Player)); } return; } @@ -697,7 +697,7 @@ class CHandlerOpenTitleHelp : public IActionHandler } } if(!name.empty()) - CInterfaceManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type)); + CAHManager::getInstance()->runActionHandler("show_hide", pCaller, "profile|pname="+name.toUtf8()+"|ptype="+toString((int)selection->Type)); return; } } @@ -994,7 +994,7 @@ class CHandlerBrowse : public IActionHandler CInterfaceManager::parseTokens(ucparams); params = ucparams.toUtf8(); // go. NB: the action handler himself may translate params from utf8 - CInterfaceManager::getInstance()->runActionHandler(action, elementGroup, params); + CAHManager::getInstance()->runActionHandler(action, elementGroup, params); // Next name start = end+2; @@ -3913,7 +3913,7 @@ void updateStatReport () if ((ingameTime0 () <= time4StatReport) && (ingameTime1 () > time4StatReport)) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler ("proc", NULL, "proc_stat_report"); + CAHManager::getInstance()->runActionHandler ("proc", NULL, "proc_stat_report"); } } diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 16b7cdc68..511b59c2e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -1498,7 +1498,7 @@ class CHandlerMoveItem : public IActionHandler if (pLS->getSheet(i)->getSheetId() == 0) { // Send swap_item - pIM->runActionHandler("swap_item", pLS->getSheet(i), "src="+toString(pCaller->getId())); + CAHManager::getInstance()->runActionHandler("swap_item", pLS->getSheet(i), "src="+toString(pCaller->getId())); return; } } @@ -1563,7 +1563,7 @@ class CHandlerMoveItem : public IActionHandler (pCS->getSheetId() == 0) && pCS->canDropItem(item) && (!pCS->getGrayed())) { // Send swap_item - pIM->runActionHandler("swap_item", pCS, "src="+toString(pCaller->getId())); + CAHManager::getInstance()->runActionHandler("swap_item", pCS, "src="+toString(pCaller->getId())); return; } } @@ -1597,7 +1597,7 @@ class CHandlerMoveItem : public IActionHandler if ((pCS->canDropItem(item)) && (!pCS->getGrayed())) { // Send swap_item - pIM->runActionHandler("swap_item", pCS, "src="+toString(pCaller->getId())); + CAHManager::getInstance()->runActionHandler("swap_item", pCS, "src="+toString(pCaller->getId())); return; } } @@ -1629,7 +1629,7 @@ class CHandlerDragNDrop : public IActionHandler CDBCtrlSheet *pCSsrc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sSrc)); CDBCtrlSheet *pCSdst = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sDst)); if ((pCSdst == NULL) || (pCSsrc == NULL) || sAH.empty()) return; - pIM->runActionHandler(sAH, pCSdst, "src="+pCSsrc->getId()); + CAHManager::getInstance()->runActionHandler(sAH, pCSdst, "src="+pCSsrc->getId()); } }; REGISTER_ACTION_HANDLER( CHandlerDragNDrop, "drag_n_drop" ); @@ -1657,7 +1657,7 @@ class CHandlerItemCristalEnchant : public IActionHandler void execute (CCtrlBase *pCaller, const std::string &sParams) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("item_cristal_reload", pCaller, sParams); + CAHManager::getInstance()->runActionHandler("item_cristal_reload", pCaller, sParams); } }; REGISTER_ACTION_HANDLER( CHandlerItemCristalEnchant, "item_cristal_enchant" ); diff --git a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp index c544594d5..f38ecdfe7 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -180,7 +180,7 @@ public: sendMsgToServer("OUTPOST:INSERT_SQUAD", getOutpostSheet(), nSquadSlot); // Then set the selected squad at this place - pIM->runActionHandler("outpost_set_squad", pCaller, sParams); + CAHManager::getInstance()->runActionHandler("outpost_set_squad", pCaller, sParams); } }; REGISTER_ACTION_HANDLER(COutpostInsertSquad, "outpost_insert_squad"); @@ -410,7 +410,7 @@ public: node->setValue32(localToGmt(attPeriod)); // Nead to resend a Declare War Start (because wanted Att Hour changed) - pIM->runActionHandler("outpost_declare_war_start", pCaller); + CAHManager::getInstance()->runActionHandler("outpost_declare_war_start", pCaller); } }; REGISTER_ACTION_HANDLER(CAHOutpostSelectAttPeriod, "outpost_select_att_period"); diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 551c17f5c..2eda5c560 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -250,7 +250,7 @@ public: { // Act as if the player click on this button CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(button->getActionOnLeftClick(), button, button->getParamsOnLeftClick() ); + CAHManager::getInstance()->runActionHandler(button->getActionOnLeftClick(), button, button->getParamsOnLeftClick() ); } } }; @@ -721,7 +721,7 @@ public: string mode = getParam(Params, "mode"); //default mode is copy if (mode == "cut") //need delete src { - CInterfaceManager::getInstance()->runActionHandler("forget_phrase_or_macro", ctrl); + CAHManager::getInstance()->runActionHandler("forget_phrase_or_macro", ctrl); } } } @@ -895,7 +895,7 @@ void CHandlerMemorizePhraseOrMacro::execute (CCtrlBase *pCaller, const string &P memorizePhraseOrMacro(dstMemoryIndex, srcIsMacro, srcPhraseId, srcMacroId); // forget src (after shorctut change!) - pIM->runActionHandler("forget_phrase_or_macro", pCSSrc); + CAHManager::getInstance()->runActionHandler("forget_phrase_or_macro", pCSSrc); } } } @@ -1273,9 +1273,9 @@ public: { // run the standard cast case. if(ctrl->isMacro()) - pIM->runActionHandler("cast_macro", ctrl); + CAHManager::getInstance()->runActionHandler("cast_macro", ctrl); else - pIM->runActionHandler("cast_phrase", ctrl); + CAHManager::getInstance()->runActionHandler("cast_phrase", ctrl); } } } @@ -1303,7 +1303,7 @@ public: // if a phrase is on this slot, just cast the phrase if(phraseId) { - pIM->runActionHandler("cast_phrase", pCaller, Params); + CAHManager::getInstance()->runActionHandler("cast_phrase", pCaller, Params); } // else open the RightMenuEmpty, to have "NewAction" else @@ -1339,7 +1339,7 @@ public: CDBCtrlSheet *ctrl= dynamic_cast(parent->getCtrl("ctrl_phrase")); if(ctrl) { - pIM->runActionHandler(ctrl->getActionOnRightClick(), ctrl, ctrl->getParamsOnRightClick()); + CAHManager::getInstance()->runActionHandler(ctrl->getActionOnRightClick(), ctrl, ctrl->getParamsOnRightClick()); } } diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index 745b89d57..d4e83c4fb 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -233,9 +233,9 @@ class CAHUIPopupPopin : public IActionHandler } if (!isContainerAuthorized(pGC)) return; if (pGC->isPopuped()) - pIM->runActionHandler("popin", NULL, Params); + CAHManager::getInstance()->runActionHandler("popin", NULL, Params); else - pIM->runActionHandler("popup", NULL, Params); + CAHManager::getInstance()->runActionHandler("popup", NULL, Params); } }; REGISTER_ACTION_HANDLER( CAHUIPopupPopin, "popup_popin" ); @@ -561,7 +561,7 @@ class CAHTalkUntalk : public IActionHandler double distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2); if(distanceSquare <= MaxTalkingDistSquare) { - pIM->runActionHandler("context_talk",NULL); + CAHManager::getInstance()->runActionHandler("context_talk",NULL); } } } @@ -593,7 +593,7 @@ class CAHMountUnmount : public IActionHandler else if(UserEntity->isRiding()) { // We are currently mounted so unmount - pIM->runActionHandler("context_unseat",NULL); + CAHManager::getInstance()->runActionHandler("context_unseat",NULL); } // Not in combat mode. else @@ -607,7 +607,7 @@ class CAHMountUnmount : public IActionHandler if(distanceSquare <= MaxTalkingDistSquare) { // Ok lets mount - pIM->runActionHandler("context_mount",NULL); + CAHManager::getInstance()->runActionHandler("context_mount",NULL); } } } @@ -638,7 +638,7 @@ class CAHExchange : public IActionHandler { if (selection && selection->properties().canExchangeItem()) if (!UserEntity->isBusy()) - pIM->runActionHandler("context_exchange",NULL); + CAHManager::getInstance()->runActionHandler("context_exchange",NULL); } } }; diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index b6b797246..89ffb9f65 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -1219,7 +1219,7 @@ public: if( button && !button->getFrozen() ) { // Act as if the player click on this button - pIM->runActionHandler("phrase_faber_validate", button ); + CAHManager::getInstance()->runActionHandler("phrase_faber_validate", button ); } } }; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index 4584ac003..dbcc1c9aa 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -229,7 +229,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < pIM->getUserDblClickDelay()) { - pIM->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams); _LeftDblClickHandled = true; _LastLeftClickButton = NULL; return true; @@ -279,7 +279,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { //nlinfo("clicked on %s", _Id.c_str()); pIM->submitEvent ("button_click:"+getId());//TEMP - pIM->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); //pIM->submitEvent ("button_click:"+getId()); } */ @@ -316,7 +316,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if(_AHOnRightClick != NULL) { handled= true; - pIM->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); } if (pIM->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted // Run Menu @@ -339,7 +339,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (_AHOnClockTick != NULL) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnClockTick, this, _AHClockTickParams); + CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams); } CInterfaceManager *pIM = CInterfaceManager::getInstance(); @@ -355,7 +355,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if ((T1 - _LeftLongClickDate) > repeatDelay) { _LeftLongClickHandled = true; - pIM->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams); + CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams); } } } @@ -504,7 +504,7 @@ void CCtrlBaseButton::runLeftClickAction() //nlinfo("clicked on %s", _Id.c_str()); pIM->submitEvent ("button_click:"+getId());//TEMP - pIM->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); //pIM->submitEvent ("button_click:"+getId()); } } diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index 112759519..cbccfc131 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -224,7 +224,7 @@ void CCtrlButton::draw () { if ((lastOver == false) && (_AHOnOver != NULL)) - pIM->runActionHandler (_AHOnOver, this, _AHOverParams); + CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); // the pointer is over the button color= getCurrentColorOver(globalColor); diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index 70a1856e8..6e38caf46 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -187,7 +187,7 @@ void CCtrlColPick::selectColor (sint32 x, sint32 y) _ColSelA.setSInt32(_ColorSelect.A); if (!_AHOnChange.empty()) - pIM->runActionHandler(_AHOnChange, this, _AHOnChangeParams); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _AHOnChangeParams); } // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index f77bb4397..59c5ca636 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -70,7 +70,7 @@ void CCtrlScroll::runAH(const std::string &name, const std::string ¶ms) if (_CallingAH) return; // avoid infinite loop CInterfaceManager *pIM = CInterfaceManager::getInstance(); _CallingAH = true; - pIM->runActionHandler(name, this, params); + CAHManager::getInstance()->runActionHandler(name, this, params); _CallingAH = false; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 9014ebdc8..ad791b5c1 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -365,7 +365,7 @@ void CCtrlTextButton::draw () if (_Over && (_OverWhenPushed || !(_Pushed || pIM->getCapturePointerLeft() == this))) { if ((lastOver == false) && (_AHOnOver != NULL)) - pIM->runActionHandler (_AHOnOver, this, _AHOverParams); + CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); // the pointer is over the button. color= getCurrentColorOver(globalColor); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index c42e1699b..d00d0ba77 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1881,7 +1881,7 @@ void CDBCtrlSheet::draw() params = sTmp + "|" + params; } } - pIM->runActionHandler (_AHOnCanDrop, this, params); + CAHManager::getInstance()->runActionHandler (_AHOnCanDrop, this, params); } } } @@ -2633,7 +2633,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if (validClic && _AHOnCanDrag != NULL) { _TempCanDrag= true; - pIM->runActionHandler (_AHOnCanDrag, this, _AHCanDragParams); + CAHManager::getInstance()->runActionHandler (_AHOnCanDrag, this, _AHCanDragParams); validClic= _TempCanDrag; } @@ -2650,7 +2650,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if (_AHOnDrag != NULL) { - pIM->runActionHandler (_AHOnDrag, this, _AHDragParams); + CAHManager::getInstance()->runActionHandler (_AHOnDrag, this, _AHDragParams); } } } @@ -2698,7 +2698,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) params = sTmp + "|" + params; } } - pIM->runActionHandler (pCSdest->_AHOnCanDrop, pCSdest, params); + CAHManager::getInstance()->runActionHandler (pCSdest->_AHOnCanDrop, pCSdest, params); // Drop only if canDrop. if(pCSdest->_CanDrop) @@ -2719,7 +2719,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) } } // call action - pIM->runActionHandler (pCSdest->_AHOnDrop, pCSdest, params); + CAHManager::getInstance()->runActionHandler (pCSdest->_AHOnDrop, pCSdest, params); handled = true; } } @@ -2763,7 +2763,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) params = sTmp + "|" + params; } } - pIM->runActionHandler (pList->getCtrlSheetInfo()._AHOnCanDrop, pList, params); + CAHManager::getInstance()->runActionHandler (pList->getCtrlSheetInfo()._AHOnCanDrop, pList, params); // Drop only if canDrop. if(pList->getCanDrop()) @@ -2784,7 +2784,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) } } // call action - pIM->runActionHandler (pList->getCtrlSheetInfo()._AHOnDrop, pList, params); + CAHManager::getInstance()->runActionHandler (pList->getCtrlSheetInfo()._AHOnDrop, pList, params); handled = true; } } @@ -2799,7 +2799,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) string sTmp = pTextList->getCtrlSheetInfo()._AHCanDropParams; params = sTmp + "|" + params; } - pIM->runActionHandler (pTextList->getCtrlSheetInfo()._AHOnCanDrop, pTextList, params); + CAHManager::getInstance()->runActionHandler (pTextList->getCtrlSheetInfo()._AHOnCanDrop, pTextList, params); // Drop only if canDrop. if(pTextList->getCanDrop()) @@ -2812,7 +2812,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) params = sTmp + "|" + params; // must copy 'drop' params at start because it could be the name of a procedure } // call action - pIM->runActionHandler (pTextList->getCtrlSheetInfo()._AHOnDrop, pTextList, params); + CAHManager::getInstance()->runActionHandler (pTextList->getCtrlSheetInfo()._AHOnDrop, pTextList, params); handled = true; } } @@ -2822,7 +2822,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if (!handled && _AHOnCannotDrop != NULL ) { - pIM->runActionHandler (_AHOnCannotDrop, this, _AHCannotDropParams); + CAHManager::getInstance()->runActionHandler (_AHOnCannotDrop, this, _AHCannotDropParams); handled = true; } @@ -2854,7 +2854,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) // RunAction if(_AHOnLeftClick != NULL) - pIM->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); // Run Menu (if item is not being dragged) if (!_ListMenuLeft.empty() && _LastDraggedSheet == NULL) { @@ -2884,7 +2884,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if(_AHOnRightClick != NULL) { handled= true; - pIM->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); + CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); } // Run Menu (if item is not being dragged) if (!_ListMenuRight.empty() || !_ListMenuRightEmptySlot.empty()) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 30d25ba22..f376c306a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -295,7 +295,7 @@ void CDBGroupComboBox::setSelection(sint32 val) if (!_CallingOnChangeActionHandler) { _CallingOnChangeActionHandler = true; - CInterfaceManager::getInstance()->runActionHandler (_AHOnChange, this, _AHOnChangeParams); + CAHManager::getInstance()->runActionHandler (_AHOnChange, this, _AHOnChangeParams); _CallingOnChangeActionHandler = false; } } @@ -578,7 +578,7 @@ public: // After menu init, Call user activation method if( !pCB->_AHOnSelectStart.empty() ) { - pIM->runActionHandler(pCB->_AHOnSelectStart, pCB); + CAHManager::getInstance()->runActionHandler(pCB->_AHOnSelectStart, pCB); } // launch the menu diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index f5b920383..dc6a9dd91 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -730,7 +730,7 @@ void CDBGroupListSheet::draw () string sTmp = _CtrlInfo._AHCanDropParams; params = sTmp + "|" + params; } - pIM->runActionHandler (_CtrlInfo._AHOnCanDrop, this, params); + CAHManager::getInstance()->runActionHandler (_CtrlInfo._AHOnCanDrop, this, params); } } } diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 0dfd0c909..2dcea9d7a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -640,7 +640,7 @@ void CDBGroupListSheetText::draw () string sTmp = _CtrlInfo._AHCanDropParams; params = sTmp + "|" + params; } - pIM->runActionHandler (_CtrlInfo._AHOnCanDrop, this, params); + CAHManager::getInstance()->runActionHandler (_CtrlInfo._AHOnCanDrop, this, params); } } } @@ -1138,7 +1138,7 @@ class CHandlerListSheetTextSelect : public IActionHandler CCtrlButton *ctrlButton= listSheetTrade->_SheetChildren[selected]->Button; // run it, but take the wanted action handler - pIM->runActionHandler( + CAHManager::getInstance()->runActionHandler( listSheetTrade->_CtrlInfo._AHOnLeftClick, ctrlSheet, listSheetTrade->_CtrlInfo._AHLeftClickParams); @@ -1175,7 +1175,7 @@ class CHandlerListSheetTextRightClick : public IActionHandler CDBCtrlSheet::setCurrSelSheet(ctrlSheet); // run it, but take the wanted action handler - pIM->runActionHandler( + CAHManager::getInstance()->runActionHandler( listSheetTrade->_CtrlInfo._AHOnRightClick, ctrlSheet, listSheetTrade->_CtrlInfo._AHRightClickParams); diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 629dba6fe..bc442c0f4 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -330,7 +330,7 @@ bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) if (gc && gc->getAHOnResizePtr() != NULL) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(gc->getAHOnResize(), gc, gc->getAHOnResizeParams()); + CAHManager::getInstance()->runActionHandler(gc->getAHOnResize(), gc, gc->getAHOnResizeParams()); } } return true; @@ -716,7 +716,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (gc->getAHOnBeginMovePtr()) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(gc->getAHOnBeginMove(), gc, gc->getAHOnBeginMoveParams()); + CAHManager::getInstance()->runActionHandler(gc->getAHOnBeginMove(), gc, gc->getAHOnBeginMoveParams()); } return true; } @@ -825,7 +825,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) // udpate XReal/YReal coords only of the container gc->CInterfaceElement::updateCoords(); // execute the AH - pIM->runActionHandler(gc->getAHOnMovePtr(), this, gc->getAHOnMoveParams()); + CAHManager::getInstance()->runActionHandler(gc->getAHOnMovePtr(), this, gc->getAHOnMoveParams()); } } else @@ -1033,13 +1033,13 @@ bool CCtrlMover::runTitleActionHandler() CInterfaceGroup *gr = gc->isOpen() ? gc->getHeaderOpened() : gc->getHeaderClosed(); if (gr && !gr->getLeftClickHandler().empty()) { - im->runActionHandler(gr->getLeftClickHandler(), this, gr->getLeftClickHandlerParams()); + CAHManager::getInstance()->runActionHandler(gr->getLeftClickHandler(), this, gr->getLeftClickHandlerParams()); return true; } // try with the main group if (!gc->getLeftClickHandler().empty()) { - im->runActionHandler(gc->getLeftClickHandler(), this, gc->getLeftClickHandlerParams()); + CAHManager::getInstance()->runActionHandler(gc->getLeftClickHandler(), this, gc->getLeftClickHandlerParams()); return true; } return false; @@ -2330,7 +2330,7 @@ void CGroupContainer::open() if (_AHOnOpen != NULL) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(_AHOnOpen, this, _AHOnOpenParams); + CAHManager::getInstance()->runActionHandler(_AHOnOpen, this, _AHOnOpenParams); } } @@ -2358,7 +2358,7 @@ void CGroupContainer::close() if (_AHOnClose != NULL) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(_AHOnClose, this, _AHOnCloseParams); + CAHManager::getInstance()->runActionHandler(_AHOnClose, this, _AHOnCloseParams); } } @@ -3502,7 +3502,7 @@ public: CGroupContainer::_ValidateCanDeactivate = true; if (!pIC->getAHOnDeactiveCheck().empty()) { - im->runActionHandler(pIC->getAHOnDeactiveCheck(), pCaller, pIC->getAHOnDeactiveCheckParams()); + CAHManager::getInstance()->runActionHandler(pIC->getAHOnDeactiveCheck(), pCaller, pIC->getAHOnDeactiveCheckParams()); } if (CGroupContainer::_ValidateCanDeactivate) @@ -3510,7 +3510,7 @@ public: // send close button msg if (!pIC->getAHOnCloseButton().empty()) { - im->runActionHandler(pIC->getAHOnCloseButton(), pCaller, pIC->getAHOnCloseButtonParams()); + CAHManager::getInstance()->runActionHandler(pIC->getAHOnCloseButton(), pCaller, pIC->getAHOnCloseButtonParams()); } CWidgetManager::getInstance()->setBackWindow(pIC); pIC->setActive(false); @@ -3596,7 +3596,7 @@ class CICHelp : public IActionHandler { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // open the web browser, and point to the page - pIM->runActionHandler("launch_help", NULL, "url=" + helpPage); + CAHManager::getInstance()->runActionHandler("launch_help", NULL, "url=" + helpPage); } } }; @@ -4035,7 +4035,7 @@ void CGroupContainer::triggerAlphaSettingsChangedAH() if (_AHOnAlphaSettingsChanged != NULL) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); + CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); } } diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index c42878ef8..ea5811b9b 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -594,7 +594,7 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) // stop selection _CurrSelection = NULL; _CursorAtPreviousLineEnd = false; - pIM->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); } else { @@ -701,7 +701,7 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) } if (rEDK.getChar() == KeyRETURN) { - pIM->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); } } _CursorAtPreviousLineEnd = false; @@ -753,7 +753,7 @@ void CGroupEditBox::triggerOnChangeAH() if (!_AHOnChange.empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } @@ -1291,7 +1291,7 @@ void CGroupEditBox::setCommand(const ucstring &command, bool execute) // stop selection _CurrSelection = NULL; _CursorAtPreviousLineEnd = false; - CInterfaceManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); } else { @@ -1409,7 +1409,7 @@ void CGroupEditBox::onKeyboardCaptureLost() if (!_AHOnFocusLost.empty()) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); + CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); } } diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index 964f6ca82..01d87d4f8 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -338,7 +338,7 @@ public: { ghe->setW(_TargetGroup->getW()); ghe->invalidateCoords(); - im->runActionHandler(ghe->getAHOnResize(), ghe, ghe->getAHOnResizeParams()); + CAHManager::getInstance()->runActionHandler(ghe->getAHOnResize(), ghe, ghe->getAHOnResizeParams()); } return true; } diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp index 426c6dbd5..4bf0a1fac 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.cpp @@ -55,7 +55,7 @@ void CGroupHTMLQCM::addText (const char * buf, int len) if (sTmp.find("zzz_QUIT_RYZOM_zzz") != string::npos) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("quit_ryzom", NULL); + CAHManager::getInstance()->runActionHandler("quit_ryzom", NULL); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId("ui:interface:web_on_quit"); pIE->setActive(false); } diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index be8d1a950..cd7ee194b 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -790,7 +790,7 @@ void CGroupInSceneBubbleManager::addContextHelpHTML (const string &url, const st if (context) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("browse", NULL, "name="+context->Group->getId()+":header_opened:window:html|url="+url); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name="+context->Group->getId()+":header_opened:window:html|url="+url); // Add the URL context->Url = url; @@ -1277,7 +1277,7 @@ void CGroupInSceneBubbleManager::CDynBubble::skip() if (nNbOptions == 1) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("dynchat_click_option", Bubble, "0"); + CAHManager::getInstance()->runActionHandler("dynchat_click_option", Bubble, "0"); } } diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index f2bf62aff..20429edb0 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -3410,11 +3410,11 @@ class CAHWorldMapRightClick : public IActionHandler if (!gm) return; if (!gm->isIsland()) { - im->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu"); + CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu"); } else { - im->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island"); + CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island"); } } }; diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 9f8bbf3aa..7635a5344 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -983,7 +983,7 @@ bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed())) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler ( _Lines[_Selected].AHName, + CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHName, CWidgetManager::getInstance()->getCtrlLaunchingModal(), _Lines[_Selected].AHParams ); diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 26245433a..5de2f530d 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -326,7 +326,7 @@ void CGroupQuickHelp::activateCurrentStep () // A link to follow ? if (!step.URL.empty()) - pIM->runActionHandler("browse", NULL, "url="+step.URL); + CAHManager::getInstance()->runActionHandler("browse", NULL, "url="+step.URL); // Test a skip condition if (!step.Condition.empty() && evalExpression (step.Condition)) @@ -411,7 +411,7 @@ class CHandlerRunQuickHelp : public IActionHandler button->setPushed(true); // Run the left click action handler - pIM->runActionHandler(button->getActionOnLeftClick(), button, button->getParamsOnLeftClick()); + CAHManager::getInstance()->runActionHandler(button->getActionOnLeftClick(), button, button->getParamsOnLeftClick()); } } } diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index 8fc17fac5..a4ede0d59 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -192,7 +192,7 @@ void CGroupSkills::CSkillsObs::update (ICDBNode *node) uint skillId; if (skillParent->getNodeIndex (skill, skillId)) { - pIM->runActionHandler("skill_popup", NULL, "skillId="+toString(skillId)+"|delta="+toString(leaf->getValue32()-leaf->getOldValue32())); + CAHManager::getInstance()->runActionHandler("skill_popup", NULL, "skillId="+toString(skillId)+"|delta="+toString(leaf->getValue32()-leaf->getOldValue32())); // Context help contextHelp ("skill"); diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 8c189ae11..69d66694c 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -133,7 +133,7 @@ void CGroupTab::addTab(CCtrlTabButton * tabB) if(_HideOutTabs && !_AHOnChange.empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } @@ -227,7 +227,7 @@ void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) if(_HideOutTabs && !_AHOnChange.empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } @@ -247,7 +247,7 @@ int CGroupTab::luaAddTab(CLuaState &ls) if(_HideOutTabs && !_AHOnChange.empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } return 0; @@ -334,7 +334,7 @@ void CGroupTab::removeTab(sint index) if(!_AHOnChange.empty()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } } @@ -505,7 +505,7 @@ void CGroupTab::updateFirstTabButton() if(!_AHOnChange.empty() && ((oldFirstTabIndex!=_FirstTabIndex) || (oldLastTabIndex!=_LastTabIndex))) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(_AHOnChange, this, _ParamsOnChange); + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); } } diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 9797f0844..01f7b5e63 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -727,7 +727,7 @@ void CGroupTree::selectLine(uint line, bool runAH /*= true*/) { _CancelNextSelectLine = false; /* - pIM->runActionHandler ( _Lines[line].Node->AHName, + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, this, _Lines[line].Node->AHParams ); */ @@ -736,7 +736,7 @@ void CGroupTree::selectLine(uint line, bool runAH /*= true*/) _SelectedLine = line; _SelectedNode = _Lines[line].Node; } - pIM->runActionHandler ( _Lines[line].Node->AHName, + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, this, _Lines[line].Node->AHParams ); _CancelNextSelectLine = false; @@ -755,7 +755,7 @@ bool CGroupTree::rightButton(uint line) if (line != (uint) _SelectedLine) selectLine(line, false); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler ( _Lines[line].Node->AHNameRight, + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHNameRight, this, _Lines[line].Node->AHParamsRight ); return true; @@ -863,7 +863,7 @@ bool CGroupTree::handleEvent (const NLGUI::CEventDescriptor& event) } CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler(changedNode->AHNameClose, this, changedNode->AHParamsClose); + CAHManager::getInstance()->runActionHandler(changedNode->AHNameClose, this, changedNode->AHParamsClose); } forceRebuild(); } @@ -1303,7 +1303,7 @@ bool CGroupTree::selectNodeById(const std::string &nodeId, bool triggerAH) _AvoidSelectNodeByIdIR= true; // launch the action handler - pIM->runActionHandler ( selNode->AHName, + CAHManager::getInstance()->runActionHandler ( selNode->AHName, this, selNode->AHParams ); } diff --git a/code/ryzom/client/src/interface_v3/group_wheel.cpp b/code/ryzom/client/src/interface_v3/group_wheel.cpp index 78bd079b5..b8b25c70b 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.cpp +++ b/code/ryzom/client/src/interface_v3/group_wheel.cpp @@ -54,12 +54,12 @@ bool CInterfaceGroupWheel::handleEvent(const NLGUI::CEventDescriptor &event) CInterfaceManager *im = CInterfaceManager::getInstance(); if (eventDesc.getWheel() > 0 && _AHWheelUp) { - im->runActionHandler (_AHWheelUp, this, _AHWheelUpParams); + CAHManager::getInstance()->runActionHandler (_AHWheelUp, this, _AHWheelUpParams); return true; } else if (_AHWheelDown) { - im->runActionHandler (_AHWheelDown, this, _AHWheelDownParams); + CAHManager::getInstance()->runActionHandler (_AHWheelDown, this, _AHWheelDownParams); return true; } } diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 7092cd903..9271753f9 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -437,7 +437,7 @@ void CGuildManager::update() } // Rebuild interface. Rebuild members only if needed - pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=%d", (uint)_NeedUpdateMembers) ); + CAHManager::getInstance()->runActionHandler("guild_sheet_open", NULL, toString("update_members=%d", (uint)_NeedUpdateMembers) ); } } @@ -1035,7 +1035,7 @@ public: } NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->setValue32((sint32)order); - pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=1")); + CAHManager::getInstance()->runActionHandler("guild_sheet_open", NULL, toString("update_members=1")); } }; REGISTER_ACTION_HANDLER(CAHGuildSheetSortGuildList, "sort_guild_list"); diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index 436b84133..a27c248d6 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -642,7 +642,7 @@ void CInterfaceAnim::stop() CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (!_AHOnFinish.empty()) - pIM->runActionHandler(_AHOnFinish, _Parent, _AHOnFinishParams); + CAHManager::getInstance()->runActionHandler(_AHOnFinish, _Parent, _AHOnFinishParams); } // ************************** diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 1a4a380b6..4d917a80d 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -116,11 +116,11 @@ void CInterfaceGroup::setActive(bool state) CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (_AHOnActive != NULL && state) { - pIM->runActionHandler (_AHOnActive, this, _AHOnActiveParams); + CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); } if (_AHOnDeactive != NULL && !state) { - pIM->runActionHandler (_AHOnDeactive, this, _AHOnDeactiveParams); + CAHManager::getInstance()->runActionHandler (_AHOnDeactive, this, _AHOnDeactiveParams); } notifyActiveCalled(NLGUI::CEventDescriptorActiveCalledOnParent(state)); @@ -739,7 +739,7 @@ bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) { if (_AHOnLeftClick != NULL) { - im->runActionHandler(_AHOnLeftClick, this, _AHOnLeftClickParams); + CAHManager::getInstance()->runActionHandler(_AHOnLeftClick, this, _AHOnLeftClickParams); return true; } } @@ -748,7 +748,7 @@ bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) { if (_AHOnRightClick != NULL) { - im->runActionHandler(_AHOnRightClick, this, _AHOnRightClickParams); + CAHManager::getInstance()->runActionHandler(_AHOnRightClick, this, _AHOnRightClickParams); return true; } } @@ -868,7 +868,7 @@ void CInterfaceGroup::executeLuaScriptOnDraw() if(!_LUAOnDraw.empty()) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->runActionHandler("lua", this, _LUAOnDraw); + CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); } } diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 4a7315ef0..c61891634 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -365,7 +365,7 @@ void CInterfaceLink::update() if(launch) { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->runActionHandler(_ActionHandler, _AHParent, _AHParams); + CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); // do not add any code after this line because this can be deleted !!!! } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 9872b5962..e07e4b64f 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1386,79 +1386,6 @@ CInterfaceOptions *CInterfaceManager::getOptions(const string &name) return it->second; } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams) -{ - if (ahCmdLine.empty()) return; - - // Special AH form ("ah:params") ? - string::size_type i = ahCmdLine.find(':'); - string ahName; - string ahParams; - if(i!=string::npos) - { - ahName= ahCmdLine.substr(0, i); - ahParams= ahCmdLine.substr(i+1); - } - else - { - ahName= ahCmdLine; - } - - // Replace params if defined - if(!ahUserParams.empty()) - ahParams= ahUserParams; - - // Execute the action handler - CAHManager *pAHFM = CAHManager::getInstance(); - map::iterator it = pAHFM->FactoryMap.find (ahName); - if (it == pAHFM->FactoryMap.end()) - { - nlwarning ("not found action handler : %s",ahName.c_str()); - return; - } - IActionHandler *pAH = it->second; - pAH->execute (pCaller, ahParams); - - // Quick Help - const string submitQuickHelp = "submit_quick_help"; - it = pAHFM->FactoryMap.find(submitQuickHelp); - if(it == pAHFM->FactoryMap.end()) - { - nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); - return; - } - pAH = it->second; - const std::string event = ahName + ":" + ahParams; - pAH->execute(NULL, event); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params) -{ - if (pAH == NULL) - { - nlwarning ("no action handler"); - return; - } - pAH->execute (pCaller, Params); - string AHName = CAHManager::getInstance()->getAHName(pAH); - - // Quick Help - const string submitQuickHelp = "submit_quick_help"; - CAHManager *pAHFM = CAHManager::getInstance(); - map::iterator it = pAHFM->FactoryMap.find (AHName); - it = pAHFM->FactoryMap.find(submitQuickHelp); - if(it == pAHFM->FactoryMap.end()) - { - nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); - return; - } - pAH = it->second; - const std::string event = AHName + ":" + Params; - pAH->execute(NULL, event); -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::setupOptions() { @@ -2403,7 +2330,7 @@ void CInterfaceManager::drawContextHelp () // UserDefined context help if( !newCtrl->getContextHelpActionHandler().empty() ) { - runActionHandler(newCtrl->getContextHelpActionHandler(), newCtrl, newCtrl->getContextHelpAHParams() ); + CAHManager::getInstance()->runActionHandler(newCtrl->getContextHelpActionHandler(), newCtrl, newCtrl->getContextHelpAHParams() ); } // If the text is finally empty (Special AH case), abort @@ -2726,7 +2653,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if( dynamic_cast(win) ) { if(!win->getAHOnEscape().empty()) - runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); + CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); CWidgetManager::getInstance()->popModalWindow(); handled= true; } @@ -2735,7 +2662,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) else if(!_CaptureKeyboard ) { if(!win->getAHOnEscape().empty()) - runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); + CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); win->setActive(false); handled= true; } @@ -2760,7 +2687,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) else { // The window or modal control the OnEnter. Execute, and don't go to the chat. - runActionHandler(tw->getAHOnEnter(), tw, tw->getAHOnEnterParams()); + CAHManager::getInstance()->runActionHandler(tw->getAHOnEnter(), tw, tw->getAHOnEnterParams()); handled= true; } } @@ -2880,7 +2807,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown || (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) if (!mwi.ModalHandlerClickOut.empty()) - runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams); + CAHManager::getInstance()->runActionHandler(mwi.ModalHandlerClickOut,NULL,mwi.ModalClickOutParams); // If the current window is not the modal and if must quit on click out if(pNewCurrentWnd != mwi.ModalWindow && mwi.ModalExitClickOut) @@ -2945,7 +2872,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) notifyElementCaptured(_CapturePointerLeft); if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) { - runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerLeft, clickedOutModalWindow->OnPostClickOutParams); + CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerLeft, clickedOutModalWindow->OnPostClickOutParams); } } //if found @@ -2994,7 +2921,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) notifyElementCaptured(_CapturePointerRight); if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) { - runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerRight, clickedOutModalWindow->OnPostClickOutParams); + CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerRight, clickedOutModalWindow->OnPostClickOutParams); } } //if found @@ -3681,7 +3608,7 @@ void CInterfaceManager::setCaptureKeyboard(CCtrlBase *c) if (!newEb->getAHOnFocus().empty()) { - runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); + CAHManager::getInstance()->runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); } } @@ -3739,7 +3666,7 @@ void CInterfaceManager::runProcedure (const string &procName, CCtrlBase *pCaller action.buildParams(paramList, params); // run //nlwarning("step %d : %s, %s", (int) i, action.Action.c_str(), params.c_str()); - runActionHandler(action.Action, pCaller, params); + CAHManager::getInstance()->runActionHandler(action.Action, pCaller, params); } } } @@ -4715,7 +4642,7 @@ uint CInterfaceManager::getUserDblClickDelay() void CInterfaceManager::submitEvent (const std::string &event) { // Submit the event to the quick help system - runActionHandler("submit_quick_help", NULL, event); + CAHManager::getInstance()->runActionHandler("submit_quick_help", NULL, event); } // *************************************************************************** @@ -4888,7 +4815,7 @@ void CInterfaceManager::displayWebWindow(const string & name, const string & url pIG->center(); } - runActionHandler("browse", NULL, "name="+name+":content:html|url="+url); + CAHManager::getInstance()->runActionHandler("browse", NULL, "name="+name+":content:html|url="+url); } /* // *************************************************************************** @@ -4897,7 +4824,7 @@ class CHandlerDispWebOnQuit : public IActionHandler virtual void execute (CCtrlBase *pCaller, const string &Params) { if (ClientCfg.Local) - CInterfaceManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:quit_dialog"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:quit_dialog"); else CInterfaceManager::getInstance()->displayWebWindow("ui:interface:web_on_quit", "http://213.208.119.190/igpoll/poll_form.php"); } @@ -4909,7 +4836,7 @@ class CHandlerExitWebOnQuit : public IActionHandler { virtual void execute (CCtrlBase *pCaller, const string &Params) { - CInterfaceManager::getInstance()->runActionHandler("quit_ryzom", pCaller); + CAHManager::getInstance()->runActionHandler("quit_ryzom", pCaller); } }; REGISTER_ACTION_HANDLER (CHandlerExitWebOnQuit, "exit_web_on_quit"); @@ -5188,7 +5115,6 @@ void CInterfaceManager::updateEmotes() // Just call the action handler with good params bool CInterfaceManager::CEmoteCmd::execute(const std::string &/* rawCommandString */, const vector &args, CLog &/* log */, bool /* quiet */, bool /* human */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); string customPhrase; if( args.size() > 0 ) { @@ -5199,7 +5125,7 @@ bool CInterfaceManager::CEmoteCmd::execute(const std::string &/* rawCommandStrin customPhrase += " "; customPhrase += args[i]; } - pIM->runActionHandler("emote", NULL, "nb="+toString(EmoteNb)+"|behav="+toString(Behaviour)+"|custom_phrase="+customPhrase); + CAHManager::getInstance()->runActionHandler("emote", NULL, "nb="+toString(EmoteNb)+"|behav="+toString(Behaviour)+"|custom_phrase="+customPhrase); return true; } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index ac8e9b408..9bf7849e4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -276,10 +276,6 @@ public: /// Handle The Event. return true if the interfaceManager catch it and if must not send to the Game Action Manager bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); bool handleMouseMoveEvent( const NLGUI::CEventDescriptor &eventDesc ); - void runActionHandler (const std::string &AHName, CCtrlBase *pCaller, - const std::string &Params=std::string("")); - void runActionHandler (IActionHandler *ah, CCtrlBase *pCaller, - const std::string &Params=std::string("")); // execute a procedure. give a list of parameters. NB: the first param is the name of the proc (skipped)... void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector ¶mList); // replace an action in a procedure (if possible) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index db5f1dc7d..7e1b15f34 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -2313,7 +2313,7 @@ bool CInterfaceParser::initCoordsAndLuaScript() { // execute the script on this group CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->runActionHandler("lua", itLua->first, itLua->second); + CAHManager::getInstance()->runActionHandler("lua", itLua->first, itLua->second); } diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index bb959f0ba..cdb2a2e36 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -1746,12 +1746,12 @@ void CTempInvManager::update() { // If all slots are empty, close the interface pGC->setActive(false); - pIM->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); + CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); } else { pGC->setActive(true); - pIM->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); + CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); // Something arrived, change text switch(_Mode) { @@ -1884,7 +1884,7 @@ void CTempInvManager::open(TEMP_INV_MODE::TInventoryMode m) }; pGC->setActive(true); - pIM->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); + CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); } } @@ -1906,7 +1906,7 @@ void CTempInvManager::close() if (pIG != NULL) { pIG->setActive(false); - pIM->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); + CAHManager::getInstance()->runActionHandler("phrase_update_all_memory_ctrl_regen_tick_range", NULL); } } @@ -2706,7 +2706,7 @@ class CHandlerInvDropTo : public IActionHandler if (((pListDstText != NULL) && (pListDstText->getInvType() == CInventoryManager::InvBag)) || ((pListDstIcon != NULL) && (pListDstIcon->getInvType() == CInventoryManager::InvBag))) { - pIM->runActionHandler("proc", pCSSrc, "move_to_bag"); + CAHManager::getInstance()->runActionHandler("proc", pCSSrc, "move_to_bag"); } else if (((pListDstText != NULL) && ((pListDstText->getInvType() == CInventoryManager::InvPA0) || (pListDstText->getInvType() == CInventoryManager::InvPA1) || @@ -2722,18 +2722,18 @@ class CHandlerInvDropTo : public IActionHandler string sTmp; if (pListDstText != NULL) sTmp = toString("%d",pListDstText->getInvType()-CInventoryManager::InvPA0); if (pListDstIcon != NULL) sTmp = toString("%d",pListDstIcon->getInvType()-CInventoryManager::InvPA0); - pIM->runActionHandler("proc", pCSSrc, "move_to_pa|"+sTmp); + CAHManager::getInstance()->runActionHandler("proc", pCSSrc, "move_to_pa|"+sTmp); } else if (((pListDstText != NULL) && (pListDstText->getInvType() == CInventoryManager::InvGuild)) || ((pListDstIcon != NULL) && (pListDstIcon->getInvType() == CInventoryManager::InvGuild))) { if (strnicmp(pCSSrc->getSheet().c_str(), "LOCAL:INVENTORY:BAG", 19) == 0) - pIM->runActionHandler("proc", pCSSrc, "move_to_guild"); + CAHManager::getInstance()->runActionHandler("proc", pCSSrc, "move_to_guild"); } else if (((pListDstText != NULL) && (pListDstText->getInvType() == CInventoryManager::InvRoom)) || ((pListDstIcon != NULL) && (pListDstIcon->getInvType() == CInventoryManager::InvRoom))) { - pIM->runActionHandler("proc", pCSSrc, "move_to_room"); + CAHManager::getInstance()->runActionHandler("proc", pCSSrc, "move_to_room"); } } } @@ -2760,7 +2760,7 @@ class CHandlerInvDropTo : public IActionHandler if (i1 != 0) getInventory().equip(sBag + toString(i1-1), invPath2); } - pIM->runActionHandler("inv_cannot_drop", pCSSrc); + CAHManager::getInstance()->runActionHandler("inv_cannot_drop", pCSSrc); } }; REGISTER_ACTION_HANDLER( CHandlerInvDropTo, "inv_drop" ); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 6c9ebb167..3211c20e9 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1179,7 +1179,7 @@ int CLuaIHMRyzom::runAH(CLuaState &ls) if(!ctrl) throw ELuaIHMException("runAH(): '%s' is not a ctrl", pIE->getId().c_str()); } - pIM->runActionHandler(ah, ctrl, params); + CAHManager::getInstance()->runActionHandler(ah, ctrl, params); return 0; } diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 4103026e1..d7b2bdb4b 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -584,13 +584,13 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std onChangeCategory(); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); - //pIM->runActionHandler("editcmd_change_category",NULL); + //CAHManager::getInstance()->runActionHandler("editcmd_change_category",NULL); pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+WIN_EDITCMD_COMBO_ACTION)); pCB->setSelection(actCBIndex); onChangeAction(); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); - //pIM->runActionHandler("editcmd_change_action",NULL); + //CAHManager::getInstance()->runActionHandler("editcmd_change_action",NULL); // Count number of displayed param uint nbRealParam = 0; @@ -1310,7 +1310,7 @@ public: { pMCM->CurrentEditMacro.addCommand(pMCM->EditCmd->CurrentEditCmdLine.ActionName.Name.c_str(),pMCM->EditCmd->CurrentEditCmdLine.ActionName.Argu.c_str()); } - pIM->runActionHandler("new_macro_open", pCaller); + CAHManager::getInstance()->runActionHandler("new_macro_open", pCaller); pMCM->EditCmd->deactivate(); } } diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 47b770a10..5548f9354 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -485,7 +485,7 @@ void CMacroCmdManager::updateMacroExecution () } // Here we have to execute the current command - pIM->runActionHandler(rC.Name, NULL, rC.Params); + CAHManager::getInstance()->runActionHandler(rC.Name, NULL, rC.Params); // Flush interface links (else bug with Macro "Select ShortCutBar/Run Shortcut" IngameDbMngr.flushObserverCalls(); @@ -526,9 +526,9 @@ void CMacroCmdManager::refreshAllKeyDisplays() { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Refresh Key Window - pIM->runActionHandler("keys_open", NULL); + CAHManager::getInstance()->runActionHandler("keys_open", NULL); // Refresh gestion_windows container - pIM->runActionHandler("gestion_windows_update_key_binding", NULL); + CAHManager::getInstance()->runActionHandler("gestion_windows_update_key_binding", NULL); } // ------------------------------------------------------------------------------------------------ @@ -670,9 +670,9 @@ public: CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); - pIM->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_BACK); - pIM->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_ICON); - pIM->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_OVER); + CAHManager::getInstance()->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_BACK); + CAHManager::getInstance()->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_ICON); + CAHManager::getInstance()->runActionHandler("reset_pushed", NULL, string("dblink=")+GROUP_MACROICONCREATION_OVER); uint8 back = pMCM->CurrentEditMacro.BitmapBack; if (back != 0xff) @@ -707,9 +707,9 @@ public: pCS->setMacroText(pEB->getInputStringAsStdString()); } - pIM->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back)); - pIM->runActionHandler("set_macro_icon", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(icon)); - pIM->runActionHandler("set_macro_over", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(over)); + CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back)); + CAHManager::getInstance()->runActionHandler("set_macro_icon", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(icon)); + CAHManager::getInstance()->runActionHandler("set_macro_over", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(over)); } }; REGISTER_ACTION_HANDLER( CHandlerMacroIconCreationOpen, "macro_icon_creation_open"); @@ -740,7 +740,7 @@ public: pMCM->CurrentEditMacro.moveUpCommand(nCmdNb); CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager::getInstance()->EditCmd->deactivate(); - pIM->runActionHandler("new_macro_open",NULL); + CAHManager::getInstance()->runActionHandler("new_macro_open",NULL); } }; REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdMoveUp, "new_macro_cmd_move_up"); @@ -757,7 +757,7 @@ public: pMCM->CurrentEditMacro.moveDownCommand(nCmdNb); CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager::getInstance()->EditCmd->deactivate(); - pIM->runActionHandler("new_macro_open",NULL); + CAHManager::getInstance()->runActionHandler("new_macro_open",NULL); } }; REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdMoveDown, "new_macro_cmd_move_down"); @@ -790,7 +790,7 @@ public: pMCM->CurrentEditMacro.delCommand(nCmdNb); CInterfaceManager *pIM = CInterfaceManager::getInstance(); CMacroCmdManager::getInstance()->EditCmd->deactivate(); - pIM->runActionHandler("new_macro_open",NULL); + CAHManager::getInstance()->runActionHandler("new_macro_open",NULL); } }; REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdDelete, "new_macro_cmd_delete"); @@ -820,7 +820,7 @@ public: virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("new_macro_enter_name",NULL); + CAHManager::getInstance()->runActionHandler("new_macro_enter_name",NULL); CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); pMCM->EditCmd->activate(); } @@ -914,7 +914,7 @@ public: CSPhraseManager *pPM = CSPhraseManager::getInstance(); // Validate name - pIM->runActionHandler("new_macro_enter_name",NULL); + CAHManager::getInstance()->runActionHandler("new_macro_enter_name",NULL); // Check if macro has more than one command if (pMCM->CurrentEditMacro.Commands.size() == 0) return; @@ -939,7 +939,7 @@ public: CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_NEWMACRO)); if (pGC != NULL) pGC->setActive (false); - pIM->runActionHandler("macros_open",NULL); + CAHManager::getInstance()->runActionHandler("macros_open",NULL); // Refresh key containers pMCM->refreshAllKeyDisplays(); @@ -1060,7 +1060,7 @@ public: { sint nMacNb = getMacroFromId(pCaller->getId()); - CInterfaceManager::getInstance()->runActionHandler(AH_MACRO_EXEC,pCaller,toString(nMacNb)); + CAHManager::getInstance()->runActionHandler(AH_MACRO_EXEC,pCaller,toString(nMacNb)); } }; REGISTER_ACTION_HANDLER( CHandlerMacrosExec, "macros_exec"); @@ -1124,7 +1124,7 @@ public: pPM->deleteMacroShortcuts(pMCM->getMacros()[nMacNb].ID); // then delete pMCM->delMacro(nMacNb); - pIM->runActionHandler("macros_open",NULL); + CAHManager::getInstance()->runActionHandler("macros_open",NULL); // Refresh key containers pMCM->refreshAllKeyDisplays(); diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index c357505cc..f2ca589b8 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2236,7 +2236,7 @@ public: CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb")); geb->setInputString(ucstring("")); } - pIM->runActionHandler("enter_modal", pCaller, sParams); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } } } @@ -2300,7 +2300,7 @@ public: } } } - pIM->runActionHandler("leave_modal", pCaller, ""); + CAHManager::getInstance()->runActionHandler("leave_modal", pCaller, ""); } }; REGISTER_ACTION_HANDLER( CHandlerAddContact, "add_contact"); @@ -2745,12 +2745,12 @@ class CHandlerChatTargetSelected : public IActionHandler if (cw == PeopleInterraction.ChatGroup.Window) { PeopleInterraction.TheUserChat.Filter.setTargetGroup(cf.getTargetGroup(), cf.getTargetDynamicChannelDbIndex()); - CInterfaceManager::getInstance()->runActionHandler("chat_group_filter", NULL, "user"); + CAHManager::getInstance()->runActionHandler("chat_group_filter", NULL, "user"); } if (cw == PeopleInterraction.TheUserChat.Window) { PeopleInterraction.TheUserChat.Filter.setTargetGroup(cf.getTargetGroup(), cf.getTargetDynamicChannelDbIndex()); - CInterfaceManager::getInstance()->runActionHandler("user_chat_active", NULL, ""); + CAHManager::getInstance()->runActionHandler("user_chat_active", NULL, ""); } // The target should be a party chat diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index 0df3a071e..832b23f2b 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -587,7 +587,7 @@ void CSkillManager::checkTitleUnblocked(CHARACTER_TITLE::ECharacterTitle i, bool string titleStr = CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)i); bool womenTitle = (UserEntity && UserEntity->getGender() == GSGENDER::female); const ucstring newtitle(CStringManagerClient::getTitleLocalizedName(titleStr, womenTitle)); - pIM->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold").toUtf8()); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+newtitle.toUtf8()+"|text0="+CI18N::get("uiNewTitleBold").toUtf8()); } else { @@ -612,7 +612,7 @@ void CSkillManager::checkTitleUnblocked(CHARACTER_TITLE::ECharacterTitle i, bool } // Update title combo box - pIM->runActionHandler("title_init_combobox", NULL); + CAHManager::getInstance()->runActionHandler("title_init_combobox", NULL); } } } @@ -1032,7 +1032,7 @@ void CSkillManager::blockTitleFromServer(CHARACTER_TITLE::ECharacterTitle ct) void CSkillManager::setPlayerTitle(const std::string &name) { setCurrentTitle(CHARACTER_TITLE::toCharacterTitle(name)); - CInterfaceManager::getInstance()->runActionHandler("title_init_combobox", NULL); + CAHManager::getInstance()->runActionHandler("title_init_combobox", NULL); } @@ -1051,7 +1051,7 @@ public: virtual void execute(CCtrlBase * /* pCaller */, const string &/* Params */) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("title_combobox_button", NULL); + CAHManager::getInstance()->runActionHandler("title_combobox_button", NULL); // Setup UI:TITLE from current title CSkillManager *pSM = CSkillManager::getInstance(); diff --git a/code/ryzom/client/src/light_cycle_manager.cpp b/code/ryzom/client/src/light_cycle_manager.cpp index 4b0488dd5..1299aa802 100644 --- a/code/ryzom/client/src/light_cycle_manager.cpp +++ b/code/ryzom/client/src/light_cycle_manager.cpp @@ -255,7 +255,7 @@ void CLightCycleManager::updateState() CInterfaceManager * pIM = CInterfaceManager::getInstance(); if( pIM ) { - pIM->runActionHandler("set",NULL,"dblink=UI:VARIABLES:NIGHT_WARNING_WANTED|value=1"); + CAHManager::getInstance()->runActionHandler("set",NULL,"dblink=UI:VARIABLES:NIGHT_WARNING_WANTED|value=1"); } } _State = Night; diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 1457aa396..4abecf8c1 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -221,7 +221,7 @@ void initEula() } else { - pIM->runActionHandler("accept_eula", NULL); + CAHManager::getInstance()->runActionHandler("accept_eula", NULL); } } @@ -265,7 +265,7 @@ void initCatDisplay() else { LoginSM.pushEvent(CLoginStateMachine::ev_run_patch); -// pIM->runActionHandler("login_patch", NULL); +// CAHManager::getInstance()->runActionHandler("login_patch", NULL); } } @@ -492,7 +492,7 @@ void loginMainLoop() else { LoginSM.pushEvent(CLoginStateMachine::ev_no_patch); - // pIM->runActionHandler("login_patch", NULL); + // CAHManager::getInstance()->runActionHandler("login_patch", NULL); } } else @@ -744,11 +744,11 @@ void initLoginScreen() { pGEB->setInputString(l); } - pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); + CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); } else { - pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); + CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); } @@ -766,7 +766,7 @@ void initAutoLogin() CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); pGEBLog->setInputString(LoginLogin); pGEBPwd->setInputString(LoginPassword); - pIM->runActionHandler("on_login", NULL, ""); + CAHManager::getInstance()->runActionHandler("on_login", NULL, ""); if (ClientCfg.R2Mode) { @@ -793,7 +793,7 @@ void initAutoLogin() else { LoginSM.pushEvent(CLoginStateMachine::ev_login_ok); - // pIM->runActionHandler("login_connect_2", NULL); + // CAHManager::getInstance()->runActionHandler("login_connect_2", NULL); } } } @@ -869,11 +869,11 @@ bool login() // CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); // if (pGEB != NULL) // pGEB->setInputString(l); -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); // } // else // { -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); // } ShardSelected = -1; @@ -891,7 +891,7 @@ bool login() // CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); // pGEBLog->setInputString(LoginLogin); // pGEBPwd->setInputString(LoginPassword); -// pIM->runActionHandler("on_login", NULL, ""); +// CAHManager::getInstance()->runActionHandler("on_login", NULL, ""); // // Select good shard // ShardSelected = -1; // for (uint32 i = 0; i < Shards.size(); ++i) @@ -906,7 +906,7 @@ bool login() // if (ShardSelected == -1) // pIM->messageBox(CI18N::get("uiErrServerLost"), "ui:login"); // else -// pIM->runActionHandler("login_connect_2", NULL); +// CAHManager::getInstance()->runActionHandler("login_connect_2", NULL); // } // start the login state machine @@ -1090,7 +1090,7 @@ void initShardDisplay() CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); if (pCB != NULL) pCB->setPushed(true); - pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); + CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); } pList->invalidateCoords(); @@ -1217,7 +1217,7 @@ void onlogin(bool vanishScreen = true) // CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but")); // if (pCB != NULL) // pCB->setPushed(true); -// pIM->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); +// CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick()); // // } // pList->invalidateCoords(); @@ -1233,9 +1233,9 @@ void onlogin(bool vanishScreen = true) // NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_CHECKPASS); // // if (LoginLogin.empty()) -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); // else -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); } } @@ -1470,7 +1470,7 @@ class CAHLoginConnect : public IActionHandler // } // else // { -// pIM->runActionHandler("login_patch",NULL); +// CAHManager::getInstance()->runActionHandler("login_patch",NULL); // } } }; @@ -2173,9 +2173,9 @@ class CAHOnScanDataClose : public IActionHandler // loginEB= pGEB->getInputStringAsStdString(); // // if none entered // if (loginEB.empty()) -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_LOGIN "|select_all=false"); // else -// pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); +// CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false"); } } }; @@ -2354,7 +2354,7 @@ bool initCreateAccount() rulesGr->setActive(false); // must be done after hide rules - pIM->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_CREATEACCOUNT_LOGIN "|select_all=false"); + CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_CREATEACCOUNT_LOGIN "|select_all=false"); } diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 21662969d..f4683d72e 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -1665,13 +1665,13 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason) switch(tpContext) { case R2::TPContext_Mainland: - CInterfaceManager::getInstance()->runActionHandler("return_to_mainland", NULL); + CAHManager::getInstance()->runActionHandler("return_to_mainland", NULL); break; case R2::TPContext_Edit: - CInterfaceManager::getInstance()->runActionHandler("r2ed_stop_test", NULL); + CAHManager::getInstance()->runActionHandler("r2ed_stop_test", NULL); break; case R2::TPContext_IslandOwner: - CInterfaceManager::getInstance()->runActionHandler("r2_stop_live", NULL); + CAHManager::getInstance()->runActionHandler("r2_stop_live", NULL); break; default: break; diff --git a/code/ryzom/client/src/outpost_manager.cpp b/code/ryzom/client/src/outpost_manager.cpp index 1f6deb320..31d0fd647 100644 --- a/code/ryzom/client/src/outpost_manager.cpp +++ b/code/ryzom/client/src/outpost_manager.cpp @@ -105,7 +105,7 @@ void COutpostManager::update() CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Force the neutral choose - pIM->runActionHandler("outpost_pvp_join", NULL, "neutral"); + CAHManager::getInstance()->runActionHandler("outpost_pvp_join", NULL, "neutral"); // close the window CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal")); diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 24b0cd302..620ffd6c9 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -5281,7 +5281,7 @@ void CEditor::onTestModeConnected() CHECK_EDITOR // TODO nico : change the name of the function : should rather be 'onAnimationModeConnected' // start as a GM - getUI().runActionHandler("r2ed_anim_dm_mode", NULL, ""); + CAHManager::getInstance()->runActionHandler("r2ed_anim_dm_mode", NULL, ""); _DMC->CDynamicMapClient::onTestModeConnected(); } @@ -7394,7 +7394,7 @@ class CAHInviteCharacter : public IActionHandler CHECK_EDITOR CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("leave_modal", pCaller, ""); + CAHManager::getInstance()->runActionHandler("leave_modal", pCaller, ""); if(pCaller) { @@ -7429,11 +7429,11 @@ class CAHInviteCharacter : public IActionHandler if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial")); - pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial"); } else if(sessionBrowser._LastInvokeResult == 12) { - pIM->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); + CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer"); } geb->setInputString(ucstring("")); diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index cbbcf6283..ccbc4ee7a 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -141,7 +141,7 @@ void CToolCreateEntity::commit(const NLMISC::CVector &createPosition, float crea // prevent newly created ghost to be removed twice ... removeGhostSlot(); // re set this tool to generate a new entity look - getUI().runActionHandler("r2ed_create_entity", NULL, "PaletteId=" + _PaletteId); + CAHManager::getInstance()->runActionHandler("r2ed_create_entity", NULL, "PaletteId=" + _PaletteId); } } @@ -616,7 +616,7 @@ void CToolCreateEntity::updateAfterRender() { commitArray(); CTool::TSmartPtr hold(this); - getUI().runActionHandler("r2ed_create_entity", NULL, "PaletteId="+_PaletteId); + CAHManager::getInstance()->runActionHandler("r2ed_create_entity", NULL, "PaletteId="+_PaletteId); return; } break; @@ -825,7 +825,7 @@ class CAHR2EDToggleDrawArray : public IActionHandler CToolCreateEntity *tce = dynamic_cast(getEditor().getCurrentTool()); if (tce) { - im->runActionHandler("r2ed_create_entity", NULL, "PaletteId=" + tce->getPaletteId()); + CAHManager::getInstance()->runActionHandler("r2ed_create_entity", NULL, "PaletteId=" + tce->getPaletteId()); } } } diff --git a/code/ryzom/client/src/session_browser_impl.cpp b/code/ryzom/client/src/session_browser_impl.cpp index b408686aa..856d1f204 100644 --- a/code/ryzom/client/src/session_browser_impl.cpp +++ b/code/ryzom/client/src/session_browser_impl.cpp @@ -222,7 +222,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls) CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text")); if (pVT != NULL) pVT->setText(CI18N::get("uiRingWarningFreeTrial")); - pIM->runActionHandler("enter_modal", NULL, "group=ui:interface:warning_free_trial"); + CAHManager::getInstance()->runActionHandler("enter_modal", NULL, "group=ui:interface:warning_free_trial"); } return 0; @@ -326,7 +326,7 @@ void CSessionBrowserImpl::on_joinSessionResult(NLNET::TSockId /* from */, uint32 if (result == 0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->runActionHandler("on_connect_to_shard", NULL, string("cookie=")+NetMngr.getLoginCookie().toString()+"|fsAddr="+shardAddr); + CAHManager::getInstance()->runActionHandler("on_connect_to_shard", NULL, string("cookie=")+NetMngr.getLoginCookie().toString()+"|fsAddr="+shardAddr); } } diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index 08d12fd0d..f91e22eb4 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -1571,12 +1571,12 @@ void CUserEntity::moveToAction(CEntityCL *ent) // Quartering case CUserEntity::Quarter: if((ent->properties()).harvestable()) - IM->runActionHandler("context_quartering", 0); + CAHManager::getInstance()->runActionHandler("context_quartering", 0); break; // Loot case CUserEntity::Loot: if((ent->properties()).lootable()) - IM->runActionHandler("context_loot", 0); + CAHManager::getInstance()->runActionHandler("context_loot", 0); break; // Pick Up case CUserEntity::PickUp: @@ -1587,57 +1587,57 @@ void CUserEntity::moveToAction(CEntityCL *ent) break; // Trade Item case CUserEntity::TradeItem: - IM->runActionHandler("context_trade_item", 0); + CAHManager::getInstance()->runActionHandler("context_trade_item", 0); break; // Trade Phrase case CUserEntity::TradePhrase: - IM->runActionHandler("context_trade_phrase", 0); + CAHManager::getInstance()->runActionHandler("context_trade_phrase", 0); break; // Trade Pact case CUserEntity::TradePact: - IM->runActionHandler("context_trade_pact", 0); + CAHManager::getInstance()->runActionHandler("context_trade_pact", 0); break; // Mission case CUserEntity::Mission: { string param = toString("id=%d", _MoveToMissionId); - IM->runActionHandler("mission_option", 0, param); + CAHManager::getInstance()->runActionHandler("mission_option", 0, param); } break; // Dynamic Mission case CUserEntity::DynamicMission: - IM->runActionHandler("context_dynamic_mission", 0); + CAHManager::getInstance()->runActionHandler("context_dynamic_mission", 0); break; // Static Mission case CUserEntity::StaticMission: - IM->runActionHandler("context_choose_mission", 0); + CAHManager::getInstance()->runActionHandler("context_choose_mission", 0); break; // Mission case CUserEntity::MissionRing: { string param = toString("id=%d", _MoveToMissionId); - IM->runActionHandler("mission_ring", 0, param); + CAHManager::getInstance()->runActionHandler("mission_ring", 0, param); } break; // Create Guild case CUserEntity::CreateGuild: - IM->runActionHandler("context_create_guild", 0); + CAHManager::getInstance()->runActionHandler("context_create_guild", 0); break; // News case CUserEntity::News: - IM->runActionHandler("context_talk", 0); + CAHManager::getInstance()->runActionHandler("context_talk", 0); break; // Trade Teleport case CUserEntity::TradeTeleport: - IM->runActionHandler("context_trade_teleport", 0); + CAHManager::getInstance()->runActionHandler("context_trade_teleport", 0); break; // Trade Faction items case CUserEntity::TradeFaction: - IM->runActionHandler("context_trade_faction", 0); + CAHManager::getInstance()->runActionHandler("context_trade_faction", 0); break; // Trade Cosmetic case CUserEntity::TradeCosmetic: - IM->runActionHandler("context_trade_cosmetic", 0); + CAHManager::getInstance()->runActionHandler("context_trade_cosmetic", 0); break; // Talk case CUserEntity::Talk: @@ -1658,7 +1658,7 @@ void CUserEntity::moveToAction(CEntityCL *ent) } // WebPage case CUserEntity::WebPage: - IM->runActionHandler("context_web_page", 0); + CAHManager::getInstance()->runActionHandler("context_web_page", 0); break; // Outpost case CUserEntity::Outpost: @@ -2248,7 +2248,7 @@ void CUserEntity::setDead() // virtual //CInterfaceManager * pIM = CInterfaceManager::getInstance(); if( pIM ) { - pIM->runActionHandler("set",NULL,"dblink=UI:VARIABLES:DEATH_WARNING_WANTED|value=1"); + CAHManager::getInstance()->runActionHandler("set",NULL,"dblink=UI:VARIABLES:DEATH_WARNING_WANTED|value=1"); } }// setDead // @@ -3746,7 +3746,7 @@ void CUserEntity::CSkillPointsObserver::update(ICDBNode* node ) spTitle= CI18N::get(toString("uiSkillPointsBold%d",SpType)); // run the popup - pIM->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle.toUtf8()); + CAHManager::getInstance()->runActionHandler("message_popup", NULL, "text1="+deltaStr+"|text0="+spTitle.toUtf8()); // Context help contextHelp ("skill_point"); From 891859406fd2c05c36888edbf996d282e88cb03f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 1 Jun 2012 03:41:44 +0200 Subject: [PATCH 041/339] CHANGED: #1471 CViewRenderer is now a separate Simpleton and not a part of CInterfaceManager. --- code/ryzom/client/src/cursor_functions.cpp | 4 +- code/ryzom/client/src/decal.cpp | 2 +- .../src/interface_v3/action_handler_help.cpp | 4 +- .../src/interface_v3/action_handler_misc.cpp | 6 +- .../client/src/interface_v3/ctrl_button.cpp | 22 +++--- .../client/src/interface_v3/ctrl_col_pick.cpp | 10 +-- .../client/src/interface_v3/ctrl_polygon.cpp | 2 +- .../client/src/interface_v3/ctrl_quad.cpp | 8 +- .../client/src/interface_v3/ctrl_scroll.cpp | 10 +-- .../src/interface_v3/ctrl_sheet_selection.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 4 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 40 +++++----- .../src/interface_v3/dbgroup_build_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../dbgroup_list_sheet_bonus_malus.cpp | 4 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../client/src/interface_v3/dbview_bar.cpp | 4 +- .../client/src/interface_v3/dbview_bar3.cpp | 4 +- .../client/src/interface_v3/dbview_digit.cpp | 4 +- .../src/interface_v3/group_container.cpp | 24 +++--- .../client/src/interface_v3/group_editbox.cpp | 8 +- .../client/src/interface_v3/group_frame.cpp | 4 +- .../client/src/interface_v3/group_html.cpp | 6 +- .../src/interface_v3/group_in_scene.cpp | 8 +- .../interface_v3/group_in_scene_bubble.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 4 +- .../client/src/interface_v3/group_map.cpp | 4 +- .../client/src/interface_v3/group_menu.cpp | 16 ++-- .../client/src/interface_v3/group_modal.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 4 +- .../client/src/interface_v3/group_table.cpp | 6 +- .../client/src/interface_v3/group_tree.cpp | 6 +- .../interface_v3/input_handler_manager.cpp | 4 +- .../src/interface_v3/interface_3d_scene.cpp | 18 ++--- .../src/interface_v3/interface_element.cpp | 6 +- .../src/interface_v3/interface_group.cpp | 10 +-- .../src/interface_v3/interface_manager.cpp | 73 ++++++++++--------- .../src/interface_v3/interface_manager.h | 5 +- .../src/interface_v3/interface_options.cpp | 12 +-- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/inventory_manager.cpp | 4 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../client/src/interface_v3/view_bitmap.cpp | 14 ++-- .../src/interface_v3/view_bitmap_combo.cpp | 6 +- .../src/interface_v3/view_bitmap_faber_mp.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 8 +- .../client/src/interface_v3/view_polygon.cpp | 2 +- .../client/src/interface_v3/view_quad.cpp | 8 +- .../client/src/interface_v3/view_radar.cpp | 4 +- .../client/src/interface_v3/view_renderer.cpp | 42 ++++++----- .../client/src/interface_v3/view_renderer.h | 21 ++++-- .../client/src/interface_v3/view_text.cpp | 6 +- code/ryzom/client/src/main_loop.cpp | 4 +- .../r2/displayer_visual_activity_sequence.cpp | 2 +- code/ryzom/client/src/r2/island_collision.cpp | 4 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- code/ryzom/client/src/r2/tool.cpp | 6 +- 58 files changed, 256 insertions(+), 243 deletions(-) diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index ef9c5fcb3..64df4e5d2 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -244,7 +244,7 @@ void checkUnderCursor() return; // No Op if screen minimized - if(IM->getViewRenderer().isMinimized()) + if(CViewRenderer::getInstance()->isMinimized()) return; // Get the pointer position (in pixel) @@ -258,7 +258,7 @@ void checkUnderCursor() if(x < 0 || y <0) return; uint32 w, h; - CViewRenderer &viewRender = IM->getViewRenderer(); + CViewRenderer &viewRender = *CViewRenderer::getInstance(); viewRender.getScreenSize(w, h); if(x>=(sint32)w || y>=(sint32)h) return; diff --git a/code/ryzom/client/src/decal.cpp b/code/ryzom/client/src/decal.cpp index 6d7020bcb..753850c55 100644 --- a/code/ryzom/client/src/decal.cpp +++ b/code/ryzom/client/src/decal.cpp @@ -190,7 +190,7 @@ void CDecal::setTexture(const std::string &fileName, bool clampU, bool clamp if (getTextureFileName() != fileName) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); UTexture *tex = vr.getGlobalTexture(fileName); if (tex != NULL) { diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 6a93a9da3..7812df510 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -464,7 +464,7 @@ void CInterfaceHelp::resetWindowPos(sint y) sint maxHelpWindow= (sint)_InfoWindows.size(); uint32 w, h; - pIM->getViewRenderer().getScreenSize(w,h); + CViewRenderer::getInstance()->getScreenSize(w,h); // For all windows, reset pos for(uint i=0;i<(uint)maxHelpWindow;i++) @@ -3978,7 +3978,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { #ifdef NL_OS_WINDOWS - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if (Driver) { HWND wnd = (HWND) Driver->getDisplay(); diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 050ac1cd1..082669574 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -520,7 +520,7 @@ CCameraBackup setupCameraForScreenshot(UScene &scene, uint left, uint right, uin // Build a viewport CViewport viewport; - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); viewport.init (0, 0, (float)(right-left)/Driver->getWindowWidth(),(float)(bottom-top)/Driver->getWindowHeight()); // Activate all this @@ -553,7 +553,7 @@ void renderSceneScreenShot (uint left, uint right, uint top, uint bottom, uint s void getBuffer (CBitmap &btm) { - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); // if (ClientCfg.ScreenShotWidth && ClientCfg.ScreenShotHeight) { @@ -613,7 +613,7 @@ bool screenshotZBuffer(const std::string &filename) std::string ext = filename.substr(pos+1); std::vector z; - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); Driver->getZBuffer(z); diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index cbccfc131..001f83c2b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -107,7 +107,7 @@ void CCtrlButton::draw () CRGBA color; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA globalColor= pIM->getGlobalColorForContent(); // *** Detect Over @@ -204,7 +204,7 @@ void CCtrlButton::draw () if (!_Scale) { - pIM->getViewRenderer().getTextureSizeFromId (nTxId, txw, txh); + CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh); if (_Align&1) x = x + _WReal - txw; if (_Align&2) @@ -249,7 +249,7 @@ void CCtrlButton::updateCoords() if (!_Scale) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 txw, txh; rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); _W = txw; @@ -262,7 +262,7 @@ void CCtrlButton::updateCoords() void CCtrlButton::setTexture(const std::string&name) { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureIdNormal.setTexture(name.c_str()); } @@ -270,7 +270,7 @@ void CCtrlButton::setTexture(const std::string&name) void CCtrlButton::setTexturePushed(const std::string&name) { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureIdPushed.setTexture(name.c_str()); } @@ -278,7 +278,7 @@ void CCtrlButton::setTexturePushed(const std::string&name) void CCtrlButton::setTextureOver(const std::string&name) { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureIdOver.setTexture(name.c_str()); } @@ -286,7 +286,7 @@ void CCtrlButton::setTextureOver(const std::string&name) std::string CCtrlButton::getTexture() const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdNormal); } @@ -294,7 +294,7 @@ std::string CCtrlButton::getTexture() const std::string CCtrlButton::getTexturePushed() const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdPushed); } @@ -302,7 +302,7 @@ std::string CCtrlButton::getTexturePushed() const std::string CCtrlButton::getTextureOver() const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdOver); } @@ -311,7 +311,7 @@ sint32 CCtrlButton::getMaxUsedW() const { sint32 txw, txh; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); return txw; } @@ -326,7 +326,7 @@ sint32 CCtrlButton::getMinUsedW() const void CCtrlButton::fitTexture() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(_TextureIdNormal, w, h); setW(w); diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index 6e38caf46..d158b0280 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -41,7 +41,7 @@ CCtrlColPick::~CCtrlColPick() if (_Texture>=0) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.deleteTexture (_Texture); } } @@ -56,7 +56,7 @@ bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) // Read textures prop = (char*) xmlGetProp( node, (xmlChar*)"texture" ); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if(prop) { string sTmp = NLMISC::strlwr((const char*)prop); @@ -84,7 +84,7 @@ bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) void CCtrlColPick::updateCoords() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 txw, txh; rVR.getTextureSizeFromId (_Texture, txw, txh); _W = txw; @@ -96,7 +96,7 @@ void CCtrlColPick::updateCoords() void CCtrlColPick::draw() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col = CRGBA(255,255,255,(uint8)pIM->getGlobalColor().A); @@ -194,7 +194,7 @@ void CCtrlColPick::selectColor (sint32 x, sint32 y) CRGBA CCtrlColPick::getColor (sint32 x, sint32 y) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (x < 0) x = 0; if (y < 0) y = 0; diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp index 9bcc2411f..08d1fb691 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp @@ -149,7 +149,7 @@ void CCtrlPolygon::draw() if (_Tris.empty()) return; if (!_Parent) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); if (_Touched) { _RealTris.clear(); diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp index e517342bf..75886ef82 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp @@ -61,7 +61,7 @@ void CCtrlQuad::draw() H_AUTO(Rz_CCtrlQuad_draw) nlassert(_Parent); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col; if(getModulateGlobalColor()) @@ -297,7 +297,7 @@ void CCtrlQuad::setTexture(const std::string &texName) { H_AUTO(Rz_CCtrlQuad_setTexture) // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureId.setTexture(texName.c_str()); } @@ -306,7 +306,7 @@ std::string CCtrlQuad::getTexture() const { H_AUTO(Rz_CCtrlQuad_getTexture) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId (_TextureId); } @@ -357,7 +357,7 @@ void CCtrlQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPo H_AUTO(Rz_CCtrlQuad_setQuad) NLMISC::CVector pos = srcPos; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); if (angle == 0.f) diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 59c5ca636..d433b2a07 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -227,7 +227,7 @@ void CCtrlScroll::updateCoords() if (_Target->getActive()) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId (_TxIdB, w, h); @@ -410,7 +410,7 @@ void CCtrlScroll::updateCoords() void CCtrlScroll::draw() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col = pIM->getGlobalColorForContent(); if (_Target) @@ -694,7 +694,7 @@ sint32 CCtrlScroll::moveTrackY (sint32 dy) void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdB = rVR.getTextureIdFromName(txName); } @@ -702,7 +702,7 @@ void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) void CCtrlScroll::setTextureMiddle (const std::string &txName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdM = rVR.getTextureIdFromName(txName); } @@ -710,7 +710,7 @@ void CCtrlScroll::setTextureMiddle (const std::string &txName) void CCtrlScroll::setTextureTopOrRight (const std::string &txName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdT = rVR.getTextureIdFromName(txName); } diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp index 7f7dee1d7..f4c9b5f9f 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp @@ -24,7 +24,7 @@ void CSheetSelectionGroup::setTexture(const std::string &texName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureIndex = rVR.getTextureIdFromName(texName); rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight); } diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index ad791b5c1..faa74d213 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -70,7 +70,7 @@ bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { CXMLAutoPtr prop; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); //try to get props that can be inherited from groups //if a property is not defined, try to find it in the parent group. @@ -273,7 +273,7 @@ void CCtrlTextButton::draw () CRGBA color; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA globalColor= pIM->getGlobalColorForContent(); // *** Detect Over diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index d00d0ba77..b4af18ea7 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -318,7 +318,7 @@ CCtrlSheetInfo::CCtrlSheetInfo() void CDBCtrlSheet::release () { - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if (Driver) Driver->deleteMaterial(_GuildMat); @@ -367,7 +367,7 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr { string TxName = (const char *) prop; TxName = strlwr (TxName); - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _DispNoSheetBmpId = rVR.getTextureIdFromName (TxName); } @@ -558,7 +558,7 @@ CDBCtrlSheet::CDBCtrlSheet(const TCtorParam ¶m) // ---------------------------------------------------------------------------- CDBCtrlSheet::~CDBCtrlSheet() { - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if (_GuildBack) { @@ -656,7 +656,7 @@ void CDBCtrlSheet::initSheet(const std::string &dbBranchId, const CCtrlSheetInfo // get over for spell CInterfaceManager *pIM = CInterfaceManager::getInstance(); - _TextureIdOver = pIM->getViewRenderer().getTextureIdFromName ("w_slot_spell_over.tga"); + _TextureIdOver = CViewRenderer::getInstance()->getTextureIdFromName ("w_slot_spell_over.tga"); } // Init size. @@ -682,7 +682,7 @@ void CDBCtrlSheet::initSheetFast( const std::string &dbParentBranchId, int sheet // get over for spell CInterfaceManager *pIM = CInterfaceManager::getInstance(); - _TextureIdOver = pIM->getViewRenderer().getTextureIdFromName ("w_slot_spell_over.tga"); + _TextureIdOver = CViewRenderer::getInstance()->getTextureIdFromName ("w_slot_spell_over.tga"); } // Init size. @@ -944,7 +944,7 @@ uint CDBCtrlSheet::getInventorySlot( const string &dbBranchId ) void CDBCtrlSheet::initSheetSize() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // If the user type is auto, then select always item slot. if(_Type==SheetType_Auto) { @@ -1030,7 +1030,7 @@ void CDBCtrlSheet::updateCoords () void CDBCtrlSheet::updateIconSize() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (_DispSheetBmpId != -1) { rVR.getTextureSizeFromId(_DispSheetBmpId, _IconW, _IconH); @@ -1062,7 +1062,7 @@ void CDBCtrlSheet::setupPact() if (_LastSheetId != sheet || _NeedSetup) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _LastSheetId = sheet; CSheetId sheetId(sheet); @@ -1105,7 +1105,7 @@ void CDBCtrlSheet::setupItem () // If this is the same sheet, need to resetup if (_LastSheetId != sheet || _NeedSetup) { - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _NeedSetup= false; _LastSheetId = sheet; @@ -1324,7 +1324,7 @@ void CDBCtrlSheet::setupMission() CMissionIconSheet *pMIS = (CMissionIconSheet*)pES; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _DispBackBmpId = rVR.getTextureIdFromName(pMIS->MainIconBg); _DispSheetBmpId = rVR.getTextureIdFromName(pMIS->MainIconFg); @@ -1375,7 +1375,7 @@ void CDBCtrlSheet::setupGuildFlag () sint8 nLastGuildBack = (sint8)(_MacroID&15); // 4 bits en pos 0 sint8 nLastGuildSymbol = (sint8)((_MacroID>>4)&63); // 6 bits en pos 4 - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if (_GuildMat.empty()) { @@ -1454,7 +1454,7 @@ void CDBCtrlSheet::setupDisplayAsSBrick(sint32 sheet, sint32 optSheet) { // Setup with the param sheet CSBrickManager *pBM = CSBrickManager::getInstance(); - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CSBrickSheet *pBR = pBM->getBrick (CSheetId(sheet)); CSBrickSheet *pBROpt = pBM->getBrick (CSheetId(optSheet)); @@ -1662,7 +1662,7 @@ void CDBCtrlSheet::setupOutpostBuilding() // If this is the same sheet, need to resetup if (_LastSheetId != sheet || _NeedSetup) { - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _NeedSetup= false; _LastSheetId = sheet; @@ -1747,7 +1747,7 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar // Use the optString for the Macro name _OptString = strlwr(_OptString); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _CharBitmaps.clear(); @@ -1804,7 +1804,7 @@ void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar void CDBCtrlSheet::displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, CRGBA color) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); for (uint i = 0; i < _CharBitmaps.size(); ++i) { @@ -1820,7 +1820,7 @@ void CDBCtrlSheet::draw() H_AUTO( RZ_Interface_CDBCtrlSheet_draw ) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA color = CRGBA(255,255,255,255); if (_Type != SheetType_Macro) @@ -2091,7 +2091,7 @@ static inline CRGBA fastMulRGB(CRGBA sheetColor, CRGBA iconColor) void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelectionBorder /*= true*/) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // The sheet is the slot-2 sint32 wSheet= _WReal-2; sint32 hSheet= _HReal-2; @@ -2548,7 +2548,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti sint32 CDBCtrlSheet::drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 /* hSheet */, CRGBA color, sint32 value, bool rightAlign) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 wDigit= rVR.getFigurTextureW(); sint32 hDigit= rVR.getFigurTextureH(); @@ -3927,7 +3927,7 @@ void CDBCtrlSheet::setInvertGuildSymbol(bool b) void CDBCtrlSheet::setSlot(const std::string &textureName) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _DispSlotBmpId = rVR.getTextureIdFromName (textureName); rVR.getTextureSizeFromId (_DispSlotBmpId, _W, _H); _DrawSlot = true; @@ -4262,7 +4262,7 @@ void CDBCtrlSheet::updateArmourColor(sint8 col) if(_ArmourColorIndex>=0 && _ArmourColorIndex<=7) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CViewRenderer &rVR= pIM->getViewRenderer(); + CViewRenderer &rVR= *CViewRenderer::getInstance(); // if the BMP have not been correctly setuped if(!_ArmourColorBmpOk) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index e3b2fb407..d6ee00ef1 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -94,7 +94,7 @@ bool CDBGroupBuildPhrase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) CInterfaceManager *pIM= CInterfaceManager::getInstance(); // Init the disabled texture id - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureIdSlotDisabled= rVR.getTextureIdFromName ("w_slot_brick_disabled.tga"); // Create now (before sons ctrl sheet parsing) the variables diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index dc6a9dd91..eb539384c 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -141,7 +141,7 @@ bool CDBGroupListSheet::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) } // get item size. - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 dispSlotBmpId = 0; switch(_CtrlInfo._Type) { diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp index 0b5d1f985..0130aa703 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_bonus_malus.cpp @@ -56,7 +56,7 @@ bool CDBGroupListSheetBonusMalus::parse (xmlNodePtr cur, CInterfaceGroup *parent if (prop) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextId= rVR.getTextureIdFromName ((const char *)prop); } @@ -86,7 +86,7 @@ void CDBGroupListSheetBonusMalus::draw () CDBGroupListSheet::draw(); // CInterfaceManager *pIM= CInterfaceManager::getInstance(); -// CViewRenderer &rVR= pIM->getViewRenderer(); +// CViewRenderer &rVR= *CViewRenderer::getInstance(); // sint32 drl= getRenderLayer()+1; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 2dcea9d7a..d3f2e75b7 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -125,7 +125,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) } // get item size. - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 dispSlotBmpId = 0; switch(_CtrlInfo._Type) { diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index 6f4bf906d..a9235b435 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -120,7 +120,7 @@ void CDBViewBar::setType (TViewBar vb) // Get the Height Size. CInterfaceManager *pIM= CInterfaceManager::getInstance(); sint32 wBar; - pIM->getViewRenderer().getTextureSizeFromId(_TextureId, wBar, _HBar); + CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, wBar, _HBar); } // ---------------------------------------------------------------------------- @@ -180,7 +180,7 @@ void CDBViewBar::draw () _Slot.draw(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); color.A = (uint8)(((sint32)color.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp index 490952fb9..73f261dde 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp @@ -141,7 +141,7 @@ void CDBViewBar3::updateCoords () // get the height of the texture sint32 dummy; - CInterfaceManager::getInstance()->getViewRenderer().getTextureSizeFromId(_TextureId, dummy, _BarH); + CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, dummy, _BarH); CViewBitmap::updateCoords(); } @@ -162,7 +162,7 @@ void CDBViewBar3::draw () _Slot.draw(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA gColor = pIM->getGlobalColorForContent(); if (_Mini) diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.cpp b/code/ryzom/client/src/interface_v3/dbview_digit.cpp index 86e79783d..683662fef 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_digit.cpp @@ -45,7 +45,7 @@ bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) return false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // link to the db CXMLAutoPtr ptr; @@ -103,7 +103,7 @@ void CDBViewDigit::updateCoords() void CDBViewDigit::draw () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 wDigit= rVR.getFigurTextureW(); sint32 hDigit= rVR.getFigurTextureH(); diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index bc442c0f4..f5519bcd5 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -61,7 +61,7 @@ bool CGroupContainer::_ValidateCanDeactivate = true; #ifdef DRAW_GC_TEST_QUADS static void drawGCTestQuad(sint renderLayer, sint32 xreal, sint32 yreal, sint32 wreal, sint32 hreal, CRGBA color) { - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if(rVR.isMinimized()) return; sint32 x, y, w, h; @@ -348,7 +348,7 @@ sint32 CCtrlResizer::resizeW (sint32 dx) NLMISC::clamp(clippedNewW, WMin, WMax); // clip by screen uint32 sw, sh; - CViewRenderer &vr = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.getScreenSize(sw, sh); if (_Parent->getPosRef() & Hotspot_xR) { @@ -405,7 +405,7 @@ sint32 CCtrlResizer::resizeH (sint32 dy) // clip by screen uint32 sw, sh; - CViewRenderer &vr = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.getScreenSize(sw, sh); if (_Parent->getPosRef() & Hotspot_Tx) { @@ -483,7 +483,7 @@ void CCtrlMover::draw () // No Op if window is minimized CInterfaceManager *pIM= CInterfaceManager::getInstance(); - if(pIM->getViewRenderer().isMinimized()) + if(CViewRenderer::getInstance()->isMinimized()) return; // draw insertion position if moving in parent list @@ -491,14 +491,14 @@ void CCtrlMover::draw () { COptionsContainerInsertion *options = getInsertionOptions(); if (!options) return; - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 oldSciX, oldSciY, oldSciW, oldSciH; rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); uint32 sw, sh; rVR.getScreenSize(sw, sh); rVR.setClipWindow (0, 0, (sint32) sw, (sint32) sh); CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); // CGroupContainer *gc = dynamic_cast(_Parent); if (!gc) return; @@ -807,7 +807,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { // clip, in real coords space uint32 wScreen, hScreen; - pIM->getViewRenderer().getScreenSize(wScreen, hScreen); + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); x+= _MoveDeltaXReal; y+= _MoveDeltaYReal; @@ -1067,7 +1067,7 @@ void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceMan sint32 newX = gc->getXReal() + deltaX; sint32 newY = gc->getYReal() + deltaY; uint32 wScreen, hScreen; - pIM->getViewRenderer().getScreenSize(wScreen, hScreen); + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); clamp(newX, 0, (sint32)wScreen - gc->getWReal()); clamp(newY, 0, (sint32)hScreen - gc->getHReal()); // move window @@ -1516,7 +1516,7 @@ void CGroupContainer::updateCoords() { // Clip by screen uint32 sw, sh; - CViewRenderer &vr = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.getScreenSize(sw, sh); // ensure the maxH is > minH and < sh (prioritary > minH, in case of shgetViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.getScreenSize(sw, sh); if((sint32)sw>_PopupMinW && _W>(sint32)sw) _W= sw; if((sint32)sh>_PopupMinH && _H>(sint32)sh) _H= sh; @@ -1725,7 +1725,7 @@ void CGroupContainer::updateCoords() { // test if must clip uint32 wScreen, hScreen; - CInterfaceManager::getInstance()->getViewRenderer().getScreenSize(wScreen, hScreen); + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); if (_WReal <= (sint32) wScreen && _HReal <= (sint32) hScreen) { sint32 newX = _XReal; @@ -1849,7 +1849,7 @@ void CGroupContainer::draw () makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); // Draw the container - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col = pIM->getGlobalColor(); bool bGrayed = isGrayed(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index ea5811b9b..0615a6428 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -109,7 +109,7 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) return false; CXMLAutoPtr prop; // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); if (! CInterfaceGroup::parse(cur,parentGroup) ) { @@ -219,7 +219,7 @@ void CGroupEditBox::draw () { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // /*CRGBA col; col.modulateFromColor(CRGBA(64,64,64,255), pIM->getGlobalColorForContent()); @@ -335,7 +335,7 @@ void CGroupEditBox::copy() stopParentBlink(); // get the selection and copy it - if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->copyTextToClipboard(getSelection())) + if (CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(getSelection())) nlinfo ("Chat input was copied in the clipboard"); } @@ -353,7 +353,7 @@ void CGroupEditBox::paste() ucstring sString; - if (CInterfaceManager::getInstance()->getViewRenderer().getDriver()->pasteTextFromClipboard(sString)) + if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString)) { // append string now appendStringFromClipboard(sString); diff --git a/code/ryzom/client/src/interface_v3/group_frame.cpp b/code/ryzom/client/src/interface_v3/group_frame.cpp index 54b95476e..6b4782dab 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.cpp +++ b/code/ryzom/client/src/interface_v3/group_frame.cpp @@ -72,7 +72,7 @@ bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) // Get the borders texture _DispTypeDefined= false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" ); CInterfaceOptions *pIO = NULL; @@ -160,7 +160,7 @@ void CGroupFrame::draw () if (_DisplayFrame) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // get global color CRGBA col; diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index c566fd477..640ce8def 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -2737,7 +2737,7 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ { // search in the compressed texture CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(normal); if(id == -1) { @@ -2757,7 +2757,7 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ { // search in the compressed texture CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(pushed); if(id == -1) { @@ -3031,7 +3031,7 @@ bool CGroupHTML::lookupLocalFile (string &result, const char *url, bool isUrl) { // Is it a texture in the big texture ? CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getViewRenderer().getTextureIdFromName (result) >= 0) + if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0) { return true; } diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index bad4e4236..ba1023f48 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -78,7 +78,7 @@ void CGroupInScene::computeWindowPos(sint32 &newX, sint32 &newY, CVector &newPro if(getActive()) { - CViewRenderer &pVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &pVR = *CViewRenderer::getInstance(); nlassert(isValidDouble(Position.x) && isValidDouble(Position.y) && isValidDouble(Position.z)); CVector tmp = MainSceneViewMatrix * Position; if (tmp.y>=0.001) @@ -86,8 +86,8 @@ void CGroupInScene::computeWindowPos(sint32 &newX, sint32 &newY, CVector &newPro tmp = pVR.getFrustum().projectZ (tmp); // Get the width and height - tmp.x *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowWidth(); - tmp.y *= (float)CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getWindowHeight(); + tmp.x *= (float)CViewRenderer::getInstance()->getDriver()->getWindowWidth(); + tmp.y *= (float)CViewRenderer::getInstance()->getDriver()->getWindowHeight(); // position without offset, in float newProjCenter.x= tmp.x; @@ -156,7 +156,7 @@ void CGroupInScene::draw() if (_ProjCenter.z > NearDrawClip) { - CViewRenderer &pVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &pVR = *CViewRenderer::getInstance(); // Set the current Z, and projCenter / scale if(_UserScale) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index cd7ee194b..b5734ce35 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -667,7 +667,7 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont if (target) { // Find a position - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); const uint width = Driver->getWindowWidth(); const uint height = Driver->getWindowHeight(); h = (target->getXReal() < ((sint)width-target->getXReal()-target->getWReal()))?"l":"r"; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index c8d45b576..fad80e694 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -566,12 +566,12 @@ void CGroupList::updateCoords() void CGroupList::draw () { // TEMP TEMP - //CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + //CViewRenderer &rVR = *CViewRenderer::getInstance(); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0, 255, 0, 255) ); if (_Over) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (CWidgetManager::getInstance()->getModalWindow() == NULL) { diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 20429edb0..125183f5a 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -257,7 +257,7 @@ float CGroupMap::getActualMaxScale() const void CGroupMap::CPolyButton::drawPolyButton() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); float oow, ooh; rVR.getScreenOOSize(oow, ooh); @@ -1470,7 +1470,7 @@ void CGroupMap::draw() sint32 oldSciX, oldSciY, oldSciW, oldSciH; makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); uint8 alpha = im->getGlobalColorForContent().A; updateScale(); diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 7635a5344..2ffd1d95d 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -208,7 +208,7 @@ void CGroupSubMenu::initOptions(CInterfaceGroup *parent) { _SelectionView = new CViewBitmap(CViewBase::TCtorParam()); // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _SelectionView->setParent (this); _SelectionView->setActive (false); _SelectionView->setTexture ("blank.tga"); @@ -437,7 +437,7 @@ void CGroupSubMenu::updateCoords () setY(_GroupMenu->SpawnMouseY); CGroupFrame::updateCoords(); - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 screenW, screenH; rVR.getScreenSize(screenW, screenH); if ((_XReal+_WReal) > (sint32)screenW) @@ -458,7 +458,7 @@ void CGroupSubMenu::updateCoords () CGroupFrame::updateCoords(); // get screen size - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 screenW, screenH; rVR.getScreenSize(screenW, screenH); @@ -673,7 +673,7 @@ void CGroupSubMenu::updateCoords () _SubMenus[RALineNb]->setParentPos (this); // According to mouse position, set the sub menu on the left or right, begin at top or bottom - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 screenW, screenH; rVR.getScreenSize(screenW, screenH); if ((_GroupMenu->SpawnMouseX <= ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY <= ((sint32)screenH/2))) @@ -875,7 +875,7 @@ void CGroupSubMenu::checkCoords() (yMouse <= (_YReal+ _HReal)))) _Selected= -1; -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); // Highlight (background under the selection) if (_Selected != -1) @@ -2060,7 +2060,7 @@ void CGroupMenu::recurseDraw(CGroupSubMenu *pSubMenu) if (pGSM != NULL) { recurseDraw(pGSM); - CInterfaceManager::getInstance()->getViewRenderer().flush(); + CViewRenderer::getInstance()->flush(); } } } @@ -2071,7 +2071,7 @@ void CGroupMenu::draw () if (!_Active) return; // TEMP TEMP - //CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + //CViewRenderer &rVR = *CViewRenderer::getInstance(); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(255, 0, 0, 255) ); _RootMenu->_Active = true; @@ -2105,7 +2105,7 @@ void CGroupMenu::setActive (bool state) { if (SpawnOnMousePos) { - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 w,h; rVR.getScreenSize(w,h); setW(w); diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/ryzom/client/src/interface_v3/group_modal.cpp index bbd6a8015..78aad5ed4 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal.cpp @@ -100,7 +100,7 @@ void CGroupModal::updateCoords () if(SpawnOnMousePos) { // Special for menu for instance: If the size is bigger or equal to the screen, keep 0, because will be clipped just after - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 w,h; rVR.getScreenSize(w,h); if(_W>=(sint32)w && _H>=(sint32)h) diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index e600638a4..d1daf9ce8 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -766,12 +766,12 @@ void CGroupParagraph::checkCoords () void CGroupParagraph::draw () { // TEMP TEMP - //CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + //CViewRenderer &rVR = *CViewRenderer::getInstance(); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); if (_Over) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (CWidgetManager::getInstance()->getModalWindow() == NULL) { diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 378c33be5..b4ae09527 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -195,7 +195,7 @@ void CGroupCell::draw () if (DebugUICell) { // Draw cell - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal-1, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); @@ -205,7 +205,7 @@ void CGroupCell::draw () // Draw the background if (_UserTexture || BgColor.A != 0) { - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (_UserTexture) { CRGBA col; @@ -950,7 +950,7 @@ void CGroupTable::draw () finalColor.A = CurrentAlpha; // Draw the top and bottom lines - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal-border+_HReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 01f7b5e63..e5c7afba7 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -476,7 +476,7 @@ bool CGroupTree::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) _RootNode->Opened = true; _ResizeFromChildW = _ResizeFromChildH = true; - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(_ArboOpenFirst); if (id != -1) rVR.getTextureSizeFromId(id, _BmpW, _BmpH); @@ -522,7 +522,7 @@ void CGroupTree::updateCoords() void CGroupTree::drawSelection(sint x, sint y, sint w, CRGBA col) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if(!_RectangleOutlineMode) { @@ -557,7 +557,7 @@ CGroupTree::SNode *CGroupTree::getNodeUnderMouse() const void CGroupTree::draw() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); // get the clip area sint32 clipx, clipy, clipw, cliph; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 3332e33ac..e83d2b5af 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -163,13 +163,13 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) UserControls.stopFreeLook(); } // be nice with other app : let the mouse reappear (useful in direct 3D mode with no hardware cursor) - CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(true); + CViewRenderer::getInstance()->getDriver()->showCursor(true); // Driver->setSystemArrow(); } else { _RecoverFocusLost = true; // force to update mouse pos on next click or move - CInterfaceManager::getInstance()->getViewRenderer().getDriver()->showCursor(IsMouseCursorHardware()); + CViewRenderer::getInstance()->getDriver()->showCursor(IsMouseCursorHardware()); _Focus = true; } diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index fc0582d19..609ebc351 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -78,7 +78,7 @@ CInterface3DScene::~CInterface3DScene() for (i = 0; i < _FXs.size(); ++i) delete _FXs[i]; - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if (_Scene != NULL) Driver->deleteScene (_Scene); @@ -172,7 +172,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) return true; } - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); nlassert ( Driver != NULL); _Scene = Driver->createScene(true); @@ -299,7 +299,7 @@ bool CInterface3DScene::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) if (!animName.empty()) { if (_AutoAnimSet == NULL) - _AutoAnimSet = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet(); + _AutoAnimSet = CViewRenderer::getInstance()->getDriver()->createAnimationSet(); uint id = _AutoAnimSet->addAnimation (ptr, animName.c_str ()); if (id == UAnimationSet::NotFound) { @@ -378,14 +378,14 @@ void CInterface3DScene::draw () { H_AUTO( RZ_Interface_CInterface3DScene_draw ) - NL3D::UDriver *Driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *Driver = CViewRenderer::getInstance()->getDriver(); if ( Driver == NULL) return; // No Op if screen minimized CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if(rVR.isMinimized()) return; @@ -438,7 +438,7 @@ void CInterface3DScene::draw () float vpW = (float) clipw / iavoid0(wsw); float vpH = (float) cliph / iavoid0(wsh); newVP.init(vpX, vpY, vpW, vpH); - NL3D::CFrustum oldFrustum = CInterfaceManager::getInstance()->getViewRenderer().getDriver()->getFrustum(); + NL3D::CFrustum oldFrustum = CViewRenderer::getInstance()->getDriver()->getFrustum(); NL3D::CFrustum newFrustum; newFrustum.initPerspective (pI3DCam->getFOV() * (float) (NLMISC::Pi / 180), (float) _WReal / iavoid0(_HReal), 0.1f, 100.f); @@ -540,7 +540,7 @@ void CInterface3DScene::draw () Driver->setFrustum(oldFrustum); // Restaure render states - pIM->getViewRenderer().setRenderStates(); + CViewRenderer::getInstance()->setRenderStates(); restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); } @@ -1097,7 +1097,7 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) setRotX (_Rot.x); setRotY (_Rot.y); setRotZ (_Rot.z); - _IG->addToScene (*parentGroup->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); + _IG->addToScene (*parentGroup->getScene(), CViewRenderer::getInstance()->getDriver() ); parentGroup->getScene()->setToGlobalInstanceGroup (_IG); return true; @@ -1218,7 +1218,7 @@ void CInterface3DIG::setName (const std::string &ht) _IG = UInstanceGroup::createInstanceGroup(_Name); if (_IG == NULL) return; _IG->setPos (_Pos); - _IG->addToScene (*pI3DS->getScene(), CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); + _IG->addToScene (*pI3DS->getScene(), CViewRenderer::getInstance()->getDriver() ); pI3DS->getScene()->setToGlobalInstanceGroup (_IG); } } diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index ff9977ce6..90176baae 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -1001,7 +1001,7 @@ void CInterfaceElement::center() { // center the pc CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); uint32 sw, sh; vr.getScreenSize(sw, sh); setX(sw / 2 - getWReal() / 2); @@ -1025,7 +1025,7 @@ void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &u ) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); drawHotSpot(_PosRef, CRGBA::Red); if (_Parent) _Parent->drawHotSpot(_ParentPosRef, CRGBA::Blue); @@ -1064,7 +1064,7 @@ void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col) px = _XReal + _WReal - radius; } CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); } diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 4d917a80d..8104c5676 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -787,7 +787,7 @@ void CInterfaceGroup::draw () makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); // Display sons only if not total clipped - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if( !rVR.isClipWindowEmpty() ) { // Draw all decorative elements @@ -807,7 +807,7 @@ void CInterfaceGroup::draw () void CInterfaceGroup::drawNoClip() { // Display sons only if not total clipped - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if( !rVR.isClipWindowEmpty() ) { // Draw all decorative elements @@ -1417,7 +1417,7 @@ void CInterfaceGroup::computeCurrentClipContribution(sint32 oldSciX, sint32 oldS // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::makeNewClip (sint32 &oldSciX, sint32 &oldSciY, sint32 &oldSciW, sint32 &oldSciH) { - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); sint32 newSciX, newSciY, newSciW, newSciH; @@ -1428,7 +1428,7 @@ void CInterfaceGroup::makeNewClip (sint32 &oldSciX, sint32 &oldSciY, sint32 &old // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const { - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 sw, sh; rVR.getScreenSize(sw, sh); sint32 sciX = 0, sciY = 0, sciW = sw, sciH =sh; @@ -1447,7 +1447,7 @@ void CInterfaceGroup::getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH) { - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.setClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e07e4b64f..42e465fc0 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -254,11 +254,14 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS // ------------------------------------------------------------------------------------------------ -CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) : -_ViewRenderer( driver, textcontext ) +CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { this->driver = driver; this->textcontext = textcontext; + CViewRenderer::setDriver( driver ); + CViewRenderer::setTextContext( textcontext ); + CViewRenderer::getInstance(); + _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); interfaceLinkUpdater = new CInterfaceLink::CInterfaceLinkUpdater(); @@ -298,8 +301,8 @@ _ViewRenderer( driver, textcontext ) // ********************* // Interface Manager init - _ViewRenderer.checkNewScreenSize(); - _ViewRenderer.init(); + CViewRenderer::getInstance()->checkNewScreenSize(); + CViewRenderer::getInstance()->init(); _CurrentMode = 0; @@ -370,7 +373,7 @@ CInterfaceManager::~CInterfaceManager() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::reset() { - _ViewRenderer.reset(); + CViewRenderer::getInstance()->reset(); _CtrlsUnderPointer.clear(); CWidgetManager::getInstance()->setCurContextHelp( NULL ); _ViewsUnderPointer.clear(); @@ -645,7 +648,7 @@ void CInterfaceManager::uninitOutGame() void badXMLParseMessageBox() { - NL3D::UDriver *driver = CInterfaceManager::getInstance()->getViewRenderer().getDriver(); + NL3D::UDriver *driver = CViewRenderer::getInstance()->getDriver(); NL3D::UDriver::TMessageBoxId ret = driver->systemMessageBox( "Interface XML reading failed!\n" "Some XML files are corrupted and may have been removed.\n" "Ryzom may need to be restarted to run properly.\n" @@ -1366,7 +1369,7 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) H_AUTO ( RZ_Interface_updateFrameViews ) if (!camera.empty()) - _ViewRenderer.setWorldSpaceFrustum (camera.getFrustum()); + CViewRenderer::getInstance()->setWorldSpaceFrustum (camera.getFrustum()); checkCoords(); drawViews(camera); @@ -1452,7 +1455,7 @@ bool CInterfaceManager::parseInterface (const std::vector &xmlFileN // ------------------------------------------------------------------------------------------------ void CInterfaceManager::loadTextures (const string &textFileName, const string &uvFileName, bool uploadDXTC) { - _ViewRenderer.loadTextures (textFileName, uvFileName, uploadDXTC); + CViewRenderer::getInstance()->loadTextures (textFileName, uvFileName, uploadDXTC); } // ------------------------------------------------------------------------------------------------ @@ -1473,7 +1476,7 @@ bool CInterfaceManager::loadConfig (const string &filename) { uint32 w,h; // NB: even if minimzed, getScreenSize() no more return 0 values (return the last setuped screen size) - _ViewRenderer.getScreenSize(w, h); + CViewRenderer::getInstance()->getScreenSize(w, h); // Windows are positioned according to resolution, and we must backup W/H for the system that move windows when the resolution change _LastInGameScreenW= w; _LastInGameScreenH= h; @@ -1912,7 +1915,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) { H_AUTO ( RZ_Interface_DrawViews_Setup ) - _ViewRenderer.activateWorldSpaceMatrix (false); + CViewRenderer::getInstance()->activateWorldSpaceMatrix (false); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); @@ -1934,12 +1937,12 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) } // Check if screen size changed uint32 w, h; - _ViewRenderer.checkNewScreenSize (); - _ViewRenderer.getScreenSize (w, h); + CViewRenderer::getInstance()->checkNewScreenSize (); + CViewRenderer::getInstance()->getScreenSize (w, h); if ((w != _ScreenW) || (h != _ScreenH)) { // No Op if screen minimized - if(w!=0 && h!=0 && !_ViewRenderer.isMinimized()) + if(w!=0 && h!=0 && !CViewRenderer::getInstance()->isMinimized()) { updateAllLocalisedElements (); _ScreenW = w; @@ -2006,7 +2009,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) driver->setViewMatrix(CMatrix::Identity); driver->setModelMatrix(CMatrix::Identity); driver->setFrustum(camera.getFrustum()); - _ViewRenderer.activateWorldSpaceMatrix (true); + CViewRenderer::getInstance()->activateWorldSpaceMatrix (true); } list &rList = rMG.PrioritizedWindows[nPriority]; @@ -2022,7 +2025,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // Draw all the elements of this window in the layers in ViewRendered pIG->draw (); // flush the layers - _ViewRenderer.flush (); + CViewRenderer::getInstance()->flush (); } } } @@ -2030,7 +2033,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty()) { driver->setMatrixMode2D11(); - _ViewRenderer.activateWorldSpaceMatrix (false); + CViewRenderer::getInstance()->activateWorldSpaceMatrix (false); } } } @@ -2066,7 +2069,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) // if the control support CopyDrag, and if copy key pressed, display a tiny "+" if(pCS->canDragCopy() && testDragCopyKey()) { - CViewRenderer &rVR = getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint w= rVR.getSystemTextureW(CViewRenderer::DragCopyTexture); sint h= rVR.getSystemTextureW(CViewRenderer::DragCopyTexture); rVR.draw11RotFlipBitmap (pCS->getRenderLayer()+1, x-w/2, y-h/2, 0, false, @@ -2083,7 +2086,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) } // flush layers - _ViewRenderer.flush(); + CViewRenderer::getInstance()->flush(); // todo hulud remove Return in 2d world driver->setMatrixMode2D11(); @@ -2374,7 +2377,7 @@ void CInterfaceManager::drawContextHelp () groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers - _ViewRenderer.flush(); + CViewRenderer::getInstance()->flush(); } } else @@ -2382,7 +2385,7 @@ void CInterfaceManager::drawContextHelp () groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers - _ViewRenderer.flush(); + CViewRenderer::getInstance()->flush(); } } else @@ -2390,7 +2393,7 @@ void CInterfaceManager::drawContextHelp () groupContextHelp->executeLuaScriptOnDraw(); groupContextHelp->draw (); // flush layers - _ViewRenderer.flush(); + CViewRenderer::getInstance()->flush(); } } } @@ -3023,7 +3026,7 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve nlassert( e.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ); uint32 screenW, screenH; - _ViewRenderer.getScreenSize( screenW, screenH ); + CViewRenderer::getInstance()->getScreenSize( screenW, screenH ); sint32 oldX = CWidgetManager::getInstance()->getPointer()->getX(); sint32 oldY = CWidgetManager::getInstance()->getPointer()->getY(); @@ -3054,7 +3057,7 @@ void CInterfaceManager::movePointer (sint32 dx, sint32 dy) uint32 nScrW, nScrH; sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; - _ViewRenderer.getScreenSize (nScrW, nScrH); + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); _Pointer->getPointerPos (oldpx, oldpy); olddisppx = oldpx; @@ -3089,7 +3092,7 @@ void CInterfaceManager::movePointerAbs(sint32 px, sint32 py) { if (!CWidgetManager::getInstance()->getPointer()) return; uint32 nScrW, nScrH; - _ViewRenderer.getScreenSize (nScrW, nScrH); + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); clamp(px, 0, (sint32) nScrW); clamp(py, 0, (sint32) nScrH); // @@ -3256,8 +3259,8 @@ void CInterfaceManager::updateAllLocalisedElements() uint32 nMasterGroup; uint32 w, h; - _ViewRenderer.checkNewScreenSize (); - _ViewRenderer.getScreenSize (w, h); + CViewRenderer::getInstance()->checkNewScreenSize (); + CViewRenderer::getInstance()->getScreenSize (w, h); std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); @@ -3268,7 +3271,7 @@ void CInterfaceManager::updateAllLocalisedElements() rMG.Group->setW (w); rMG.Group->setH (h); } - _ViewRenderer.setClipWindow(0, 0, w, h); + CViewRenderer::getInstance()->setClipWindow(0, 0, w, h); // If all conditions are OK, move windows so they fit correctly with new screen size // Do this work only InGame when Config is loaded @@ -3464,13 +3467,13 @@ void CInterfaceManager::getViewsUnder (sint32 x, sint32 y, std::vectorisMinimized()) return; std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 sw, sh; - _ViewRenderer.getScreenSize(sw, sh); + CViewRenderer::getInstance()->getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; @@ -3502,13 +3505,13 @@ void CInterfaceManager::getCtrlsUnder (sint32 x, sint32 y, std::vectorisMinimized()) return; std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 sw, sh; - _ViewRenderer.getScreenSize(sw, sh); + CViewRenderer::getInstance()->getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; @@ -3542,13 +3545,13 @@ void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vectorisMinimized()) return; std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); uint32 sw, sh; - _ViewRenderer.getScreenSize(sw, sh); + CViewRenderer::getInstance()->getScreenSize(sw, sh); for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; @@ -4744,7 +4747,7 @@ void CInterfaceManager::drawOverExtendViewText() // draw groupOver->draw (); // flush layers - _ViewRenderer.flush(); + CViewRenderer::getInstance()->flush(); } } @@ -6126,7 +6129,7 @@ bool CInterfaceManager::parseTokens(ucstring& ucstr) void CInterfaceManager::setTextContext( NL3D::UTextContext *textcontext ) { this->textcontext = textcontext; - _ViewRenderer.setTextContext( textcontext ); + CViewRenderer::getInstance()->setTextContext( textcontext ); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 9bf7849e4..717176359 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -49,6 +49,8 @@ #include "../string_manager_client.h" #include "yubo_chat.h" +#include "../ingame_database_manager.h" + static const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; static const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; @@ -302,7 +304,6 @@ public: void drawContextHelp (); //void drawContextMenu (); - CViewRenderer &getViewRenderer () { return _ViewRenderer; } void setGlobalColor (NLMISC::CRGBA col); NLMISC::CRGBA getGlobalColor() { return _GlobalColor; } void setContentAlpha(uint8 alpha); @@ -821,8 +822,6 @@ private: }; std::vector _IDStringWaiters; - /// Renderer - CViewRenderer _ViewRenderer; uint32 _ScreenW, _ScreenH; // Change res detection NLMISC::CRGBA _GlobalColor; sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/ryzom/client/src/interface_v3/interface_options.cpp index f46111c79..eb85bdb42 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options.cpp @@ -169,7 +169,7 @@ bool COptionsLayer::parse (xmlNodePtr cur) return false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); Tile_Blank = getValSInt32("tile_blank"); Tile_M_Header = getValSInt32("tile_m_header"); @@ -267,7 +267,7 @@ bool COptionsContainerInsertion::parse(xmlNodePtr cur) return false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); TxId_T_Arrow = rVR.getTextureIdFromName (getValStr("arrow_top")); TxId_B_Arrow = rVR.getTextureIdFromName (getValStr("arrow_down")); TxId_L_Arrow = rVR.getTextureIdFromName (getValStr("arrow_left")); @@ -355,7 +355,7 @@ bool CMissionIconList::parse(xmlNodePtr cur) bool result = CInterfaceOptions::parse(cur); if (!result) return false; CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); for(std::map::iterator it = _ParamValue.begin(); it != _ParamValue.end(); ++it) { int index; @@ -414,7 +414,7 @@ COptionsAnimationSet::~COptionsAnimationSet() BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList (see deleteAnimationSet() doc) */ - CInterfaceManager::getInstance()->getViewRenderer().getDriver()->deleteAnimationSet(AnimationSet); + CViewRenderer::getInstance()->getDriver()->deleteAnimationSet(AnimationSet); AnimationSet= NULL; } } @@ -424,10 +424,10 @@ bool COptionsAnimationSet::parse (xmlNodePtr cur) { bool result = CInterfaceOptions::parse(cur); if (!result) return false; - nlassert( CInterfaceManager::getInstance()->getViewRenderer().getDriver() ); + nlassert( CViewRenderer::getInstance()->getDriver() ); // create the animation set - AnimationSet= CInterfaceManager::getInstance()->getViewRenderer().getDriver()->createAnimationSet(); + AnimationSet= CViewRenderer::getInstance()->getDriver()->createAnimationSet(); nlassert(AnimationSet); AnimMale.clear(); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 7e1b15f34..7ca6c77a6 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -122,7 +122,7 @@ using namespace NLMISC; void badLuaParseMessageBox() { NL3D::UDriver::TMessageBoxId ret = - CInterfaceManager::getInstance()->getViewRenderer().getDriver()->systemMessageBox( "LUA files reading failed!\n" + CViewRenderer::getInstance()->getDriver()->systemMessageBox( "LUA files reading failed!\n" "Some LUA files are corrupted, moved or may have been removed.\n" "Ryzom may need to be restarted to run properly.\n" "Would you like to quit now?", diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index cdb2a2e36..2756e6391 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -1112,7 +1112,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) } // reset display of left hand - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); pCSLeftHand->setTextureNoItem(rVR.getTextureIdFromName("hand_left.tga")); pCSLeftHand->setGrayed(false); pCSLeftHand->setItemSlot(SLOTTYPE::stringToSlotType("LEFT_HAND")); @@ -1187,7 +1187,7 @@ void CInventoryManager::CDBEquipObs::update(ICDBNode* node) CDBCtrlSheet *pCSLeftHand = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_HAND_LEFT)); if ( pCSLeftHand ) { - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); pCSLeftHand->setActionOnLeftClick("proc"); pCSLeftHand->setGrayed(false); diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 3211c20e9..b111b4440 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1608,7 +1608,7 @@ int CLuaIHMRyzom::getWindowSize(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getWindowSize", 0); CInterfaceManager *pIM= CInterfaceManager::getInstance(); uint32 w, h; - pIM->getViewRenderer().getScreenSize(w, h); + CViewRenderer::getInstance()->getScreenSize(w, h); ls.push((double) w); ls.push((double) h); return 2; diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 5548f9354..b87ecafda 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -204,7 +204,7 @@ void CMacroCmdManager::initInGame() { // Get all custom icon bitmaps CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CInterfaceOptions *pIO = pIM->getOptions("macro_custom_icon"); if (pIO != NULL) { diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index 3ec51b270..7372f9401 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -80,7 +80,7 @@ bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) TxName = strlwr (TxName); setTexture (TxName); //CInterfaceManager *pIM = CInterfaceManager::getInstance(); - //CViewRenderer &rVR = pIM->getViewRenderer(); + //CViewRenderer &rVR = *CViewRenderer::getInstance(); //_TextureId = rVR.getTextureIdFromName (TxName); } @@ -145,7 +145,7 @@ bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) void CViewBitmap::draw () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col; if(getModulateGlobalColor()) @@ -209,7 +209,7 @@ void CViewBitmap::updateCoords() if (!_Scale) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 txw, txh; rVR.getTextureSizeFromId (_TextureId, txw, txh); _W = txw; @@ -222,7 +222,7 @@ void CViewBitmap::updateCoords() void CViewBitmap::setTexture(const std::string & TxName) { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); } @@ -231,7 +231,7 @@ void CViewBitmap::setTexture(const std::string & TxName) std::string CViewBitmap::getTexture () const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId (_TextureId); } @@ -239,7 +239,7 @@ std::string CViewBitmap::getTexture () const void CViewBitmap::fitTexture() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(_TextureId, w, h); setW(w); @@ -287,7 +287,7 @@ sint32 CViewBitmap::getMaxUsedW() const { sint32 txw, txh; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureId, txw, txh); return txw; } diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index a44dcf509..43c9be22c 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -276,7 +276,7 @@ void CViewBitmapCombo::draw() sint32 mx = 0, my = 0; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); const std::vector &rVB = pIM->getViewsUnderPointer(); if (!CWidgetManager::getInstance()->getPointer()) return; CWidgetManager::getInstance()->getPointer()->getPointerDispPos(mx, my); @@ -377,7 +377,7 @@ void CViewBitmapCombo::draw() textId = getTexId(_TexsId, texIndex); color = getCol(_Col, texIndex); } - pIM->getViewRenderer().drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, + CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, textId, color); } @@ -454,7 +454,7 @@ void CViewBitmapCombo::draw() } } - pIM->getViewRenderer().drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, + CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, textId, color); } diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp index ff7b0fa70..b2f05769e 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.cpp @@ -119,7 +119,7 @@ void CViewBitmapFaberMp::draw () */ //get the item - CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); uint32 sheet = (uint32)_SheetId.getSInt64(); CSheetId sheetId(sheet); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 941f5ffb1..7a6740176 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -170,7 +170,7 @@ void CViewPointer::draw () return; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (pIM->isInGame()) if (!_StringCursor) @@ -573,7 +573,7 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) nlinfo(tooltip.c_str()); setString(ucstring(tooltip)); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor; @@ -596,7 +596,7 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) else { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); drawCursor(texId, col, 0); return true; @@ -760,7 +760,7 @@ void CViewPointer::setString (const ucstring &str) void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 xPos = _XReal + _OffsetX; sint32 yPos = _YReal + _OffsetY; if (!IsMouseCursorHardware()) diff --git a/code/ryzom/client/src/interface_v3/view_polygon.cpp b/code/ryzom/client/src/interface_v3/view_polygon.cpp index 4ed849c7c..b033b2885 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/view_polygon.cpp @@ -77,7 +77,7 @@ void CViewPolygon::draw() if (_Tris.empty()) return; if (!_Parent) return; CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); if (_Touched) { _RealTris.clear(); diff --git a/code/ryzom/client/src/interface_v3/view_quad.cpp b/code/ryzom/client/src/interface_v3/view_quad.cpp index a788fc226..296643a2d 100644 --- a/code/ryzom/client/src/interface_v3/view_quad.cpp +++ b/code/ryzom/client/src/interface_v3/view_quad.cpp @@ -58,7 +58,7 @@ void CViewQuad::draw() { nlassert(_Parent); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col; if(getModulateGlobalColor()) @@ -280,7 +280,7 @@ void CViewQuad::setAlpha(sint32 a) void CViewQuad::setTexture(const std::string &texName) { // CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = pIM->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); _TextureId.setTexture(texName.c_str()); } @@ -288,7 +288,7 @@ void CViewQuad::setTexture(const std::string &texName) std::string CViewQuad::getTexture() const { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId (_TextureId); } @@ -335,7 +335,7 @@ void CViewQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPo { NLMISC::CVector pos = srcPos; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); if (angle == 0.f) diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 933d57b80..06382059d 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -60,7 +60,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) // Spot textures CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // Large missions Icons const char *spotTextureNames[NbRadarSpotIds] = { "texture_std", "texture_missionlist", "texture_missionauto", "texture_missionstep" }; @@ -105,7 +105,7 @@ bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) void CViewRadar::draw () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); CEntityCL *user = EntitiesMngr.entity(0); if (user == NULL) return; diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp index 395b719af..6dfb1e977 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ b/code/ryzom/client/src/interface_v3/view_renderer.cpp @@ -14,28 +14,26 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "view_renderer.h" #include "nel/misc/path.h" #include "nel/misc/file.h" #include "nel/misc/uv.h" #include "nel/misc/hierarchical_timer.h" -#include "interface_manager.h" #include "../client_cfg.h" using namespace NLMISC; using namespace std; using namespace NL3D; -CViewRenderer::CViewRenderer( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) -{ - setup(); +CViewRenderer* CViewRenderer::instance = NULL; +NL3D::UDriver* CViewRenderer::driver = NULL; +NL3D::UTextContext* CViewRenderer::textcontext = NULL; - this->driver = driver; - this->textcontext = textcontext; +CViewRenderer::CViewRenderer() +{ + nlassert( driver != NULL ); + nlassert( textcontext != NULL ); + setup(); } CViewRenderer::~CViewRenderer() @@ -49,6 +47,13 @@ CViewRenderer::~CViewRenderer() } +CViewRenderer* CViewRenderer::getInstance() +{ + if( instance == NULL ) + instance = new CViewRenderer; + return instance; +} + /* * setClipWindow : set the current clipping window * (this window do not inherit properties from parent or whatever) @@ -203,7 +208,12 @@ NL3D::UDriver* CViewRenderer::getDriver(){ void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext) { - this->textcontext = textcontext; + CViewRenderer::textcontext = textcontext; +} + +void CViewRenderer::setDriver( NL3D::UDriver *driver ) +{ + CViewRenderer::driver = driver; } // *************************************************************************** @@ -1732,10 +1742,8 @@ void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, CViewRenderer::CTextureId::~CTextureId () { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); if (_TextureId>=0) - rVR.deleteTexture(_TextureId); + CViewRenderer::getInstance()->deleteTexture(_TextureId); _TextureId = -1; } @@ -1744,8 +1752,7 @@ CViewRenderer::CTextureId::~CTextureId () bool CViewRenderer::CTextureId::setTexture (const char *textureName, sint32 offsetX, sint32 offsetY, sint32 width, sint32 height, bool uploadDXTC, bool bReleasable) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); if (_TextureId>=0) rVR.deleteTexture(_TextureId); _TextureId = rVR.getTextureIdFromName(textureName); @@ -1766,8 +1773,7 @@ void CViewRenderer::CTextureId::serial(NLMISC::IStream &f) } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); texName = rVR.getTextureNameFromId(_TextureId); f.serial(texName); } diff --git a/code/ryzom/client/src/interface_v3/view_renderer.h b/code/ryzom/client/src/interface_v3/view_renderer.h index f5e46c5ae..cc96cee34 100644 --- a/code/ryzom/client/src/interface_v3/view_renderer.h +++ b/code/ryzom/client/src/interface_v3/view_renderer.h @@ -26,8 +26,6 @@ #include "nel/misc/rgba.h" #include "nel/misc/uv.h" #include "nel/3d/frustum.h" -#include "../ingame_database_manager.h" - // *************************************************************************** #define VR_NUM_LAYER 32 @@ -104,9 +102,12 @@ public: sint32 _TextureId; }; - CViewRenderer( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); +private: + CViewRenderer(); + ~CViewRenderer(); - ~CViewRenderer (); +public: + static CViewRenderer* getInstance(); /// setup the default values for everything void setup(); @@ -121,10 +122,13 @@ public: void reset(); /// Retrieves the 3d driver we are using - NL3D::UDriver* getDriver(); + static NL3D::UDriver* getDriver(); /// Sets the current TextContext. - void setTextContext( NL3D::UTextContext *textcontext ); + static void setTextContext( NL3D::UTextContext *textcontext ); + + /// Sets the current driver + static void setDriver( NL3D::UDriver *driver ); /* * setClipWindow : set the current clipping window @@ -564,8 +568,9 @@ private: bool _WorldSpaceScale; - NL3D::UDriver *driver; - NL3D::UTextContext *textcontext; + static CViewRenderer *instance; + static NL3D::UDriver *driver; + static NL3D::UTextContext *textcontext; }; diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 6167fd5f9..98904d390 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -418,7 +418,7 @@ void CViewText::draw () H_AUTO( RZ_Interface_CViewText_draw ) CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); // *** Out Of Clip? sint32 ClipX, ClipY, ClipW, ClipH; @@ -1559,7 +1559,7 @@ void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousL TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); -// CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); height = getFontHeight(); // if (_MultiLine) @@ -1691,7 +1691,7 @@ void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); // find the line where the character is -// CViewRenderer &rVR = CInterfaceManager::getInstance()->getViewRenderer(); +// CViewRenderer &rVR = *CViewRenderer::getInstance(); uint charPos = 0; if (_MultiLine) { diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 1abf1dc28..c35b680d8 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1735,7 +1735,7 @@ bool mainLoop() H_AUTO_USE ( RZ_Client_Main_Loop_Cursor ) // Change only if screen is not minimized - if(!pIMinstance->getViewRenderer().isMinimized()) + if(!CViewRenderer::getInstance()->isMinimized()) { // Get the cursor instance CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); @@ -1746,7 +1746,7 @@ bool mainLoop() cursor->getPointerPos(x, y); uint32 w, h; - CViewRenderer &viewRender = pIMinstance->getViewRenderer(); + CViewRenderer &viewRender = *CViewRenderer::getInstance(); viewRender.getScreenSize(w, h); if(w) diff --git a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp index c997c64a5..95b8f089b 100644 --- a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp @@ -598,7 +598,7 @@ void CDisplayerVisualActivitySequence::onUpdate(CGroupMap &owner) //H_AUTO(R2_CDisplayerVisualActivitySequence_onUpdate) nlassert(_AddedToWorldMap); nlassert(_FootSteps.size() == _WorldMapEdges.size()); - CViewRenderer &vr = getEditor().getUI().getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); sint32 id = vr.getTextureIdFromName(CV_FootStepMapTexture.get()); sint32 width, height; vr.getTextureSizeFromId(id, width, height); diff --git a/code/ryzom/client/src/r2/island_collision.cpp b/code/ryzom/client/src/r2/island_collision.cpp index b096a4255..2c32fefb6 100644 --- a/code/ryzom/client/src/r2/island_collision.cpp +++ b/code/ryzom/client/src/r2/island_collision.cpp @@ -141,7 +141,7 @@ void CIslandCollision::releaseAccessibilityTexture() //H_AUTO(R2_CIslandCollision_releaseAccessibilityTexture) delete _AccessibilityTexture; _AccessibilityTexture = NULL; - CViewRenderer &vr = getEditor().getUI().getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); vr.setExternalTexture(_AccessibilityTextureId, NULL, 0, 0, 0, 0); } @@ -460,7 +460,7 @@ CPackedWorld *CIslandCollision::reloadPackedIsland(const CScenarioEntryPoints::C uint height = std::max(_HeightMap.getHeight() / MapSizeDivisor, 1u); uint realWidth = NLMISC::raiseToNextPowerOf2(width); uint realHeight = NLMISC::raiseToNextPowerOf2(height); - CViewRenderer &vr = getEditor().getUI().getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); // create / update texture vr.setExternalTexture(_AccessibilityTextureId, _AccessibilityTexture, realWidth, realHeight, width, height); if (vr.getTextureIdFromName(_AccessibilityTextureId) == -1) diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index ac05a1633..c932643d8 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -157,7 +157,7 @@ void CPrimRender::setLook(const CPrimLook &look) if (!look.EdgeLook.WorldMapTexture.empty()) { CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = im->getViewRenderer(); + CViewRenderer &vr = *CViewRenderer::getInstance(); sint32 width, height; sint32 id = vr.getTextureIdFromName(look.EdgeLook.WorldMapTexture); vr.getTextureSizeFromId(id, width, height); diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index 4d3e890e2..b7e4ee069 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -130,7 +130,7 @@ CInterfaceManager &CTool::getUI() void CTool::getScreenSize(uint32 &scrW, uint32 &scrH) { //H_AUTO(R2_CTool_getScreenSize) - getUI().getViewRenderer().getScreenSize(scrW, scrH); + CViewRenderer::getInstance()->getScreenSize(scrW, scrH); } // *************************************************************** @@ -138,7 +138,7 @@ uint32 CTool::getScreenWidth() { //H_AUTO(R2_CTool_getScreenWidth) uint32 scrW, scrH; - getUI().getViewRenderer().getScreenSize(scrW, scrH); + CViewRenderer::getInstance()->getScreenSize(scrW, scrH); return scrW; } @@ -147,7 +147,7 @@ uint32 CTool::getScreenHeight() { //H_AUTO(R2_CTool_getScreenHeight) uint32 scrW, scrH; - getUI().getViewRenderer().getScreenSize(scrW, scrH); + CViewRenderer::getInstance()->getScreenSize(scrW, scrH); return scrH; } From 5ea64cb530d5f962093a5af4bbb7137a7f7178d6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 2 Jun 2012 02:09:58 +0200 Subject: [PATCH 042/339] CHANGED: #1471 CViewRenderer no longer depends on CClientConfig, and is now part of NELGUI, under the NLGUI namespace. --- code/nel/include/nel/gui/view_renderer.h | 591 ++++++ code/nel/src/gui/view_renderer.cpp | 1869 +++++++++++++++++ .../client/src/interface_v3/ctrl_button.h | 2 +- .../client/src/interface_v3/ctrl_polygon.cpp | 2 +- .../client/src/interface_v3/ctrl_polygon.h | 3 +- .../ryzom/client/src/interface_v3/ctrl_quad.h | 2 +- .../src/interface_v3/ctrl_text_button.h | 2 +- .../client/src/interface_v3/dbctrl_sheet.h | 7 +- .../src/interface_v3/group_in_scene.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 + .../src/interface_v3/interface_manager.h | 2 +- .../client/src/interface_v3/view_bitmap.h | 2 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_polygon.cpp | 2 +- .../client/src/interface_v3/view_polygon.h | 2 +- .../ryzom/client/src/interface_v3/view_quad.h | 2 +- .../client/src/interface_v3/view_radar.h | 2 +- .../client/src/interface_v3/view_renderer.cpp | 1863 ---------------- .../client/src/interface_v3/view_renderer.h | 579 ----- .../r2/displayer_visual_activity_sequence.cpp | 2 +- .../client/src/r2/displayer_visual_entity.cpp | 2 +- code/ryzom/client/src/r2/island_collision.h | 2 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- 23 files changed, 2485 insertions(+), 2461 deletions(-) create mode 100644 code/nel/include/nel/gui/view_renderer.h create mode 100644 code/nel/src/gui/view_renderer.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_renderer.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_renderer.h diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h new file mode 100644 index 000000000..5adde3cb3 --- /dev/null +++ b/code/nel/include/nel/gui/view_renderer.h @@ -0,0 +1,591 @@ +// Ryzom - MMORPG Framework +// 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 NL_VIEW_RENDERER_H +#define NL_VIEW_RENDERER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/misc/uv.h" +#include "nel/misc/plane.h" +#include "nel/3d/u_texture.h" +#include "nel/3d/u_material.h" +#include "nel/3d/u_text_context.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/frustum.h" + +namespace NLGUI +{ + + // *************************************************************************** + #define VR_NUM_LAYER 32 + #define VR_BIAS_LAYER (VR_NUM_LAYER/2) + #define VR_LAYER_MAX (VR_NUM_LAYER-VR_BIAS_LAYER-1) + #define VR_LAYER_MIN (-VR_BIAS_LAYER) + + // *************************************************************************** + /** + * class rendering the views + * All the quads of the interface are displayed in the following order + * + * 3--2 + * | | + * 0--1 + * + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CViewRenderer + { + public: + enum TSystemTexture + { + QuantityCrossTexture= 0, + DefaultBrickTexture, + DefaultItemTexture, + ItemPlanTexture, + SkillTexture, + ItemEnchantedTexture, + DragCopyTexture, + ItemWornedTexture, + OutOfRangeTexture, + RegenTexture, + RegenBackTexture, + GlowStarTexture, + ItemLockedByOwnerTexture, + NumSystemTextures, + }; + + + public: + + /** That class hold a texture id. It handle texture id destruction. + * Please use this class in your view and not sint32 to hold a texture id + */ + class CTextureId + { + public: + + // Default constructor + CTextureId () + { + _TextureId = -2; + } + + // Destructor call deleteTextureId; + ~CTextureId (); + + // Set the texture id + bool setTexture (const char *textureName, sint32 offsetX = 0, sint32 offsetY = 0, sint32 width = -1, sint32 height = -1, + bool uploadDXTC=true, bool bReleasable=true); + + // Convert in texture id + operator sint32 () const + { + return _TextureId; + } + + void serial(NLMISC::IStream &f); + + private: + sint32 _TextureId; + }; + + private: + CViewRenderer(); + ~CViewRenderer(); + + public: + static CViewRenderer* getInstance(); + + /// setup the default values for everything + void setup(); + + /// init when TextContext and Driver are created + void init(); + + /// set the driver render states for the interface + void setRenderStates (); + + /// Delete all textures and the like and reset the view renderer + void reset(); + + /// Retrieves the 3d driver we are using + static NL3D::UDriver* getDriver(); + + /// Sets the current TextContext. + static void setTextContext( NL3D::UTextContext *textcontext ); + + /// Sets the current driver + static void setDriver( NL3D::UDriver *driver ); + + /* + * setClipWindow : set the current clipping window + * (this window do not inherit properties from parent or whatever) + */ + void setClipWindow (sint32 x, sint32 y, sint32 w, sint32 h); + + /* + * getClipWindow : get the current clipping region + */ + void getClipWindow (sint32 &x, sint32 &y, sint32 &w, sint32 &h) + { + x = _ClipX; + y = _ClipY; + w = _ClipW; + h = _ClipH; + } + + /* + * true if the clipping region is empty: clipW or clipH is <=0 + */ + bool isClipWindowEmpty() const {return _ClipW<=0 || _ClipH<=0;} + + /* + * checkNewScreenSize : check if the opengl screen size. This is SLOW ! + * NB: if the window is minimized (w==h==0), then the old screen size is kept, and isMinimized() return true + */ + void checkNewScreenSize (); + + /* + * getScreenSize : get the screen window size changed (at last checkNewScreenSize called) + */ + void getScreenSize (uint32 &w, uint32 &h); + + /* + * get OOW / OOH + */ + void getScreenOOSize (float &oow, float &ooh); + + /* + * is the Screen minimized? + */ + bool isMinimized() const {return _IsMinimized;} + + /* + * drawBitmap : this is the interface with all the views + * + */ + void drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv, + sint32 nTxId, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); + + /* + * Draw a simple wired quad. No flushing is done as the draw is done instantly (usually for debug) + */ + void drawWiredQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White); + + /* + * Draw a simple filled quad. No flushing is done as the draw is done instantly (usually for debug) + */ + void drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White); + + /* + * drawBitmap : Tiled version + * \param tileOrigin 2 bits 1 - Left/Right (0/1) 2 - Bottom/Top (0/1) (0-BL)(1-BR)(2-TL)(3-TR) + * + */ + void drawRotFlipBitmapTiled (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv, + sint32 nTxId, uint tileOrigin, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); + + + + /* + * drawBitmap : draw a bitmap roted by 90 degrees in CW 'rot times' + * flipv is a boolean that indicates if there is a vertical flip + * this is a 1:1 ratio so if texture is x long there are x pixels on screen + */ + void draw11RotFlipBitmap (sint layerId, sint32 x, sint32 y, uint8 rot, bool flipv, sint32 nTxId, + const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); + + /** Draw an arbitrary quad (fast version) , possibly clipping it. Unlike draw11RotFlipBitmap & the like, texture is filtered here. + * quads are all batched in the same render layer + */ + void drawQuad(sint layerId, const NLMISC::CQuadUV &quadUV, sint32 nTxId, + NLMISC::CRGBA col, bool additif, bool filtered = true); + /** Draw a set of untextured triangle in the given layer. all triangles of the same layer are batched + */ + void drawUnclippedTriangles(sint layerId, const std::vector &tris, NLMISC::CRGBA col); + + /* + * Draw a text + */ + void drawText (sint layerId, float x, float y, uint wordIndex, float xmin, float ymin, float xmax, float ymax, NL3D::UTextContext &textContext); + + /* + * loadTextures : load all textures associated with the interface + * this function add a globaltexture to the vector of global textures + */ + void loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC); + + /* + * createTexture : create a texture for the interface, possibly from an externally created texture + * If no external texture is given, then 'sGlobalTextureName' is the filename of the big texture + * You should call deleteTexture when the texture is not used anymore + * The method returns the texture id of the new texture + */ + sint32 createTexture (const std::string &sGlobalTextureName, // unique id identifying this big texture, (its filename if not externally created) + sint32 offsetX = 0, + sint32 offsetY = 0, + sint32 width = -1, + sint32 height = -1, + bool uploadDXTC=true, + bool bReleasable=true + ); + + + // change position of a sub-texture (inside its big texture) from the sub-texture filename + void updateTexturePos(const std::string &texturefileName, + sint32 offsetX = 0, + sint32 offsetY = 0, + sint32 width = -1, + sint32 height = -1 + ); + + /** Add / change a global texture from an externally created texture + * \param defaultTexWidth width to used when CTextureId::createTexture is used without giving the width (e.g width = -1), useful for cropped textures + * \param defaultTexHeight height to used when CTextureId::createTexture is used without giving the height (e.g height = -1), useful for cropped textures + */ + + void setExternalTexture(const std::string &sGlobalTextureName, + NL3D::UTexture *externalTexture = NULL, + uint32 externalTexWidth = 1, + uint32 externalTexHeight = 1, + uint32 defaultTexWidth = 1, + uint32 defaultTexHeight = 1 + ); + + /* + * deleteTexture : create a texture for the interface + */ + void deleteTexture (sint32 textureId); + + // get a global texture pointer from its name + NL3D::UTexture *getGlobalTexture(const std::string &name); + + /* + * Flush all parsed view and computed strings to screen + */ + void flush (); + + /** + * get a texture file pointer from a string name. O(logN) + * \param id : the id of the texture + * \return a texture file pointer. -1 if not found or if sName is empty() + */ + sint32 getTextureIdFromName (const std::string &sName) const; + std::string getTextureNameFromId (sint32 TxID); + void getTextureSizeFromId (sint32 id, sint32 &width, sint32 &height); + NLMISC::CRGBA getTextureColor(sint32 id, sint32 x, sint32 y); + + + /** + * \return the texture associated with the param figur + */ + sint32 getFigurTextureId(uint index) + { + nlassert(index < 10); + return _IndexesToTextureIds[index]; + } + + /** + * \return the texture for figur separator '-' + */ + sint32 getFigurSeparator() const { return _FigurSeparatorTextureId; } + + sint32 getFigurTextureW() const {return _WFigurTexture;} + sint32 getFigurTextureH() const {return _HFigurTexture;} + sint32 getFigurSeparatorW() const {return _WFigurSeparatorTexture;} + sint32 getFigurSeparatorH() const {return _HFigurSeparatorTexture;} + + + sint32 getFigurBlankTextureId () + { + return _FigurBlankId; + } + sint32 getBlankTextureId () + { + return _BlankId; + } + + + sint32 getTypoTextureW(char c); + sint32 getTypoTextureH(char c); + sint32 getTypoTextureId(char c); + + /// System Texture Manager. Used to avoid storing an id in each Ctrl for some texture code is aware of + // @{ + sint32 getSystemTextureId(TSystemTexture e) const {return _SystemTextures[e].Id;} + sint32 getSystemTextureW(TSystemTexture e) const {return _SystemTextures[e].W;} + sint32 getSystemTextureH(TSystemTexture e) const {return _SystemTextures[e].H;} + // @} + + /// For string rendering, get the RenderBuffer to the specified layer + NL3D::URenderStringBuffer *getStringRenderBuffer(sint layerId); + + + /** Custom Rendering Interface + * Note that this function is EXTREMLY SLOW so it should be used with care + * This function flush the quad cache, clip the quad passed with current clipping region + * and draw (with drawQuedUV2) it with the material passed in parameter. There is no cache operation done. + * uv used are from (0,0) -> (1,1) for the 2 stages + */ + void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col, NL3D::UMaterial Mat); + // Same but we can control uv mapping of first stage + void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, + const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, + NLMISC::CRGBA col, NL3D::UMaterial Mat); + // Same but we can control uv mapping of 2 stages + void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, + const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, const NLMISC::CUV &uv1Min, const NLMISC::CUV &uv1Max, + NLMISC::CRGBA col, NL3D::UMaterial Mat); + + // **** World space interface methods + + /** Set the current Z in projCenter.z. + * If you want to scale the window position, set a scale!=1. projCenter.x/y is used as the + * pivot (in window coordinates) + */ + void setInterfaceDepth (const NLMISC::CVector &projCenter, float scale); + + // Activate world space transformation + void activateWorldSpaceMatrix (bool activate); + + // Set the screen to world space matrix + void setWorldSpaceFrustum (const NL3D::CFrustum &cameraFrustum); + + // Get the current Frustum + const NL3D::CFrustum &getFrustum () const + { + return _CameraFrustum; + } + + private: + /** + * init the map _IndexesToTextures + */ + void initIndexesToTextureIds (); + void initTypo (); + + bool needClipping (const NLMISC::CQuad &q); + + void clip (NLMISC::CQuadColorUV &qout, const NLMISC::CQuadColorUV &qin, uint rot); + void clip (NLMISC::CQuadColorUV2 &qout, const NLMISC::CQuadColorUV2 &qin); + private: + + // A layer is a vector of Quads. + class CLayer + { + public: + // unfiltered quads + std::vector Quads; + uint32 NbQuads; + std::vector Tris; + // filtered alpha blended quads + std::vector FilteredAlphaBlendedQuads; + // filtered alpha blended tris + std::vector FilteredAlphaBlendedTris; + // filtered additif blended quads + std::vector FilteredAdditifQuads; + // filtered additif blended tris + std::vector FilteredAdditifTris; + + CLayer() + { + NbQuads= 0; + } + }; + + // SGlobalTexture is a texture that regroup other texture. We store also current quads to render + struct SGlobalTexture + { + SGlobalTexture () + { + FromGlobaleTexture = true; + } + uint32 Width, Height; + uint32 DefaultWidth, DefaultHeight; + NL3D::UTexture *Texture; + std::string Name; + bool FromGlobaleTexture; + // Array of layers + CLayer Layers[VR_NUM_LAYER]; + }; + + // For each Layer, store a string Buffer + NL3D::URenderStringBuffer *_StringRBLayers[VR_NUM_LAYER]; + + // For each Layer, tells if empty or not + bool _EmptyLayer[VR_NUM_LAYER]; + + // SImage is one texture of the SGlobalTexture textures + struct SImage + { + std::string Name; + SGlobalTexture *GlobalTexturePtr; + NLMISC::CUV UVMin, UVMax; + + // Assign UV of this image to a quad depending on the flip and rot + void setupQuadUV(bool flipv, uint8 rot, NLMISC::CQuadColorUV &dest); + }; + + // *************************************************************************** + // \name Texture management + // *************************************************************************** + + // SImage accessors + SImage *getSImage(sint32 textureId) + { + return &(*(_SImageIterators[textureId])); + } + + + // Add a SImage + sint32 addSImage(const SImage &image) + { + uint i; + for (i=0; i<_SImageIterators.size(); i++) + { + // Free ? + if (_SImageIterators[i] == _SImages.end()) + break; + } + + // Nothing free ? + if (i == _SImageIterators.size()) + _SImageIterators.push_back(_SImages.end()); + + _SImages.push_back(image); + _SImageIterators[i] = _SImages.end(); + _SImageIterators[i]--; + return (sint32)i; + } + + // Remove a SImage + void removeSImage(sint32 textureId) + { + // Allocated ? + nlassert (_SImageIterators[textureId] != _SImages.end()); + + // Remove the image + _SImages.erase (_SImageIterators[textureId]); + + // Remove the index entry + _SImageIterators[textureId] = _SImages.end(); + } + + typedef std::list TGlobalTextureList; + typedef std::list TSImageList; + typedef std::vector::iterator> TSImageIterator; + + // List of global textures + TGlobalTextureList _GlobalTextures; + + // List of SImage + TSImageList _SImages; + + // Array used to convert a texture ID in _SImages iterator + TSImageIterator _SImageIterators; + + // *************************************************************************** + + typedef std::map TTextureMap; + TTextureMap _TextureMap; + + NL3D::UMaterial _Material; + + // Clip & screen system + sint32 _ClipX, _ClipY, _ClipW, _ClipH; + float _XMin, _XMax, _YMin, _YMax; + + sint32 _ScreenW, _ScreenH; + float _OneOverScreenW, _OneOverScreenH; + bool _IsMinimized; + + + //map linking a uint to a bitmap. Used to display figurs + std::vector _IndexesToTextureIds; + sint32 _FigurSeparatorTextureId; + sint32 _FigurBlankId, _BlankId; + sint32 _WFigurTexture; + sint32 _HFigurTexture; + sint32 _WFigurSeparatorTexture; + sint32 _HFigurSeparatorTexture; + NLMISC::CUV _BlankUV; + SGlobalTexture *_BlankGlobalTexture; + + // System textures + class CSystemTexture + { + public: + sint32 Id; + sint32 W; + sint32 H; + + CSystemTexture() + { + Id= -1; + W= H= 0; + } + }; + CSystemTexture _SystemTextures[NumSystemTextures]; + + // Typo texture + enum + { + NumTypoChar= 127, + }; + sint32 _TypoCharToTextureIds[NumTypoChar]; + sint32 _TypoCharWs[NumTypoChar]; + sint32 _TypoH; + + + void addSystemTexture(TSystemTexture e, const char *s); + void initSystemTextures(); + + /** + * put a new quad in the cache (call flush if texture different) + */ + void putQuadInLayer (SGlobalTexture >, sint layerId, const NLMISC::CQuadColorUV &qcoluv, uint rot); + + // World space interface methods + void worldSpaceTransformation (NLMISC::CQuadColorUV &qcoluv); + + bool _WorldSpaceTransformation; // Transform into world space + float _CurrentZ; // Current z used for the scene + NL3D::CFrustum _CameraFrustum; // Transform from screen space to world space + NLMISC::CMatrix _WorldSpaceMatrix; // Matrix to be applied for world space transformation + bool _WorldSpaceScale; + + + static CViewRenderer *instance; + static NL3D::UDriver *driver; + static NL3D::UTextContext *textcontext; + + public: + static std::set< std::string > *hwCursors; + static float hwCursorScale; + + }; + + +} + +#endif // NL_VIEW_RENDERER_H + +/* End of view_renderer.h */ diff --git a/code/nel/src/gui/view_renderer.cpp b/code/nel/src/gui/view_renderer.cpp new file mode 100644 index 000000000..6e66c3edf --- /dev/null +++ b/code/nel/src/gui/view_renderer.cpp @@ -0,0 +1,1869 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/path.h" +#include "nel/misc/file.h" +#include "nel/misc/uv.h" +#include "nel/misc/hierarchical_timer.h" +#include "nel/gui/view_renderer.h" + +using namespace NLMISC; +using namespace std; +using namespace NL3D; + +namespace NLGUI +{ + + CViewRenderer* CViewRenderer::instance = NULL; + NL3D::UDriver* CViewRenderer::driver = NULL; + NL3D::UTextContext* CViewRenderer::textcontext = NULL; + std::set< std::string >* CViewRenderer::hwCursors = NULL; + float CViewRenderer::hwCursorScale = 1.0f; + + CViewRenderer::CViewRenderer() + { + nlassert( CViewRenderer::driver != NULL ); + nlassert( CViewRenderer::textcontext != NULL ); + nlassert( CViewRenderer::hwCursors != NULL ); + setup(); + } + + CViewRenderer::~CViewRenderer() + { + for(uint i=0;igetWindowSize (w, h); + // not minimized? change coords + if(w!=0 && h!=0) + { + _IsMinimized= false; + _ScreenW = w; + _ScreenH = h; + if(_ScreenW>0) + _OneOverScreenW = 1.0f / (float)_ScreenW; + else + _OneOverScreenW = 1000; + if(_ScreenH>0) + _OneOverScreenH = 1.0f / (float)_ScreenH; + else + _OneOverScreenH = 1000; + } + else + { + // Keep old coordinates (suppose resolution won't change, even if typically false wen we swithch from outgame to ingame) + _IsMinimized= true; + } + } + + + /* + * getScreenSize : get the screen window size + */ + void CViewRenderer::getScreenSize (uint32 &w, uint32 &h) + { + w = _ScreenW; + h = _ScreenH; + } + + /* + * get OOW / OOH + */ + void CViewRenderer::getScreenOOSize (float &oow, float &ooh) + { + oow= _OneOverScreenW; + ooh= _OneOverScreenH; + } + + void CViewRenderer::setup() + { + _ClipX = _ClipY = 0; + _ClipW = 800; + _ClipH = 600; + _ScreenW = 800; + _ScreenH = 600; + _OneOverScreenW= 1.0f / (float)_ScreenW; + _OneOverScreenH= 1.0f / (float)_ScreenH; + _IsMinimized= false; + _WFigurTexture= 0; + _HFigurTexture= 0; + _WFigurSeparatorTexture = 0; + _FigurSeparatorTextureId = -1; + _FigurBlankId = -1; + _BlankId = -1; + _WorldSpaceTransformation = true; + _CurrentZ = 10; + for(uint i=0;icreateMaterial(); + + setRenderStates(); + + // Init all renderBuffer + for(uint i=0;icreateRenderBuffer(); + } + } + + void CViewRenderer::setRenderStates() + { + _Material.setDoubleSided(); + _Material.setZWrite(false); + _Material.setZFunc(UMaterial::always); + _Material.setBlend (true); + _Material.setBlendFunc (NL3D::UMaterial::srcalpha, NL3D::UMaterial::invsrcalpha); + _Material.setColor(CRGBA::White); + _Material.setTexture(0, NULL); + _Material.setTexture(1, NULL); + _Material.setTexture(2, NULL); + _Material.setTexture(3, NULL); + _Material.setZBias(0); + } + /* + * reset: reset the whole view renderer + */ + void CViewRenderer::reset() + { + TGlobalTextureList::iterator ite = _GlobalTextures.begin(); + while (ite != _GlobalTextures.end()) + { + UTextureFile *tf = dynamic_cast(ite->Texture); + if (tf) + { + driver->deleteTextureFile (tf); + } + ite++; + } + + _GlobalTextures.clear(); + _SImages.clear(); + _SImageIterators.clear(); + _TextureMap.clear(); + _IndexesToTextureIds.clear(); + } + + NL3D::UDriver* CViewRenderer::getDriver(){ + return driver; + } + + void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext) + { + CViewRenderer::textcontext = textcontext; + } + + void CViewRenderer::setDriver( NL3D::UDriver *driver ) + { + CViewRenderer::driver = driver; + } + + // *************************************************************************** + void CViewRenderer::SImage::setupQuadUV(bool flipv, uint8 rot, CQuadColorUV &dest) + { + nlassert(rot<=3); + // Rotation is CW and flip is along x axis + // Flip is vertical flip (this means we invert all y for a constant x) + // The transforms are done in this order : first apply the flip (or not) and then rotate + static const CUV UVTab[8][4] = { + { CUV(0, 0), CUV(1, 0), CUV(1, 1), CUV(0, 1) }, // rot 0, no flip + { CUV(1, 0), CUV(1, 1), CUV(0, 1), CUV(0, 0) }, // rot 1, no flip + { CUV(1, 1), CUV(0, 1), CUV(0, 0), CUV(1, 0) }, // rot 2, no flip + { CUV(0, 1), CUV(0, 0), CUV(1, 0), CUV(1, 1) }, // rot 3, no flip + { CUV(1, 0), CUV(0, 0), CUV(0, 1), CUV(1, 1) }, // rot 0, flipped + { CUV(0, 0), CUV(0, 1), CUV(1, 1), CUV(1, 0) }, // rot 1, flipped + { CUV(0, 1), CUV(1, 1), CUV(1, 0), CUV(0, 0) }, // rot 2, flipped + { CUV(1, 1), CUV(1, 0), CUV(0, 0), CUV(0, 1) } // rot 3, flipped + }; + + // Take care that the origin in the texture is top left so to get the texture in bottom-up + // we have to start at Max and go at Min. For left and right this is Min to Max. + + float du = UVMax.U - UVMin.U; + float dv = UVMin.V - UVMax.V; + + uint idx = flipv*4 + rot; + + dest.Uv0 = CUV (UVMin.U + UVTab[idx][0].U * du, UVMax.V + UVTab[idx][0].V * dv); + dest.Uv1 = CUV (UVMin.U + UVTab[idx][1].U * du, UVMax.V + UVTab[idx][1].V * dv); + dest.Uv2 = CUV (UVMin.U + UVTab[idx][2].U * du, UVMax.V + UVTab[idx][2].V * dv); + dest.Uv3 = CUV (UVMin.U + UVTab[idx][3].U * du, UVMax.V + UVTab[idx][3].V * dv); + + /* // TRAP : Unrolled Version (To be tested to know if it is faster than the previous one) + if (flipv) + { + switch (rot) + { + case 0: + qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMax.V; + qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMax.V; + qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMin.V; + qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMin.V; + break; + case 1: + qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; + qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMin.V; + qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; + qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMax.V; + break; + case 2: + qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMin.V; + qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMin.V; + qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMax.V; + qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMax.V; + break; + case 3: + qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMin.V; + qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; + qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMax.V; + qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; + break; + } + } + else + { + switch (rot) + { + case 0: + qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; + qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; + qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; + qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; + break; + case 1: + qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMin.V; + qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMax.V; + qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMax.V; + qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMin.V; + break; + case 2: + qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMin.V; + qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMin.V; + qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMax.V; + qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMax.V; + break; + case 3: + qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMax.V; + qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMin.V; + qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMin.V; + qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMax.V; + break; + } + } + */ + } + // *************************************************************************** + + /* + * drawRotFlipBitmapTiled + */ + void CViewRenderer::drawRotFlipBitmapTiled (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flip, + sint32 nTxId, uint tileOrigin, const CRGBA &col) + { + static volatile bool draw = true; + if (!draw) return; + if (width <= 0 || height <= 0) return; + + if (nTxId < 0) return; + + // Is totally clipped ? + if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || + (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) + return; + + SImage &rI = *getSImage(nTxId); + + sint32 txw, txh; + // start to draw at the reference corner + getTextureSizeFromId (nTxId, txw, txh); + + if (rot > 3) rot = 3; + + sint32 startX = x, startY = y; + sint32 stepX = txw, stepY = txh; + + if (rot & 1) + { + std::swap(txw, txh); + } + + // choose new start pos & uvs depending on the reference corner + // Along x axis + if (tileOrigin & 1) // right or left ? + { // right + startX = x + width - txw; + stepX = -txw; + } + + // Along y axis + if (tileOrigin & 2) // bottom or top ? + { // top + startY = y + height - txh; + stepY = -txh; + } + + // Fit screen coordinates + + float fStartX = (float) startX * _OneOverScreenW; + float fStartY = (float) startY * _OneOverScreenH; + float fStepX = (float) stepX * _OneOverScreenW; + float fStepY = (float) stepY * _OneOverScreenH; + float fTxW = (float) txw * _OneOverScreenW; + float fTxH = (float) txh * _OneOverScreenH; + + CQuadColorUV qcoluv; + + qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; + qcoluv.V0.z = qcoluv.V1.z = qcoluv.V2.z = qcoluv.V3.z = 0; + rI.setupQuadUV(flip,rot,qcoluv); + + uint numTileX = (uint32)((width - 1) / txw); + uint numTileY = (uint32)((height- 1) / txh); + + float currY = fStartY; + + sint32 oldClipX = _ClipX; + sint32 oldClipY = _ClipY; + sint32 oldClipW = _ClipW; + sint32 oldClipH = _ClipH; + if (x < _ClipX) { width -= _ClipX - x; x = _ClipX; } + if (y < _ClipY) { height -= _ClipY - y; y = _ClipY; } + if ((x+width) > (_ClipX+_ClipW)) width -= (x+width) - (_ClipX+_ClipW); + if ((y+height) > (_ClipY+_ClipH)) height -= (y+height) - (_ClipY+_ClipH); + setClipWindow (x, y, width, height); + + // draw result let the clipper clip the quads + for(uint py = 0; py <= numTileY; ++py) + { + float currX = fStartX; + for(uint px = 0; px <= numTileX; ++px) + { + /// There is room for speedup there + qcoluv.V0.x = currX; + qcoluv.V1.x = currX + fTxW; + qcoluv.V2.x = currX + fTxW; + qcoluv.V3.x = currX; + + qcoluv.V0.y = currY; + qcoluv.V1.y = currY; + qcoluv.V2.y = currY + fTxH; + qcoluv.V3.y = currY + fTxH; + + // Is NOT totally clipped ? + if ( !( (qcoluv.V0.x > _XMax) || (qcoluv.V2.x < _XMin) || + (qcoluv.V0.y > _YMax) || (qcoluv.V2.y < _YMin) ) ) + putQuadInLayer (*(rI.GlobalTexturePtr), layerId, qcoluv, rot); + + currX += fStepX; + } + currY += fStepY; + } + + setClipWindow (oldClipX, oldClipY, oldClipW, oldClipH); + } + + + /* + * drawBitmap + */ + void CViewRenderer::drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, + uint8 rot, bool flipv, sint32 nTxId, const CRGBA &col) + { + if (width <= 0 || height <= 0) return; + + if (nTxId < 0) + return; + + + + float dstXmin, dstYmin, dstXmax, dstYmax; + + // Is totally clipped ? + if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || + (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) + return; + + dstXmin = (float)(x) * _OneOverScreenW; + dstYmin = (float)(y) * _OneOverScreenH; + dstXmax = (float)(x + width) * _OneOverScreenW; + dstYmax = (float)(y + height) * _OneOverScreenH; + + CQuadColorUV qcoluv; + qcoluv.V0.set (dstXmin, dstYmin, 0); + qcoluv.V1.set (dstXmax, dstYmin, 0); + qcoluv.V2.set (dstXmax, dstYmax, 0); + qcoluv.V3.set (dstXmin, dstYmax, 0); + + qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; + + SImage &rI = *getSImage(nTxId); + + // Avoid switch in common case + if (!flipv && !rot) + { + qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; + qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; + qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; + qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; + } + // else standard case + else + { + if (rot > 3) + rot = 3; + + rI.setupQuadUV(flipv, rot, qcoluv); + } + + static volatile bool doRot[4] = { true, true, true, true }; + if (doRot[rot]) + { + putQuadInLayer (*(rI.GlobalTexturePtr), layerId, qcoluv, rot); + } + } + + + /* + * draw11RotBitmap + * sTx must be lowered !!! + */ + void CViewRenderer::draw11RotFlipBitmap (sint layerId, sint32 x, sint32 y, uint8 rot, bool flipv, sint32 nTxId, const CRGBA &col) + { + if (nTxId < 0) + return; + + sint32 txw, txh; + SImage &rImage = *getSImage(nTxId); + txw = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f); + txh = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f); + + drawRotFlipBitmap (layerId, x, y, txw, txh, rot, flipv, nTxId, col); + } + + + inline void remapUV(CUV &dest, const CUV &src, const CUV &min, const CUV &max) + { + dest.set(src.U * (max.U - min.U) + min.U, src.V * (max.V - min.V) + min.V); + } + + void CViewRenderer::drawQuad(sint layerId, const NLMISC::CQuadUV &quadUV, sint32 nTxId, NLMISC::CRGBA col /*=NLMISC::CRGBA(255,255,255,255)*/, bool additif, bool filtered) + { + nlassert(!(additif && !filtered)); // not implemented yet! + if (nTxId < 0) + return; + CQuadColorUV normedQuad; + // + normedQuad.V0.set(quadUV.V0.x * _OneOverScreenW, quadUV.V0.y * _OneOverScreenH, 0.f); + normedQuad.V1.set(quadUV.V1.x * _OneOverScreenW, quadUV.V1.y * _OneOverScreenH, 0.f); + normedQuad.V2.set(quadUV.V2.x * _OneOverScreenW, quadUV.V2.y * _OneOverScreenH, 0.f); + normedQuad.V3.set(quadUV.V3.x * _OneOverScreenW, quadUV.V3.y * _OneOverScreenH, 0.f); + // + float qXMin = minof(normedQuad.V0.x, normedQuad.V1.x, normedQuad.V2.x, normedQuad.V3.x); + if (qXMin > _XMax) return; + float qXMax = maxof(normedQuad.V0.x, normedQuad.V1.x, normedQuad.V2.x, normedQuad.V3.x); + if (qXMax < _XMin) return; + float qYMin = minof(normedQuad.V0.y, normedQuad.V1.y, normedQuad.V2.y, normedQuad.V3.y); + if (qYMin > _YMax) return; + float qYMax = maxof(normedQuad.V0.y, normedQuad.V1.y, normedQuad.V2.y, normedQuad.V3.y); + if (qYMax < _YMin) return; + // + + + + SImage &rImage = *getSImage(nTxId); + SGlobalTexture > = *(rImage.GlobalTexturePtr); + CUV deltaUV(1.f / (float) gt.Width, 1.f / (float) gt.Height); + CUV cornerMin = rImage.UVMin + deltaUV; + CUV cornerMax = rImage.UVMax - deltaUV; + remapUV(normedQuad.Uv0, quadUV.Uv0, cornerMin, cornerMax); + remapUV(normedQuad.Uv1, quadUV.Uv1, cornerMin, cornerMax); + remapUV(normedQuad.Uv2, quadUV.Uv2, cornerMin, cornerMax); + remapUV(normedQuad.Uv3, quadUV.Uv3, cornerMin, cornerMax); + + // test if clipping is required + if (qXMin >= _XMin && qYMin >= _YMin && qXMax <= _XMax && qYMax <= _YMax) + { + // not clipped, easy case + normedQuad.Color0 = normedQuad.Color1 = normedQuad.Color2 = normedQuad.Color3 = col; + + if (_WorldSpaceTransformation) + { + worldSpaceTransformation (normedQuad); + } + + layerId+= VR_BIAS_LAYER; + nlassert(layerId>=0 && layerIdLayers[layerId]; + if (!filtered) + { + if (layer.NbQuads == layer.Quads.size()) + layer.Quads.push_back (normedQuad); + else + layer.Quads[layer.NbQuads] = normedQuad; + ++ layer.NbQuads; + } + else if (additif) layer.FilteredAdditifQuads.push_back(normedQuad); + else layer.FilteredAlphaBlendedQuads.push_back(normedQuad); + _EmptyLayer[layerId]= false; + } + else + { + // Partially clipped (slowest case) + // Must do the clip manually + static const uint maxNumCorners = 8; + // + static CVector outPos0[maxNumCorners]; + static CUV outUV0[maxNumCorners]; + static CVector outPos1[maxNumCorners]; + static CUV outUV1[maxNumCorners]; + // + outUV0[0] = normedQuad.Uv0; + outUV0[1] = normedQuad.Uv1; + outUV0[2] = normedQuad.Uv2; + outUV0[3] = normedQuad.Uv3; + // + outPos0[0] = normedQuad.V0; + outPos0[1] = normedQuad.V1; + outPos0[2] = normedQuad.V2; + outPos0[3] = normedQuad.V3; + // + CVector *pPos0 = outPos0; + CVector *pPos1 = outPos1; + CUV *pUV0 = outUV0; + CUV *pUV1 = outUV1; + // + sint count = 4; + // + if (qXMin < _XMin) + { + // clip left + CPlane clipper(-1.f, 0.f, 0.f, _XMin); + count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); + std::swap(pPos0, pPos1); + std::swap(pUV0, pUV1); + } + if (qXMax > _XMax) + { + // clip right + CPlane clipper(1.f, 0.f, 0.f, -_XMax); + count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); + std::swap(pPos0, pPos1); + std::swap(pUV0, pUV1); + } + // + if (qYMin < _YMin) + { + // clip bottom + CPlane clipper(0.f, -1.f, 0.f, _YMin); + count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); + std::swap(pPos0, pPos1); + std::swap(pUV0, pUV1); + } + if (qYMax > _YMax) + { + // clip top + CPlane clipper(0.f, 1.f, 0.f, -_YMax); + count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); + std::swap(pPos0, pPos1); + std::swap(pUV0, pUV1); + } + + nlassert(count <= (sint)maxNumCorners); + if (count >= 3) + { + count -= 2; + layerId+= VR_BIAS_LAYER; + nlassert(layerId>=0 && layerIdLayers[layerId]; + std::vector *tris; + if (!filtered) + { + tris = &layer.Tris; + } + else + { + tris = additif ? &layer.FilteredAdditifTris : &layer.FilteredAlphaBlendedTris; + } + tris->resize(tris->size() + count); + CTriangleColorUV *lastTri = &tris->back() + 1; + CTriangleColorUV *currTri = lastTri - count; + const CVector *firstPos = pPos0++; + const CUV *firstUV = pUV0++; + do + { + currTri->V0 = *firstPos; + currTri->V1 = *pPos0; + currTri->V2 = *(pPos0 + 1); + currTri->Color0 = col; + currTri->Color1 = col; + currTri->Color2 = col; + currTri->Uv0 = *firstUV; + currTri->Uv1 = *pUV0; + currTri->Uv2 = *(pUV0 + 1); + + pPos0 ++; + pUV0 ++; + ++currTri; + } + while (currTri != lastTri); + _EmptyLayer[layerId]= false; + } + } + } + + + void CViewRenderer::drawUnclippedTriangles(sint layerId, const std::vector &tris, NLMISC::CRGBA col) + { + if (tris.empty()) return; + if (!_BlankGlobalTexture) return; + // primary goal here is batching, so we prefer to draw the triangle with a blank texture rather than + // switching material and having to flush all primitives . + layerId+= VR_BIAS_LAYER; + nlassert(layerId>=0 && layerIdLayers[layerId]; + uint startCount = (uint)layer.FilteredAlphaBlendedTris.size(); + layer.FilteredAlphaBlendedTris.resize(startCount + tris.size()); + const NLMISC::CTriangle *src =&tris[0]; + const NLMISC::CTriangle *last = src + tris.size(); + NLMISC::CTriangleColorUV *dest = &layer.FilteredAlphaBlendedTris[0] + startCount; + _EmptyLayer[layerId]= false; + do + { + dest->V0.set(src->V0.x * _OneOverScreenW, src->V0.y * _OneOverScreenH, 0.f); + dest->V1.set(src->V1.x * _OneOverScreenW, src->V1.y * _OneOverScreenH, 0.f); + dest->V2.set(src->V2.x * _OneOverScreenW, src->V2.y * _OneOverScreenH, 0.f); + static volatile bool testOpaque = false; + if (testOpaque) + { + dest->Color0 = CRGBA::White; + dest->Color1 = CRGBA::White; + dest->Color2 = CRGBA::White; + dest->Uv0.set(0.f, 0.f); + dest->Uv1.set(1.f, 0.f); + dest->Uv2.set(1.f, 1.f); + } + else + { + dest->Color0 = col; + dest->Color1 = col; + dest->Color2 = col; + dest->Uv0 = _BlankUV; + dest->Uv1 = _BlankUV; + dest->Uv2 = _BlankUV; + } + ++ dest; + ++ src; + } + while (src != last); + } + + /* + * loadTextures + */ + void CViewRenderer::loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC) + { + SGlobalTexture gt; + // Load texture file + string filename = CPath::lookup (textureFileName, false); + if (filename == "") return; + CIFile ifTmp; + if (ifTmp.open(filename)) + CBitmap::loadSize (ifTmp, gt.Width, gt.Height); + gt.Texture = driver->createTextureFile (filename); + // Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again. + // Its why we don't release it at the end, because it is likely to be uploaded soon) + CBitmap *texDatas = gt.Texture->generateDatas(); + // + gt.Name = filename; + gt.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); + if(uploadDXTC) + gt.Texture->setUploadFormat(UTexture::DXTC5); + + // Load uv file + CIFile iFile; + filename = CPath::lookup (uvFileName, false); + if (filename == "") return; + if (!iFile.open(filename)) return; + + _GlobalTextures.push_back (gt); + + driver->setCursorScale( CViewRenderer::hwCursorScale ); + + char bufTmp[256], tgaName[256]; + string sTGAname; + float uvMinU, uvMinV, uvMaxU, uvMaxV; + while (!iFile.eof()) + { + iFile.getline (bufTmp, 256); + sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); + SImage image; + image.UVMin.U = uvMinU; + image.UVMin.V = uvMinV; + image.UVMax.U = uvMaxU; + image.UVMax.V = uvMaxV; + sTGAname = toLower(string(tgaName)); + + string::size_type stripPng = sTGAname.find(".png"); + if (stripPng != string::npos) + { + sTGAname[stripPng + 1] = 't'; + sTGAname[stripPng + 2] = 'g'; + sTGAname[stripPng + 3] = 'a'; + } + + image.Name = sTGAname; + image.GlobalTexturePtr = &(_GlobalTextures.back()); + if (getTextureIdFromName(sTGAname) != -1) + { + string tmp = string("duplicate texture name in ") + textureFileName + "(" + sTGAname + ")"; + nlwarning(tmp.c_str()); + } + else + { + sint32 textureId = addSImage(image); + //nlwarning("SIMAGE ADDED: id = %x, name = %s", textureId, image.Name.c_str()); + // Insert in map. + _TextureMap.insert( make_pair(image.Name, textureId) ); + } + + // if this is a cursor texture, extract it now (supported for rgba only now, because of the blit) + if (texDatas && texDatas->getPixelFormat() == CBitmap::RGBA) + { + if( CViewRenderer::hwCursors->count( image.Name ) > 0 ) + { + uint x0 = (uint) (image.UVMin.U * gt.Width); + uint y0 = (uint) (image.UVMin.V * gt.Height); + uint x1 = (uint) (image.UVMax.U * gt.Width); + uint y1 = (uint) (image.UVMax.V * gt.Height); + if (x1 != x0 && y1 != y0) + { + CBitmap curs; + curs.resize(x1 - x0, y1 - y0); + curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0); + driver->addCursor(image.Name, curs); + } + } + } + } + + initIndexesToTextureIds (); + initSystemTextures(); + initTypo(); + } + + + + + void CViewRenderer::setExternalTexture(const std::string &sGlobalTextureName, + NL3D::UTexture *externalTexture, + uint32 externalTexWidth, + uint32 externalTexHeight, + uint32 defaultTexWidth, + uint32 defaultTexHeight + ) + { + if (sGlobalTextureName.empty()) + { + nlwarning("Can't create aglobal texture with an empty name"); + return; + } + // Look if already existing + string sLwrGTName = strlwr(sGlobalTextureName); + TGlobalTextureList::iterator ite = _GlobalTextures.begin(); + while (ite != _GlobalTextures.end()) + { + std::string sText = strlwr(ite->Name); + if (sText == sLwrGTName) + break; + ite++; + } + if (ite == _GlobalTextures.end()) + { + SGlobalTexture gtTmp; + gtTmp.FromGlobaleTexture = true; + + gtTmp.Name = sLwrGTName; + _GlobalTextures.push_back(gtTmp); + ite = _GlobalTextures.end(); + ite--; + } + ite->Width = externalTexWidth; + ite->Height = externalTexHeight; + ite->DefaultWidth = defaultTexWidth; + ite->DefaultHeight = defaultTexHeight; + ite->Texture = externalTexture; + } + + /* + * createTexture + */ + sint32 CViewRenderer::createTexture (const std::string &sGlobalTextureName, + sint32 offsetX, + sint32 offsetY, + sint32 width, + sint32 height, + bool uploadDXTC, + bool bReleasable + ) + { + if (sGlobalTextureName.empty()) return -1; + // Look if already existing + string sLwrGTName = strlwr(sGlobalTextureName); + TGlobalTextureList::iterator ite = _GlobalTextures.begin(); + while (ite != _GlobalTextures.end()) + { + std::string sText = strlwr(ite->Name); + if (sText == sLwrGTName) + break; + ite++; + } + + // If global texture not exists create it + if (ite == _GlobalTextures.end()) + { + SGlobalTexture gtTmp; + gtTmp.FromGlobaleTexture = false; + string filename = CPath::lookup (sLwrGTName, false); + if (filename == "") return -1; + CIFile ifTmp; + if (ifTmp.open(filename)) + { + CBitmap::loadSize (ifTmp, gtTmp.Width, gtTmp.Height); + gtTmp.DefaultWidth = gtTmp.Width; + gtTmp.DefaultHeight = gtTmp.Height; + if (gtTmp.Width == 0 || gtTmp.Height == 0) + { + nlwarning("Failed to load the texture '%s', please check image format", filename.c_str()); + } + } + gtTmp.Texture = driver->createTextureFile (sLwrGTName); + gtTmp.Name = sLwrGTName; + gtTmp.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); + if(uploadDXTC) + gtTmp.Texture->setUploadFormat(UTexture::DXTC5); + gtTmp.Texture->setReleasable(bReleasable); + _GlobalTextures.push_back(gtTmp); + ite = _GlobalTextures.end(); + ite--; + } + + // Add a texture with reference to the i th global texture + SImage iTmp; + + // Set default parameters + if (width == -1) + width = ite->DefaultWidth; + if (height == -1) + height = ite->DefaultHeight; + + iTmp.Name = sLwrGTName; + iTmp.GlobalTexturePtr = &(*ite); + iTmp.UVMin = CUV(((float)offsetX)/ite->Width , ((float)offsetY)/ite->Height); + iTmp.UVMax = CUV(((float)offsetX+width)/ite->Width , ((float)offsetY+height)/ite->Height); + sint32 TextID = addSImage(iTmp); + //nlwarning("SIMAGE ADDED: id = %d, name = %s", TextID, iTmp.Name.c_str()); + + // Insert / replace in map. + // TMP TMP FIX NICO + //_TextureMap.insert( make_pair(iTmp.Name, TextID) ); + + + return TextID; + } + + void CViewRenderer::updateTexturePos(const std::string &texturefileName, sint32 offsetX /*=0*/, sint32 offsetY /*=0*/, sint32 width /*=-1*/, sint32 height /*=-1*/) + { + sint32 id = getTextureIdFromName (texturefileName); + if (id == -1) + { + nlwarning("Unknwown texture %s, can't update pos", texturefileName.c_str()); + return; + } + SImage *im = getSImage(id); + nlassert(im); + // Set default parameters + sint32 gw = im->GlobalTexturePtr->Width; + sint32 gh = im->GlobalTexturePtr->Height; + if (width == -1) + width = gw; + if (height == -1) + height = gh; + im->UVMin = CUV(((float)offsetX)/gw , ((float)offsetY)/gh); + im->UVMax = CUV(((float)offsetX+width)/gw, ((float)offsetY+height)/gh); + } + + + /* + * getGlobalTexture + */ + NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name) + { + string sLwrGTName = strlwr(name); + TGlobalTextureList::iterator ite = _GlobalTextures.begin(); + while (ite != _GlobalTextures.end()) + { + std::string sText = strlwr(ite->Name); + if (sText == sLwrGTName) + break; + ite++; + } + if (ite != _GlobalTextures.end()) + { + return ite->Texture; + } + return NULL; + } + + /* + * deleteTexture + */ + void CViewRenderer::deleteTexture (sint32 textureId) + { + // Checks + nlassert ((uint)textureId < _SImageIterators.size()); + if (_SImageIterators[textureId] == _SImages.end()) + { + nlwarning("Can't delete texture with name %s", getTextureNameFromId(textureId).c_str()); + nlassert(0); + return; + } + + // Backup global texture pointer + SGlobalTexture *gt = getSImage(textureId)->GlobalTexturePtr; + + // Erase only texture from global texture + if (!(gt->FromGlobaleTexture)) + { + //nlwarning("Removing texture with id %d", (int) textureId); + // Erase the SImage + //nlwarning("SIMAGE REMOVE : id = %x, name = %s", (int) textureId, getSImage(textureId)->Name.c_str()); + + + removeSImage (textureId); + + // Check if someone else use this global texture.. + TSImageList::iterator ite = _SImages.begin(); + while (ite != _SImages.end()) + { + // Same global texture ? + if (ite->GlobalTexturePtr == gt) + break; + + ite++; + } + + // Global texture still used ? + if (ite == _SImages.end()) + { + //nlwarning("REMOVE GLOBAL TEXTURE : id of simage = %x", (int) textureId); + // No, remove the global texture + for (TGlobalTextureList::iterator iteGT = _GlobalTextures.begin(); iteGT != _GlobalTextures.end(); iteGT++) + { + // This one ? + if (&(*iteGT) == gt) + { + // Remove this global texture + UTextureFile *tf = dynamic_cast(iteGT->Texture); + if (tf) + { + driver->deleteTextureFile (tf); + } + _GlobalTextures.erase (iteGT); + return; + } + } + // Global texture has not been found + nlstop; + } + } + } + + /* + * getTextureIdFromName + */ + sint32 CViewRenderer::getTextureIdFromName (const string &sName) const + { + if(sName.empty()) + return -1; + + // convert to lowCase + string nameLwr = toLower(sName); + + string::size_type stripPng = nameLwr.find(".png"); + if (stripPng != string::npos) + { + nameLwr[stripPng + 1] = 't'; + nameLwr[stripPng + 2] = 'g'; + nameLwr[stripPng + 3] = 'a'; + } + + // Search in map + TTextureMap::const_iterator it= _TextureMap.find(nameLwr); + if( it==_TextureMap.end() ) + return -1; + else + return it->second; + } + + /* + * getTextureNameFromId + */ + std::string CViewRenderer::getTextureNameFromId (sint32 TxID) + { + if ((TxID < 0) || (TxID >= (sint32)_SImageIterators.size())) + return ""; + SImage *img = getSImage(TxID); + return img->Name; + } + + /* + * getTextureSizeFromName + */ + void CViewRenderer::getTextureSizeFromId (sint32 id, sint32 &width, sint32 &height) + { + if ((id < 0) || (id >= (sint32)_SImageIterators.size())) + { + width = height = 0; + } + else + { + SImage &rImage = *getSImage(id); + width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f); + height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f); + } + } + /* + * getTextureColor + */ + CRGBA CViewRenderer::getTextureColor(sint32 id, sint32 x, sint32 y) + { + if ((id < 0) || (id >= (sint32)_SImageIterators.size())) + { + return CRGBA(255,255,255); + } + + SImage &rImage = *getSImage(id); + SGlobalTexture &rGT = *rImage.GlobalTexturePtr; + sint32 width, height; + width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rGT.Width+0.5f); + height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rGT.Height+0.5f); + float xRatio = ((float)x) / ((float)(width)); + float yRatio = ((float)y) / ((float)(height)); + UTexture *pTF = rGT.Texture; + sint32 xConv = (sint32)((rImage.UVMin.U + xRatio * (rImage.UVMax.U - rImage.UVMin.U))*rGT.Width+0.5f); + sint32 yConv = (rGT.Height-1)-(sint32)((rImage.UVMin.V + yRatio * (rImage.UVMax.V - rImage.UVMin.V))*rGT.Height+0.5f); + return pTF->getPixelColor(xConv, yConv); + } + + // *************************************************************************** + sint32 CViewRenderer::getTypoTextureW(char c) + { + if ((c>=0) && (c=0) && (cLayers[layerId]; + if(layer.NbQuads>0 || !layer.Tris.empty()) + { + // setup the global texture to material + _Material.setTexture(0, ite->Texture); + + // Special Case if _WorldSpaceTransformation and _WorldSpaceScale, enable bilinear + if(_WorldSpaceTransformation && _WorldSpaceScale) + ite->Texture->setFilterMode(UTexture::Linear, UTexture::LinearMipMapOff); + + // draw quads and empty list + if (layer.NbQuads != 0) + { + driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material); + layer.NbQuads = 0; + } + + if (!layer.Tris.empty()) + { + driver->drawTriangles(layer.Tris, _Material); + layer.Tris.clear(); + } + + // Special Case if _WorldSpaceTransformation and _WorldSpaceScale, reset + if(_WorldSpaceTransformation && _WorldSpaceScale) + ite->Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); + } + if (!layer.FilteredAlphaBlendedQuads.empty() || + !layer.FilteredAlphaBlendedTris.empty() || + !layer.FilteredAdditifQuads.empty() || + !layer.FilteredAdditifTris.empty()) + { + // setup the global texture to material + _Material.setTexture(0, ite->Texture); + + // force filtering + ite->Texture->setFilterMode(UTexture::Linear, UTexture::LinearMipMapOff); + // alpha blended + if (!layer.FilteredAlphaBlendedQuads.empty()) + { + driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material); + layer.FilteredAlphaBlendedQuads.clear(); + } + if (!layer.FilteredAlphaBlendedTris.empty()) + { + driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material); + layer.FilteredAlphaBlendedTris.clear(); + } + // additif + if (!layer.FilteredAdditifQuads.empty() || + !layer.FilteredAdditifTris.empty()) + { + _Material.setBlendFunc (NL3D::UMaterial::one, NL3D::UMaterial::one); + if (!layer.FilteredAdditifQuads.empty()) + { + driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material); + layer.FilteredAdditifQuads.clear(); + } + if (!layer.FilteredAdditifTris.empty()) + { + driver->drawTriangles(layer.FilteredAdditifTris, _Material); + layer.FilteredAdditifTris.clear(); + } + // restore alpha blend + _Material.setBlendFunc (NL3D::UMaterial::srcalpha, NL3D::UMaterial::invsrcalpha); + } + ite->Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); + } + ite++; + } + + // **** Display Computed Strings of this layer + if (_WorldSpaceTransformation) + textcontext->flushRenderBufferUnProjected(_StringRBLayers[layerId], false); + else + textcontext->flushRenderBuffer(_StringRBLayers[layerId]); + + // flushed + _EmptyLayer[layerId]= true; + } + } + + + /** + * init the map _IndexesToTextures + */ + void CViewRenderer::initIndexesToTextureIds() + { + char buf[20]; + _IndexesToTextureIds.clear(); + for (uint i = 0; i < 10; i++) + { + sprintf (buf, "numbers_%d.tga", i); + _IndexesToTextureIds.push_back (getTextureIdFromName(buf)); + } + _FigurSeparatorTextureId = getTextureIdFromName("Numbers_sep.tga"); + _FigurBlankId = getTextureIdFromName("numbers_blank.tga"); + _BlankId = getTextureIdFromName("blank.tga"); + + SImage *blank = getSImage(_BlankId); + if (blank) + { + _BlankGlobalTexture = blank->GlobalTexturePtr; + _BlankUV = 0.5f * (blank->UVMin + blank->UVMax); + } + else + { + _BlankUV.set(0.f, 0.f); + } + + + // Init size + if(_IndexesToTextureIds[0]!=-1) + { + getTextureSizeFromId (_IndexesToTextureIds[0], _WFigurTexture, _HFigurTexture); + } + if (_FigurSeparatorTextureId != -1) + { + getTextureSizeFromId (_FigurSeparatorTextureId, _WFigurSeparatorTexture, _HFigurSeparatorTexture); + } + + } + + /** + * + */ + void CViewRenderer::initTypo() + { + _TypoH = 0; + + // since filename dose not support special char (?,. ....), specify a map from char to string. + map specialCharMap; + specialCharMap['?']= "question"; + + + char buf[256]; + // For all supported chars (if tga exist) + for (uint i = 0; i < NumTypoChar; i++) + { + // Get the token string for this char. + string token; + map::iterator it= specialCharMap.find(i); + // General case + if(it==specialCharMap.end()) + token= (char)i; + else + token= it->second; + + // get the fileName + sprintf (buf, "typo_%s.tga", token.c_str()); + sint32 id = getTextureIdFromName(buf); + if(id>=0) + { + _TypoCharToTextureIds[i]= id; + sint32 w,h; + getTextureSizeFromId (id, w, h); + _TypoCharWs[i]= w; + _TypoH = h; + } + else + { + _TypoCharToTextureIds[i]= -1; + // simulate a space. + _TypoCharWs[i]= 1; + } + } + } + + + /** + * needClipping + */ + bool CViewRenderer::needClipping (const CQuad &q) + { + if ((q.V0.x >= _XMin) && (q.V0.y >= _YMin) && (q.V2.x <= _XMax) && (q.V2.y <= _YMax)) + return false; + else + return true; + } + + /** + * clip + */ + void CViewRenderer::clip (CQuadColorUV &qout, const CQuadColorUV &qin, uint rot) + { + float ratio; + + qout = qin; + + if (rot & 1) + { + // must reverse U & V during clipping + if (qin.V0.x < _XMin) + { + ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); + qout.V3.x = qout.V0.x = _XMin; + qout.Uv0.V += ratio*(qin.Uv1.V-qin.Uv0.V); + qout.Uv3.V += ratio*(qin.Uv2.V-qin.Uv3.V); + } + + if (qin.V0.y < _YMin) + { + ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); + qout.V1.y = qout.V0.y = _YMin; + qout.Uv0.U += ratio*(qin.Uv3.U-qin.Uv0.U); + qout.Uv1.U += ratio*(qin.Uv2.U-qin.Uv1.U); + } + + if (qin.V2.x > _XMax) + { + ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); + qout.V2.x = qout.V1.x = _XMax; + qout.Uv2.V += ratio*(qin.Uv3.V-qin.Uv2.V); + qout.Uv1.V += ratio*(qin.Uv0.V-qin.Uv1.V); + } + + if (qin.V2.y > _YMax) + { + ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); + qout.V2.y = qout.V3.y = _YMax; + qout.Uv2.U += ratio*(qin.Uv1.U-qin.Uv2.U); + qout.Uv3.U += ratio*(qin.Uv0.U-qin.Uv3.U); + } + } + else + { + if (qin.V0.x < _XMin) + { + ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); + qout.V3.x = qout.V0.x = _XMin; + qout.Uv0.U += ratio*(qin.Uv1.U-qin.Uv0.U); + qout.Uv3.U += ratio*(qin.Uv2.U-qin.Uv3.U); + } + + if (qin.V0.y < _YMin) + { + ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); + qout.V1.y = qout.V0.y = _YMin; + qout.Uv0.V += ratio*(qin.Uv3.V-qin.Uv0.V); + qout.Uv1.V += ratio*(qin.Uv2.V-qin.Uv1.V); + } + + if (qin.V2.x > _XMax) + { + ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); + qout.V2.x = qout.V1.x = _XMax; + qout.Uv2.U += ratio*(qin.Uv3.U-qin.Uv2.U); + qout.Uv1.U += ratio*(qin.Uv0.U-qin.Uv1.U); + } + + if (qin.V2.y > _YMax) + { + ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); + qout.V2.y = qout.V3.y = _YMax; + qout.Uv2.V += ratio*(qin.Uv1.V-qin.Uv2.V); + qout.Uv3.V += ratio*(qin.Uv0.V-qin.Uv3.V); + } + } + } + + /** + * clip with uv2 + */ + void CViewRenderer::clip (CQuadColorUV2 &qout, const CQuadColorUV2 &qin) + { + float ratio; + + qout = qin; + + if (qin.V0.x < _XMin) + { + ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); + qout.V3.x = qout.V0.x = _XMin; + qout.Uv0.U += ratio*(qin.Uv1.U-qin.Uv0.U); + qout.Uv3.U += ratio*(qin.Uv2.U-qin.Uv3.U); + qout.Uv02.U += ratio*(qin.Uv12.U-qin.Uv02.U); + qout.Uv32.U += ratio*(qin.Uv22.U-qin.Uv32.U); + } + + if (qin.V0.y < _YMin) + { + ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); + qout.V1.y = qout.V0.y = _YMin; + qout.Uv0.V += ratio*(qin.Uv3.V-qin.Uv0.V); + qout.Uv1.V += ratio*(qin.Uv2.V-qin.Uv1.V); + qout.Uv02.V += ratio*(qin.Uv32.V-qin.Uv02.V); + qout.Uv12.V += ratio*(qin.Uv22.V-qin.Uv12.V); + } + + if (qin.V2.x > _XMax) + { + ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); + qout.V2.x = qout.V1.x = _XMax; + qout.Uv2.U += ratio*(qin.Uv3.U-qin.Uv2.U); + qout.Uv1.U += ratio*(qin.Uv0.U-qin.Uv1.U); + qout.Uv22.U += ratio*(qin.Uv32.U-qin.Uv22.U); + qout.Uv12.U += ratio*(qin.Uv02.U-qin.Uv12.U); + } + + if (qin.V2.y > _YMax) + { + ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); + qout.V2.y = qout.V3.y = _YMax; + qout.Uv2.V += ratio*(qin.Uv1.V-qin.Uv2.V); + qout.Uv3.V += ratio*(qin.Uv0.V-qin.Uv3.V); + qout.Uv22.V += ratio*(qin.Uv12.V-qin.Uv22.V); + qout.Uv32.V += ratio*(qin.Uv02.V-qin.Uv32.V); + } + } + + + // *************************************************************************** + /** + * putQuadInLayer : put a quad in a specific layer of a specific texture + */ + void CViewRenderer::putQuadInLayer (SGlobalTexture >, sint layerId, const NLMISC::CQuadColorUV &qcoluv, uint rot) + { + layerId+= VR_BIAS_LAYER; + nlassert(layerId>=0 && layerId=0 && layerIddrawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); + } + + // *************************************************************************** + void CViewRenderer::drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/) + { + driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); + } + + + + // *************************************************************************** + void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, CRGBA col, UMaterial Mat) + { + float dstXmin, dstYmin, dstXmax, dstYmax; + + // Is totally clipped ? + if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || + (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) + return; + + flush(); + + // Initialize quad + dstXmin = (float)(x) * _OneOverScreenW; + dstYmin = (float)(y) * _OneOverScreenH; + dstXmax = (float)(x + width) * _OneOverScreenW; + dstYmax = (float)(y + height) * _OneOverScreenH; + + CQuadColorUV2 qcoluv2; + qcoluv2.V0.set (dstXmin, dstYmin, 0); + qcoluv2.V1.set (dstXmax, dstYmin, 0); + qcoluv2.V2.set (dstXmax, dstYmax, 0); + qcoluv2.V3.set (dstXmin, dstYmax, 0); + + qcoluv2.Color0 = qcoluv2.Color1 = qcoluv2.Color2 = qcoluv2.Color3 = col; + + qcoluv2.Uv0.U = 0; qcoluv2.Uv0.V = 1; + qcoluv2.Uv1.U = 1; qcoluv2.Uv1.V = 1; + qcoluv2.Uv2.U = 1; qcoluv2.Uv2.V = 0; + qcoluv2.Uv3.U = 0; qcoluv2.Uv3.V = 0; + + qcoluv2.Uv02.U = 0; qcoluv2.Uv02.V = 1; + qcoluv2.Uv12.U = 1; qcoluv2.Uv12.V = 1; + qcoluv2.Uv22.U = 1; qcoluv2.Uv22.V = 0; + qcoluv2.Uv32.U = 0; qcoluv2.Uv32.V = 0; + + // Clipping part + CQuadColorUV2 qcoluv2_clipped; + if (!needClipping(qcoluv2)) + { + // No need to clip the quad + qcoluv2_clipped = qcoluv2; + } + else + { + clip (qcoluv2_clipped, qcoluv2); + } + + // World space transformation + if (_WorldSpaceTransformation) + worldSpaceTransformation (qcoluv2_clipped); + + // Draw clipped quad + driver->drawQuads (&qcoluv2_clipped, 1, Mat); + } + + // *************************************************************************** + void CViewRenderer::drawCustom(sint32 x, sint32 y, sint32 width, sint32 height, const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, NLMISC::CRGBA col, NL3D::UMaterial Mat) + { + float dstXmin, dstYmin, dstXmax, dstYmax; + + // Is totally clipped ? + if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || + (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) + return; + + flush(); + + // Initialize quad + dstXmin = (float)(x) * _OneOverScreenW; + dstYmin = (float)(y) * _OneOverScreenH; + dstXmax = (float)(x + width) * _OneOverScreenW; + dstYmax = (float)(y + height) * _OneOverScreenH; + + CQuadColorUV qcoluv; + qcoluv.V0.set (dstXmin, dstYmin, 0); + qcoluv.V1.set (dstXmax, dstYmin, 0); + qcoluv.V2.set (dstXmax, dstYmax, 0); + qcoluv.V3.set (dstXmin, dstYmax, 0); + + qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; + + qcoluv.Uv0.U = uv0Min.U; qcoluv.Uv0.V = uv0Max.V; + qcoluv.Uv1.U = uv0Max.U; qcoluv.Uv1.V = uv0Max.V; + qcoluv.Uv2.U = uv0Max.U; qcoluv.Uv2.V = uv0Min.V; + qcoluv.Uv3.U = uv0Min.U; qcoluv.Uv3.V = uv0Min.V; + + + // Clipping part + CQuadColorUV qcoluv_clipped; + if (!needClipping(qcoluv)) + { + // No need to clip the quad + qcoluv_clipped = qcoluv; + } + else + { + clip (qcoluv_clipped, qcoluv, 0); + } + + // Draw clipped quad + driver->drawQuads (&qcoluv_clipped, 1, Mat); + } + + // *************************************************************************** + void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, + const CUV &uv0Min, const CUV &uv0Max, const CUV &uv1Min, const CUV &uv1Max, + NLMISC::CRGBA col, NL3D::UMaterial Mat) + { + float dstXmin, dstYmin, dstXmax, dstYmax; + + // Is totally clipped ? + if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || + (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) + return; + + flush(); + + // Initialize quad + dstXmin = (float)(x) * _OneOverScreenW; + dstYmin = (float)(y) * _OneOverScreenH; + dstXmax = (float)(x + width) * _OneOverScreenW; + dstYmax = (float)(y + height) * _OneOverScreenH; + + CQuadColorUV2 qcoluv2; + qcoluv2.V0.set (dstXmin, dstYmin, 0); + qcoluv2.V1.set (dstXmax, dstYmin, 0); + qcoluv2.V2.set (dstXmax, dstYmax, 0); + qcoluv2.V3.set (dstXmin, dstYmax, 0); + + qcoluv2.Color0 = qcoluv2.Color1 = qcoluv2.Color2 = qcoluv2.Color3 = col; + + qcoluv2.Uv0.U = uv0Min.U; qcoluv2.Uv0.V = uv0Max.V; + qcoluv2.Uv1.U = uv0Max.U; qcoluv2.Uv1.V = uv0Max.V; + qcoluv2.Uv2.U = uv0Max.U; qcoluv2.Uv2.V = uv0Min.V; + qcoluv2.Uv3.U = uv0Min.U; qcoluv2.Uv3.V = uv0Min.V; + + qcoluv2.Uv02.U = uv1Min.U; qcoluv2.Uv02.V = uv1Max.V; + qcoluv2.Uv12.U = uv1Max.U; qcoluv2.Uv12.V = uv1Max.V; + qcoluv2.Uv22.U = uv1Max.U; qcoluv2.Uv22.V = uv1Min.V; + qcoluv2.Uv32.U = uv1Min.U; qcoluv2.Uv32.V = uv1Min.V; + + // Clipping part + CQuadColorUV2 qcoluv2_clipped; + if (!needClipping(qcoluv2)) + { + // No need to clip the quad + qcoluv2_clipped = qcoluv2; + } + else + { + clip (qcoluv2_clipped, qcoluv2); + } + + // World space transformation + if (_WorldSpaceTransformation) + worldSpaceTransformation (qcoluv2_clipped); + + // Draw clipped quad + driver->drawQuads (&qcoluv2_clipped, 1, Mat); + } + + // *************************************************************************** + + CViewRenderer::CTextureId::~CTextureId () + { + if (_TextureId>=0) + CViewRenderer::getInstance()->deleteTexture(_TextureId); + _TextureId = -1; + } + + // *************************************************************************** + + bool CViewRenderer::CTextureId::setTexture (const char *textureName, sint32 offsetX, sint32 offsetY, sint32 width, sint32 height, + bool uploadDXTC, bool bReleasable) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if (_TextureId>=0) + rVR.deleteTexture(_TextureId); + _TextureId = rVR.getTextureIdFromName(textureName); + if (_TextureId<0) + _TextureId = rVR.createTexture (textureName, offsetX, offsetY, width, height, uploadDXTC, bReleasable); + + return _TextureId >= 0; + } + + // *************************************************************************** + void CViewRenderer::CTextureId::serial(NLMISC::IStream &f) + { + std::string texName; + if (f.isReading()) + { + f.serial(texName); + setTexture(texName.c_str()); + } + else + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + texName = rVR.getTextureNameFromId(_TextureId); + f.serial(texName); + } + } + + // *************************************************************************** + + void CViewRenderer::worldSpaceTransformation (NLMISC::CQuadColorUV &qcoluv) + { + // set the world Z + qcoluv.V0.z = _CurrentZ; + qcoluv.V1.z = _CurrentZ; + qcoluv.V2.z = _CurrentZ; + qcoluv.V3.z = _CurrentZ; + + // for scaled interface, apply the scale matrix + qcoluv.V0= _WorldSpaceMatrix * qcoluv.V0; + qcoluv.V1= _WorldSpaceMatrix * qcoluv.V1; + qcoluv.V2= _WorldSpaceMatrix * qcoluv.V2; + qcoluv.V3= _WorldSpaceMatrix * qcoluv.V3; + + // unproject + qcoluv.V0 = _CameraFrustum.unProjectZ(qcoluv.V0); + qcoluv.V1 = _CameraFrustum.unProjectZ(qcoluv.V1); + qcoluv.V2 = _CameraFrustum.unProjectZ(qcoluv.V2); + qcoluv.V3 = _CameraFrustum.unProjectZ(qcoluv.V3); + } + + // *************************************************************************** + + void CViewRenderer::setWorldSpaceFrustum (const NL3D::CFrustum &cameraFrustum) + { + _CameraFrustum = cameraFrustum; + } + + // *************************************************************************** + + void CViewRenderer::activateWorldSpaceMatrix (bool activate) + { + _WorldSpaceTransformation = activate; + if (!_Material.empty()) + _Material.setZFunc(activate?UMaterial::lessequal:UMaterial::always); + } + + // *************************************************************************** + + void CViewRenderer::drawText (sint layerId, float x, float y, uint wordIndex, float xmin, float ymin, float xmax, float ymax, UTextContext &textContext) + { + if (_WorldSpaceTransformation) + { + textContext.printClipAtUnProjected(*getStringRenderBuffer(layerId), _CameraFrustum, _WorldSpaceMatrix, x, y, _CurrentZ, wordIndex, xmin, ymin, xmax, ymax); + } + else + { + textContext.printClipAt(*getStringRenderBuffer(layerId), x, y, wordIndex, xmin, ymin, xmax, ymax); + } + + // layer is no more empty + _EmptyLayer[layerId + VR_BIAS_LAYER]= false; + } + + // *************************************************************************** + + void CViewRenderer::setInterfaceDepth (const NLMISC::CVector &projCenter, float scale) + { + _CurrentZ = projCenter.z; + + // no scale? => identity matrix (faster) + if(scale==1) + { + _WorldSpaceMatrix.identity(); + _WorldSpaceScale= false; + } + else + { + _WorldSpaceMatrix.identity(); + // must be in 0..1 coordinate here... + CVector pos= projCenter; + pos.x*= _OneOverScreenW; + pos.y*= _OneOverScreenH; + // set a pivoted scale matrix + _WorldSpaceMatrix.translate(pos); + _WorldSpaceMatrix.scale(scale); + _WorldSpaceMatrix.translate(-pos); + _WorldSpaceScale= true; + } + } +} diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.h b/code/ryzom/client/src/interface_v3/ctrl_button.h index 3b035b01c..8ff9686af 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_button.h @@ -20,7 +20,7 @@ #define RZ_CTRL_BUTTON_H #include "ctrl_base_button.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" namespace NLGUI { diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp index 08d1fb691..bf404259b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "ctrl_polygon.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.h b/code/ryzom/client/src/interface_v3/ctrl_polygon.h index 356f37e55..4ad4cd34e 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.h +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.h @@ -19,8 +19,7 @@ #define RZ_CTRL_POLYGON_H #include "ctrl_base.h" -#include "view_renderer.h" -// +#include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" #include "nel/misc/polygon.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.h b/code/ryzom/client/src/interface_v3/ctrl_quad.h index c2ce759cb..1f3f5328c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.h +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.h @@ -19,7 +19,7 @@ #define RZ_CTRL_QUAD_H #include "ctrl_base.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" /** Display of an arbitrary textured quad in the UI. The applied texture is filtered. diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h index 6383f3374..965f3c42d 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.h @@ -20,7 +20,7 @@ #define NL_CTRL_TEXT_BUTTON_H #include "ctrl_base_button.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 29b6d21ad..b683ea597 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -46,7 +46,12 @@ class IListSheetBase; class CSBrickSheet; class CSPhraseSheet; class COutpostBuildingSheet; -class CViewRenderer; + +namespace NLGUI +{ + class CViewRenderer; +} + // *************************************************************************** /** Common info for CDBCtrlSheet and CDBGroupListSheet diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index ba1023f48..2e468acd9 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -23,7 +23,7 @@ #include "group_in_scene.h" #include "interface_manager.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "nel/misc/xml_auto_ptr.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 42e465fc0..96b55998f 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -260,6 +260,8 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext this->textcontext = textcontext; CViewRenderer::setDriver( driver ); CViewRenderer::setTextContext( textcontext ); + CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale; + CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::getInstance(); _Instance = this; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 717176359..374853162 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -32,7 +32,7 @@ #include "ctrl_base.h" #include "ctrl_scroll.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" // InterfaceV3 #include "interface_parser.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.h b/code/ryzom/client/src/interface_v3/view_bitmap.h index 670c6fdf7..ce3be1d6a 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap.h @@ -21,7 +21,7 @@ #include "view_base.h" #include "nel/3d/u_texture.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" /** * class implementing a bitmap view diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 7a6740176..3cb386281 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -22,7 +22,7 @@ // #include "view_pointer.h" #include "interface_manager.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "ctrl_col_pick.h" #include "group_paragraph.h" #include "group_html.h" diff --git a/code/ryzom/client/src/interface_v3/view_polygon.cpp b/code/ryzom/client/src/interface_v3/view_polygon.cpp index b033b2885..06c34025d 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/view_polygon.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "view_polygon.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/view_polygon.h b/code/ryzom/client/src/interface_v3/view_polygon.h index cd07a2bba..581f96f4e 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.h +++ b/code/ryzom/client/src/interface_v3/view_polygon.h @@ -19,7 +19,7 @@ #define RZ_VIEW_POLYGON_H #include "view_base.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" // #include "nel/misc/geom_ext.h" #include "nel/misc/polygon.h" diff --git a/code/ryzom/client/src/interface_v3/view_quad.h b/code/ryzom/client/src/interface_v3/view_quad.h index 907f65962..3d6b82923 100644 --- a/code/ryzom/client/src/interface_v3/view_quad.h +++ b/code/ryzom/client/src/interface_v3/view_quad.h @@ -19,7 +19,7 @@ #define RZ_VIEW_QUAD_H #include "view_base.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" /** Display of an arbitrary textured quad in the UI. The applied texture is filtered. diff --git a/code/ryzom/client/src/interface_v3/view_radar.h b/code/ryzom/client/src/interface_v3/view_radar.h index 888aadb78..accad18d2 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.h +++ b/code/ryzom/client/src/interface_v3/view_radar.h @@ -21,7 +21,7 @@ #include "view_base.h" #include "nel/3d/u_texture.h" -#include "view_renderer.h" +#include "nel/gui/view_renderer.h" /** * class implementing a radar view diff --git a/code/ryzom/client/src/interface_v3/view_renderer.cpp b/code/ryzom/client/src/interface_v3/view_renderer.cpp deleted file mode 100644 index 6dfb1e977..000000000 --- a/code/ryzom/client/src/interface_v3/view_renderer.cpp +++ /dev/null @@ -1,1863 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_renderer.h" -#include "nel/misc/path.h" -#include "nel/misc/file.h" -#include "nel/misc/uv.h" -#include "nel/misc/hierarchical_timer.h" -#include "../client_cfg.h" - -using namespace NLMISC; -using namespace std; -using namespace NL3D; - -CViewRenderer* CViewRenderer::instance = NULL; -NL3D::UDriver* CViewRenderer::driver = NULL; -NL3D::UTextContext* CViewRenderer::textcontext = NULL; - -CViewRenderer::CViewRenderer() -{ - nlassert( driver != NULL ); - nlassert( textcontext != NULL ); - setup(); -} - -CViewRenderer::~CViewRenderer() -{ - for(uint i=0;igetWindowSize (w, h); - // not minimized? change coords - if(w!=0 && h!=0) - { - _IsMinimized= false; - _ScreenW = w; - _ScreenH = h; - if(_ScreenW>0) - _OneOverScreenW = 1.0f / (float)_ScreenW; - else - _OneOverScreenW = 1000; - if(_ScreenH>0) - _OneOverScreenH = 1.0f / (float)_ScreenH; - else - _OneOverScreenH = 1000; - } - else - { - // Keep old coordinates (suppose resolution won't change, even if typically false wen we swithch from outgame to ingame) - _IsMinimized= true; - } -} - - -/* - * getScreenSize : get the screen window size - */ -void CViewRenderer::getScreenSize (uint32 &w, uint32 &h) -{ - w = _ScreenW; - h = _ScreenH; -} - -/* - * get OOW / OOH - */ -void CViewRenderer::getScreenOOSize (float &oow, float &ooh) -{ - oow= _OneOverScreenW; - ooh= _OneOverScreenH; -} - -void CViewRenderer::setup() -{ - _ClipX = _ClipY = 0; - _ClipW = 800; - _ClipH = 600; - _ScreenW = 800; - _ScreenH = 600; - _OneOverScreenW= 1.0f / (float)_ScreenW; - _OneOverScreenH= 1.0f / (float)_ScreenH; - _IsMinimized= false; - _WFigurTexture= 0; - _HFigurTexture= 0; - _WFigurSeparatorTexture = 0; - _FigurSeparatorTextureId = -1; - _FigurBlankId = -1; - _BlankId = -1; - _WorldSpaceTransformation = true; - _CurrentZ = 10; - for(uint i=0;icreateMaterial(); - - setRenderStates(); - - // Init all renderBuffer - for(uint i=0;icreateRenderBuffer(); - } -} - -void CViewRenderer::setRenderStates() -{ - _Material.setDoubleSided(); - _Material.setZWrite(false); - _Material.setZFunc(UMaterial::always); - _Material.setBlend (true); - _Material.setBlendFunc (NL3D::UMaterial::srcalpha, NL3D::UMaterial::invsrcalpha); - _Material.setColor(CRGBA::White); - _Material.setTexture(0, NULL); - _Material.setTexture(1, NULL); - _Material.setTexture(2, NULL); - _Material.setTexture(3, NULL); - _Material.setZBias(0); -} -/* - * reset: reset the whole view renderer - */ -void CViewRenderer::reset() -{ - TGlobalTextureList::iterator ite = _GlobalTextures.begin(); - while (ite != _GlobalTextures.end()) - { - UTextureFile *tf = dynamic_cast(ite->Texture); - if (tf) - { - driver->deleteTextureFile (tf); - } - ite++; - } - - _GlobalTextures.clear(); - _SImages.clear(); - _SImageIterators.clear(); - _TextureMap.clear(); - _IndexesToTextureIds.clear(); -} - -NL3D::UDriver* CViewRenderer::getDriver(){ - return driver; -} - -void CViewRenderer::setTextContext(NL3D::UTextContext *textcontext) -{ - CViewRenderer::textcontext = textcontext; -} - -void CViewRenderer::setDriver( NL3D::UDriver *driver ) -{ - CViewRenderer::driver = driver; -} - -// *************************************************************************** -void CViewRenderer::SImage::setupQuadUV(bool flipv, uint8 rot, CQuadColorUV &dest) -{ - nlassert(rot<=3); - // Rotation is CW and flip is along x axis - // Flip is vertical flip (this means we invert all y for a constant x) - // The transforms are done in this order : first apply the flip (or not) and then rotate - static const CUV UVTab[8][4] = { - { CUV(0, 0), CUV(1, 0), CUV(1, 1), CUV(0, 1) }, // rot 0, no flip - { CUV(1, 0), CUV(1, 1), CUV(0, 1), CUV(0, 0) }, // rot 1, no flip - { CUV(1, 1), CUV(0, 1), CUV(0, 0), CUV(1, 0) }, // rot 2, no flip - { CUV(0, 1), CUV(0, 0), CUV(1, 0), CUV(1, 1) }, // rot 3, no flip - { CUV(1, 0), CUV(0, 0), CUV(0, 1), CUV(1, 1) }, // rot 0, flipped - { CUV(0, 0), CUV(0, 1), CUV(1, 1), CUV(1, 0) }, // rot 1, flipped - { CUV(0, 1), CUV(1, 1), CUV(1, 0), CUV(0, 0) }, // rot 2, flipped - { CUV(1, 1), CUV(1, 0), CUV(0, 0), CUV(0, 1) } // rot 3, flipped - }; - - // Take care that the origin in the texture is top left so to get the texture in bottom-up - // we have to start at Max and go at Min. For left and right this is Min to Max. - - float du = UVMax.U - UVMin.U; - float dv = UVMin.V - UVMax.V; - - uint idx = flipv*4 + rot; - - dest.Uv0 = CUV (UVMin.U + UVTab[idx][0].U * du, UVMax.V + UVTab[idx][0].V * dv); - dest.Uv1 = CUV (UVMin.U + UVTab[idx][1].U * du, UVMax.V + UVTab[idx][1].V * dv); - dest.Uv2 = CUV (UVMin.U + UVTab[idx][2].U * du, UVMax.V + UVTab[idx][2].V * dv); - dest.Uv3 = CUV (UVMin.U + UVTab[idx][3].U * du, UVMax.V + UVTab[idx][3].V * dv); - - /* // TRAP : Unrolled Version (To be tested to know if it is faster than the previous one) - if (flipv) - { - switch (rot) - { - case 0: - qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMax.V; - qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMax.V; - qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMin.V; - qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMin.V; - break; - case 1: - qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; - qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMin.V; - qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; - qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMax.V; - break; - case 2: - qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMin.V; - qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMin.V; - qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMax.V; - qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMax.V; - break; - case 3: - qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMin.V; - qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; - qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMax.V; - qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; - break; - } - } - else - { - switch (rot) - { - case 0: - qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; - qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; - qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; - qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; - break; - case 1: - qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMin.V; - qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMax.V; - qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMax.V; - qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMin.V; - break; - case 2: - qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMin.V; - qcoluv.Uv1.U = rI.UVMin.U; qcoluv.Uv1.V = rI.UVMin.V; - qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMax.V; - qcoluv.Uv3.U = rI.UVMax.U; qcoluv.Uv3.V = rI.UVMax.V; - break; - case 3: - qcoluv.Uv0.U = rI.UVMax.U; qcoluv.Uv0.V = rI.UVMax.V; - qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMin.V; - qcoluv.Uv2.U = rI.UVMin.U; qcoluv.Uv2.V = rI.UVMin.V; - qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMax.V; - break; - } - } - */ -} -// *************************************************************************** - -/* - * drawRotFlipBitmapTiled - */ -void CViewRenderer::drawRotFlipBitmapTiled (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flip, - sint32 nTxId, uint tileOrigin, const CRGBA &col) -{ - static volatile bool draw = true; - if (!draw) return; - if (width <= 0 || height <= 0) return; - - if (nTxId < 0) return; - - // Is totally clipped ? - if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || - (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) - return; - - SImage &rI = *getSImage(nTxId); - - sint32 txw, txh; - // start to draw at the reference corner - getTextureSizeFromId (nTxId, txw, txh); - - if (rot > 3) rot = 3; - - sint32 startX = x, startY = y; - sint32 stepX = txw, stepY = txh; - - if (rot & 1) - { - std::swap(txw, txh); - } - - // choose new start pos & uvs depending on the reference corner - // Along x axis - if (tileOrigin & 1) // right or left ? - { // right - startX = x + width - txw; - stepX = -txw; - } - - // Along y axis - if (tileOrigin & 2) // bottom or top ? - { // top - startY = y + height - txh; - stepY = -txh; - } - - // Fit screen coordinates - - float fStartX = (float) startX * _OneOverScreenW; - float fStartY = (float) startY * _OneOverScreenH; - float fStepX = (float) stepX * _OneOverScreenW; - float fStepY = (float) stepY * _OneOverScreenH; - float fTxW = (float) txw * _OneOverScreenW; - float fTxH = (float) txh * _OneOverScreenH; - - CQuadColorUV qcoluv; - - qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; - qcoluv.V0.z = qcoluv.V1.z = qcoluv.V2.z = qcoluv.V3.z = 0; - rI.setupQuadUV(flip,rot,qcoluv); - - uint numTileX = (uint32)((width - 1) / txw); - uint numTileY = (uint32)((height- 1) / txh); - - float currY = fStartY; - - sint32 oldClipX = _ClipX; - sint32 oldClipY = _ClipY; - sint32 oldClipW = _ClipW; - sint32 oldClipH = _ClipH; - if (x < _ClipX) { width -= _ClipX - x; x = _ClipX; } - if (y < _ClipY) { height -= _ClipY - y; y = _ClipY; } - if ((x+width) > (_ClipX+_ClipW)) width -= (x+width) - (_ClipX+_ClipW); - if ((y+height) > (_ClipY+_ClipH)) height -= (y+height) - (_ClipY+_ClipH); - setClipWindow (x, y, width, height); - - // draw result let the clipper clip the quads - for(uint py = 0; py <= numTileY; ++py) - { - float currX = fStartX; - for(uint px = 0; px <= numTileX; ++px) - { - /// There is room for speedup there - qcoluv.V0.x = currX; - qcoluv.V1.x = currX + fTxW; - qcoluv.V2.x = currX + fTxW; - qcoluv.V3.x = currX; - - qcoluv.V0.y = currY; - qcoluv.V1.y = currY; - qcoluv.V2.y = currY + fTxH; - qcoluv.V3.y = currY + fTxH; - - // Is NOT totally clipped ? - if ( !( (qcoluv.V0.x > _XMax) || (qcoluv.V2.x < _XMin) || - (qcoluv.V0.y > _YMax) || (qcoluv.V2.y < _YMin) ) ) - putQuadInLayer (*(rI.GlobalTexturePtr), layerId, qcoluv, rot); - - currX += fStepX; - } - currY += fStepY; - } - - setClipWindow (oldClipX, oldClipY, oldClipW, oldClipH); -} - - -/* - * drawBitmap - */ -void CViewRenderer::drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, - uint8 rot, bool flipv, sint32 nTxId, const CRGBA &col) -{ - if (width <= 0 || height <= 0) return; - - if (nTxId < 0) - return; - - - - float dstXmin, dstYmin, dstXmax, dstYmax; - - // Is totally clipped ? - if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || - (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) - return; - - dstXmin = (float)(x) * _OneOverScreenW; - dstYmin = (float)(y) * _OneOverScreenH; - dstXmax = (float)(x + width) * _OneOverScreenW; - dstYmax = (float)(y + height) * _OneOverScreenH; - - CQuadColorUV qcoluv; - qcoluv.V0.set (dstXmin, dstYmin, 0); - qcoluv.V1.set (dstXmax, dstYmin, 0); - qcoluv.V2.set (dstXmax, dstYmax, 0); - qcoluv.V3.set (dstXmin, dstYmax, 0); - - qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; - - SImage &rI = *getSImage(nTxId); - - // Avoid switch in common case - if (!flipv && !rot) - { - qcoluv.Uv0.U = rI.UVMin.U; qcoluv.Uv0.V = rI.UVMax.V; - qcoluv.Uv1.U = rI.UVMax.U; qcoluv.Uv1.V = rI.UVMax.V; - qcoluv.Uv2.U = rI.UVMax.U; qcoluv.Uv2.V = rI.UVMin.V; - qcoluv.Uv3.U = rI.UVMin.U; qcoluv.Uv3.V = rI.UVMin.V; - } - // else standard case - else - { - if (rot > 3) - rot = 3; - - rI.setupQuadUV(flipv, rot, qcoluv); - } - - static volatile bool doRot[4] = { true, true, true, true }; - if (doRot[rot]) - { - putQuadInLayer (*(rI.GlobalTexturePtr), layerId, qcoluv, rot); - } -} - - -/* - * draw11RotBitmap - * sTx must be lowered !!! - */ -void CViewRenderer::draw11RotFlipBitmap (sint layerId, sint32 x, sint32 y, uint8 rot, bool flipv, sint32 nTxId, const CRGBA &col) -{ - if (nTxId < 0) - return; - - sint32 txw, txh; - SImage &rImage = *getSImage(nTxId); - txw = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f); - txh = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f); - - drawRotFlipBitmap (layerId, x, y, txw, txh, rot, flipv, nTxId, col); -} - - -inline void remapUV(CUV &dest, const CUV &src, const CUV &min, const CUV &max) -{ - dest.set(src.U * (max.U - min.U) + min.U, src.V * (max.V - min.V) + min.V); -} - -void CViewRenderer::drawQuad(sint layerId, const NLMISC::CQuadUV &quadUV, sint32 nTxId, NLMISC::CRGBA col /*=NLMISC::CRGBA(255,255,255,255)*/, bool additif, bool filtered) -{ - nlassert(!(additif && !filtered)); // not implemented yet! - if (nTxId < 0) - return; - CQuadColorUV normedQuad; - // - normedQuad.V0.set(quadUV.V0.x * _OneOverScreenW, quadUV.V0.y * _OneOverScreenH, 0.f); - normedQuad.V1.set(quadUV.V1.x * _OneOverScreenW, quadUV.V1.y * _OneOverScreenH, 0.f); - normedQuad.V2.set(quadUV.V2.x * _OneOverScreenW, quadUV.V2.y * _OneOverScreenH, 0.f); - normedQuad.V3.set(quadUV.V3.x * _OneOverScreenW, quadUV.V3.y * _OneOverScreenH, 0.f); - // - float qXMin = minof(normedQuad.V0.x, normedQuad.V1.x, normedQuad.V2.x, normedQuad.V3.x); - if (qXMin > _XMax) return; - float qXMax = maxof(normedQuad.V0.x, normedQuad.V1.x, normedQuad.V2.x, normedQuad.V3.x); - if (qXMax < _XMin) return; - float qYMin = minof(normedQuad.V0.y, normedQuad.V1.y, normedQuad.V2.y, normedQuad.V3.y); - if (qYMin > _YMax) return; - float qYMax = maxof(normedQuad.V0.y, normedQuad.V1.y, normedQuad.V2.y, normedQuad.V3.y); - if (qYMax < _YMin) return; - // - - - - SImage &rImage = *getSImage(nTxId); - SGlobalTexture > = *(rImage.GlobalTexturePtr); - CUV deltaUV(1.f / (float) gt.Width, 1.f / (float) gt.Height); - CUV cornerMin = rImage.UVMin + deltaUV; - CUV cornerMax = rImage.UVMax - deltaUV; - remapUV(normedQuad.Uv0, quadUV.Uv0, cornerMin, cornerMax); - remapUV(normedQuad.Uv1, quadUV.Uv1, cornerMin, cornerMax); - remapUV(normedQuad.Uv2, quadUV.Uv2, cornerMin, cornerMax); - remapUV(normedQuad.Uv3, quadUV.Uv3, cornerMin, cornerMax); - - // test if clipping is required - if (qXMin >= _XMin && qYMin >= _YMin && qXMax <= _XMax && qYMax <= _YMax) - { - // not clipped, easy case - normedQuad.Color0 = normedQuad.Color1 = normedQuad.Color2 = normedQuad.Color3 = col; - - if (_WorldSpaceTransformation) - { - worldSpaceTransformation (normedQuad); - } - - layerId+= VR_BIAS_LAYER; - nlassert(layerId>=0 && layerIdLayers[layerId]; - if (!filtered) - { - if (layer.NbQuads == layer.Quads.size()) - layer.Quads.push_back (normedQuad); - else - layer.Quads[layer.NbQuads] = normedQuad; - ++ layer.NbQuads; - } - else if (additif) layer.FilteredAdditifQuads.push_back(normedQuad); - else layer.FilteredAlphaBlendedQuads.push_back(normedQuad); - _EmptyLayer[layerId]= false; - } - else - { - // Partially clipped (slowest case) - // Must do the clip manually - static const uint maxNumCorners = 8; - // - static CVector outPos0[maxNumCorners]; - static CUV outUV0[maxNumCorners]; - static CVector outPos1[maxNumCorners]; - static CUV outUV1[maxNumCorners]; - // - outUV0[0] = normedQuad.Uv0; - outUV0[1] = normedQuad.Uv1; - outUV0[2] = normedQuad.Uv2; - outUV0[3] = normedQuad.Uv3; - // - outPos0[0] = normedQuad.V0; - outPos0[1] = normedQuad.V1; - outPos0[2] = normedQuad.V2; - outPos0[3] = normedQuad.V3; - // - CVector *pPos0 = outPos0; - CVector *pPos1 = outPos1; - CUV *pUV0 = outUV0; - CUV *pUV1 = outUV1; - // - sint count = 4; - // - if (qXMin < _XMin) - { - // clip left - CPlane clipper(-1.f, 0.f, 0.f, _XMin); - count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); - std::swap(pPos0, pPos1); - std::swap(pUV0, pUV1); - } - if (qXMax > _XMax) - { - // clip right - CPlane clipper(1.f, 0.f, 0.f, -_XMax); - count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); - std::swap(pPos0, pPos1); - std::swap(pUV0, pUV1); - } - // - if (qYMin < _YMin) - { - // clip bottom - CPlane clipper(0.f, -1.f, 0.f, _YMin); - count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); - std::swap(pPos0, pPos1); - std::swap(pUV0, pUV1); - } - if (qYMax > _YMax) - { - // clip top - CPlane clipper(0.f, 1.f, 0.f, -_YMax); - count = clipper.clipPolygonBack(pPos0, pUV0, pPos1, pUV1, count); - std::swap(pPos0, pPos1); - std::swap(pUV0, pUV1); - } - - nlassert(count <= (sint)maxNumCorners); - if (count >= 3) - { - count -= 2; - layerId+= VR_BIAS_LAYER; - nlassert(layerId>=0 && layerIdLayers[layerId]; - std::vector *tris; - if (!filtered) - { - tris = &layer.Tris; - } - else - { - tris = additif ? &layer.FilteredAdditifTris : &layer.FilteredAlphaBlendedTris; - } - tris->resize(tris->size() + count); - CTriangleColorUV *lastTri = &tris->back() + 1; - CTriangleColorUV *currTri = lastTri - count; - const CVector *firstPos = pPos0++; - const CUV *firstUV = pUV0++; - do - { - currTri->V0 = *firstPos; - currTri->V1 = *pPos0; - currTri->V2 = *(pPos0 + 1); - currTri->Color0 = col; - currTri->Color1 = col; - currTri->Color2 = col; - currTri->Uv0 = *firstUV; - currTri->Uv1 = *pUV0; - currTri->Uv2 = *(pUV0 + 1); - - pPos0 ++; - pUV0 ++; - ++currTri; - } - while (currTri != lastTri); - _EmptyLayer[layerId]= false; - } - } -} - - -void CViewRenderer::drawUnclippedTriangles(sint layerId, const std::vector &tris, NLMISC::CRGBA col) -{ - if (tris.empty()) return; - if (!_BlankGlobalTexture) return; - // primary goal here is batching, so we prefer to draw the triangle with a blank texture rather than - // switching material and having to flush all primitives . - layerId+= VR_BIAS_LAYER; - nlassert(layerId>=0 && layerIdLayers[layerId]; - uint startCount = (uint)layer.FilteredAlphaBlendedTris.size(); - layer.FilteredAlphaBlendedTris.resize(startCount + tris.size()); - const NLMISC::CTriangle *src =&tris[0]; - const NLMISC::CTriangle *last = src + tris.size(); - NLMISC::CTriangleColorUV *dest = &layer.FilteredAlphaBlendedTris[0] + startCount; - _EmptyLayer[layerId]= false; - do - { - dest->V0.set(src->V0.x * _OneOverScreenW, src->V0.y * _OneOverScreenH, 0.f); - dest->V1.set(src->V1.x * _OneOverScreenW, src->V1.y * _OneOverScreenH, 0.f); - dest->V2.set(src->V2.x * _OneOverScreenW, src->V2.y * _OneOverScreenH, 0.f); - static volatile bool testOpaque = false; - if (testOpaque) - { - dest->Color0 = CRGBA::White; - dest->Color1 = CRGBA::White; - dest->Color2 = CRGBA::White; - dest->Uv0.set(0.f, 0.f); - dest->Uv1.set(1.f, 0.f); - dest->Uv2.set(1.f, 1.f); - } - else - { - dest->Color0 = col; - dest->Color1 = col; - dest->Color2 = col; - dest->Uv0 = _BlankUV; - dest->Uv1 = _BlankUV; - dest->Uv2 = _BlankUV; - } - ++ dest; - ++ src; - } - while (src != last); -} - -/* - * loadTextures - */ -void CViewRenderer::loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC) -{ - SGlobalTexture gt; - // Load texture file - string filename = CPath::lookup (textureFileName, false); - if (filename == "") return; - CIFile ifTmp; - if (ifTmp.open(filename)) - CBitmap::loadSize (ifTmp, gt.Width, gt.Height); - gt.Texture = driver->createTextureFile (filename); - // Force to generate the texture now. This way we can extract the mouse bitmaps from it now without having to load it again. - // Its why we don't release it at the end, because it is likely to be uploaded soon) - CBitmap *texDatas = gt.Texture->generateDatas(); - // - gt.Name = filename; - gt.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); - if(uploadDXTC) - gt.Texture->setUploadFormat(UTexture::DXTC5); - - // Load uv file - CIFile iFile; - filename = CPath::lookup (uvFileName, false); - if (filename == "") return; - if (!iFile.open(filename)) return; - - _GlobalTextures.push_back (gt); - - driver->setCursorScale(ClientCfg.HardwareCursorScale); - - char bufTmp[256], tgaName[256]; - string sTGAname; - float uvMinU, uvMinV, uvMaxU, uvMaxV; - while (!iFile.eof()) - { - iFile.getline (bufTmp, 256); - sscanf (bufTmp, "%s %f %f %f %f", tgaName, &uvMinU, &uvMinV, &uvMaxU, &uvMaxV); - SImage image; - image.UVMin.U = uvMinU; - image.UVMin.V = uvMinV; - image.UVMax.U = uvMaxU; - image.UVMax.V = uvMaxV; - sTGAname = toLower(string(tgaName)); - - string::size_type stripPng = sTGAname.find(".png"); - if (stripPng != string::npos) - { - sTGAname[stripPng + 1] = 't'; - sTGAname[stripPng + 2] = 'g'; - sTGAname[stripPng + 3] = 'a'; - } - - image.Name = sTGAname; - image.GlobalTexturePtr = &(_GlobalTextures.back()); - if (getTextureIdFromName(sTGAname) != -1) - { - string tmp = string("duplicate texture name in ") + textureFileName + "(" + sTGAname + ")"; - nlwarning(tmp.c_str()); - } - else - { - sint32 textureId = addSImage(image); - //nlwarning("SIMAGE ADDED: id = %x, name = %s", textureId, image.Name.c_str()); - // Insert in map. - _TextureMap.insert( make_pair(image.Name, textureId) ); - } - - // if this is a cursor texture, extract it now (supported for rgba only now, because of the blit) - if (texDatas && texDatas->getPixelFormat() == CBitmap::RGBA) - { - if (ClientCfg.HardwareCursors.count(image.Name)) - { - uint x0 = (uint) (image.UVMin.U * gt.Width); - uint y0 = (uint) (image.UVMin.V * gt.Height); - uint x1 = (uint) (image.UVMax.U * gt.Width); - uint y1 = (uint) (image.UVMax.V * gt.Height); - if (x1 != x0 && y1 != y0) - { - CBitmap curs; - curs.resize(x1 - x0, y1 - y0); - curs.blit(*texDatas, x0, y0, (x1 - x0), (y1 - y0), 0, 0); - driver->addCursor(image.Name, curs); - } - } - } - } - - initIndexesToTextureIds (); - initSystemTextures(); - initTypo(); -} - - - - -void CViewRenderer::setExternalTexture(const std::string &sGlobalTextureName, - NL3D::UTexture *externalTexture, - uint32 externalTexWidth, - uint32 externalTexHeight, - uint32 defaultTexWidth, - uint32 defaultTexHeight - ) -{ - if (sGlobalTextureName.empty()) - { - nlwarning("Can't create aglobal texture with an empty name"); - return; - } - // Look if already existing - string sLwrGTName = strlwr(sGlobalTextureName); - TGlobalTextureList::iterator ite = _GlobalTextures.begin(); - while (ite != _GlobalTextures.end()) - { - std::string sText = strlwr(ite->Name); - if (sText == sLwrGTName) - break; - ite++; - } - if (ite == _GlobalTextures.end()) - { - SGlobalTexture gtTmp; - gtTmp.FromGlobaleTexture = true; - - gtTmp.Name = sLwrGTName; - _GlobalTextures.push_back(gtTmp); - ite = _GlobalTextures.end(); - ite--; - } - ite->Width = externalTexWidth; - ite->Height = externalTexHeight; - ite->DefaultWidth = defaultTexWidth; - ite->DefaultHeight = defaultTexHeight; - ite->Texture = externalTexture; -} - -/* - * createTexture - */ -sint32 CViewRenderer::createTexture (const std::string &sGlobalTextureName, - sint32 offsetX, - sint32 offsetY, - sint32 width, - sint32 height, - bool uploadDXTC, - bool bReleasable - ) -{ - if (sGlobalTextureName.empty()) return -1; - // Look if already existing - string sLwrGTName = strlwr(sGlobalTextureName); - TGlobalTextureList::iterator ite = _GlobalTextures.begin(); - while (ite != _GlobalTextures.end()) - { - std::string sText = strlwr(ite->Name); - if (sText == sLwrGTName) - break; - ite++; - } - - // If global texture not exists create it - if (ite == _GlobalTextures.end()) - { - SGlobalTexture gtTmp; - gtTmp.FromGlobaleTexture = false; - string filename = CPath::lookup (sLwrGTName, false); - if (filename == "") return -1; - CIFile ifTmp; - if (ifTmp.open(filename)) - { - CBitmap::loadSize (ifTmp, gtTmp.Width, gtTmp.Height); - gtTmp.DefaultWidth = gtTmp.Width; - gtTmp.DefaultHeight = gtTmp.Height; - if (gtTmp.Width == 0 || gtTmp.Height == 0) - { - nlwarning("Failed to load the texture '%s', please check image format", filename.c_str()); - } - } - gtTmp.Texture = driver->createTextureFile (sLwrGTName); - gtTmp.Name = sLwrGTName; - gtTmp.Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); - if(uploadDXTC) - gtTmp.Texture->setUploadFormat(UTexture::DXTC5); - gtTmp.Texture->setReleasable(bReleasable); - _GlobalTextures.push_back(gtTmp); - ite = _GlobalTextures.end(); - ite--; - } - - // Add a texture with reference to the i th global texture - SImage iTmp; - - // Set default parameters - if (width == -1) - width = ite->DefaultWidth; - if (height == -1) - height = ite->DefaultHeight; - - iTmp.Name = sLwrGTName; - iTmp.GlobalTexturePtr = &(*ite); - iTmp.UVMin = CUV(((float)offsetX)/ite->Width , ((float)offsetY)/ite->Height); - iTmp.UVMax = CUV(((float)offsetX+width)/ite->Width , ((float)offsetY+height)/ite->Height); - sint32 TextID = addSImage(iTmp); - //nlwarning("SIMAGE ADDED: id = %d, name = %s", TextID, iTmp.Name.c_str()); - - // Insert / replace in map. - // TMP TMP FIX NICO - //_TextureMap.insert( make_pair(iTmp.Name, TextID) ); - - - return TextID; -} - -void CViewRenderer::updateTexturePos(const std::string &texturefileName, sint32 offsetX /*=0*/, sint32 offsetY /*=0*/, sint32 width /*=-1*/, sint32 height /*=-1*/) -{ - sint32 id = getTextureIdFromName (texturefileName); - if (id == -1) - { - nlwarning("Unknwown texture %s, can't update pos", texturefileName.c_str()); - return; - } - SImage *im = getSImage(id); - nlassert(im); - // Set default parameters - sint32 gw = im->GlobalTexturePtr->Width; - sint32 gh = im->GlobalTexturePtr->Height; - if (width == -1) - width = gw; - if (height == -1) - height = gh; - im->UVMin = CUV(((float)offsetX)/gw , ((float)offsetY)/gh); - im->UVMax = CUV(((float)offsetX+width)/gw, ((float)offsetY+height)/gh); -} - - -/* - * getGlobalTexture - */ -NL3D::UTexture *CViewRenderer::getGlobalTexture(const std::string &name) -{ - string sLwrGTName = strlwr(name); - TGlobalTextureList::iterator ite = _GlobalTextures.begin(); - while (ite != _GlobalTextures.end()) - { - std::string sText = strlwr(ite->Name); - if (sText == sLwrGTName) - break; - ite++; - } - if (ite != _GlobalTextures.end()) - { - return ite->Texture; - } - return NULL; -} - -/* - * deleteTexture - */ -void CViewRenderer::deleteTexture (sint32 textureId) -{ - // Checks - nlassert ((uint)textureId < _SImageIterators.size()); - if (_SImageIterators[textureId] == _SImages.end()) - { - nlwarning("Can't delete texture with name %s", getTextureNameFromId(textureId).c_str()); - nlassert(0); - return; - } - - // Backup global texture pointer - SGlobalTexture *gt = getSImage(textureId)->GlobalTexturePtr; - - // Erase only texture from global texture - if (!(gt->FromGlobaleTexture)) - { - //nlwarning("Removing texture with id %d", (int) textureId); - // Erase the SImage - //nlwarning("SIMAGE REMOVE : id = %x, name = %s", (int) textureId, getSImage(textureId)->Name.c_str()); - - - removeSImage (textureId); - - // Check if someone else use this global texture.. - TSImageList::iterator ite = _SImages.begin(); - while (ite != _SImages.end()) - { - // Same global texture ? - if (ite->GlobalTexturePtr == gt) - break; - - ite++; - } - - // Global texture still used ? - if (ite == _SImages.end()) - { - //nlwarning("REMOVE GLOBAL TEXTURE : id of simage = %x", (int) textureId); - // No, remove the global texture - for (TGlobalTextureList::iterator iteGT = _GlobalTextures.begin(); iteGT != _GlobalTextures.end(); iteGT++) - { - // This one ? - if (&(*iteGT) == gt) - { - // Remove this global texture - UTextureFile *tf = dynamic_cast(iteGT->Texture); - if (tf) - { - driver->deleteTextureFile (tf); - } - _GlobalTextures.erase (iteGT); - return; - } - } - // Global texture has not been found - nlstop; - } - } -} - -/* - * getTextureIdFromName - */ -sint32 CViewRenderer::getTextureIdFromName (const string &sName) const -{ - if(sName.empty()) - return -1; - - // convert to lowCase - string nameLwr = toLower(sName); - - string::size_type stripPng = nameLwr.find(".png"); - if (stripPng != string::npos) - { - nameLwr[stripPng + 1] = 't'; - nameLwr[stripPng + 2] = 'g'; - nameLwr[stripPng + 3] = 'a'; - } - - // Search in map - TTextureMap::const_iterator it= _TextureMap.find(nameLwr); - if( it==_TextureMap.end() ) - return -1; - else - return it->second; -} - -/* - * getTextureNameFromId - */ -std::string CViewRenderer::getTextureNameFromId (sint32 TxID) -{ - if ((TxID < 0) || (TxID >= (sint32)_SImageIterators.size())) - return ""; - SImage *img = getSImage(TxID); - return img->Name; -} - -/* - * getTextureSizeFromName - */ -void CViewRenderer::getTextureSizeFromId (sint32 id, sint32 &width, sint32 &height) -{ - if ((id < 0) || (id >= (sint32)_SImageIterators.size())) - { - width = height = 0; - } - else - { - SImage &rImage = *getSImage(id); - width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rImage.GlobalTexturePtr->Width+0.5f); - height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rImage.GlobalTexturePtr->Height+0.5f); - } -} -/* - * getTextureColor - */ -CRGBA CViewRenderer::getTextureColor(sint32 id, sint32 x, sint32 y) -{ - if ((id < 0) || (id >= (sint32)_SImageIterators.size())) - { - return CRGBA(255,255,255); - } - - SImage &rImage = *getSImage(id); - SGlobalTexture &rGT = *rImage.GlobalTexturePtr; - sint32 width, height; - width = (sint32)((rImage.UVMax.U - rImage.UVMin.U)*rGT.Width+0.5f); - height = (sint32)((rImage.UVMax.V - rImage.UVMin.V)*rGT.Height+0.5f); - float xRatio = ((float)x) / ((float)(width)); - float yRatio = ((float)y) / ((float)(height)); - UTexture *pTF = rGT.Texture; - sint32 xConv = (sint32)((rImage.UVMin.U + xRatio * (rImage.UVMax.U - rImage.UVMin.U))*rGT.Width+0.5f); - sint32 yConv = (rGT.Height-1)-(sint32)((rImage.UVMin.V + yRatio * (rImage.UVMax.V - rImage.UVMin.V))*rGT.Height+0.5f); - return pTF->getPixelColor(xConv, yConv); -} - -// *************************************************************************** -sint32 CViewRenderer::getTypoTextureW(char c) -{ - if ((c>=0) && (c=0) && (cLayers[layerId]; - if(layer.NbQuads>0 || !layer.Tris.empty()) - { - // setup the global texture to material - _Material.setTexture(0, ite->Texture); - - // Special Case if _WorldSpaceTransformation and _WorldSpaceScale, enable bilinear - if(_WorldSpaceTransformation && _WorldSpaceScale) - ite->Texture->setFilterMode(UTexture::Linear, UTexture::LinearMipMapOff); - - // draw quads and empty list - if (layer.NbQuads != 0) - { - driver->drawQuads (&(layer.Quads[0]), layer.NbQuads, _Material); - layer.NbQuads = 0; - } - - if (!layer.Tris.empty()) - { - driver->drawTriangles(layer.Tris, _Material); - layer.Tris.clear(); - } - - // Special Case if _WorldSpaceTransformation and _WorldSpaceScale, reset - if(_WorldSpaceTransformation && _WorldSpaceScale) - ite->Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); - } - if (!layer.FilteredAlphaBlendedQuads.empty() || - !layer.FilteredAlphaBlendedTris.empty() || - !layer.FilteredAdditifQuads.empty() || - !layer.FilteredAdditifTris.empty()) - { - // setup the global texture to material - _Material.setTexture(0, ite->Texture); - - // force filtering - ite->Texture->setFilterMode(UTexture::Linear, UTexture::LinearMipMapOff); - // alpha blended - if (!layer.FilteredAlphaBlendedQuads.empty()) - { - driver->drawQuads (&(layer.FilteredAlphaBlendedQuads[0]), (uint32)layer.FilteredAlphaBlendedQuads.size(), _Material); - layer.FilteredAlphaBlendedQuads.clear(); - } - if (!layer.FilteredAlphaBlendedTris.empty()) - { - driver->drawTriangles(layer.FilteredAlphaBlendedTris, _Material); - layer.FilteredAlphaBlendedTris.clear(); - } - // additif - if (!layer.FilteredAdditifQuads.empty() || - !layer.FilteredAdditifTris.empty()) - { - _Material.setBlendFunc (NL3D::UMaterial::one, NL3D::UMaterial::one); - if (!layer.FilteredAdditifQuads.empty()) - { - driver->drawQuads (&(layer.FilteredAdditifQuads[0]), (uint32)layer.FilteredAdditifQuads.size(), _Material); - layer.FilteredAdditifQuads.clear(); - } - if (!layer.FilteredAdditifTris.empty()) - { - driver->drawTriangles(layer.FilteredAdditifTris, _Material); - layer.FilteredAdditifTris.clear(); - } - // restore alpha blend - _Material.setBlendFunc (NL3D::UMaterial::srcalpha, NL3D::UMaterial::invsrcalpha); - } - ite->Texture->setFilterMode(UTexture::Nearest, UTexture::NearestMipMapOff); - } - ite++; - } - - // **** Display Computed Strings of this layer - if (_WorldSpaceTransformation) - textcontext->flushRenderBufferUnProjected(_StringRBLayers[layerId], false); - else - textcontext->flushRenderBuffer(_StringRBLayers[layerId]); - - // flushed - _EmptyLayer[layerId]= true; - } -} - - -/** - * init the map _IndexesToTextures - */ -void CViewRenderer::initIndexesToTextureIds() -{ - char buf[20]; - _IndexesToTextureIds.clear(); - for (uint i = 0; i < 10; i++) - { - sprintf (buf, "numbers_%d.tga", i); - _IndexesToTextureIds.push_back (getTextureIdFromName(buf)); - } - _FigurSeparatorTextureId = getTextureIdFromName("Numbers_sep.tga"); - _FigurBlankId = getTextureIdFromName("numbers_blank.tga"); - _BlankId = getTextureIdFromName("blank.tga"); - - SImage *blank = getSImage(_BlankId); - if (blank) - { - _BlankGlobalTexture = blank->GlobalTexturePtr; - _BlankUV = 0.5f * (blank->UVMin + blank->UVMax); - } - else - { - _BlankUV.set(0.f, 0.f); - } - - - // Init size - if(_IndexesToTextureIds[0]!=-1) - { - getTextureSizeFromId (_IndexesToTextureIds[0], _WFigurTexture, _HFigurTexture); - } - if (_FigurSeparatorTextureId != -1) - { - getTextureSizeFromId (_FigurSeparatorTextureId, _WFigurSeparatorTexture, _HFigurSeparatorTexture); - } - -} - -/** - * - */ -void CViewRenderer::initTypo() -{ - _TypoH = 0; - - // since filename dose not support special char (?,. ....), specify a map from char to string. - map specialCharMap; - specialCharMap['?']= "question"; - - - char buf[256]; - // For all supported chars (if tga exist) - for (uint i = 0; i < NumTypoChar; i++) - { - // Get the token string for this char. - string token; - map::iterator it= specialCharMap.find(i); - // General case - if(it==specialCharMap.end()) - token= (char)i; - else - token= it->second; - - // get the fileName - sprintf (buf, "typo_%s.tga", token.c_str()); - sint32 id = getTextureIdFromName(buf); - if(id>=0) - { - _TypoCharToTextureIds[i]= id; - sint32 w,h; - getTextureSizeFromId (id, w, h); - _TypoCharWs[i]= w; - _TypoH = h; - } - else - { - _TypoCharToTextureIds[i]= -1; - // simulate a space. - _TypoCharWs[i]= 1; - } - } -} - - -/** - * needClipping - */ -bool CViewRenderer::needClipping (const CQuad &q) -{ - if ((q.V0.x >= _XMin) && (q.V0.y >= _YMin) && (q.V2.x <= _XMax) && (q.V2.y <= _YMax)) - return false; - else - return true; -} - -/** - * clip - */ -void CViewRenderer::clip (CQuadColorUV &qout, const CQuadColorUV &qin, uint rot) -{ - float ratio; - - qout = qin; - - if (rot & 1) - { - // must reverse U & V during clipping - if (qin.V0.x < _XMin) - { - ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); - qout.V3.x = qout.V0.x = _XMin; - qout.Uv0.V += ratio*(qin.Uv1.V-qin.Uv0.V); - qout.Uv3.V += ratio*(qin.Uv2.V-qin.Uv3.V); - } - - if (qin.V0.y < _YMin) - { - ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); - qout.V1.y = qout.V0.y = _YMin; - qout.Uv0.U += ratio*(qin.Uv3.U-qin.Uv0.U); - qout.Uv1.U += ratio*(qin.Uv2.U-qin.Uv1.U); - } - - if (qin.V2.x > _XMax) - { - ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); - qout.V2.x = qout.V1.x = _XMax; - qout.Uv2.V += ratio*(qin.Uv3.V-qin.Uv2.V); - qout.Uv1.V += ratio*(qin.Uv0.V-qin.Uv1.V); - } - - if (qin.V2.y > _YMax) - { - ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); - qout.V2.y = qout.V3.y = _YMax; - qout.Uv2.U += ratio*(qin.Uv1.U-qin.Uv2.U); - qout.Uv3.U += ratio*(qin.Uv0.U-qin.Uv3.U); - } - } - else - { - if (qin.V0.x < _XMin) - { - ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); - qout.V3.x = qout.V0.x = _XMin; - qout.Uv0.U += ratio*(qin.Uv1.U-qin.Uv0.U); - qout.Uv3.U += ratio*(qin.Uv2.U-qin.Uv3.U); - } - - if (qin.V0.y < _YMin) - { - ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); - qout.V1.y = qout.V0.y = _YMin; - qout.Uv0.V += ratio*(qin.Uv3.V-qin.Uv0.V); - qout.Uv1.V += ratio*(qin.Uv2.V-qin.Uv1.V); - } - - if (qin.V2.x > _XMax) - { - ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); - qout.V2.x = qout.V1.x = _XMax; - qout.Uv2.U += ratio*(qin.Uv3.U-qin.Uv2.U); - qout.Uv1.U += ratio*(qin.Uv0.U-qin.Uv1.U); - } - - if (qin.V2.y > _YMax) - { - ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); - qout.V2.y = qout.V3.y = _YMax; - qout.Uv2.V += ratio*(qin.Uv1.V-qin.Uv2.V); - qout.Uv3.V += ratio*(qin.Uv0.V-qin.Uv3.V); - } - } -} - -/** - * clip with uv2 - */ -void CViewRenderer::clip (CQuadColorUV2 &qout, const CQuadColorUV2 &qin) -{ - float ratio; - - qout = qin; - - if (qin.V0.x < _XMin) - { - ratio = ((float)(_XMin - qin.V0.x))/((float)(qin.V1.x - qin.V0.x)); - qout.V3.x = qout.V0.x = _XMin; - qout.Uv0.U += ratio*(qin.Uv1.U-qin.Uv0.U); - qout.Uv3.U += ratio*(qin.Uv2.U-qin.Uv3.U); - qout.Uv02.U += ratio*(qin.Uv12.U-qin.Uv02.U); - qout.Uv32.U += ratio*(qin.Uv22.U-qin.Uv32.U); - } - - if (qin.V0.y < _YMin) - { - ratio = ((float)(_YMin - qin.V0.y))/((float)(qin.V3.y - qin.V0.y)); - qout.V1.y = qout.V0.y = _YMin; - qout.Uv0.V += ratio*(qin.Uv3.V-qin.Uv0.V); - qout.Uv1.V += ratio*(qin.Uv2.V-qin.Uv1.V); - qout.Uv02.V += ratio*(qin.Uv32.V-qin.Uv02.V); - qout.Uv12.V += ratio*(qin.Uv22.V-qin.Uv12.V); - } - - if (qin.V2.x > _XMax) - { - ratio = ((float)(_XMax - qin.V2.x))/((float)(qin.V3.x - qin.V2.x)); - qout.V2.x = qout.V1.x = _XMax; - qout.Uv2.U += ratio*(qin.Uv3.U-qin.Uv2.U); - qout.Uv1.U += ratio*(qin.Uv0.U-qin.Uv1.U); - qout.Uv22.U += ratio*(qin.Uv32.U-qin.Uv22.U); - qout.Uv12.U += ratio*(qin.Uv02.U-qin.Uv12.U); - } - - if (qin.V2.y > _YMax) - { - ratio = ((float)(_YMax - qin.V2.y))/((float)(qin.V1.y - qin.V2.y)); - qout.V2.y = qout.V3.y = _YMax; - qout.Uv2.V += ratio*(qin.Uv1.V-qin.Uv2.V); - qout.Uv3.V += ratio*(qin.Uv0.V-qin.Uv3.V); - qout.Uv22.V += ratio*(qin.Uv12.V-qin.Uv22.V); - qout.Uv32.V += ratio*(qin.Uv02.V-qin.Uv32.V); - } -} - - -// *************************************************************************** -/** - * putQuadInLayer : put a quad in a specific layer of a specific texture - */ -void CViewRenderer::putQuadInLayer (SGlobalTexture >, sint layerId, const NLMISC::CQuadColorUV &qcoluv, uint rot) -{ - layerId+= VR_BIAS_LAYER; - nlassert(layerId>=0 && layerId=0 && layerIddrawWiredQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); -} - -// *************************************************************************** -void CViewRenderer::drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col /*=NLMISC::CRGBA::White*/) -{ - driver->drawQuad(x * _OneOverScreenW, y * _OneOverScreenH, (x + width) * _OneOverScreenW, (y + height) * _OneOverScreenH, col); -} - - - -// *************************************************************************** -void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, CRGBA col, UMaterial Mat) -{ - float dstXmin, dstYmin, dstXmax, dstYmax; - - // Is totally clipped ? - if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || - (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) - return; - - flush(); - - // Initialize quad - dstXmin = (float)(x) * _OneOverScreenW; - dstYmin = (float)(y) * _OneOverScreenH; - dstXmax = (float)(x + width) * _OneOverScreenW; - dstYmax = (float)(y + height) * _OneOverScreenH; - - CQuadColorUV2 qcoluv2; - qcoluv2.V0.set (dstXmin, dstYmin, 0); - qcoluv2.V1.set (dstXmax, dstYmin, 0); - qcoluv2.V2.set (dstXmax, dstYmax, 0); - qcoluv2.V3.set (dstXmin, dstYmax, 0); - - qcoluv2.Color0 = qcoluv2.Color1 = qcoluv2.Color2 = qcoluv2.Color3 = col; - - qcoluv2.Uv0.U = 0; qcoluv2.Uv0.V = 1; - qcoluv2.Uv1.U = 1; qcoluv2.Uv1.V = 1; - qcoluv2.Uv2.U = 1; qcoluv2.Uv2.V = 0; - qcoluv2.Uv3.U = 0; qcoluv2.Uv3.V = 0; - - qcoluv2.Uv02.U = 0; qcoluv2.Uv02.V = 1; - qcoluv2.Uv12.U = 1; qcoluv2.Uv12.V = 1; - qcoluv2.Uv22.U = 1; qcoluv2.Uv22.V = 0; - qcoluv2.Uv32.U = 0; qcoluv2.Uv32.V = 0; - - // Clipping part - CQuadColorUV2 qcoluv2_clipped; - if (!needClipping(qcoluv2)) - { - // No need to clip the quad - qcoluv2_clipped = qcoluv2; - } - else - { - clip (qcoluv2_clipped, qcoluv2); - } - - // World space transformation - if (_WorldSpaceTransformation) - worldSpaceTransformation (qcoluv2_clipped); - - // Draw clipped quad - driver->drawQuads (&qcoluv2_clipped, 1, Mat); -} - -// *************************************************************************** -void CViewRenderer::drawCustom(sint32 x, sint32 y, sint32 width, sint32 height, const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, NLMISC::CRGBA col, NL3D::UMaterial Mat) -{ - float dstXmin, dstYmin, dstXmax, dstYmax; - - // Is totally clipped ? - if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || - (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) - return; - - flush(); - - // Initialize quad - dstXmin = (float)(x) * _OneOverScreenW; - dstYmin = (float)(y) * _OneOverScreenH; - dstXmax = (float)(x + width) * _OneOverScreenW; - dstYmax = (float)(y + height) * _OneOverScreenH; - - CQuadColorUV qcoluv; - qcoluv.V0.set (dstXmin, dstYmin, 0); - qcoluv.V1.set (dstXmax, dstYmin, 0); - qcoluv.V2.set (dstXmax, dstYmax, 0); - qcoluv.V3.set (dstXmin, dstYmax, 0); - - qcoluv.Color0 = qcoluv.Color1 = qcoluv.Color2 = qcoluv.Color3 = col; - - qcoluv.Uv0.U = uv0Min.U; qcoluv.Uv0.V = uv0Max.V; - qcoluv.Uv1.U = uv0Max.U; qcoluv.Uv1.V = uv0Max.V; - qcoluv.Uv2.U = uv0Max.U; qcoluv.Uv2.V = uv0Min.V; - qcoluv.Uv3.U = uv0Min.U; qcoluv.Uv3.V = uv0Min.V; - - - // Clipping part - CQuadColorUV qcoluv_clipped; - if (!needClipping(qcoluv)) - { - // No need to clip the quad - qcoluv_clipped = qcoluv; - } - else - { - clip (qcoluv_clipped, qcoluv, 0); - } - - // Draw clipped quad - driver->drawQuads (&qcoluv_clipped, 1, Mat); -} - -// *************************************************************************** -void CViewRenderer::drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, - const CUV &uv0Min, const CUV &uv0Max, const CUV &uv1Min, const CUV &uv1Max, - NLMISC::CRGBA col, NL3D::UMaterial Mat) -{ - float dstXmin, dstYmin, dstXmax, dstYmax; - - // Is totally clipped ? - if ((x > (_ClipX+_ClipW)) || ((x+width) < _ClipX) || - (y > (_ClipY+_ClipH)) || ((y+height) < _ClipY)) - return; - - flush(); - - // Initialize quad - dstXmin = (float)(x) * _OneOverScreenW; - dstYmin = (float)(y) * _OneOverScreenH; - dstXmax = (float)(x + width) * _OneOverScreenW; - dstYmax = (float)(y + height) * _OneOverScreenH; - - CQuadColorUV2 qcoluv2; - qcoluv2.V0.set (dstXmin, dstYmin, 0); - qcoluv2.V1.set (dstXmax, dstYmin, 0); - qcoluv2.V2.set (dstXmax, dstYmax, 0); - qcoluv2.V3.set (dstXmin, dstYmax, 0); - - qcoluv2.Color0 = qcoluv2.Color1 = qcoluv2.Color2 = qcoluv2.Color3 = col; - - qcoluv2.Uv0.U = uv0Min.U; qcoluv2.Uv0.V = uv0Max.V; - qcoluv2.Uv1.U = uv0Max.U; qcoluv2.Uv1.V = uv0Max.V; - qcoluv2.Uv2.U = uv0Max.U; qcoluv2.Uv2.V = uv0Min.V; - qcoluv2.Uv3.U = uv0Min.U; qcoluv2.Uv3.V = uv0Min.V; - - qcoluv2.Uv02.U = uv1Min.U; qcoluv2.Uv02.V = uv1Max.V; - qcoluv2.Uv12.U = uv1Max.U; qcoluv2.Uv12.V = uv1Max.V; - qcoluv2.Uv22.U = uv1Max.U; qcoluv2.Uv22.V = uv1Min.V; - qcoluv2.Uv32.U = uv1Min.U; qcoluv2.Uv32.V = uv1Min.V; - - // Clipping part - CQuadColorUV2 qcoluv2_clipped; - if (!needClipping(qcoluv2)) - { - // No need to clip the quad - qcoluv2_clipped = qcoluv2; - } - else - { - clip (qcoluv2_clipped, qcoluv2); - } - - // World space transformation - if (_WorldSpaceTransformation) - worldSpaceTransformation (qcoluv2_clipped); - - // Draw clipped quad - driver->drawQuads (&qcoluv2_clipped, 1, Mat); -} - -// *************************************************************************** - -CViewRenderer::CTextureId::~CTextureId () -{ - if (_TextureId>=0) - CViewRenderer::getInstance()->deleteTexture(_TextureId); - _TextureId = -1; -} - -// *************************************************************************** - -bool CViewRenderer::CTextureId::setTexture (const char *textureName, sint32 offsetX, sint32 offsetY, sint32 width, sint32 height, - bool uploadDXTC, bool bReleasable) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if (_TextureId>=0) - rVR.deleteTexture(_TextureId); - _TextureId = rVR.getTextureIdFromName(textureName); - if (_TextureId<0) - _TextureId = rVR.createTexture (textureName, offsetX, offsetY, width, height, uploadDXTC, bReleasable); - - return _TextureId >= 0; -} - -// *************************************************************************** -void CViewRenderer::CTextureId::serial(NLMISC::IStream &f) -{ - std::string texName; - if (f.isReading()) - { - f.serial(texName); - setTexture(texName.c_str()); - } - else - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - texName = rVR.getTextureNameFromId(_TextureId); - f.serial(texName); - } -} - -// *************************************************************************** - -void CViewRenderer::worldSpaceTransformation (NLMISC::CQuadColorUV &qcoluv) -{ - // set the world Z - qcoluv.V0.z = _CurrentZ; - qcoluv.V1.z = _CurrentZ; - qcoluv.V2.z = _CurrentZ; - qcoluv.V3.z = _CurrentZ; - - // for scaled interface, apply the scale matrix - qcoluv.V0= _WorldSpaceMatrix * qcoluv.V0; - qcoluv.V1= _WorldSpaceMatrix * qcoluv.V1; - qcoluv.V2= _WorldSpaceMatrix * qcoluv.V2; - qcoluv.V3= _WorldSpaceMatrix * qcoluv.V3; - - // unproject - qcoluv.V0 = _CameraFrustum.unProjectZ(qcoluv.V0); - qcoluv.V1 = _CameraFrustum.unProjectZ(qcoluv.V1); - qcoluv.V2 = _CameraFrustum.unProjectZ(qcoluv.V2); - qcoluv.V3 = _CameraFrustum.unProjectZ(qcoluv.V3); -} - -// *************************************************************************** - -void CViewRenderer::setWorldSpaceFrustum (const NL3D::CFrustum &cameraFrustum) -{ - _CameraFrustum = cameraFrustum; -} - -// *************************************************************************** - -void CViewRenderer::activateWorldSpaceMatrix (bool activate) -{ - _WorldSpaceTransformation = activate; - if (!_Material.empty()) - _Material.setZFunc(activate?UMaterial::lessequal:UMaterial::always); -} - -// *************************************************************************** - -void CViewRenderer::drawText (sint layerId, float x, float y, uint wordIndex, float xmin, float ymin, float xmax, float ymax, UTextContext &textContext) -{ - if (_WorldSpaceTransformation) - { - textContext.printClipAtUnProjected(*getStringRenderBuffer(layerId), _CameraFrustum, _WorldSpaceMatrix, x, y, _CurrentZ, wordIndex, xmin, ymin, xmax, ymax); - } - else - { - textContext.printClipAt(*getStringRenderBuffer(layerId), x, y, wordIndex, xmin, ymin, xmax, ymax); - } - - // layer is no more empty - _EmptyLayer[layerId + VR_BIAS_LAYER]= false; -} - -// *************************************************************************** - -void CViewRenderer::setInterfaceDepth (const NLMISC::CVector &projCenter, float scale) -{ - _CurrentZ = projCenter.z; - - // no scale? => identity matrix (faster) - if(scale==1) - { - _WorldSpaceMatrix.identity(); - _WorldSpaceScale= false; - } - else - { - _WorldSpaceMatrix.identity(); - // must be in 0..1 coordinate here... - CVector pos= projCenter; - pos.x*= _OneOverScreenW; - pos.y*= _OneOverScreenH; - // set a pivoted scale matrix - _WorldSpaceMatrix.translate(pos); - _WorldSpaceMatrix.scale(scale); - _WorldSpaceMatrix.translate(-pos); - _WorldSpaceScale= true; - } -} diff --git a/code/ryzom/client/src/interface_v3/view_renderer.h b/code/ryzom/client/src/interface_v3/view_renderer.h deleted file mode 100644 index cc96cee34..000000000 --- a/code/ryzom/client/src/interface_v3/view_renderer.h +++ /dev/null @@ -1,579 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_VIEW_RENDERER_H -#define NL_VIEW_RENDERER_H - -#include "nel/misc/types_nl.h" -#include "nel/3d/u_texture.h" -#include "nel/3d/u_text_context.h" -#include "nel/3d/u_driver.h" -#include "nel/misc/rgba.h" -#include "nel/misc/uv.h" -#include "nel/3d/frustum.h" - -// *************************************************************************** -#define VR_NUM_LAYER 32 -#define VR_BIAS_LAYER (VR_NUM_LAYER/2) -#define VR_LAYER_MAX (VR_NUM_LAYER-VR_BIAS_LAYER-1) -#define VR_LAYER_MIN (-VR_BIAS_LAYER) - -// *************************************************************************** -/** - * class rendering the views - * All the quads of the interface are displayed in the following order - * - * 3--2 - * | | - * 0--1 - * - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CViewRenderer -{ -public: - enum TSystemTexture - { - QuantityCrossTexture= 0, - DefaultBrickTexture, - DefaultItemTexture, - ItemPlanTexture, - SkillTexture, - ItemEnchantedTexture, - DragCopyTexture, - ItemWornedTexture, - OutOfRangeTexture, - RegenTexture, - RegenBackTexture, - GlowStarTexture, - ItemLockedByOwnerTexture, - NumSystemTextures, - }; - - -public: - - /** That class hold a texture id. It handle texture id destruction. - * Please use this class in your view and not sint32 to hold a texture id - */ - class CTextureId - { - public: - - // Default constructor - CTextureId () - { - _TextureId = -2; - } - - // Destructor call deleteTextureId; - ~CTextureId (); - - // Set the texture id - bool setTexture (const char *textureName, sint32 offsetX = 0, sint32 offsetY = 0, sint32 width = -1, sint32 height = -1, - bool uploadDXTC=true, bool bReleasable=true); - - // Convert in texture id - operator sint32 () const - { - return _TextureId; - } - - void serial(NLMISC::IStream &f); - - private: - sint32 _TextureId; - }; - -private: - CViewRenderer(); - ~CViewRenderer(); - -public: - static CViewRenderer* getInstance(); - - /// setup the default values for everything - void setup(); - - /// init when TextContext and Driver are created - void init(); - - /// set the driver render states for the interface - void setRenderStates (); - - /// Delete all textures and the like and reset the view renderer - void reset(); - - /// Retrieves the 3d driver we are using - static NL3D::UDriver* getDriver(); - - /// Sets the current TextContext. - static void setTextContext( NL3D::UTextContext *textcontext ); - - /// Sets the current driver - static void setDriver( NL3D::UDriver *driver ); - - /* - * setClipWindow : set the current clipping window - * (this window do not inherit properties from parent or whatever) - */ - void setClipWindow (sint32 x, sint32 y, sint32 w, sint32 h); - - /* - * getClipWindow : get the current clipping region - */ - void getClipWindow (sint32 &x, sint32 &y, sint32 &w, sint32 &h) - { - x = _ClipX; - y = _ClipY; - w = _ClipW; - h = _ClipH; - } - - /* - * true if the clipping region is empty: clipW or clipH is <=0 - */ - bool isClipWindowEmpty() const {return _ClipW<=0 || _ClipH<=0;} - - /* - * checkNewScreenSize : check if the opengl screen size. This is SLOW ! - * NB: if the window is minimized (w==h==0), then the old screen size is kept, and isMinimized() return true - */ - void checkNewScreenSize (); - - /* - * getScreenSize : get the screen window size changed (at last checkNewScreenSize called) - */ - void getScreenSize (uint32 &w, uint32 &h); - - /* - * get OOW / OOH - */ - void getScreenOOSize (float &oow, float &ooh); - - /* - * is the Screen minimized? - */ - bool isMinimized() const {return _IsMinimized;} - - /* - * drawBitmap : this is the interface with all the views - * - */ - void drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv, - sint32 nTxId, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); - - /* - * Draw a simple wired quad. No flushing is done as the draw is done instantly (usually for debug) - */ - void drawWiredQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White); - - /* - * Draw a simple filled quad. No flushing is done as the draw is done instantly (usually for debug) - */ - void drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White); - - /* - * drawBitmap : Tiled version - * \param tileOrigin 2 bits 1 - Left/Right (0/1) 2 - Bottom/Top (0/1) (0-BL)(1-BR)(2-TL)(3-TR) - * - */ - void drawRotFlipBitmapTiled (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv, - sint32 nTxId, uint tileOrigin, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); - - - - /* - * drawBitmap : draw a bitmap roted by 90 degrees in CW 'rot times' - * flipv is a boolean that indicates if there is a vertical flip - * this is a 1:1 ratio so if texture is x long there are x pixels on screen - */ - void draw11RotFlipBitmap (sint layerId, sint32 x, sint32 y, uint8 rot, bool flipv, sint32 nTxId, - const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255)); - - /** Draw an arbitrary quad (fast version) , possibly clipping it. Unlike draw11RotFlipBitmap & the like, texture is filtered here. - * quads are all batched in the same render layer - */ - void drawQuad(sint layerId, const NLMISC::CQuadUV &quadUV, sint32 nTxId, - NLMISC::CRGBA col, bool additif, bool filtered = true); - /** Draw a set of untextured triangle in the given layer. all triangles of the same layer are batched - */ - void drawUnclippedTriangles(sint layerId, const std::vector &tris, NLMISC::CRGBA col); - - /* - * Draw a text - */ - void drawText (sint layerId, float x, float y, uint wordIndex, float xmin, float ymin, float xmax, float ymax, NL3D::UTextContext &textContext); - - /* - * loadTextures : load all textures associated with the interface - * this function add a globaltexture to the vector of global textures - */ - void loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC); - - /* - * createTexture : create a texture for the interface, possibly from an externally created texture - * If no external texture is given, then 'sGlobalTextureName' is the filename of the big texture - * You should call deleteTexture when the texture is not used anymore - * The method returns the texture id of the new texture - */ - sint32 createTexture (const std::string &sGlobalTextureName, // unique id identifying this big texture, (its filename if not externally created) - sint32 offsetX = 0, - sint32 offsetY = 0, - sint32 width = -1, - sint32 height = -1, - bool uploadDXTC=true, - bool bReleasable=true - ); - - - // change position of a sub-texture (inside its big texture) from the sub-texture filename - void updateTexturePos(const std::string &texturefileName, - sint32 offsetX = 0, - sint32 offsetY = 0, - sint32 width = -1, - sint32 height = -1 - ); - - /** Add / change a global texture from an externally created texture - * \param defaultTexWidth width to used when CTextureId::createTexture is used without giving the width (e.g width = -1), useful for cropped textures - * \param defaultTexHeight height to used when CTextureId::createTexture is used without giving the height (e.g height = -1), useful for cropped textures - */ - - void setExternalTexture(const std::string &sGlobalTextureName, - NL3D::UTexture *externalTexture = NULL, - uint32 externalTexWidth = 1, - uint32 externalTexHeight = 1, - uint32 defaultTexWidth = 1, - uint32 defaultTexHeight = 1 - ); - - /* - * deleteTexture : create a texture for the interface - */ - void deleteTexture (sint32 textureId); - - // get a global texture pointer from its name - NL3D::UTexture *getGlobalTexture(const std::string &name); - - /* - * Flush all parsed view and computed strings to screen - */ - void flush (); - - /** - * get a texture file pointer from a string name. O(logN) - * \param id : the id of the texture - * \return a texture file pointer. -1 if not found or if sName is empty() - */ - sint32 getTextureIdFromName (const std::string &sName) const; - std::string getTextureNameFromId (sint32 TxID); - void getTextureSizeFromId (sint32 id, sint32 &width, sint32 &height); - NLMISC::CRGBA getTextureColor(sint32 id, sint32 x, sint32 y); - - - /** - * \return the texture associated with the param figur - */ - sint32 getFigurTextureId(uint index) - { - nlassert(index < 10); - return _IndexesToTextureIds[index]; - } - - /** - * \return the texture for figur separator '-' - */ - sint32 getFigurSeparator() const { return _FigurSeparatorTextureId; } - - sint32 getFigurTextureW() const {return _WFigurTexture;} - sint32 getFigurTextureH() const {return _HFigurTexture;} - sint32 getFigurSeparatorW() const {return _WFigurSeparatorTexture;} - sint32 getFigurSeparatorH() const {return _HFigurSeparatorTexture;} - - - sint32 getFigurBlankTextureId () - { - return _FigurBlankId; - } - sint32 getBlankTextureId () - { - return _BlankId; - } - - - sint32 getTypoTextureW(char c); - sint32 getTypoTextureH(char c); - sint32 getTypoTextureId(char c); - - /// System Texture Manager. Used to avoid storing an id in each Ctrl for some texture code is aware of - // @{ - sint32 getSystemTextureId(TSystemTexture e) const {return _SystemTextures[e].Id;} - sint32 getSystemTextureW(TSystemTexture e) const {return _SystemTextures[e].W;} - sint32 getSystemTextureH(TSystemTexture e) const {return _SystemTextures[e].H;} - // @} - - /// For string rendering, get the RenderBuffer to the specified layer - NL3D::URenderStringBuffer *getStringRenderBuffer(sint layerId); - - - /** Custom Rendering Interface - * Note that this function is EXTREMLY SLOW so it should be used with care - * This function flush the quad cache, clip the quad passed with current clipping region - * and draw (with drawQuedUV2) it with the material passed in parameter. There is no cache operation done. - * uv used are from (0,0) -> (1,1) for the 2 stages - */ - void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col, NL3D::UMaterial Mat); - // Same but we can control uv mapping of first stage - void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, - const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, - NLMISC::CRGBA col, NL3D::UMaterial Mat); - // Same but we can control uv mapping of 2 stages - void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, - const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, const NLMISC::CUV &uv1Min, const NLMISC::CUV &uv1Max, - NLMISC::CRGBA col, NL3D::UMaterial Mat); - - // **** World space interface methods - - /** Set the current Z in projCenter.z. - * If you want to scale the window position, set a scale!=1. projCenter.x/y is used as the - * pivot (in window coordinates) - */ - void setInterfaceDepth (const NLMISC::CVector &projCenter, float scale); - - // Activate world space transformation - void activateWorldSpaceMatrix (bool activate); - - // Set the screen to world space matrix - void setWorldSpaceFrustum (const NL3D::CFrustum &cameraFrustum); - - // Get the current Frustum - const NL3D::CFrustum &getFrustum () const - { - return _CameraFrustum; - } - -private: - /** - * init the map _IndexesToTextures - */ - void initIndexesToTextureIds (); - void initTypo (); - - bool needClipping (const NLMISC::CQuad &q); - - void clip (NLMISC::CQuadColorUV &qout, const NLMISC::CQuadColorUV &qin, uint rot); - void clip (NLMISC::CQuadColorUV2 &qout, const NLMISC::CQuadColorUV2 &qin); -private: - - // A layer is a vector of Quads. - class CLayer - { - public: - // unfiltered quads - std::vector Quads; - uint32 NbQuads; - std::vector Tris; - // filtered alpha blended quads - std::vector FilteredAlphaBlendedQuads; - // filtered alpha blended tris - std::vector FilteredAlphaBlendedTris; - // filtered additif blended quads - std::vector FilteredAdditifQuads; - // filtered additif blended tris - std::vector FilteredAdditifTris; - - CLayer() - { - NbQuads= 0; - } - }; - - // SGlobalTexture is a texture that regroup other texture. We store also current quads to render - struct SGlobalTexture - { - SGlobalTexture () - { - FromGlobaleTexture = true; - } - uint32 Width, Height; - uint32 DefaultWidth, DefaultHeight; - NL3D::UTexture *Texture; - std::string Name; - bool FromGlobaleTexture; - // Array of layers - CLayer Layers[VR_NUM_LAYER]; - }; - - // For each Layer, store a string Buffer - NL3D::URenderStringBuffer *_StringRBLayers[VR_NUM_LAYER]; - - // For each Layer, tells if empty or not - bool _EmptyLayer[VR_NUM_LAYER]; - - // SImage is one texture of the SGlobalTexture textures - struct SImage - { - std::string Name; - SGlobalTexture *GlobalTexturePtr; - NLMISC::CUV UVMin, UVMax; - - // Assign UV of this image to a quad depending on the flip and rot - void setupQuadUV(bool flipv, uint8 rot, NLMISC::CQuadColorUV &dest); - }; - - // *************************************************************************** - // \name Texture management - // *************************************************************************** - - // SImage accessors - SImage *getSImage(sint32 textureId) - { - return &(*(_SImageIterators[textureId])); - } - - - // Add a SImage - sint32 addSImage(const SImage &image) - { - uint i; - for (i=0; i<_SImageIterators.size(); i++) - { - // Free ? - if (_SImageIterators[i] == _SImages.end()) - break; - } - - // Nothing free ? - if (i == _SImageIterators.size()) - _SImageIterators.push_back(_SImages.end()); - - _SImages.push_back(image); - _SImageIterators[i] = _SImages.end(); - _SImageIterators[i]--; - return (sint32)i; - } - - // Remove a SImage - void removeSImage(sint32 textureId) - { - // Allocated ? - nlassert (_SImageIterators[textureId] != _SImages.end()); - - // Remove the image - _SImages.erase (_SImageIterators[textureId]); - - // Remove the index entry - _SImageIterators[textureId] = _SImages.end(); - } - - typedef std::list TGlobalTextureList; - typedef std::list TSImageList; - typedef std::vector::iterator> TSImageIterator; - - // List of global textures - TGlobalTextureList _GlobalTextures; - - // List of SImage - TSImageList _SImages; - - // Array used to convert a texture ID in _SImages iterator - TSImageIterator _SImageIterators; - - // *************************************************************************** - - typedef std::map TTextureMap; - TTextureMap _TextureMap; - - NL3D::UMaterial _Material; - - // Clip & screen system - sint32 _ClipX, _ClipY, _ClipW, _ClipH; - float _XMin, _XMax, _YMin, _YMax; - - sint32 _ScreenW, _ScreenH; - float _OneOverScreenW, _OneOverScreenH; - bool _IsMinimized; - - - //map linking a uint to a bitmap. Used to display figurs - std::vector _IndexesToTextureIds; - sint32 _FigurSeparatorTextureId; - sint32 _FigurBlankId, _BlankId; - sint32 _WFigurTexture; - sint32 _HFigurTexture; - sint32 _WFigurSeparatorTexture; - sint32 _HFigurSeparatorTexture; - NLMISC::CUV _BlankUV; - SGlobalTexture *_BlankGlobalTexture; - - // System textures - class CSystemTexture - { - public: - sint32 Id; - sint32 W; - sint32 H; - - CSystemTexture() - { - Id= -1; - W= H= 0; - } - }; - CSystemTexture _SystemTextures[NumSystemTextures]; - - // Typo texture - enum - { - NumTypoChar= 127, - }; - sint32 _TypoCharToTextureIds[NumTypoChar]; - sint32 _TypoCharWs[NumTypoChar]; - sint32 _TypoH; - - - void addSystemTexture(TSystemTexture e, const char *s); - void initSystemTextures(); - - /** - * put a new quad in the cache (call flush if texture different) - */ - void putQuadInLayer (SGlobalTexture >, sint layerId, const NLMISC::CQuadColorUV &qcoluv, uint rot); - - // World space interface methods - void worldSpaceTransformation (NLMISC::CQuadColorUV &qcoluv); - - bool _WorldSpaceTransformation; // Transform into world space - float _CurrentZ; // Current z used for the scene - NL3D::CFrustum _CameraFrustum; // Transform from screen space to world space - NLMISC::CMatrix _WorldSpaceMatrix; // Matrix to be applied for world space transformation - bool _WorldSpaceScale; - - - static CViewRenderer *instance; - static NL3D::UDriver *driver; - static NL3D::UTextContext *textcontext; -}; - - -#endif // NL_VIEW_RENDERER_H - -/* End of view_renderer.h */ diff --git a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp index 95b8f089b..a15d4492a 100644 --- a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp @@ -21,7 +21,7 @@ // #include "../interface_v3/ctrl_quad.h" #include "../interface_v3/interface_manager.h" -#include "../interface_v3/view_renderer.h" +#include "nel/gui/view_renderer.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/r2/displayer_visual_entity.cpp b/code/ryzom/client/src/r2/displayer_visual_entity.cpp index 744d99246..f92dcf0e2 100644 --- a/code/ryzom/client/src/r2/displayer_visual_entity.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_entity.cpp @@ -54,7 +54,7 @@ #include "../pacs_client.h" #include "../time_client.h" // -#include "../interface_v3/view_renderer.h" +#include "nel/gui/view_renderer.h" // #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/r2/island_collision.h b/code/ryzom/client/src/r2/island_collision.h index ffb8b19ff..f1c8de182 100644 --- a/code/ryzom/client/src/r2/island_collision.h +++ b/code/ryzom/client/src/r2/island_collision.h @@ -26,7 +26,7 @@ #include "nel/3d/texture_user.h" #include "nel/3d/packed_world.h" // -#include "../interface_v3/view_renderer.h" +#include "nel/gui/view_renderer.h" #include "../interface_v3/interface_element.h" namespace NL3D diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index c932643d8..9d6c16393 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -26,7 +26,7 @@ #include "../interface_v3/ctrl_quad.h" #include "../interface_v3/ctrl_polygon.h" #include "../interface_v3/interface_manager.h" -#include "../interface_v3/view_renderer.h" +#include "nel/gui/view_renderer.h" #include "../interface_v3/group_map.h" From 1f58c8ddc2feed3152127ee985615874961b6074 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 2 Jun 2012 21:48:11 +0200 Subject: [PATCH 043/339] ADDED: #1471 IParser interface with a few methods, accessible from CWidgetManager, just so that I don't have to move CInterfaceParser right now. --- .../src/interface_v3/interface_element.cpp | 20 +++++-------------- .../src/interface_v3/interface_group.cpp | 14 ++++--------- .../src/interface_v3/interface_link.cpp | 10 +++------- .../src/interface_v3/interface_manager.cpp | 1 + .../src/interface_v3/interface_parser.h | 2 +- .../src/interface_v3/widget_manager.cpp | 1 + .../client/src/interface_v3/widget_manager.h | 11 ++++++++++ 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index 90176baae..b0145363e 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -14,15 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "interface_group.h" #include "nel/gui/interface_property.h" -#include "interface_manager.h" +#include "nel/gui/view_renderer.h" +#include "widget_manager.h" +#include "nel/gui/db_manager.h" #include "group_container.h" -#include "../misc.h" #include "interface_link.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" @@ -157,7 +154,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) idparent = parentGroup->getId() +":"; else idparent = "ui:"; - CInterfaceManager::getInstance()->addParentPositionAssociation (this, idparent + string((const char*)ptr)); + CWidgetManager::parser->addParentPositionAssociation(this, idparent + string((const char*)ptr)); } } @@ -178,7 +175,7 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if (parentGroup) idparent = parentGroup->getId(); } - CInterfaceManager::getInstance()->addParentSizeAssociation (this, idparent); + CWidgetManager::parser->addParentSizeAssociation( this, idparent ); } ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref"); @@ -527,7 +524,6 @@ void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const strin return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -574,7 +570,6 @@ void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const strin return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -615,7 +610,6 @@ void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -661,7 +655,6 @@ void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::stri return; } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint32 decal = 0; if (val[0] == ':') decal = 1; @@ -1000,7 +993,6 @@ void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other) void CInterfaceElement::center() { // center the pc - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); uint32 sw, sh; vr.getScreenSize(sw, sh); @@ -1024,7 +1016,6 @@ void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &u _Id.compare(_Id.size()-uiFilter.size(),string::npos,uiFilter)!=0) ) return; - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); drawHotSpot(_PosRef, CRGBA::Red); @@ -1063,7 +1054,6 @@ void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col) { px = _XReal + _WReal - radius; } - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 8104c5676..6681ea366 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -113,7 +113,6 @@ void CInterfaceGroup::setActive(bool state) if(state != getActive()) { CCtrlBase::setActive(state); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (_AHOnActive != NULL && state) { CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); @@ -323,7 +322,7 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) if (parentGroup) idparent = parentGroup->getId(); } - CInterfaceManager::getInstance()->addParentSizeMaxAssociation (this, idparent); + CWidgetManager::parser->addParentSizeMaxAssociation (this, idparent); } // left & right clicks @@ -346,7 +345,8 @@ bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) // LuaClass script ptr = xmlGetProp (cur, (xmlChar*)"lua_class"); - if(ptr) CInterfaceManager::getInstance()->addLuaClassAssociation(this, (const char*)ptr); + if( ptr ) + CWidgetManager::parser->addLuaClassAssociation( this, (const char*)ptr ); return true; } @@ -693,8 +693,6 @@ bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) if (!_Active) return false; - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (event.getType() == NLGUI::CEventDescriptor::system) { NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; @@ -866,10 +864,8 @@ void CInterfaceGroup::executeLuaScriptOnDraw() { // If some LUA script attached to me, execute it if(!_LUAOnDraw.empty()) - { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); - } + } // ------------------------------------------------------------------------------------------------ @@ -1748,7 +1744,6 @@ void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy) // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::pushLUAEnvTable() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); @@ -1783,7 +1778,6 @@ void CInterfaceGroup::deleteLUAEnvTable(bool recurse) { if(_LUAEnvTableCreated) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index c61891634..2ef066363 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -14,13 +14,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - -#include "stdpch.h" +#include "action_handler.h" #include "interface_link.h" +#include "interface_group.h" #include "interface_element.h" -#include "interface_manager.h" +#include "widget_manager.h" #include "nel/gui/interface_expr.h" #include "nel/gui/interface_expr_node.h" #include "nel/gui/reflect.h" @@ -364,7 +362,6 @@ void CInterfaceLink::update() } if(launch) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); // do not add any code after this line because this can be deleted !!!! } @@ -543,7 +540,6 @@ void CInterfaceLink::setTargetProperty (const std::string &Target, const CInt { // Eval target ! string elt = Target.substr(0,Target.rfind(':')); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); CInterfaceGroup *pIG = dynamic_cast(pIE); if (pIG == NULL) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 96b55998f..c1d3e2a71 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -256,6 +256,7 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { + CWidgetManager::parser = this; this->driver = driver; this->textcontext = textcontext; CViewRenderer::setDriver( driver ); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 650e60cb9..70cf5a200 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -50,7 +50,7 @@ class CCtrlBase; */ // this is the base class for CInterfaceManager -class CInterfaceParser +class CInterfaceParser : public IParser { public: diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 2bf490e13..f50c7113a 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -22,6 +22,7 @@ CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; +IParser* CWidgetManager::parser = NULL; // ---------------------------------------------------------------------------- // SMasterGroup diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index 76d03b514..4b77010d2 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -28,6 +28,15 @@ class CCtrlBase; class CInterfaceGroup; class CViewPointer; +class IParser +{ +public: + virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; +}; + /// Manages the GUI widgets class CWidgetManager{ public: @@ -177,6 +186,8 @@ public: CViewPointer* getPointer(){ return _Pointer; } void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } + static IParser *parser; + private: CWidgetManager(); ~CWidgetManager(); From 7a32e739e79086860943d2854d5f6176c514b88d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 3 Jun 2012 03:48:31 +0200 Subject: [PATCH 044/339] CHANGED: #1471 Moved lots of code from CInterfaceManager to CWidgetManager ( mostly code that is directly used by the widgets ) --- code/ryzom/client/src/client_chat_manager.cpp | 10 +- code/ryzom/client/src/commands.cpp | 2 +- code/ryzom/client/src/cursor_functions.cpp | 2 +- code/ryzom/client/src/init_main_loop.cpp | 8 +- .../src/interface_v3/action_handler_base.cpp | 7 +- .../src/interface_v3/action_handler_edit.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 10 +- .../src/interface_v3/action_handler_ui.cpp | 10 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../client/src/interface_v3/ctrl_base.cpp | 11 +- .../src/interface_v3/ctrl_base_button.cpp | 18 +- .../client/src/interface_v3/ctrl_button.cpp | 6 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 6 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 18 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 6 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 18 +- .../src/interface_v3/group_container.cpp | 70 +- .../client/src/interface_v3/group_editbox.cpp | 43 +- .../client/src/interface_v3/group_header.cpp | 8 +- .../client/src/interface_v3/group_html.cpp | 8 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../client/src/interface_v3/group_map.cpp | 24 +- .../src/interface_v3/group_modal_get_key.cpp | 4 +- .../src/interface_v3/group_paragraph.cpp | 4 +- .../client/src/interface_v3/group_tab.cpp | 4 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../interface_v3/input_handler_manager.cpp | 2 +- .../src/interface_v3/interface_3d_scene.cpp | 8 +- .../src/interface_v3/interface_group.cpp | 3 +- .../src/interface_v3/interface_manager.cpp | 660 ++---------------- .../src/interface_v3/interface_manager.h | 82 --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 6 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../client/src/interface_v3/view_base.cpp | 3 +- .../src/interface_v3/view_bitmap_combo.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 16 +- .../client/src/interface_v3/view_text.cpp | 4 +- .../src/interface_v3/widget_manager.cpp | 540 ++++++++++++++ .../client/src/interface_v3/widget_manager.h | 92 +++ code/ryzom/client/src/login.cpp | 8 +- code/ryzom/client/src/main_loop.cpp | 12 +- code/ryzom/client/src/r2/editor.cpp | 14 +- code/ryzom/client/src/r2/tool.cpp | 14 +- .../client/src/r2/tool_create_entity.cpp | 2 +- .../client/src/r2/tool_maintained_action.cpp | 2 +- code/ryzom/client/src/release.cpp | 6 +- 51 files changed, 906 insertions(+), 887 deletions(-) diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index f62b02323..b9ed783b3 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -1211,7 +1211,7 @@ class CHandlerEnterTell : public IActionHandler CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb")); if (eb) { - im->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); } } } @@ -1419,18 +1419,18 @@ class CHandlerSwapChatMode : public IActionHandler node->setValue32(0); // also leave Chat Focus (important if comes from command) if (updateCapture) - pIM->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); } else { // enter chat mode (enter dont quit CB) node->setValue32(1); // enter Chat focus if '/c' entered - if (updateCapture && !pIM->getCaptureKeyboard()) + if (updateCapture && !CWidgetManager::getInstance()->getCaptureKeyboard()) { // reset to the old captured keyboard (should be the one that have launched the command) - if(pIM->getOldCaptureKeyboard()) - pIM->setCaptureKeyboard(pIM->getOldCaptureKeyboard()); + if(CWidgetManager::getInstance()->getOldCaptureKeyboard()) + CWidgetManager::getInstance()->setCaptureKeyboard(CWidgetManager::getInstance()->getOldCaptureKeyboard()); } } } diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 6b6c2b01b..8e7fbf52f 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5296,7 +5296,7 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std: } // Run the action handler - CAHManager::getInstance()->runActionHandler (mode->Action, pIM->getOldCaptureKeyboard(), finalArgs); + CAHManager::getInstance()->runActionHandler (mode->Action, CWidgetManager::getInstance()->getOldCaptureKeyboard(), finalArgs); } else { diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 64df4e5d2..10942ef3c 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -252,7 +252,7 @@ void checkUnderCursor() cursor->getPointerPos(x, y); // Over the interface ? - if (IM->getWindowUnder(x, y) == NULL) + if (CWidgetManager::getInstance()->getWindowUnder(x, y) == NULL) { // Is the pointer in the window ? if(x < 0 || y <0) diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 6a79b0de3..4b2247566 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -1274,11 +1274,11 @@ void initMainLoop() // Set the default edit box for the enter key // if (PeopleInterraction.MainChat.Window) -// CInterfaceManager::getInstance()->setCaptureKeyboard(PeopleInterraction.MainChat.Window->getEditBox()); +// CWidgetManager::getInstance()->setCaptureKeyboard(PeopleInterraction.MainChat.Window->getEditBox()); if (PeopleInterraction.ChatGroup.Window) { CGroupEditBox *eb= dynamic_cast(PeopleInterraction.ChatGroup.Window->getEditBox()); - CInterfaceManager::getInstance()->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); // For user help, set a default input string. // NB: must do it after interface loadConfig, else it is reseted // NB: it is reseted also on first mode switch @@ -1286,8 +1286,8 @@ void initMainLoop() eb->setDefaultInputString(CI18N::get("uiDefaultChatInput")); } else - CInterfaceManager::getInstance()->setCaptureKeyboard(NULL); - CInterfaceManager::getInstance()->setCaptureKeyboard(NULL); // previous set editbox becomes '_OldCaptureKeyboard' + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); // previous set editbox becomes '_OldCaptureKeyboard' // Some init after connection ready sent if(BotChatPageAll && (!ClientCfg.R2EDEnabled)) diff --git a/code/ryzom/client/src/interface_v3/action_handler_base.cpp b/code/ryzom/client/src/interface_v3/action_handler_base.cpp index c7acaf3f2..cfb6c6549 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_base.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_base.cpp @@ -97,7 +97,7 @@ public: nlwarning(" Can't get target edit box %s, or bad type", target.c_str()); return; } - pIM->setCaptureKeyboard(geb); + CWidgetManager::getInstance()->setCaptureKeyboard(geb); string selectAllStr = getParam (Params, "select_all"); bool selectAll = CInterfaceElement::convertBool(selectAllStr.c_str()); if (selectAll) @@ -114,8 +114,7 @@ class CAHResetKeyboardFocus : public IActionHandler public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->resetCaptureKeyboard(); + CWidgetManager::getInstance()->resetCaptureKeyboard(); } }; REGISTER_ACTION_HANDLER (CAHResetKeyboardFocus, "reset_keyboard_focus"); @@ -351,7 +350,7 @@ class CAHResetInterface : public IActionHandler } } - pIM->checkCoords(); + CWidgetManager::getInstance()->checkCoords(); CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).centerAllContainers(); // Pop in and close all containers diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index 042f2788b..8ae94c30f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -115,7 +115,7 @@ protected: CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (pIM) { - CCtrlBase *basectrl = pIM->getCaptureKeyboard(); + CCtrlBase *basectrl = CWidgetManager::getInstance()->getCaptureKeyboard(); if (basectrl) _GroupEdit = dynamic_cast(basectrl); } diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 511b59c2e..5c64d2219 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -126,7 +126,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() editBoxLarge->setActive(true); // Set the Keyboard focus to the editbox (after the enableModalWindow()) - pIM->setCaptureKeyboard(editBoxLarge); + CWidgetManager::getInstance()->setCaptureKeyboard(editBoxLarge); // Select all the text for easier selection editBoxLarge->setSelectionAll(); } @@ -144,7 +144,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived() editBoxShort->setActive(true); // Set the Keyboard focus to the editbox (after the enableModalWindow()) - pIM->setCaptureKeyboard(editBoxShort); + CWidgetManager::getInstance()->setCaptureKeyboard(editBoxShort); // Select all the text for easier selection editBoxShort->setSelectionAll(); } @@ -239,7 +239,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() editBoxLarge->setActive(true); // Set the Keyboard focus to the editbox - pIM->setCaptureKeyboard(editBoxLarge); + CWidgetManager::getInstance()->setCaptureKeyboard(editBoxLarge); // Select all the text for easier selection editBoxLarge->setSelectionAll(); } @@ -258,7 +258,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin() editBoxShort->setActive(true); // Set the Keyboard focus to the editbox - pIM->setCaptureKeyboard(editBoxShort); + CWidgetManager::getInstance()->setCaptureKeyboard(editBoxShort); // Select all the text for easier selection editBoxShort->setSelectionAll(); } @@ -503,7 +503,7 @@ static void displayQuantityPopup(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCt CWidgetManager::getInstance()->enableModalWindow(pCaller, group); // Set the Keyboard focus to the editbox (after the enableModalWindow()) - pIM->setCaptureKeyboard(editBox); + CWidgetManager::getInstance()->setCaptureKeyboard(editBox); // Select all the text for easier selection editBox->setSelectionAll(); } diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index d4e83c4fb..94bd9e9b3 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -169,8 +169,8 @@ class CAHUIPopup : public IActionHandler // pGC->popup(); // - pIM->setCapturePointerLeft(NULL); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } }; REGISTER_ACTION_HANDLER( CAHUIPopup, "popup" ); @@ -204,8 +204,8 @@ class CAHUIPopin : public IActionHandler pGC->setPopupH(pGC->getH()); // pGC->popin(); - pIM->setCapturePointerLeft(NULL); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } }; REGISTER_ACTION_HANDLER( CAHUIPopin, "popin" ); @@ -535,7 +535,7 @@ class CAHTalkUntalk : public IActionHandler CInterfaceManager *im = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->setTopWindow(cw->getContainer()); cw->enableBlink(1); - im->setCaptureKeyboard(cw->getEditBox()); + CWidgetManager::getInstance()->setCaptureKeyboard(cw->getEditBox()); PeopleInterraction.MainChat.Filter.setTargetPlayer(selection->getName()); } } diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 89ffb9f65..f469e53b1 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -708,7 +708,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot) CGroupEditBox *eb = dynamic_cast(quantityModal->getGroup("eb")); if (eb) { - pIM->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setInputString(toString(maxQuantity)); eb->setSelectionAll(); } diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index c3b1f2df8..809a433e9 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -1067,7 +1067,7 @@ void CBotChatPageTrade::setFocusOnEditBox(CInterfaceGroup *ebi) CGroupEditBox *eb = dynamic_cast(ebi); if (eb) { - pIM->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setSelectionAll(); } } diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 30985718c..b9824f115 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -315,7 +315,7 @@ bool CChatWindow::rename(const ucstring &newName, bool newNameLocalize) void CChatWindow::setKeyboardFocus() { if (!_EB || !_Chat) return; - CInterfaceManager::getInstance()->setCaptureKeyboard(_EB); + CWidgetManager::getInstance()->setCaptureKeyboard(_EB); if (!_Chat->isOpenable() || _Chat->isOpenWhenPopup()) { if (_Chat->isPopable() && !_Chat->isPopuped()) diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_base.cpp index 353b5d9e1..b68851a0f 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base.cpp @@ -27,8 +27,7 @@ using namespace NLMISC; // *************************************************************************** CCtrlBase::~CCtrlBase() { - CInterfaceManager *manager = CInterfaceManager::getInstance(); - manager->removeRefOnCtrl (this); + CWidgetManager::getInstance()->removeRefOnCtrl (this); } // *************************************************************************** @@ -43,13 +42,13 @@ bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event) { // the mouse capture should be lost when the ctrl is hidden CInterfaceManager *manager = CInterfaceManager::getInstance(); - if (manager->getCapturePointerLeft() == this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { - manager->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); } - if (manager->getCapturePointerRight() == this) + if (CWidgetManager::getInstance()->getCapturePointerRight() == this) { - manager->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } // NB : don't call return here because derived class may be interested // in handling event more speciffically diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp index dbcc1c9aa..8babc835a 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp @@ -212,7 +212,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if (pIM->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; _LeftLongClickHandled = true; } @@ -248,7 +248,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if (pIM->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled @@ -284,7 +284,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) } */ runLeftClickAction(); - if (pIM->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example) // Run Menu if (!_ListMenuLeft.empty()) @@ -309,7 +309,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) _LastLeftClickButton = NULL; bool handled= false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getCapturePointerRight() != this) + if (CWidgetManager::getInstance()->getCapturePointerRight() != this) return false; // RunAction @@ -318,7 +318,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) handled= true; CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); } - if (pIM->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted + if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted // Run Menu if (!_ListMenuRight .empty()) { @@ -343,7 +343,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) } CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getCapturePointerLeft() == this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { if (!_LeftLongClickHandled) { @@ -452,16 +452,16 @@ void CCtrlBaseButton::updateOver(bool &lastOver) return; } - if (pIM->getCapturePointerLeft() != NULL) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) { - if (pIM->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) { _Over = false; } return; } - const vector &rVB = pIM->getCtrlsUnderPointer (); + const vector &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer (); if (!_Frozen) { diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index 001f83c2b..0dde15dc7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -163,7 +163,7 @@ void CCtrlButton::draw () } else { - if ((_Over) && (pIM->getCapturePointerLeft() == this)) + if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) { nTxId = _TextureIdPushed; color = getCurrentColorPushed(globalColor); @@ -179,7 +179,7 @@ void CCtrlButton::draw () break; case PushButton: { - if (_Over && (pIM->getCapturePointerLeft() == this)) + if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) { nTxId = _TextureIdPushed; color = getCurrentColorPushed(globalColor); @@ -215,7 +215,7 @@ void CCtrlButton::draw () nTxId, color ); - if ((_OverWhenPushed == false) && (_Pushed == true || (pIM->getCapturePointerLeft() == this))) + if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this))) return; diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index d158b0280..eb886c15d 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -116,7 +116,7 @@ bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event) if (event.getType() == NLGUI::CEventDescriptor::mouse) { const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && (!((eventDesc.getX() >= _XReal) && (eventDesc.getX() < (_XReal + _WReal))&& (eventDesc.getY() > _YReal) && diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index d433b2a07..f537561b0 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -466,7 +466,7 @@ bool CCtrlScroll::handleEvent (const NLGUI::CEventDescriptor &event) if (event.getType() == NLGUI::CEventDescriptor::mouse) { const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && (!((eventDesc.getX() >= _XReal) && (eventDesc.getX() < (_XReal + _WReal))&& (eventDesc.getY() > _YReal) && diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index faa74d213..d3067a81c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -311,7 +311,7 @@ void CCtrlTextButton::draw () } else { - if ((_Over) && (pIM->getCapturePointerLeft() == this)) + if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) { pTxId = _TextureIdPushed; color = getCurrentColorPushed(globalColor); @@ -327,7 +327,7 @@ void CCtrlTextButton::draw () break; case PushButton: { - if (_Over && (pIM->getCapturePointerLeft() == this)) + if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) { pTxId = _TextureIdPushed; color = getCurrentColorPushed(globalColor); @@ -362,7 +362,7 @@ void CCtrlTextButton::draw () rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); // *** Draw Over - if (_Over && (_OverWhenPushed || !(_Pushed || pIM->getCapturePointerLeft() == this))) + if (_Over && (_OverWhenPushed || !(_Pushed || CWidgetManager::getInstance()->getCapturePointerLeft() == this))) { if ((lastOver == false) && (_AHOnOver != NULL)) CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index b4af18ea7..c30fcf776 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1836,7 +1836,7 @@ void CDBCtrlSheet::draw() // Manage over for brick if( _BrickOverable && (isMacro() || isSBrickOrSPhraseId() || isSPhrase()) ) { - const vector &rVB = pIM->getCtrlsUnderPointer (); + const vector &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer (); uint32 i; for (i = 0; i < rVB.size(); ++i) if (rVB[i] == this) @@ -1856,15 +1856,15 @@ void CDBCtrlSheet::draw() // Drag'N'Drop : display the selected slot bitmap if this slot accept the currently dragged element _CanDrop = false; if (_AHOnCanDrop != NULL) - if ((pIM->getCapturePointerLeft() != NULL) && (pIM->getCapturePointerLeft() != this)) + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) && (CWidgetManager::getInstance()->getCapturePointerLeft() != this)) { if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) - if (pIM->getCurrentWindowUnder() == CWidgetManager::getInstance()->getWindow(this)) + if (CWidgetManager::getInstance()->getCurrentWindowUnder() == CWidgetManager::getInstance()->getWindow(this)) { - CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); + CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) { string params = string("src=") + pCSSrc->getId(); @@ -2602,7 +2602,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // Handle drag'n'drop - if (pIM->getCapturePointerLeft() == this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Draging) { @@ -2662,7 +2662,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) { bool handled = false; // get the ctrl under the drop - const vector &rCUP = pIM->getCtrlsUnderPointer(); + const vector &rCUP = CWidgetManager::getInstance()->getCtrlsUnderPointer(); CDBCtrlSheet *pCSdest = NULL; for (uint32 i = 0; i < rCUP.size(); ++i) { @@ -2727,7 +2727,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) else // If slot not found try to drop on a list { // get the list under the drop - const vector &rGUP = pIM->getGroupsUnderPointer(); + const vector &rGUP = CWidgetManager::getInstance()->getGroupsUnderPointer(); CDBGroupListSheet *pList = NULL; CDBGroupListSheetText *pTextList = NULL; for (uint32 i = 0; i < rGUP.size(); ++i) @@ -2849,7 +2849,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; // RunAction @@ -2877,7 +2877,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) { bool handled= false; CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getCapturePointerRight() != this) + if (CWidgetManager::getInstance()->getCapturePointerRight() != this) return false; // RunAction diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index eb539384c..b9ca8c283 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -711,17 +711,17 @@ void CDBGroupListSheet::draw () _CanDrop = false; if (_CtrlInfo._AHOnCanDrop != NULL) - if (pIM->getCapturePointerLeft()) + if (CWidgetManager::getInstance()->getCapturePointerLeft()) { CGroupContainer *pGC = getContainer(); - if (pIM->getCurrentWindowUnder() == pGC) + if (CWidgetManager::getInstance()->getCurrentWindowUnder() == pGC) { if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { - CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); + CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) { string params = string("src=") + pCSSrc->getId(); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index d3f2e75b7..250f7adcc 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -621,17 +621,17 @@ void CDBGroupListSheetText::draw () _CanDrop = false; if (_CtrlInfo._AHOnCanDrop != NULL) - if (pIM->getCapturePointerLeft()) + if (CWidgetManager::getInstance()->getCapturePointerLeft()) { CGroupContainer *pGC = getContainer(); - if (pIM->getCurrentWindowUnder() == pGC) + if (CWidgetManager::getInstance()->getCurrentWindowUnder() == pGC) { if ((CWidgetManager::getInstance()->getPointer()->getX() >= _XReal) && (CWidgetManager::getInstance()->getPointer()->getX() < (_XReal + _WReal))&& (CWidgetManager::getInstance()->getPointer()->getY() > _YReal) && (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { - CDBCtrlSheet *pCSSrc = dynamic_cast(pIM->getCapturePointerLeft()); + CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); if ((pCSSrc != NULL) && pCSSrc->isDraging()) { string params = string("src=") + pCSSrc->getId(); @@ -674,10 +674,10 @@ bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) { // Drag'n'drop from a ctrl sheet that belongs to this list CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if ((pIM->getCapturePointerLeft() != NULL) && (pIM->getCapturePointerLeft()->getParent() == _List)) + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) && (CWidgetManager::getInstance()->getCapturePointerLeft()->getParent() == _List)) { CDBCtrlSheet *pDraggedSheet = NULL; - CCtrlButton *pCB = dynamic_cast(pIM->getCapturePointerLeft()); + CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); if (pCB != NULL) { // A button has been captured -> Transform the capture to the corresponding ctrlsheet @@ -686,7 +686,7 @@ bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) _SheetChildren[pos]->Ctrl->isDragable() && (!_SheetChildren[pos]->Ctrl->getGrayed())) { pDraggedSheet = _SheetChildren[pos]->Ctrl; - pIM->setCapturePointerLeft(pDraggedSheet); + CWidgetManager::getInstance()->setCapturePointerLeft(pDraggedSheet); NLGUI::CEventDescriptorMouse newEv = eventDesc; // Send this because not send (the captured button has processed the event mouseleftdown) newEv.setEventTypeExtended(NLGUI::CEventDescriptorMouse::mouseleftdown); @@ -695,7 +695,7 @@ bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) } else { - pDraggedSheet = dynamic_cast(pIM->getCapturePointerLeft()); + pDraggedSheet = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); // auto scroll only if swapable if(swapable()) { @@ -714,7 +714,7 @@ bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { sint posdst = -1,possrc = -1; - const vector &rV = pIM->getCtrlsUnderPointer(); + const vector &rV = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for (uint i = 0; i < rV.size(); ++i) { CCtrlButton *pCB = dynamic_cast(rV[i]); @@ -920,7 +920,7 @@ void CDBGroupListSheetText::setup() _SheetChildren[i]->init(this, i); } - pIM->registerClockMsgTarget(this); + CWidgetManager::getInstance()->registerClockMsgTarget(this); } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index f5519bcd5..5a4820c71 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -175,7 +175,7 @@ bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) if (event.getType() == NLGUI::CEventDescriptor::mouse) { const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc.getX(), eventDesc.getY())) + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc.getX(), eventDesc.getY())) return false; CGroupContainer *gc = dynamic_cast(_Parent); @@ -586,7 +586,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; // the ctrl must have been captured - if (pIM->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; CGroupContainer *gc = dynamic_cast(_Parent); @@ -604,7 +604,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_WaitToOpenClose) { _WaitToOpenClose = false; - pIM->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // _WaitToOpen can only be set if the container is popable if (gc) { @@ -642,8 +642,8 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) } gc->invalidateCoords(2); // - pIM->setCapturePointerLeft(NULL); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } return true; } @@ -652,7 +652,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_WaitToOpenClose) { _WaitToOpenClose = false; - pIM->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); } if (_CanOpen || gc->isOpenWhenPopup()) @@ -672,7 +672,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (gc->isPopable()) { _WaitToOpenClose = true; - pIM->registerClockMsgTarget(this); + CWidgetManager::getInstance()->registerClockMsgTarget(this); _WaitToOpenCloseDate = T1; } else @@ -848,14 +848,14 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_ParentScrollingUp) { _ParentScrollingUp = false; - pIM->registerClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass } if (glSciY > gl->getYReal()) // is there need for scroll ? { if (!_ParentScrollingDown) { _ParentScrollingDown = true; - pIM->registerClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass _ScrollTime = 0; } } @@ -864,7 +864,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_ParentScrollingDown) { _ParentScrollingDown = false; - pIM->unregisterClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass } } y = _ParentListBottom; @@ -874,7 +874,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_ParentScrollingDown) { _ParentScrollingDown = false; - pIM->registerClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass } sint32 topY = y + _Parent->getHReal(); if (topY > _ParentListTop) @@ -885,7 +885,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (!_ParentScrollingUp) { _ParentScrollingUp = true; - pIM->registerClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass _ScrollTime = 0; } } @@ -894,7 +894,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_ParentScrollingUp) { _ParentScrollingDown = false; - pIM->unregisterClockMsgTarget(this); // want to now when time pass + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass } } y = _ParentListTop - _Parent->getHReal(); @@ -924,7 +924,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) CGroupContainer *gc = dynamic_cast(_Parent); if (!gc) return false; _WaitToOpenClose = false; - pIM->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // do the open action if (gc->isOpenable() && !gc->isOpenWhenPopup()) { @@ -984,7 +984,7 @@ void CCtrlMover::handleScrolling() else { _ParentScrollingUp = false; - im->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); _InsertionIndex = 0; } } @@ -1018,7 +1018,7 @@ void CCtrlMover::handleScrolling() else { _ParentScrollingDown = false; - im->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); _InsertionIndex = gl->getNumChildren(); } } @@ -1083,8 +1083,8 @@ void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceMan cm->_MoveDeltaXReal= gc->getXReal() - gc->getX(); cm->_MoveDeltaYReal= gc->getYReal() - gc->getY(); cm->_Moving= true; - pIM->setCapturePointerLeft(cm); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(cm); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } // *************************************************************************** @@ -1127,8 +1127,8 @@ void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y _MoveStartY= gc->getY()-eventDesc.getY(); _MoveDeltaYReal= gc->getYReal() - gc->getY(); - pIM->setCapturePointerLeft(this); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(this); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); _Moving = false; _MovingInParentList = true; @@ -1165,7 +1165,7 @@ void CCtrlMover::stopMove(CInterfaceManager *pIM) { _ParentScrollingUp = false; _ParentScrollingDown = false; - pIM->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); _HasMoved = false; if (_Moving) { @@ -2200,9 +2200,9 @@ void CGroupContainer::draw () bool dontFade = false; // bool alphaUp = false; // should not applied if the container is being resized - if (pIM->getCapturePointerLeft() != NULL) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) { - CInterfaceGroup *ig = pIM->getCapturePointerLeft()->getParent(); + CInterfaceGroup *ig = CWidgetManager::getInstance()->getCapturePointerLeft()->getParent(); while (ig) { if (ig == this) @@ -2218,10 +2218,10 @@ void CGroupContainer::draw () bool isOver = false; - if (pIM->getCapturePointerLeft() == NULL) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) if (isIn(mousePointer->getX(), mousePointer->getY())) { - CInterfaceGroup *ig = pIM->getCurrentWindowUnder(); + CInterfaceGroup *ig = CWidgetManager::getInstance()->getCurrentWindowUnder(); while (ig) { if (ig == this) @@ -3291,8 +3291,8 @@ void CGroupContainer::popupCurrentPos() CInterfaceManager *im = CInterfaceManager::getInstance(); im->makeWindow(this); CWidgetManager::getInstance()->setTopWindow(this); - im->clearViewUnders(); - im->clearCtrlsUnders(); + CWidgetManager::getInstance()->clearViewUnders(); + CWidgetManager::getInstance()->clearCtrlsUnders(); // update coords (put coords in world) setX(getXReal()); @@ -3347,8 +3347,8 @@ void CGroupContainer::popin(sint32 insertPos /* = -1 */, bool putBackInFatherCon _MovingInParentList = false; CInterfaceManager *im = CInterfaceManager::getInstance(); im->unMakeWindow(this); - im->clearViewUnders(); - im->clearCtrlsUnders(); + CWidgetManager::getInstance()->clearViewUnders(); + CWidgetManager::getInstance()->clearCtrlsUnders(); _Parent = NULL; _ParentPos = NULL; std::vector::iterator it = std::find(_PopedCont.begin(), _PopedCont.end(), this); @@ -3534,8 +3534,8 @@ public: pIC->popup(); // CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setCapturePointerLeft(NULL); - im->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } }; REGISTER_ACTION_HANDLER (CICPopup, "ic_popup"); @@ -3559,8 +3559,8 @@ public: // pIC->popin(); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setCapturePointerLeft(NULL); - im->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } }; REGISTER_ACTION_HANDLER (CICPopin, "ic_popin"); @@ -3664,9 +3664,9 @@ void CGroupContainer::forceRolloverAlpha() bool CGroupContainer::hasKeyboardFocus() const { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getCaptureKeyboard() != NULL) + if (CWidgetManager::getInstance()->getCaptureKeyboard() != NULL) { - const CGroupEditBox *geb = dynamic_cast(im->getCaptureKeyboard()); + const CGroupEditBox *geb = dynamic_cast(CWidgetManager::getInstance()->getCaptureKeyboard()); if (geb) { const CInterfaceGroup *gr = geb->getParent(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 0615a6428..d7be6bb33 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -96,9 +96,9 @@ CGroupEditBox::~CGroupEditBox() { if (this == _CurrSelection) _CurrSelection = NULL; CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getCaptureKeyboard() == this || im->getOldCaptureKeyboard() == this) + if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) { - im->resetCaptureKeyboard(); + CWidgetManager::getInstance()->resetCaptureKeyboard(); } } @@ -296,7 +296,7 @@ void CGroupEditBox::draw () } // Display the cursor if needed - if (pIM->getCaptureKeyboard () == this) + if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) { _BlinkTime += DT; if (_BlinkTime > 0.25f) @@ -558,7 +558,7 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) { case KeyESCAPE: _CurrentHistoricIndex= -1; - CInterfaceManager::getInstance()->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); // stop selection _CurrSelection = NULL; _CursorAtPreviousLineEnd = false; @@ -589,7 +589,7 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) { if(_LooseFocusOnEnter) - pIM->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); } // stop selection _CurrSelection = NULL; @@ -720,7 +720,7 @@ void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK) bool CGroupEditBox::undo() { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getCaptureKeyboard() != this) return false; + if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanUndo) return false; _ModifiedInputString = _InputString; setInputString(_StartInputString); @@ -735,7 +735,7 @@ bool CGroupEditBox::undo() bool CGroupEditBox::redo() { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getCaptureKeyboard() != this) return false; + if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanRedo) return false; setInputString(_ModifiedInputString); _CanUndo = true; @@ -877,9 +877,9 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { - if (pIM->getCapturePointerRight() == this) + if (CWidgetManager::getInstance()->getCapturePointerRight() == this) { - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); if (!_ListMenuRight.empty()) { if (CDBCtrlSheet::getDraggedSheet() == NULL) @@ -905,7 +905,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) { _SelectingText = true; stopParentBlink(); - pIM->setCaptureKeyboard (this); + CWidgetManager::getInstance()->setCaptureKeyboard (this); // set the right cursor position uint newCurPos; bool cursorAtPreviousLineEnd; @@ -945,7 +945,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { - pIM->setCapturePointerRight(this); + CWidgetManager::getInstance()->setCapturePointerRight(this); return true; } } @@ -960,7 +960,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) NLGUI::CEventDescriptorActiveCalledOnParent &activeEvent = (NLGUI::CEventDescriptorActiveCalledOnParent &) eventDesc; if (activeEvent.getActive() == false && _ResetFocusOnHide) { - CInterfaceManager::getInstance()->resetCaptureKeyboard(); + CWidgetManager::getInstance()->resetCaptureKeyboard(); // If a selection was shown, reset it if (_CurrSelection == this) _CurrSelection = NULL; } @@ -1243,9 +1243,8 @@ void CGroupEditBox::setSelectionAll() void CGroupEditBox::setActive(bool active) { if (!active && _ResetFocusOnHide) - { - CInterfaceManager::getInstance()->resetCaptureKeyboard(); - } + CWidgetManager::getInstance()->resetCaptureKeyboard(); + CInterfaceGroup::setActive(active); } @@ -1295,7 +1294,7 @@ void CGroupEditBox::setCommand(const ucstring &command, bool execute) } else { - CInterfaceManager::getInstance()->setCaptureKeyboard (this); + CWidgetManager::getInstance()->setCaptureKeyboard (this); _CursorPos = (sint32)_InputString.length(); } } @@ -1431,7 +1430,7 @@ void CGroupEditBox::setFocusOnText() // else set the focus CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->setCaptureKeyboard (this); + CWidgetManager::getInstance()->setCaptureKeyboard (this); _CurrSelection = this; _SelectCursorPos= (sint32)_InputString.size(); @@ -1457,8 +1456,8 @@ int CGroupEditBox::luaCancelFocusOnText(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 0); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (pIM->getCaptureKeyboard()==this || pIM->getOldCaptureKeyboard()==this) - pIM->resetCaptureKeyboard(); + if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this) + CWidgetManager::getInstance()->resetCaptureKeyboard(); _CurrSelection = NULL; _SelectCursorPos= 0; @@ -1494,12 +1493,12 @@ void CGroupEditBox::setFrozen (bool state) { CInterfaceManager *pIM= CInterfaceManager::getInstance(); // stop capture and selection - pIM->setCaptureKeyboard (NULL); + CWidgetManager::getInstance()->setCaptureKeyboard (NULL); if(_CurrSelection==this) _CurrSelection = NULL; // do not allow to recover focus - if (pIM->getOldCaptureKeyboard() == this) + if (CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) { - pIM->resetCaptureKeyboard(); + CWidgetManager::getInstance()->resetCaptureKeyboard(); } } } diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index 01d87d4f8..af53eaf51 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -241,10 +241,10 @@ public: void release() { CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im->getCapturePointerLeft() == this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { _Moving = false; - im->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); } } virtual uint getDeltaDepth() const { return 100; } @@ -281,7 +281,7 @@ public: if (!this->isIn(eventDesc.getX(), eventDesc.getY())) return false; _TargetGroup = getTargetGroup(); if (!_TargetGroup) return false; - im->setCapturePointerLeft(this); + CWidgetManager::getInstance()->setCapturePointerLeft(this); _Moving = true; _OffsetX = _TargetGroup->getW() - eventDesc.getX(); return true; @@ -292,7 +292,7 @@ public: } if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { - if (_Moving && im->getCapturePointerLeft() == this) + if (_Moving && CWidgetManager::getInstance()->getCapturePointerLeft() == this) { if (!_TargetGroup) { diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 640ce8def..82c543ac6 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -1853,7 +1853,7 @@ CGroupHTML::CGroupHTML(const TCtorParam ¶m) _GroupListAdaptor = NULL; // Register - CInterfaceManager::getInstance()->registerClockMsgTarget(this); + CWidgetManager::getInstance()->registerClockMsgTarget(this); // HTML parameters BgColor = CRGBA::Black; @@ -1935,7 +1935,7 @@ CGroupHTML::~CGroupHTML() bool CGroupHTML::parse(xmlNodePtr cur,CInterfaceGroup *parentGroup) { - nlassert(CInterfaceManager::getInstance()->isClockMsgTarget(this)); + nlassert( CWidgetManager::getInstance()->isClockMsgTarget(this)); if(!CGroupScrollText::parse(cur, parentGroup)) @@ -3492,8 +3492,8 @@ void CGroupHTML::removeContent () _GroupListAdaptor->clearGroups(); _GroupListAdaptor->clearControls(); _GroupListAdaptor->clearViews(); - CInterfaceManager::getInstance()->clearViewUnders(); - CInterfaceManager::getInstance()->clearCtrlsUnders(); + CWidgetManager::getInstance()->clearViewUnders(); + CWidgetManager::getInstance()->clearCtrlsUnders(); _Paragraph = NULL; // Reset default background color diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index fad80e694..756256dbd 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -578,7 +578,7 @@ void CGroupList::draw () sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - CInterfaceGroup *pIG = pIM->getWindowUnder(x, y); + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); CInterfaceGroup *pParent = this; bool bFound = false; while (pParent != NULL) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 125183f5a..1ff4c3023 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -126,7 +126,7 @@ static void popupLandMarkNameDialog() eb->setInputString(ucstring()); } - im->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setSelectionAll(); } @@ -181,7 +181,7 @@ bool CGroupMap::CPolyButton::handleEvent (const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if (im->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) return false; // Set the map !!! @@ -198,7 +198,7 @@ bool CGroupMap::CPolyButton::handleEvent (const NLGUI::CEventDescriptor &event) } } - im->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); if (bFound) Map->setMap(Map->getCurMap()->Children[i].Name); return true; @@ -209,7 +209,7 @@ bool CGroupMap::CPolyButton::handleEvent (const NLGUI::CEventDescriptor &event) { if (contains(CVector2f((float)eventDesc.getX(), (float)eventDesc.getY()))) { - im->setCapturePointerLeft(this); + CWidgetManager::getInstance()->setCapturePointerLeft(this); return true; } } @@ -263,7 +263,7 @@ void CGroupMap::CPolyButton::drawPolyButton() rVR.getScreenOOSize(oow, ooh); bool bOver = false; - const std::vector &rCUP = pIM->getCtrlsUnderPointer(); + const std::vector &rCUP = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for (uint32 i = 0; i < rCUP.size(); ++i) if (rCUP[i] == this) { @@ -1718,7 +1718,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) panEnd = eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && _Panning && _HasMoved; if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && !panEnd) { - //if (im->getCapturePointerLeft() == this) + //if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) // NB : don't test capture of mouse here, because // some R2 tool may begin outside of this window // example : clicking in the palette window and doing a drag-and-drop to the @@ -1736,7 +1736,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) { if (!R2::getEditor().getCurrentTool()->getPreviousToolClickEndFlag()) { - if (im->getCapturePointerLeft() == this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { // unselected unless tool has been changed before last mouse left up (happens when one's finish a route using double click -> should not unselect then) R2::getEditor().setSelectedInstance(NULL); @@ -1747,7 +1747,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) } else if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { - if (im->getCapturePointerRight() == this) + if (CWidgetManager::getInstance()->getCapturePointerRight() == this) { if (isIn(eventDesc.getX(), eventDesc.getY())) { @@ -1792,7 +1792,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if (im->getCapturePointerLeft() != this) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) { return false; } @@ -1803,7 +1803,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) { - im->setCapturePointerRight(this); + CWidgetManager::getInstance()->setCapturePointerRight(this); return true; } @@ -1811,7 +1811,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) { if (isIn(eventDesc.getX(), eventDesc.getY())) { - im->setCapturePointerLeft(this); + CWidgetManager::getInstance()->setCapturePointerLeft(this); _StartXForPaning = eventDesc.getX(); _StartYForPaning = eventDesc.getY(); _StartWorldOffsetForPaning = _WorldOffset; @@ -1845,7 +1845,7 @@ bool CGroupMap::handleEvent(const NLGUI::CEventDescriptor &event) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) { - if (im->getCapturePointerLeft() != this || !_Panning) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this || !_Panning) return CInterfaceGroup::handleEvent(event); if (_MapTexW != 0 && _MapTexH != 0) diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp index 6ca9541d4..06845d30f 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -53,9 +53,9 @@ void CGroupModalGetKey::setActive (bool state) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (state == true) - pIM->setCaptureKeyboard (this); + CWidgetManager::getInstance()->setCaptureKeyboard (this); else - pIM->setCaptureKeyboard (NULL); + CWidgetManager::getInstance()->setCaptureKeyboard (NULL); CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY )); if (pVT != NULL) pVT->setText(string("")); diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index d1daf9ce8..47791ed89 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -738,7 +738,7 @@ void CGroupParagraph::checkCoords () if (_LastW != (sint) parentWidth) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlBase *pCB = pIM->getCapturePointerLeft(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { CCtrlResizer *pCR = dynamic_cast(pCB); @@ -778,7 +778,7 @@ void CGroupParagraph::draw () sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - CInterfaceGroup *pIG = pIM->getWindowUnder(x,y); + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); CInterfaceGroup *pParent = this; bool bFound = false; while (pParent != NULL) diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index 69d66694c..af6ea1fae 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -829,7 +829,7 @@ void CCtrlTabButton::setBlink (bool b) { _TextColorNormalBlink = getTextColorNormal(); _TextModulateGlobalColorNormalBlink = getTextModulateGlobalColorNormal(); - pIM->registerClockMsgTarget(this); + CWidgetManager::getInstance()->registerClockMsgTarget(this); } _Blinking = true; } @@ -837,7 +837,7 @@ void CCtrlTabButton::setBlink (bool b) { if (_Blinking) { - pIM->unregisterClockMsgTarget(this); + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); setTextColorNormal(_TextColorNormalBlink); setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); } diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index b4ae09527..1ead5f87e 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -792,7 +792,7 @@ void CGroupTable::checkCoords () else { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlBase *pCB = pIM->getCapturePointerLeft(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { CCtrlResizer *pCR = dynamic_cast(pCB); diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index e5c7afba7..23c51c12d 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -576,7 +576,7 @@ void CGroupTree::draw() sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - CInterfaceGroup *pIG = pIM->getWindowUnder(x, y); + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); CInterfaceGroup *pParent = this; bool bFound = false; while (pParent != NULL) diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index e83d2b5af..9208f9472 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -228,7 +228,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) if(event == EventKeyDownId) { CEventKeyDown* downEvent=(CEventKeyDown*)&event; - if (!pIM->getCaptureKeyboard () || !EditActions.keyPushed (*downEvent)) + if (!CWidgetManager::getInstance()->getCaptureKeyboard () || !EditActions.keyPushed (*downEvent)) Actions.keyPushed (*downEvent); } // Event from the Keyboard (UP KEYS) diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 609ebc351..589b9bf18 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -571,8 +571,8 @@ bool CInterface3DScene::handleEvent (const NLGUI::CEventDescriptor &event) if (event.getType() == NLGUI::CEventDescriptor::mouse) { const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CInterfaceManager::getInstance()->getCapturePointerLeft() != this) && - (CInterfaceManager::getInstance()->getCapturePointerRight() != this) && + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && + (CWidgetManager::getInstance()->getCapturePointerRight() != this) && (!((eventDesc.getX() >= _XReal) && (eventDesc.getX() < (_XReal + _WReal))&& (eventDesc.getY() > _YReal) && @@ -585,7 +585,7 @@ bool CInterface3DScene::handleEvent (const NLGUI::CEventDescriptor &event) _MouseLDownX = eventDesc.getX(); _MouseLDownY = eventDesc.getY(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->setCapturePointerLeft(this); // Because we are not just a control + CWidgetManager::getInstance()->setCapturePointerLeft(this); // Because we are not just a control return true; } if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) @@ -599,7 +599,7 @@ bool CInterface3DScene::handleEvent (const NLGUI::CEventDescriptor &event) _MouseRDownX = eventDesc.getX(); _MouseRDownY = eventDesc.getY(); CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->setCapturePointerRight(this); // Because we are not just a control + CWidgetManager::getInstance()->setCapturePointerRight(this); // Because we are not just a control return true; } if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 6681ea366..fb3ce0052 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -144,8 +144,7 @@ CInterfaceGroup::~CInterfaceGroup() // initStart = ryzomGetLocalTime (); clearControls(); // nlinfo ("%d seconds for clearControls '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); - CInterfaceManager *manager = CInterfaceManager::getInstance(); - manager->removeRefOnGroup (this); + CWidgetManager::getInstance()->removeRefOnGroup (this); #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS // AJM DEBUG diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index c1d3e2a71..3a16927ea 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -377,14 +377,8 @@ CInterfaceManager::~CInterfaceManager() void CInterfaceManager::reset() { CViewRenderer::getInstance()->reset(); - _CtrlsUnderPointer.clear(); - CWidgetManager::getInstance()->setCurContextHelp( NULL ); - _ViewsUnderPointer.clear(); - _GroupsUnderPointer.clear(); - _CaptureKeyboard = NULL; - _OldCaptureKeyboard = NULL; - setCapturePointerLeft(NULL); - setCapturePointerRight(NULL); + CWidgetManager::getInstance()->reset(); + _ActiveAnims.clear(); for (uint32 i = 0; i < _IDStringWaiters.size(); ++i) delete _IDStringWaiters[i]; @@ -1330,24 +1324,8 @@ void CInterfaceManager::updateFrameEvents() } } - // send clock tick msg to ctrl that are captured - NLGUI::CEventDescriptorSystem clockTick; - clockTick.setEventTypeExtended(NLGUI::CEventDescriptorSystem::clocktick); - if (_CapturePointerLeft) - { - _CapturePointerLeft->handleEvent(clockTick); - } - if (_CapturePointerRight) - { - _CapturePointerRight->handleEvent(clockTick); - } + CWidgetManager::getInstance()->sendClockTickEvent(); - // and send clock tick msg to ctrl that are registered - std::vector clockMsgTarget = _ClockMsgTargets; - for(std::vector::iterator it = clockMsgTarget.begin(); it != clockMsgTarget.end(); ++it) - { - (*it)->handleEvent(clockTick); - } IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); @@ -1374,7 +1352,7 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) if (!camera.empty()) CViewRenderer::getInstance()->setWorldSpaceFrustum (camera.getFrustum()); - checkCoords(); + CWidgetManager::getInstance()->checkCoords(); drawViews(camera); // The interface manager may change usual Global setup. reset them. @@ -1707,7 +1685,7 @@ bool CInterfaceManager::saveConfig (const string &filename) quitVisitor.Desktop = k; setMode(k); visit(&quitVisitor); - checkCoords(); + CWidgetManager::getInstance()->checkCoords(); } setMode(0); setMode(_CurrentMode); @@ -1812,106 +1790,6 @@ bool CInterfaceManager::saveConfig (const string &filename) return true; } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::checkCoords() -{ - H_AUTO ( RZ_Interface_validateCoords ) - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - - uint32 nMasterGroup; - - { - H_AUTO ( RZ_Interface_checkCoords ) - - // checkCoords all the windows - for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) - { - list &rList = rMG.PrioritizedWindows[nPriority]; - list::const_iterator itw; - for (itw = rList.begin(); itw!= rList.end();) - { - CInterfaceGroup *pIG = *itw; - itw++; // since checkCoords invalidate the iterator, be sure we move to the next one before - if (pIG->getActive()) - pIG->checkCoords (); - } - } - } - } - } - - bool bRecomputeCtrlUnderPtr = false; - { - H_AUTO ( RZ_Interface_updateCoords ) - - // updateCoords all the needed windows - for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) - { - list &rList = rMG.PrioritizedWindows[nPriority]; - list::const_iterator itw; - for (itw = rList.begin(); itw!= rList.end(); itw++) - { - CInterfaceGroup *pIG = *itw; - bool updateCoordCalled= false; - // updateCoords the window only if the master group is his parent and if need it - // do it until updateCoords() no more invalidate coordinates!! - while (pIG->getParent()==rMG.Group && (pIG->getInvalidCoords()>0)) - { - bRecomputeCtrlUnderPtr = true; - // Update as many pass wanted (3 time for complex resizing, 1 for scroll for example) - uint numPass= pIG->getInvalidCoords(); - // reset before updateCoords - pIG->resetInvalidCoords(); - for(uint i=0;iupdateCoords (); - } - updateCoordCalled= true; - } - // If the group need to update pos each frame (eg: CGroupInScene), - // and updateCoords not called - if(pIG->getParent()==rMG.Group && !updateCoordCalled && pIG->isNeedFrameUpdatePos()) - { - // This Group will compute the delta to apply. - pIG->onFrameUpdateWindowPos(0,0); - } - } - } - } - } - - if ( CWidgetManager::getInstance()->getPointer() != NULL) - CWidgetManager::getInstance()->getPointer()->updateCoords(); - } - - - - if (bRecomputeCtrlUnderPtr) - { - H_AUTO ( RZ_Interface_RecomputeCtrlUnderPtr ) - if ( CWidgetManager::getInstance()->getPointer() != NULL ) - { - sint32 mx = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 my = CWidgetManager::getInstance()->getPointer()->getY(); - getViewsUnder (mx, my, _ViewsUnderPointer); - getCtrlsUnder (mx, my, _CtrlsUnderPointer); - getGroupsUnder (mx, my, _GroupsUnderPointer); - CInterfaceGroup *ptr = getWindowUnder (mx, my); - _WindowUnder = ptr?ptr->getId():""; - } - } -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::drawViews(NL3D::UCamera camera) { @@ -1924,14 +1802,14 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) NLGUI::CDBManager::getInstance()->flushObserverCalls(); // If an element has captured the keyboard, make sure it is alway visible (all parent windows active) - if (_CaptureKeyboard != NULL) + if( CWidgetManager::getInstance()->getCaptureKeyboard() != NULL) { - CCtrlBase *cb = _CaptureKeyboard; + CCtrlBase *cb = CWidgetManager::getInstance()->getCaptureKeyboard(); do { if (!cb->getActive()) { - setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); break; } cb = cb->getParent(); @@ -2062,7 +1940,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) if ( CWidgetManager::getInstance()->getPointer()->show()) { - CDBCtrlSheet *pCS = dynamic_cast((CCtrlBase*)_CapturePointerLeft); + CDBCtrlSheet *pCS = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft() ); if ((pCS != NULL) && (pCS->isDraging())) { sint x= CWidgetManager::getInstance()->getPointer()->getX() - pCS->getDeltaDragX(); @@ -2107,6 +1985,7 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl() // get the top most ctrl under us CCtrlBase *best = NULL; sint8 bestRenderLayer = -128; + const std::vector< CCtrlBase* >& _CtrlsUnderPointer = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for (sint i = (sint32)_CtrlsUnderPointer.size()-1; i>=0; i--) { CCtrlBase *pICL = _CtrlsUnderPointer[i]; @@ -2129,6 +2008,7 @@ CCtrlBase* CInterfaceManager::getNewContextHelpCtrl() { // if a control was not found, try with the groups sint8 bestRenderLayer = -128; + const std::vector< CInterfaceGroup* >& _GroupsUnderPointer = CWidgetManager::getInstance()->getGroupsUnderPointer(); for (sint i = (sint32)_GroupsUnderPointer.size()-1; i>=0; i--) { CCtrlBase *pICL = _GroupsUnderPointer[i]; @@ -2608,16 +2488,16 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) const NLGUI::CEventDescriptorSystem &eventDesc = reinterpret_cast< const NLGUI::CEventDescriptorSystem& >( event ); if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus ) { - if( _CapturePointerLeft != NULL ) + if( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL ) { - _CapturePointerLeft->handleEvent( event ); - setCapturePointerLeft( NULL ); + CWidgetManager::getInstance()->getCapturePointerLeft()->handleEvent( event ); + CWidgetManager::getInstance()->setCapturePointerLeft( NULL ); } - if( _CapturePointerRight != NULL ) + if( CWidgetManager::getInstance()->getCapturePointerRight() != NULL ) { - _CapturePointerRight->handleEvent( event ); - setCapturePointerRight( NULL ); + CWidgetManager::getInstance()->getCapturePointerRight()->handleEvent( event ); + CWidgetManager::getInstance()->setCapturePointerRight( NULL ); } } } @@ -2665,7 +2545,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } // else just disable it. // Special case: leave the escape Key to the CaptureKeyboard . - else if(!_CaptureKeyboard ) + else if(! CWidgetManager::getInstance()->getCaptureKeyboard() ) { if(!win->getAHOnEscape().empty()) CAHManager::getInstance()->runActionHandler(win->getAHOnEscape(), win, win->getAHOnEscapeParams()); @@ -2683,9 +2563,9 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if(tw && !tw->getAHOnEnter().empty()) { // if the captured keyboard is in this Modal window, then must handle him in priority - if(_CaptureKeyboard && _CaptureKeyboard->getRootWindow()==tw) + if( CWidgetManager::getInstance()->getCaptureKeyboard() && CWidgetManager::getInstance()->getCaptureKeyboard()->getRootWindow()==tw) { - bool result = _CaptureKeyboard->handleEvent(event); + bool result = CWidgetManager::getInstance()->getCaptureKeyboard()->handleEvent(event); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); return result; @@ -2699,8 +2579,8 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } // else the 'return' key bring back to the last edit box (if possible) - CCtrlBase *oldCapture = _OldCaptureKeyboard ? _OldCaptureKeyboard : _DefaultCaptureKeyboard; - if (_CaptureKeyboard == NULL && oldCapture && !handled) + CCtrlBase *oldCapture = CWidgetManager::getInstance()->getOldCaptureKeyboard() ? CWidgetManager::getInstance()->getOldCaptureKeyboard() : CWidgetManager::getInstance()->getDefaultCaptureKeyboard(); + if ( CWidgetManager::getInstance()->getCaptureKeyboard() == NULL && oldCapture && !handled) { /* If the editbox does not want to recover focus, then abort. This possibility is normaly avoided through setCaptureKeyboard() which already test getRecoverFocusOnEnter(), but it is still possible @@ -2710,10 +2590,10 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if(!dynamic_cast(oldCapture) || dynamic_cast(oldCapture)->getRecoverFocusOnEnter()) { - _CaptureKeyboard = oldCapture; - notifyElementCaptured(_CaptureKeyboard); + CWidgetManager::getInstance()->setCaptureKeyboard( oldCapture ); + CWidgetManager::getInstance()->notifyElementCaptured( CWidgetManager::getInstance()->getCaptureKeyboard() ); // make sure all parent windows are active - CCtrlBase *cb = _CaptureKeyboard; + CCtrlBase *cb = CWidgetManager::getInstance()->getCaptureKeyboard(); CGroupContainer *lastContainer = NULL; for(;;) { @@ -2741,9 +2621,9 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } // General case: handle it in the Captured keyboard - if (_CaptureKeyboard != NULL && !handled) + if ( CWidgetManager::getInstance()->getCaptureKeyboard() != NULL && !handled) { - bool result = _CaptureKeyboard->handleEvent(event); + bool result = CWidgetManager::getInstance()->getCaptureKeyboard()->handleEvent(event); IngameDbMngr.flushObserverCalls(); NLGUI::CDBManager::getInstance()->flushObserverCalls(); return result; @@ -2773,14 +2653,15 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if( _MouseHandlingEnabled ) { // First thing to do : Capture handling - if (_CapturePointerLeft != NULL) - handled|= _CapturePointerLeft->handleEvent(event); + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) + handled|= CWidgetManager::getInstance()->getCapturePointerLeft()->handleEvent(event); - if (_CapturePointerRight != NULL && _CapturePointerRight!=_CapturePointerLeft) - handled|= _CapturePointerRight->handleEvent(event); + if ( CWidgetManager::getInstance()->getCapturePointerRight() != NULL && + CWidgetManager::getInstance()->getCapturePointerLeft() != CWidgetManager::getInstance()->getCapturePointerRight() ) + handled|= CWidgetManager::getInstance()->getCapturePointerRight()->handleEvent(event); - CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY()); - _WindowUnder = ptr?ptr->getId():""; + CInterfaceGroup *ptr = CWidgetManager::getInstance()->getWindowUnder (eventDesc.getX(), eventDesc.getY()); + CWidgetManager::getInstance()->setCurrentWindowUnder( ptr ); // Any Mouse event but move disable the ContextHelp if(eventDesc.getEventTypeExtended() != NLGUI::CEventDescriptorMouse::mousemove) @@ -2789,7 +2670,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) } // get the group under the mouse - CInterfaceGroup *pNewCurrentWnd = _WindowUnder; + CInterfaceGroup *pNewCurrentWnd = CWidgetManager::getInstance()->getCurrentWindowUnder(); _MouseOverWindow= pNewCurrentWnd!=NULL; @@ -2833,7 +2714,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if( !CWidgetManager::getInstance()->isPreviousModal( pNewCurrentWnd ) ) pNewCurrentWnd = NULL; // can't handle event before we have left all modal windows } - movePointer (0,0); // Reget controls under pointer + CWidgetManager::getInstance()->movePointer (0,0); // Reget controls under pointer } } } @@ -2862,6 +2743,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { // Take the top most control. uint nMaxDepth = 0; + const std::vector< CCtrlBase* >& _CtrlsUnderPointer = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) { CCtrlBase *ctrl= _CtrlsUnderPointer[i]; @@ -2871,24 +2753,24 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if (d > nMaxDepth) { nMaxDepth = d; - _CapturePointerLeft = ctrl; + CWidgetManager::getInstance()->setCapturePointerLeft( ctrl ); } } } - notifyElementCaptured(_CapturePointerLeft); + CWidgetManager::getInstance()->notifyElementCaptured( CWidgetManager::getInstance()->getCapturePointerLeft() ); if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) { - CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerLeft, clickedOutModalWindow->OnPostClickOutParams); + CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, CWidgetManager::getInstance()->getCapturePointerLeft(), clickedOutModalWindow->OnPostClickOutParams); } } //if found - if (_CapturePointerLeft != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) { // consider clicking on a control implies handling of the event. handled= true; // handle the capture - _CapturePointerLeft->handleEvent(event); + CWidgetManager::getInstance()->getCapturePointerLeft()->handleEvent(event); } } @@ -2911,6 +2793,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // Take the top most control. { uint nMaxDepth = 0; + const std::vector< CCtrlBase* >& _CtrlsUnderPointer = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for (sint32 i = (sint32)_CtrlsUnderPointer.size()-1; i >= 0; i--) { CCtrlBase *ctrl= _CtrlsUnderPointer[i]; @@ -2920,21 +2803,21 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if (d > nMaxDepth) { nMaxDepth = d; - _CapturePointerRight = ctrl; + CWidgetManager::getInstance()->setCapturePointerRight( ctrl ); } } } - notifyElementCaptured(_CapturePointerRight); + CWidgetManager::getInstance()->notifyElementCaptured( CWidgetManager::getInstance()->getCapturePointerRight() ); if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty()) { - CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, _CapturePointerRight, clickedOutModalWindow->OnPostClickOutParams); + CAHManager::getInstance()->runActionHandler(clickedOutModalWindow->OnPostClickOut, CWidgetManager::getInstance()->getCapturePointerRight(), clickedOutModalWindow->OnPostClickOutParams); } } //if found - if (_CapturePointerRight != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerRight() != NULL) { // handle the capture - handled |= _CapturePointerRight->handleEvent(event); + handled |= CWidgetManager::getInstance()->getCapturePointerRight()->handleEvent(event); } } if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) @@ -2942,12 +2825,12 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) if (!handled) if (pNewCurrentWnd != NULL) pNewCurrentWnd->handleEvent(event); - if (_CapturePointerRight != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerRight() != NULL) { EventsListener.addUIHandledButtonMask(rightButton); // prevent 'click in scene' as mouse was previously captured // (more a patch that anything, but 'UserControls' test for 'mouse up' // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... - setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); handled= true; } } @@ -2976,12 +2859,12 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) // Put here to let a chance to the window to handle if the capture dont if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if (_CapturePointerLeft != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) { EventsListener.addUIHandledButtonMask (leftButton); // prevent 'click in scene' as mouse was previously captured // (more a patch that anything, but 'UserControls' test for 'mouse up' // directly later in the main loop (not through message queue), so it has no way of knowing that the event was handled... - setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); //handled= true; } } @@ -3043,7 +2926,7 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve if( ( oldX != newX ) || ( oldY != newY ) ) { - movePointerAbs( newX, newY ); + CWidgetManager::getInstance()->movePointerAbs( newX, newY ); NLGUI::CEventDescriptorMouse &ve = const_cast< NLGUI::CEventDescriptorMouse& >( e ); ve.setX( CWidgetManager::getInstance()->getPointer()->getX() ); ve.setY( CWidgetManager::getInstance()->getPointer()->getY() ); @@ -3052,61 +2935,6 @@ bool CInterfaceManager::handleMouseMoveEvent( const NLGUI::CEventDescriptor &eve return true; } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::movePointer (sint32 dx, sint32 dy) -{ - if (!CWidgetManager::getInstance()->getPointer()) return; - CViewPointer *_Pointer = CWidgetManager::getInstance()->getPointer(); - uint32 nScrW, nScrH; - sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; - - CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); - _Pointer->getPointerPos (oldpx, oldpy); - - olddisppx = oldpx; - olddisppy = oldpy; - - newpx = oldpx + dx; - newpy = oldpy + dy; - - if (newpx < 0) newpx = 0; - if (newpy < 0) newpy = 0; - if (newpx > (sint32)nScrW) newpx = nScrW; - if (newpy > (sint32)nScrH) newpy = nScrH; - dx = newpx - oldpx; - dy = newpy - oldpy; - - disppx = newpx; - disppy = newpy; - - _Pointer->setPointerPos (newpx, newpy); - _Pointer->setPointerDispPos (disppx, disppy); - - // must get back coordinates because of snapping - sint32 mx = _Pointer->getX(); - sint32 my = _Pointer->getY(); - getViewsUnder (mx, my, _ViewsUnderPointer); - getCtrlsUnder (mx, my, _CtrlsUnderPointer); - getGroupsUnder (mx, my, _GroupsUnderPointer); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::movePointerAbs(sint32 px, sint32 py) -{ - if (!CWidgetManager::getInstance()->getPointer()) return; - uint32 nScrW, nScrH; - CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); - clamp(px, 0, (sint32) nScrW); - clamp(py, 0, (sint32) nScrH); - // - CWidgetManager::getInstance()->getPointer()->setPointerPos (px, py); - CWidgetManager::getInstance()->getPointer()->setPointerDispPos (px, py); - // - getViewsUnder (px, py, _ViewsUnderPointer); - getCtrlsUnder (px, py, _CtrlsUnderPointer); - getGroupsUnder (px, py, _GroupsUnderPointer); -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::getNewWindowCoordToNewScreenSize(sint32 &x, sint32 &y, sint32 w, sint32 h, sint32 newScreenW, sint32 newScreenH) const { @@ -3312,7 +3140,7 @@ void CInterfaceManager::updateAllLocalisedElements() } // update coords one - checkCoords(); + CWidgetManager::getInstance()->checkCoords(); // Action by default (container opening for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) @@ -3405,235 +3233,12 @@ void CInterfaceManager::processServerIDString() } } -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceManager::getWindowUnder (sint32 x, sint32 y) -{ - H_AUTO (RZ_Interface_Window_Under ) - - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->isWindowUnder (x, y)) - return pIG; - } - } - } - } - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceManager::getGroupUnder (sint32 x, sint32 y) -{ - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - if (pIG->getActive() && pIG->getUseCursor()) - { - CInterfaceGroup *pIGunder = pIG->getGroupUnder (x ,y); - if (pIGunder != NULL) - return pIGunder; - } - } - } - } - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::getViewsUnder (sint32 x, sint32 y, std::vector &vVB) -{ - vVB.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->getViewsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vVB)) - return ; - } - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::getCtrlsUnder (sint32 x, sint32 y, std::vector &vICL) -{ - vICL.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || CWidgetManager::getInstance()->getModal().ModalExitClickOut) - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->getCtrlsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vICL)) - return; - } - } - } - } - } -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::getGroupsUnder (sint32 x, sint32 y, std::vector &vIGL) -{ - vIGL.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) - { - const list &rList = rMG.PrioritizedWindows[nPriority-1]; - list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || - CWidgetManager::getInstance()->getModal().ModalExitClickOut) - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->isIn(x, y)) - { - vIGL.push_back(pIG); - pIG->getGroupsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vIGL); - return; - } - } - } - } - } - } -} - - // ------------------------------------------------------------------------------------------------ CInterfaceElement* CInterfaceManager::getElementFromDefine (const std::string &defineId) { return CWidgetManager::getInstance()->getElementFromId(getDefine(defineId)); } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::setCaptureKeyboard(CCtrlBase *c) -{ - CGroupEditBox *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); - CGroupEditBox *newEb= dynamic_cast(c); - - if (_CaptureKeyboard && _CaptureKeyboard != c) - { - _CaptureKeyboard->onKeyboardCaptureLost(); - } - // If the old capturedKeyboard is an editBox and allow recoverFocusOnEnter - if ( oldEb && oldEb->getRecoverFocusOnEnter() ) - { - _OldCaptureKeyboard = _CaptureKeyboard; - } - if ( newEb ) - { - CGroupEditBox::disableSelection(); - - if (!newEb->getAHOnFocus().empty()) - { - CAHManager::getInstance()->runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); - } - - } - _CaptureKeyboard = c; - notifyElementCaptured(c); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::resetCaptureKeyboard() -{ - CCtrlBase *captureKeyboard = _CaptureKeyboard; - _OldCaptureKeyboard = NULL; - _CaptureKeyboard = NULL; - if (captureKeyboard) - { - captureKeyboard->onKeyboardCaptureLost(); - } -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::runProcedure (const string &procName, CCtrlBase *pCaller, const vector ¶mList) @@ -3967,28 +3572,6 @@ void CInterfaceManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) } } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::notifyElementCaptured(CCtrlBase *c) -{ - std::set seen; - CCtrlBase *curr = c; - while (curr) - { - seen.insert(curr); - curr->elementCaptured(c); - curr = curr->getParent(); - } - // also warn the ctrl under the pointer - for (uint i = 0; i < (uint) _CtrlsUnderPointer.size(); ++i) - { - if (!seen.count(_CtrlsUnderPointer[i])) - { - _CtrlsUnderPointer[i]->elementCaptured(c); - } - } -} - - // *************************************************************************** void CInterfaceManager::enableMouseHandling(bool handle) { @@ -3999,15 +3582,15 @@ void CInterfaceManager::enableMouseHandling(bool handle) return; // If Left captured, reset - if( _CapturePointerLeft ) + if( CWidgetManager::getInstance()->getCapturePointerLeft() ) { - setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); } // Same for Right - if( _CapturePointerRight ) + if( CWidgetManager::getInstance()->getCapturePointerRight() ) { - setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); } // Avoid any problem with modals @@ -4126,36 +3709,6 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) } } -// *************************************************************************** -void CInterfaceManager::registerClockMsgTarget(CCtrlBase *vb) -{ - if (!vb) return; - if (isClockMsgTarget(vb)) - { - nlwarning(" Element %s is already registered", vb->getId().c_str()); - return; - } - _ClockMsgTargets.push_back(vb); -} - -// *************************************************************************** -void CInterfaceManager::unregisterClockMsgTarget(CCtrlBase *vb) -{ - if (!vb) return; - std::vector::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); - if (it != _ClockMsgTargets.end()) - { - _ClockMsgTargets.erase(it); - } -} - -// *************************************************************************** -bool CInterfaceManager::isClockMsgTarget(CCtrlBase *vb) const -{ - std::vector::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); - return it != _ClockMsgTargets.end(); -} - // *************************************************************************** void CInterfaceManager::setContentAlpha(uint8 alpha) { @@ -4243,13 +3796,13 @@ void CInterfaceManager::setMode(uint8 newMode) } // check if there's a special behaviour with current captured ctrl that prevent from changing desktop - if (_CapturePointerLeft != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) { - if (!_CapturePointerLeft->canChangeVirtualDesktop()) return; + if (!CWidgetManager::getInstance()->getCapturePointerLeft()->canChangeVirtualDesktop()) return; } - if (_CapturePointerRight != NULL) + if ( CWidgetManager::getInstance()->getCapturePointerRight() != NULL) { - if (!_CapturePointerRight->canChangeVirtualDesktop()) return; + if (!CWidgetManager::getInstance()->getCapturePointerRight()->canChangeVirtualDesktop()) return; } @@ -4258,7 +3811,7 @@ void CInterfaceManager::setMode(uint8 newMode) //CBotChatUI::refreshActiveWindows(); _CurrentMode = newMode; - checkCoords(); + CWidgetManager::getInstance()->checkCoords(); } // *************************************************************************** @@ -4572,66 +4125,6 @@ void CInterfaceManager::restoreAllContainersBackupPosition() } -// *************************************************************************** -void CInterfaceManager::removeRefOnCtrl (CCtrlBase *ctrlBase) -{ - if ( CWidgetManager::getInstance()->getCurContextHelp() == ctrlBase) - CWidgetManager::getInstance()->setCurContextHelp( NULL ); - if (getCapturePointerLeft() == ctrlBase) - setCapturePointerLeft(NULL); - if (getCapturePointerRight() == ctrlBase) - setCapturePointerRight (NULL); - if (getCaptureKeyboard() == ctrlBase) - setCaptureKeyboard(NULL); - if (getOldCaptureKeyboard() == ctrlBase) - setOldCaptureKeyboard(NULL); - if (getDefaultCaptureKeyboard() == ctrlBase) - setDefaultCaptureKeyboard(NULL); - uint i; - for (i=0; i<_CtrlsUnderPointer.size(); i++) - { - if (_CtrlsUnderPointer[i] == ctrlBase) - { - _CtrlsUnderPointer.erase (_CtrlsUnderPointer.begin()+i); - i--; - } - } - - // Unregister from ClockMsgTargets - unregisterClockMsgTarget (ctrlBase); -} - - -// *************************************************************************** -void CInterfaceManager::removeRefOnView (CViewBase *viewBase) -{ - uint i; - for (i=0; i<_ViewsUnderPointer.size(); i++) - { - if (_ViewsUnderPointer[i] == viewBase) - { - _ViewsUnderPointer.erase (_ViewsUnderPointer.begin()+i); - i--; - } - } -} - -// *************************************************************************** -void CInterfaceManager::removeRefOnGroup (CInterfaceGroup *group) -{ - uint i; - for (i=0; i<_GroupsUnderPointer.size(); i++) - { - if (_GroupsUnderPointer[i] == group) - { - _GroupsUnderPointer.erase (_GroupsUnderPointer.begin()+i); - i--; - } - } -} - - - // *************************************************************************** uint CInterfaceManager::getUserDblClickDelay() @@ -4801,10 +4294,10 @@ NLMISC_COMMAND(loadui, "Load an interface file", "") im->updateAllLocalisedElements(); // reset captures - im->setCapturePointerLeft(NULL); - im->setCapturePointerRight(NULL); - im->setOldCaptureKeyboard(NULL); - im->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setOldCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); return result; } @@ -5144,25 +4637,6 @@ bool CInterfaceManager::testDragCopyKey() driver->AsyncListener.isKeyDown(KeyRCONTROL); } -// *************************************************************************** -void CInterfaceManager::setCapturePointerLeft(CCtrlBase *c) -{ - // additionally, abort any dragging - if(CDBCtrlSheet::getDraggedSheet()) - { - CDBCtrlSheet::getDraggedSheet()->abortDraging(); - } - _CapturePointerLeft = c; - notifyElementCaptured(c); -} - -// *************************************************************************** -void CInterfaceManager::setCapturePointerRight(CCtrlBase *c) -{ - _CapturePointerRight = c; - notifyElementCaptured(c); -} - // *************************************************************************** void CInterfaceManager::notifyMailAvailable() { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 374853162..2a67fd038 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -232,18 +232,6 @@ public: void addServerID (const std::string &sTarget, uint32 id, IStringProcess *cb = NULL); void processServerIDString(); - /** - * get the window under a spot - * \param : X coord of the spot - * \param : Y coord of the spot - * \return : pointer to the window - */ - CInterfaceGroup* getWindowUnder (sint32 x, sint32 y); - CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; } - CInterfaceGroup* getGroupUnder (sint32 x, sint32 y); - void getViewsUnder (sint32 x, sint32 y, std::vector &vVB); - void getCtrlsUnder (sint32 x, sint32 y, std::vector &vICL); - void getGroupsUnder (sint32 x, sint32 y, std::vector &vIGL); /** * get a window from its Id of its group. * NB: "ctrl_launch_modal" is a special Id which return the last ctrl which has launch a modal. NULL if modal closed. @@ -298,7 +286,6 @@ public: /** * Draw views */ - void checkCoords(); void drawViews (NL3D::UCamera camera); void drawAutoAdd (); void drawContextHelp (); @@ -317,49 +304,6 @@ public: uint8 getGlobalRolloverFactorContent() const { return _GlobalRolloverFactorContent; } uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } - - // Relative move of pointer - void movePointer (sint32 dx, sint32 dy); - // Set absolute coordinates of pointer - void movePointerAbs(sint32 px, sint32 py); - const std::vector &getViewsUnderPointer () { return _ViewsUnderPointer; } - const std::vector &getGroupsUnderPointer () { return _GroupsUnderPointer; } - const std::vector &getCtrlsUnderPointer () { return _CtrlsUnderPointer; } - // - void clearGroupsUnders() { _GroupsUnderPointer.clear(); } - void clearViewUnders() { _ViewsUnderPointer.clear(); } - void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); } - - // Remove all references on a view (called when the ctrl is destroyed) - void removeRefOnView (CViewBase *ctrlBase); - - // Remove all references on a ctrl (called when the ctrl is destroyed) - void removeRefOnCtrl (CCtrlBase *ctrlBase); - - // Remove all references on a group (called when the group is destroyed) - void removeRefOnGroup (CInterfaceGroup *group); - - /** - * Capture - */ - CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; } - CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; } - CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; } - CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; } - CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; } - - void setCapturePointerLeft(CCtrlBase *c); - void setCapturePointerRight(CCtrlBase *c); - void setOldCaptureKeyboard(CCtrlBase *c) { _OldCaptureKeyboard = c; } - // NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture - // to come back to the last captured window (resetCaptureKeyboard() not) - void setCaptureKeyboard(CCtrlBase *c); - void resetCaptureKeyboard(); - /** Set the default box to use when no keyboard has been previously captured - * The given dialog should be static - */ - void setDefaultCaptureKeyboard(CCtrlBase *c) { _DefaultCaptureKeyboard = c; } - /// Update all the elements void updateAllLocalisedElements (); @@ -452,19 +396,12 @@ public: void unMakeWindow(CInterfaceGroup *group, bool noWarning=false); - // True if the keyboard is captured - bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;} bool isMouseOverWindow() const {return _MouseOverWindow;} // Enable mouse Events to interface. if false, release Captures. void enableMouseHandling(bool handle); bool isMouseHandlingEnabled() const { return _MouseHandlingEnabled; } - // register a view that wants to be notified at each frame (receive the msg 'clocktick') - void registerClockMsgTarget(CCtrlBase *vb); - void unregisterClockMsgTarget(CCtrlBase *vb); - bool isClockMsgTarget(CCtrlBase *vb) const; - // Modes void setMode(uint8 newMode); uint8 getMode() const { return _CurrentMode; } @@ -784,23 +721,8 @@ private: NLMISC::CCDBNodeLeaf *_DescTextTarget; - // Capture - NLMISC::CRefPtr _CaptureKeyboard; - NLMISC::CRefPtr _OldCaptureKeyboard; - NLMISC::CRefPtr _DefaultCaptureKeyboard; - NLMISC::CRefPtr _CapturePointerLeft; - NLMISC::CRefPtr _CapturePointerRight; bool _MouseOverWindow; - // view that should be notified from clock msg - std::vector _ClockMsgTargets; - - // What is under pointer - std::vector _ViewsUnderPointer; - std::vector _CtrlsUnderPointer; - std::vector _GroupsUnderPointer; - - // Context Help bool _ContextHelpActive; //CCtrlBasePtr _CurCtrlContextHelp; @@ -829,13 +751,9 @@ private: // List of active Anims std::vector _ActiveAnims; - CInterfaceGroupPtr _WindowUnder; - bool isControlInWindow (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentWnd); uint getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentWnd); - void notifyElementCaptured(CCtrlBase *c); - // System Options CInterfaceOptionValue _SystemOptions[NumSystemOptions]; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index b111b4440..eecd9afe8 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1050,7 +1050,7 @@ int CLuaIHMRyzom::setCaptureKeyboard(CLuaState &ls) CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); } CInterfaceManager *im = CInterfaceManager::getInstance(); - im->setCaptureKeyboard(ctrl); + CWidgetManager::getInstance()->setCaptureKeyboard(ctrl); return 0; } @@ -1061,7 +1061,7 @@ int CLuaIHMRyzom::resetCaptureKeyboard(CLuaState &ls) const char *funcName = "resetCaptureKeyboard"; CLuaIHM::checkArgCount(ls, funcName, 0); CInterfaceManager *im = CInterfaceManager::getInstance(); - im->resetCaptureKeyboard(); + CWidgetManager::getInstance()->resetCaptureKeyboard(); return 0; } @@ -2419,7 +2419,7 @@ int CLuaIHMRyzom::getCurrentWindowUnder(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_getCurrentWindowUnder) CLuaStackChecker lsc(&ls, 1); CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *pIE= im->getCurrentWindowUnder(); + CInterfaceElement *pIE= CWidgetManager::getInstance()->getCurrentWindowUnder(); if(!pIE) { ls.pushNil(); diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index f2ca589b8..ffd8572e4 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2423,7 +2423,7 @@ public: CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb")); if (eb) { - im->setCaptureKeyboard(eb); + CWidgetManager::getInstance()->setCaptureKeyboard(eb); eb->setInputString(ucstring("")); } // diff --git a/code/ryzom/client/src/interface_v3/view_base.cpp b/code/ryzom/client/src/interface_v3/view_base.cpp index 56c1f4484..a8cfb0213 100644 --- a/code/ryzom/client/src/interface_v3/view_base.cpp +++ b/code/ryzom/client/src/interface_v3/view_base.cpp @@ -23,8 +23,7 @@ CViewBase::~CViewBase() { - CInterfaceManager *manager = CInterfaceManager::getInstance(); - manager->removeRefOnView (this); + CWidgetManager::getInstance()->removeRefOnView (this); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index 43c9be22c..45510d662 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -277,7 +277,7 @@ void CViewBitmapCombo::draw() sint32 mx = 0, my = 0; CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - const std::vector &rVB = pIM->getViewsUnderPointer(); + const std::vector &rVB = CWidgetManager::getInstance()->getViewsUnderPointer(); if (!CWidgetManager::getInstance()->getPointer()) return; CWidgetManager::getInstance()->getPointer()->getPointerDispPos(mx, my); bool over = false; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 3cb386281..c6065f321 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -205,9 +205,9 @@ void CViewPointer::draw () _LastHightLight = NULL; } - if (pIM->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled()) + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled()) { - CCtrlMover *pCM = dynamic_cast(pIM->getCapturePointerLeft()); + CCtrlMover *pCM = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft()); if ((pCM != NULL) && (pCM->canMove() == true)) { CGroupContainer *pGC = dynamic_cast(pCM->getParent()); @@ -239,11 +239,11 @@ void CViewPointer::draw () } } - const vector &rICL = pIM->getCtrlsUnderPointer (); + const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer (); // Draw the captured cursor - CCtrlBase *pCB = pIM->getCapturePointerLeft(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { if (drawResizer(pCB,col)) return; @@ -256,7 +256,7 @@ void CViewPointer::draw () return; } - const vector &vUP = pIM->getViewsUnderPointer (); + const vector &vUP = CWidgetManager::getInstance()->getViewsUnderPointer (); for(uint i=0;igetCapturePointerRight(); + pCB = CWidgetManager::getInstance()->getCapturePointerRight(); if (pCB != NULL) { // Is it a 3d scene ? @@ -355,7 +355,7 @@ void CViewPointer::draw () CGroupContainer *pGC = dynamic_cast(pCM->getParent()); if (pGC != NULL && !pGC->isLocked()) { - if (pIM->getCapturePointerLeft() != pCM) + if (CWidgetManager::getInstance()->getCapturePointerLeft() != pCM) pGC->setHighLighted(true, 128); else pGC->setHighLighted(true, 255); @@ -373,7 +373,7 @@ void CViewPointer::draw () { if (rICL.empty()) { - const vector &rIGL = pIM->getGroupsUnderPointer (); + const vector &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer (); for (uint32 i = 0; i < rIGL.size(); ++i) { CInterfaceGroup *pG = rIGL[i]; diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 98904d390..5563b3799 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -381,7 +381,7 @@ void CViewText::checkCoords () else { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CCtrlBase *pCB = pIM->getCapturePointerLeft(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { CCtrlResizer *pCR = dynamic_cast(pCB); @@ -630,7 +630,7 @@ void CViewText::draw () if(mouseIn) { // check the window under the mouse is the root window - CInterfaceGroup *pIG = pIM->getWindowUnder(x,y); + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); CInterfaceElement *pParent = this; bool bFound = false; while (pParent != NULL) diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index f50c7113a..a27d674fd 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -19,6 +19,8 @@ #include "group_container.h" #include "group_in_scene.h" #include "view_pointer.h" +#include "group_editbox.h" +#include "dbctrl_sheet.h" CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; @@ -699,6 +701,544 @@ void CWidgetManager::popModalWindowCategory(const std::string &category) } } +// ------------------------------------------------------------------------------------------------ +CInterfaceGroup* CWidgetManager::getWindowUnder (sint32 x, sint32 y) +{ + H_AUTO (RZ_Interface_Window_Under ) + + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->isWindowUnder (x, y)) + return pIG; + } + } + } + } + } + return NULL; +} + +// ------------------------------------------------------------------------------------------------ +CInterfaceGroup* CWidgetManager::getGroupUnder (sint32 x, sint32 y) +{ + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + if (pIG->getActive() && pIG->getUseCursor()) + { + CInterfaceGroup *pIGunder = pIG->getGroupUnder (x ,y); + if (pIGunder != NULL) + return pIGunder; + } + } + } + } + } + return NULL; +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::getViewsUnder (sint32 x, sint32 y, std::vector &vVB) +{ + vVB.clear (); + + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + + // Accecpt if not modal clip + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->getViewsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vVB)) + return ; + } + } + } + } + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::getCtrlsUnder (sint32 x, sint32 y, std::vector &vICL) +{ + vICL.clear (); + + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + + // Accecpt if not modal clip + if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || CWidgetManager::getInstance()->getModal().ModalExitClickOut) + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->getCtrlsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vICL)) + return; + } + } + } + } + } +} + + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::getGroupsUnder (sint32 x, sint32 y, std::vector &vIGL) +{ + vIGL.clear (); + + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + + // Accecpt if not modal clip + if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || + CWidgetManager::getInstance()->getModal().ModalExitClickOut) + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->isIn(x, y)) + { + vIGL.push_back(pIG); + pIG->getGroupsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vIGL); + return; + } + } + } + } + } + } +} + + +// *************************************************************************** +void CWidgetManager::removeRefOnView( CViewBase *viewBase ) +{ + uint i; + for (i=0; i<_ViewsUnderPointer.size(); i++) + { + if (_ViewsUnderPointer[i] == viewBase) + { + _ViewsUnderPointer.erase (_ViewsUnderPointer.begin()+i); + i--; + } + } +} + +// *************************************************************************** +void CWidgetManager::removeRefOnCtrl(CCtrlBase *ctrlBase) +{ + if ( getCurContextHelp() == ctrlBase) + setCurContextHelp( NULL ); + if (getCapturePointerLeft() == ctrlBase) + setCapturePointerLeft(NULL); + if (getCapturePointerRight() == ctrlBase) + setCapturePointerRight (NULL); + if (getCaptureKeyboard() == ctrlBase) + setCaptureKeyboard(NULL); + if (getOldCaptureKeyboard() == ctrlBase) + setOldCaptureKeyboard(NULL); + if (getDefaultCaptureKeyboard() == ctrlBase) + setDefaultCaptureKeyboard(NULL); + uint i; + for (i=0; i<_CtrlsUnderPointer.size(); i++) + { + if (_CtrlsUnderPointer[i] == ctrlBase) + { + _CtrlsUnderPointer.erase (_CtrlsUnderPointer.begin()+i); + i--; + } + } + + // Unregister from ClockMsgTargets + unregisterClockMsgTarget(ctrlBase); +} + + +// *************************************************************************** +void CWidgetManager::removeRefOnGroup (CInterfaceGroup *group) +{ + uint i; + for (i=0; i<_GroupsUnderPointer.size(); i++) + { + if (_GroupsUnderPointer[i] == group) + { + _GroupsUnderPointer.erase (_GroupsUnderPointer.begin()+i); + i--; + } + } +} + + +void CWidgetManager::reset() +{ + setCurContextHelp( NULL ); + + _ViewsUnderPointer.clear(); + _CtrlsUnderPointer.clear(); + _GroupsUnderPointer.clear(); + + _CaptureKeyboard = NULL; + _OldCaptureKeyboard = NULL; + setCapturePointerLeft(NULL); + setCapturePointerRight(NULL); +} + + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::checkCoords() +{ + H_AUTO ( RZ_Interface_validateCoords ) + + uint32 nMasterGroup; + + { + H_AUTO ( RZ_Interface_checkCoords ) + + // checkCoords all the windows + for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + { + std::list &rList = rMG.PrioritizedWindows[nPriority]; + std::list::const_iterator itw; + for (itw = rList.begin(); itw!= rList.end();) + { + CInterfaceGroup *pIG = *itw; + itw++; // since checkCoords invalidate the iterator, be sure we move to the next one before + if (pIG->getActive()) + pIG->checkCoords (); + } + } + } + } + } + + bool bRecomputeCtrlUnderPtr = false; + { + H_AUTO ( RZ_Interface_updateCoords ) + + // updateCoords all the needed windows + for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + { + std::list &rList = rMG.PrioritizedWindows[nPriority]; + std::list::const_iterator itw; + for (itw = rList.begin(); itw!= rList.end(); itw++) + { + CInterfaceGroup *pIG = *itw; + bool updateCoordCalled= false; + // updateCoords the window only if the master group is his parent and if need it + // do it until updateCoords() no more invalidate coordinates!! + while (pIG->getParent()==rMG.Group && (pIG->getInvalidCoords()>0)) + { + bRecomputeCtrlUnderPtr = true; + // Update as many pass wanted (3 time for complex resizing, 1 for scroll for example) + uint numPass= pIG->getInvalidCoords(); + // reset before updateCoords + pIG->resetInvalidCoords(); + for(uint i=0;iupdateCoords (); + } + updateCoordCalled= true; + } + // If the group need to update pos each frame (eg: CGroupInScene), + // and updateCoords not called + if(pIG->getParent()==rMG.Group && !updateCoordCalled && pIG->isNeedFrameUpdatePos()) + { + // This Group will compute the delta to apply. + pIG->onFrameUpdateWindowPos(0,0); + } + } + } + } + } + + if ( CWidgetManager::getInstance()->getPointer() != NULL) + CWidgetManager::getInstance()->getPointer()->updateCoords(); + } + + + + if (bRecomputeCtrlUnderPtr) + { + H_AUTO ( RZ_Interface_RecomputeCtrlUnderPtr ) + if ( CWidgetManager::getInstance()->getPointer() != NULL ) + { + sint32 mx = _Pointer->getX(); + sint32 my = _Pointer->getY(); + getViewsUnder (mx, my, _ViewsUnderPointer); + getCtrlsUnder (mx, my, _CtrlsUnderPointer); + getGroupsUnder (mx, my, _GroupsUnderPointer); + CInterfaceGroup *ptr = getWindowUnder (mx, my); + _WindowUnder = ptr; + } + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::movePointer (sint32 dx, sint32 dy) +{ + if (!_Pointer) + return; + + uint32 nScrW, nScrH; + sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; + + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); + _Pointer->getPointerPos (oldpx, oldpy); + + olddisppx = oldpx; + olddisppy = oldpy; + + newpx = oldpx + dx; + newpy = oldpy + dy; + + if (newpx < 0) newpx = 0; + if (newpy < 0) newpy = 0; + if (newpx > (sint32)nScrW) newpx = nScrW; + if (newpy > (sint32)nScrH) newpy = nScrH; + dx = newpx - oldpx; + dy = newpy - oldpy; + + disppx = newpx; + disppy = newpy; + + _Pointer->setPointerPos (newpx, newpy); + _Pointer->setPointerDispPos (disppx, disppy); + + // must get back coordinates because of snapping + sint32 mx = _Pointer->getX(); + sint32 my = _Pointer->getY(); + getViewsUnder (mx, my, _ViewsUnderPointer); + getCtrlsUnder (mx, my, _CtrlsUnderPointer); + getGroupsUnder (mx, my, _GroupsUnderPointer); +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::movePointerAbs(sint32 px, sint32 py) +{ + if(!CWidgetManager::getInstance()->getPointer()) + return; + + uint32 nScrW, nScrH; + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); + NLMISC::clamp(px, 0, (sint32) nScrW); + NLMISC::clamp(py, 0, (sint32) nScrH); + // + _Pointer->setPointerPos (px, py); + _Pointer->setPointerDispPos (px, py); + // + getViewsUnder (px, py, _ViewsUnderPointer); + getCtrlsUnder (px, py, _CtrlsUnderPointer); + getGroupsUnder (px, py, _GroupsUnderPointer); +} + +// *************************************************************************** +void CWidgetManager::setCapturePointerLeft(CCtrlBase *c) +{ + // additionally, abort any dragging + if(CDBCtrlSheet::getDraggedSheet()) + { + CDBCtrlSheet::getDraggedSheet()->abortDraging(); + } + _CapturePointerLeft = c; + notifyElementCaptured(c); +} + +// *************************************************************************** +void CWidgetManager::setCapturePointerRight(CCtrlBase *c) +{ + _CapturePointerRight = c; + notifyElementCaptured(c); +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) +{ + CGroupEditBox *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); + CGroupEditBox *newEb= dynamic_cast(c); + + if (_CaptureKeyboard && _CaptureKeyboard != c) + { + _CaptureKeyboard->onKeyboardCaptureLost(); + } + // If the old capturedKeyboard is an editBox and allow recoverFocusOnEnter + if ( oldEb && oldEb->getRecoverFocusOnEnter() ) + { + _OldCaptureKeyboard = _CaptureKeyboard; + } + if ( newEb ) + { + CGroupEditBox::disableSelection(); + + if (!newEb->getAHOnFocus().empty()) + { + CAHManager::getInstance()->runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); + } + + } + _CaptureKeyboard = c; + notifyElementCaptured(c); +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::resetCaptureKeyboard() +{ + CCtrlBase *captureKeyboard = _CaptureKeyboard; + _OldCaptureKeyboard = NULL; + _CaptureKeyboard = NULL; + if (captureKeyboard) + { + captureKeyboard->onKeyboardCaptureLost(); + } +} + +// *************************************************************************** +void CWidgetManager::registerClockMsgTarget(CCtrlBase *vb) +{ + if (!vb) return; + if (isClockMsgTarget(vb)) + { + nlwarning(" Element %s is already registered", vb->getId().c_str()); + return; + } + _ClockMsgTargets.push_back(vb); +} + +// *************************************************************************** +void CWidgetManager::unregisterClockMsgTarget(CCtrlBase *vb) +{ + if (!vb) return; + std::vector::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); + if (it != _ClockMsgTargets.end()) + { + _ClockMsgTargets.erase(it); + } +} + +// *************************************************************************** +bool CWidgetManager::isClockMsgTarget(CCtrlBase *vb) const +{ + std::vector::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); + return it != _ClockMsgTargets.end(); +} + +void CWidgetManager::sendClockTickEvent() +{ + NLGUI::CEventDescriptorSystem clockTick; + clockTick.setEventTypeExtended(NLGUI::CEventDescriptorSystem::clocktick); + + if (_CapturePointerLeft) + { + _CapturePointerLeft->handleEvent(clockTick); + } + if (_CapturePointerRight) + { + _CapturePointerRight->handleEvent(clockTick); + } + + // and send clock tick msg to ctrl that are registered + std::vector clockMsgTarget = _ClockMsgTargets; + for(std::vector::iterator it = clockMsgTarget.begin(); it != clockMsgTarget.end(); ++it) + { + (*it)->handleEvent(clockTick); + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::notifyElementCaptured(CCtrlBase *c) +{ + std::set seen; + CCtrlBase *curr = c; + while (curr) + { + seen.insert(curr); + curr->elementCaptured(c); + curr = curr->getParent(); + } + // also warn the ctrl under the pointer + for (uint i = 0; i < (uint) _CtrlsUnderPointer.size(); ++i) + { + if (!seen.count(_CtrlsUnderPointer[i])) + { + _CtrlsUnderPointer[i]->elementCaptured(c); + } + } +} + CWidgetManager::CWidgetManager() { diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index 4b77010d2..68fb78a19 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -25,6 +25,7 @@ class CInterfaceElement; class CCtrlBase; +class CViewBase; class CInterfaceGroup; class CViewPointer; @@ -186,6 +187,80 @@ public: CViewPointer* getPointer(){ return _Pointer; } void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } + /** + * get the window under a spot + * \param : X coord of the spot + * \param : Y coord of the spot + * \return : pointer to the window + */ + CInterfaceGroup* getWindowUnder (sint32 x, sint32 y); + CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; } + void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; } + CInterfaceGroup* getGroupUnder (sint32 x, sint32 y); + + void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB ); + void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL ); + void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL ); + + const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; } + const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; } + const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; } + + // + void clearViewUnders(){ _ViewsUnderPointer.clear(); } + void clearGroupsUnders() { _GroupsUnderPointer.clear(); } + void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); } + + // Remove all references on a view (called when the ctrl is destroyed) + void removeRefOnView( CViewBase *ctrlBase ); + + // Remove all references on a ctrl (called when the ctrl is destroyed) + void removeRefOnCtrl (CCtrlBase *ctrlBase); + + // Remove all references on a group (called when the group is destroyed) + void removeRefOnGroup (CInterfaceGroup *group); + + void reset(); + + void checkCoords(); + // Relative move of pointer + void movePointer (sint32 dx, sint32 dy); + // Set absolute coordinates of pointer + void movePointerAbs(sint32 px, sint32 py); + + /** + * Capture + */ + CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; } + CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; } + CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; } + CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; } + CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; } + + void setCapturePointerLeft(CCtrlBase *c); + void setCapturePointerRight(CCtrlBase *c); + void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; } + // NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture + // to come back to the last captured window (resetCaptureKeyboard() not) + void setCaptureKeyboard(CCtrlBase *c); + /** Set the default box to use when no keyboard has been previously captured + * The given dialog should be static + */ + void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; } + + void resetCaptureKeyboard(); + + // True if the keyboard is captured + bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;} + + // register a view that wants to be notified at each frame (receive the msg 'clocktick') + void registerClockMsgTarget(CCtrlBase *vb); + void unregisterClockMsgTarget(CCtrlBase *vb); + bool isClockMsgTarget(CCtrlBase *vb) const; + void sendClockTickEvent(); + + void notifyElementCaptured(CCtrlBase *c); + static IParser *parser; private: @@ -198,6 +273,23 @@ private: static std::string _CtrlLaunchingModalId; NLMISC::CRefPtr< CCtrlBase > curContextHelp; CViewPointer *_Pointer; + + NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder; + + // Capture + NLMISC::CRefPtr _CaptureKeyboard; + NLMISC::CRefPtr _OldCaptureKeyboard; + NLMISC::CRefPtr _DefaultCaptureKeyboard; + NLMISC::CRefPtr _CapturePointerLeft; + NLMISC::CRefPtr _CapturePointerRight; + + // What is under pointer + std::vector< CViewBase* > _ViewsUnderPointer; + std::vector< CCtrlBase* > _CtrlsUnderPointer; + std::vector< CInterfaceGroup* > _GroupsUnderPointer; + + // view that should be notified from clock msg + std::vector _ClockMsgTargets; }; #endif diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 4abecf8c1..e730942d3 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -1319,7 +1319,7 @@ class CAHLoginTab : public IActionHandler if (NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CHECKPASS) { - CCtrlBase *pCB = pIM->getCaptureKeyboard(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCaptureKeyboard(); if (pCB != NULL) { CCtrlBase *pNewCB; @@ -1328,12 +1328,12 @@ class CAHLoginTab : public IActionHandler pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD)); else pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN)); - pIM->setCaptureKeyboard(pNewCB); + CWidgetManager::getInstance()->setCaptureKeyboard(pNewCB); } } else if (NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:SCREEN")->getValue32() == UI_VARIABLES_SCREEN_CREATE_ACCOUNT) { - CCtrlBase *pCB = pIM->getCaptureKeyboard(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCaptureKeyboard(); if (pCB != NULL) { CCtrlBase *pNewCB; @@ -1346,7 +1346,7 @@ class CAHLoginTab : public IActionHandler pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_EMAIL)); else pNewCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_CREATEACCOUNT_LOGIN)); - pIM->setCaptureKeyboard(pNewCB); + CWidgetManager::getInstance()->setCaptureKeyboard(pNewCB); } } } diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index c35b680d8..26329c055 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1388,7 +1388,7 @@ void setDefaultChatWindow(CChatWindow *defaultChatWindow) if (defaultChatWindow->getContainer()) { CInterfaceGroup *ig = defaultChatWindow->getContainer()->getGroup("eb"); - if (ig) im->setDefaultCaptureKeyboard(ig); + if (ig) CWidgetManager::getInstance()->setDefaultCaptureKeyboard(ig); } } } @@ -3010,7 +3010,7 @@ bool mainLoop() Actions.enable(false); EditActions.enable(false); - CInterfaceManager::getInstance()->setDefaultCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setDefaultCaptureKeyboard(NULL); // Interface saving CInterfaceManager::getInstance()->uninitInGame0(); @@ -3115,8 +3115,8 @@ void displayDebugUIUnderMouse() line-= 2 * lineStep; } // - const vector &rICL = pIM->getCtrlsUnderPointer (); - const vector &rIGL = pIM->getGroupsUnderPointer (); + const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer (); + const vector &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer (); // If previous highlighted element is found in the list, then keep it, else reset to first element if (std::find(rICL.begin(), rICL.end(), HighlightedDebugUI) == rICL.end() && std::find(rIGL.begin(), rIGL.end(), HighlightedDebugUI) == rIGL.end()) @@ -3183,8 +3183,8 @@ void displayDebugUIUnderMouse() static void getElementsUnderMouse(vector &ielem) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - const vector &rICL = pIM->getCtrlsUnderPointer(); - const vector &rIGL = pIM->getGroupsUnderPointer(); + const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer(); + const vector &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer(); ielem.clear(); ielem.insert(ielem.end(), rICL.begin(), rICL.end()); ielem.insert(ielem.end(), rIGL.begin(), rIGL.end()); diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 620ffd6c9..7ce61fd08 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -1664,8 +1664,8 @@ void CEditor::waitScenarioScreen() // ActionsContext.setContext("waiting_network"); TGameCycle serverTick = NetMngr.getCurrentServerTick(); - getUI().setCaptureKeyboard(NULL); - getUI().setDefaultCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setDefaultCaptureKeyboard(NULL); loadBackgroundBitmap (StartBackground); // patch for the 'sys info that pop' prb (cause unknown for now ...) @@ -2351,9 +2351,9 @@ void CEditor::setMode(TMode mode) _Mode = mode; loadKeySet(getKeySetPrefix(_Mode)); CWidgetManager::getInstance()->disableModalWindow(); - getUI().setCapturePointerLeft(NULL); - getUI().setCapturePointerRight(NULL); - getUI().setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); // Season is now unknown, until server force it (in test mode), or first set act set it (in edit mode) _Season = UnknownSeason; // @@ -7541,7 +7541,7 @@ class CAHR2Undo : public IActionHandler virtual void execute(CCtrlBase * /* pCaller */, const std::string &/* sParams */) { // if an edit box currently has focus, then try undo on it first - CGroupEditBox *eb = dynamic_cast(getEditor().getUI().getCaptureKeyboard()); + CGroupEditBox *eb = dynamic_cast( CWidgetManager::getInstance()->getCaptureKeyboard()); if (eb && eb->undo()) { return; @@ -7570,7 +7570,7 @@ class CAHR2Redo : public IActionHandler virtual void execute(CCtrlBase * /* pCaller */, const std::string &/* sParams */) { // if an edit box currently has focus, then try redo on it first - CGroupEditBox *eb = dynamic_cast(getEditor().getUI().getCaptureKeyboard()); + CGroupEditBox *eb = dynamic_cast(CWidgetManager::getInstance()->getCaptureKeyboard()); if (eb && eb->redo()) { return; diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index b7e4ee069..fd42ca4ef 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -186,7 +186,7 @@ sint32 CTool::getMouseY() bool CTool::isMouseOnUI() { //H_AUTO(R2_CTool_isMouseOnUI) - return getUI().getWindowUnder(getMouseX(), getMouseY()) != NULL; + return CWidgetManager::getInstance()->getWindowUnder(getMouseX(), getMouseY()) != NULL; } @@ -207,7 +207,7 @@ CGroupMap *CTool::getWorldMap() CGroupMap *CTool::isMouseOnWorldMap() { //H_AUTO(R2_CTool_isMouseOnWorldMap) - const std::vector &groupsUnder = getUI().getGroupsUnderPointer(); + const std::vector &groupsUnder = CWidgetManager::getInstance()->getGroupsUnderPointer(); if (groupsUnder.empty()) return NULL; for(uint k = 0; k < groupsUnder.size(); ++k) { @@ -221,7 +221,7 @@ CGroupMap *CTool::isMouseOnWorldMap() CGroupContainer *CTool::isMouseOnContainer() { //H_AUTO(R2_CTool_isMouseOnContainer) - const std::vector &groupsUnder = getUI().getGroupsUnderPointer(); + const std::vector &groupsUnder = CWidgetManager::getInstance()->getGroupsUnderPointer(); if (groupsUnder.empty()) return NULL; for(uint k = 0; k < groupsUnder.size(); ++k) { @@ -589,7 +589,7 @@ CInstance *CTool::checkInstanceUnderMouse(IDisplayerUIHandle **miniMapHandle /*= IDisplayerUIHandle *bestCandidate = NULL; sint8 bestCandidateLayer = -128; // see if the element is under the mouse - const std::vector &ctrlsUnder = getUI().getCtrlsUnderPointer(); + const std::vector &ctrlsUnder = CWidgetManager::getInstance()->getCtrlsUnderPointer(); for(sint k = (sint)ctrlsUnder.size() - 1; k >= 0; --k) { IDisplayerUIHandle *handle = dynamic_cast(ctrlsUnder[k]); @@ -637,7 +637,7 @@ CInstance *CTool::checkInstanceUnderMouse(IDisplayerUIHandle **miniMapHandle /*= } } } - else if (!IsMouseFreeLook() && !getUI().getCapturePointerLeft() && !getUI().getCapturePointerRight()) + else if (!IsMouseFreeLook() && !CWidgetManager::getInstance()->getCapturePointerLeft() && !CWidgetManager::getInstance()->getCapturePointerRight()) { // Over the screen ? if (isInScreen(x, y)) @@ -719,7 +719,7 @@ void CTool::captureMouse() CGroupMap *gm = isMouseOnWorldMap(); if (gm) { - getUI().setCapturePointerLeft(gm); + CWidgetManager::getInstance()->setCapturePointerLeft(gm); } else { @@ -734,7 +734,7 @@ void CTool::captureMouse() void CTool::releaseMouse() { //H_AUTO(R2_CTool_releaseMouse) - getUI().setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); UserControls.releaseMouse(); getUI().enableMouseHandling(true); getUI().setContextHelpActive(true); diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index ccbc4ee7a..8819dc24c 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -93,7 +93,7 @@ void CToolCreateEntity::updateInvalidCursorOnUI() { //H_AUTO(R2_CToolCreateEntity_updateInvalidCursorOnUI) // set the default cursor unless the mouse is on the palette - const std::vector &groups = getUI().getGroupsUnderPointer(); + const std::vector &groups = CWidgetManager::getInstance()->getGroupsUnderPointer(); for(uint k = 0; k < groups.size(); ++k) { if (groups[k]->getId() == "ui:interface:r2ed_palette") // hardcoded for now ... diff --git a/code/ryzom/client/src/r2/tool_maintained_action.cpp b/code/ryzom/client/src/r2/tool_maintained_action.cpp index 592808350..fb0e717fe 100644 --- a/code/ryzom/client/src/r2/tool_maintained_action.cpp +++ b/code/ryzom/client/src/r2/tool_maintained_action.cpp @@ -175,7 +175,7 @@ bool CToolMaintainedAction::onMouseLeftButtonClicked() CGroupMap *gm = CTool::isMouseOnWorldMap(); if (gm) { - if (getUI().getCapturePointerLeft()) + if (CWidgetManager::getInstance()->getCapturePointerLeft()) { return false; } diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index aad491c3f..e096beeb7 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -242,9 +242,9 @@ void releaseMainLoopReselect() EditActions.releaseAllKeyNoRunning(); Actions.releaseAllKeyNoRunning(); pIM->removeAllTemplates(); - pIM->setCaptureKeyboard(NULL); - pIM->setCapturePointerLeft(NULL); - pIM->setCapturePointerRight(NULL); + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); // Yoyo: Don't release attack list manager, because I think it only owns static data (and 3D data created from Driver, not Scenes) // Note that in initMainLoop(), CAttackListManager::getInstance().init() will do nothing (since already created and not released here) From 6a48aa9d6cb7b74b66204712de4f09fa80fcf083 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 5 Jun 2012 05:25:49 +0200 Subject: [PATCH 045/339] CHANGED: #1471 extracted some dragging related code from CDBCtrlSheet and created a new class CCtrlDraggable, so that CWidgetManager doesn't have to be coupled with CDBCtrlSheet. --- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/ctrl_draggable.cpp | 11 ++++ .../client/src/interface_v3/ctrl_draggable.h | 38 ++++++++++++ .../client/src/interface_v3/dbctrl_sheet.cpp | 59 ++++++++----------- .../client/src/interface_v3/dbctrl_sheet.h | 16 ++--- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 4 +- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/widget_manager.cpp | 9 ++- 10 files changed, 89 insertions(+), 56 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/ctrl_draggable.cpp create mode 100644 code/ryzom/client/src/interface_v3/ctrl_draggable.h diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 5c64d2219..e86c0691e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -909,7 +909,7 @@ class CIsPlayerItem : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const string &/* Params */) { - CDBCtrlSheet *cs = CDBCtrlSheet::getDraggedSheet(); + CDBCtrlSheet *cs = dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ); if (cs) { CDBCtrlSheet *pCSDst = dynamic_cast(pCaller); diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.cpp b/code/ryzom/client/src/interface_v3/ctrl_draggable.cpp new file mode 100644 index 000000000..7d98e7794 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_draggable.cpp @@ -0,0 +1,11 @@ +#include "ctrl_draggable.h" + +CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL; + +CCtrlDraggable::CCtrlDraggable(const TCtorParam ¶m) : +CCtrlBase( param ) +{ + dragged = false; + draggable = false; +} + diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.h b/code/ryzom/client/src/interface_v3/ctrl_draggable.h new file mode 100644 index 000000000..6b59af553 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_draggable.h @@ -0,0 +1,38 @@ +#ifndef CTRL_DRAGGABLE_H +#define CTRL_DRAGGABLE_H + +#include "ctrl_base.h" + +class CCtrlDraggable : public CCtrlBase +{ +public: + CCtrlDraggable( const TCtorParam ¶m ); + virtual ~CCtrlDraggable(){}; + + static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } + bool isDragged() const{ return dragged; } + void setDragged( bool dragged ){ this->dragged = dragged; } + bool isDraggable() const{ return draggable; } + void setDraggable( bool draggable ){ this->draggable = draggable; } + + void abortDragging() + { + dragged = false; + _LastDraggedSheet = NULL; + } + + + REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) + REFLECT_BOOL("dragable", isDraggable, setDraggable); + REFLECT_EXPORT_END + +protected: + static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; } + +private: + static CCtrlDraggable *_LastDraggedSheet; + bool dragged; + bool draggable; +}; + +#endif diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index c30fcf776..74a5bb132 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -62,7 +62,6 @@ using namespace STRING_MANAGER; NLMISC::CSmartPtr CDBCtrlSheet::_PhraseAdapter; CDBCtrlSheet *CDBCtrlSheet::_CurrSelection = NULL; -CDBCtrlSheet *CDBCtrlSheet::_LastDraggedSheet = NULL; CDBCtrlSheet *CDBCtrlSheet::_CurrMenuSheet = NULL; UMaterial CDBCtrlSheet::_GuildMat; @@ -131,7 +130,7 @@ ucstring CControlSheetTooltipInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet, // *************************************************************************** int CDBCtrlSheet::luaGetDraggedSheet(CLuaState &ls) { - CLuaIHMRyzom::pushUIOnStack(ls, dynamic_cast(_LastDraggedSheet)); + CLuaIHMRyzom::pushUIOnStack(ls, dynamic_cast( dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) )); return 1; } @@ -293,7 +292,6 @@ CCtrlSheetInfo::CCtrlSheetInfo() { _Type = CCtrlSheetInfo::SheetType_Item; _DispNoSheetBmpId = -1; - _Dragable = false; _InterfaceColor= true; _SheetSelectionGroup = -1; _UseQuality = true; @@ -379,9 +377,6 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr if (prop) _HasTradeSlotType= CInterfaceElement::convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"dragable" ); - if (prop) _Dragable = CInterfaceElement::convertBool(prop); - // Read Action handlers CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); @@ -502,8 +497,8 @@ bool CCtrlSheetInfo::parseCtrlInfo(xmlNodePtr cur, CInterfaceGroup * /* parentGr NLMISC_REGISTER_OBJECT(CViewBase, CDBCtrlSheet, std::string, "sheet"); // ---------------------------------------------------------------------------- -CDBCtrlSheet::CDBCtrlSheet(const TCtorParam ¶m) -: CCtrlBase(param) +CDBCtrlSheet::CDBCtrlSheet(const TCtorParam ¶m) : +CCtrlDraggable(param) { _LastSheetId = 0; _DispSlotBmpId= -1; @@ -511,7 +506,6 @@ CDBCtrlSheet::CDBCtrlSheet(const TCtorParam ¶m) _DispSheetBmpId = -1; _DispOverBmpId = -1; _DispOver2BmpId= -1; - _Draging = false; _CanDrop = false; _Stackable= 1; _DispQuality= -1; @@ -575,7 +569,8 @@ CDBCtrlSheet::~CDBCtrlSheet() // ensure erase static if(this==_CurrMenuSheet) _CurrMenuSheet = NULL; - if(this==_LastDraggedSheet) _LastDraggedSheet = NULL; + if(this == dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) ) + setDraggedSheet( NULL ); if(this==_CurrSelection) _CurrSelection = NULL; } @@ -595,6 +590,12 @@ bool CDBCtrlSheet::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if(!parseCtrlInfo(cur, parentGroup)) return false; + prop = (char*) xmlGetProp( cur, (xmlChar*)"dragable" ); + if( prop != NULL ) + setDraggable( CInterfaceElement::convertBool(prop) ); + else + setDraggable( false ); + if (_Type != SheetType_Macro) { prop = (char*) xmlGetProp( cur, (xmlChar*)"value" ); @@ -1865,7 +1866,7 @@ void CDBCtrlSheet::draw() if (CWidgetManager::getInstance()->getCurrentWindowUnder() == CWidgetManager::getInstance()->getWindow(this)) { CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); - if ((pCSSrc != NULL) && pCSSrc->isDraging()) + if ((pCSSrc != NULL) && pCSSrc->isDragged()) { string params = string("src=") + pCSSrc->getId(); if (!_AHCanDropParams.empty()) @@ -1886,7 +1887,7 @@ void CDBCtrlSheet::draw() } } - drawSheet (_XReal+1, _YReal+1, _Draging); + drawSheet (_XReal+1, _YReal+1, isDragged() ); // Draw the selection after the sheet. Important for spells because selection border is same size as spell square if (_CanDrop) @@ -2512,7 +2513,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti if (showSelectionBorder) { - if (!_Draging || (_Draging && _DuplicateOnDrag)) + if (!isDragged() || (isDragged() && _DuplicateOnDrag)) { // draw selection border if this sheet is selected if (_SheetSelectionGroup != -1) // is this sheet selectable ? @@ -2604,7 +2605,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) // Handle drag'n'drop if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Draging) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !isDragged()) { _DragX = eventDesc.getX(); _DragY = eventDesc.getY(); @@ -2616,17 +2617,17 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) // Cannot drag if grayed (LOCKED or LATENT)!. Still can drag a shortcut if (asItemSheet() && asItemSheet()->Stackable > 1 && _UseQuantity) { - validClic = _Dragable && !_Draging && (getQuantity() > 0); + validClic = isDraggable() && !isDragged() && (getQuantity() > 0); validClic = validClic && (!getItemWeared()); } else { - validClic = _Dragable && !_Draging && ((!getItemWeared()&&!getGrayed()) || isShortCut()); + validClic = isDraggable() && !isDragged() && ((!getItemWeared()&&!getGrayed()) || isShortCut()); } } if (_Type == SheetType_Macro) { - validClic = _Dragable; + validClic = isDraggable(); } // posssibly check AH to see if really can draging @@ -2645,8 +2646,8 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) _DeltaDragY= _DragY-(_YReal+1); if (_DeltaDragX > _WReal) _DeltaDragX = _WReal; if (_DeltaDragY > _HReal) _DeltaDragY = _HReal; - _Draging = true; - _LastDraggedSheet = this; + setDragged( true ); + setDraggedSheet( this ); if (_AHOnDrag != NULL) { @@ -2655,7 +2656,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) } } - if (_Draging) + if (isDragged()) { // If mouse left up, must end the Drag if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) @@ -2827,8 +2828,8 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) } // In all case, quit - _Draging = false; - _LastDraggedSheet = NULL; + setDragged( false ); + setDraggedSheet( NULL ); // In call case, end of drag => consider handled to not call another action return true; } @@ -2836,7 +2837,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) } // If we are dragging, no more event on us - if(_Draging) + if(isDragged()) return false; // true; // Mouse events that must be done over the control @@ -2856,7 +2857,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) if(_AHOnLeftClick != NULL) CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); // Run Menu (if item is not being dragged) - if (!_ListMenuLeft.empty() && _LastDraggedSheet == NULL) + if (!_ListMenuLeft.empty() && dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) == NULL) { if (getSheetId() != 0) { @@ -2891,7 +2892,7 @@ bool CDBCtrlSheet::handleEvent (const NLGUI::CEventDescriptor &event) { handled= true; // There must be no dragged sheet - if(_LastDraggedSheet == NULL) + if( dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) == NULL) { // if a macro, don't test if Sheet==0 if ( isMacro() || getSheetId() != 0) @@ -2973,7 +2974,6 @@ void CDBCtrlSheet::swapSheet(CDBCtrlSheet *other) void CDBCtrlSheet::setCurrSelection(CDBCtrlSheet *selected) { _CurrSelection = selected; - CInterfaceManager *im = CInterfaceManager::getInstance(); NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SHEET")->setValue64(selected ? selected->getSheetId() : 0); NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:QUALITY")->setValue64(selected ? selected->getQuality() : 0); NLGUI::CDBManager::getInstance()->getDbProp("UI:SELECTED_ITEM_SHEET_ID:SLOT_TYPE")->setValue64(selected ? selected->getBehaviour() : 0); @@ -4246,13 +4246,6 @@ ucstring CDBCtrlSheet::getItemActualName() const } } -// *************************************************************************** -void CDBCtrlSheet::abortDraging() -{ - _Draging = false; - _LastDraggedSheet = NULL; -} - // *************************************************************************** void CDBCtrlSheet::updateArmourColor(sint8 col) { diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index b683ea597..3071d78df 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -24,7 +24,7 @@ #include "nel/misc/smart_ptr.h" // client #include "nel/gui/reflect.h" -#include "ctrl_base.h" +#include "ctrl_draggable.h" #include "nel/gui/interface_expr.h" #include "action_handler.h" #include "sphrase_manager.h" @@ -135,7 +135,6 @@ public: // bool _InterfaceColor : 1; // Color given by the interface ? - bool _Dragable : 1; bool _UseQuantity : 1; // is the quantity read and displayed ? bool _ReadQuantityFromSheet : 1; // Read quantity from sheet rather than from database bool _UseQuality : 1; // is the quality read and displayed ? @@ -174,7 +173,7 @@ public: * \author Nevrax France * \date 2002 */ -class CDBCtrlSheet : public CCtrlBase, protected CCtrlSheetInfo +class CDBCtrlSheet : public CCtrlDraggable, protected CCtrlSheetInfo { public: DECLARE_UI_CLASS(CDBCtrlSheet) @@ -223,15 +222,11 @@ public: void setCanDrop (bool cd) { _CanDrop = cd; } bool getCanDrop () const { return _CanDrop; } - bool isDragable() { return _Dragable; } - void setDragable(bool dragable) { _Dragable = dragable; } - bool isDraging() { return _Draging; } sint32 getDeltaDragX() {return _DeltaDragX;} sint32 getDeltaDragY() {return _DeltaDragY;} // For "oncandrag" action handlers only, which would want to avoid the drag void setTempCanDrag(bool cd) {_TempCanDrag= cd;} // called when a setCapturePointerLeft(NULL) is made for instance - void abortDraging(); CCtrlSheetInfo::TSheetType getType () const; void setType (CCtrlSheetInfo::TSheetType type); @@ -267,7 +262,7 @@ public: void setSheet (const std::string &dbBranchId); void setSheetFast( const std::string &dbParentBranchId, int sheetNum, int slotNum ); - REFLECT_EXPORT_START(CDBCtrlSheet, CCtrlBase) + REFLECT_EXPORT_START(CDBCtrlSheet, CCtrlDraggable) REFLECT_STRING("sheet", getSheet, setSheet); REFLECT_RGBA("color", getSheetColor, setSheetColor); REFLECT_RGBA("color1", getGuildColor1, setGuildColor1); @@ -275,7 +270,6 @@ public: REFLECT_SINT32("back", getGuildBack, setGuildBack); REFLECT_SINT32("symbol", getGuildSymbol, setGuildSymbol); REFLECT_BOOL("invert_symbol", getInvertGuildSymbol, setInvertGuildSymbol); - REFLECT_BOOL("dragable", isDragable, setDragable); REFLECT_BOOL("can_drop", getCanDrop, setCanDrop); REFLECT_STRING ("left_click", getActionOnLeftClick, setActionOnLeftClick); REFLECT_STRING ("right_click", getActionOnRightClick, setActionOnRightClick); @@ -341,7 +335,7 @@ public: static uint getInventorySlot( const std::string &dbBranchId ); // Get the last dropped sheet. The pointer is only valid during the call of the event handler - static CDBCtrlSheet *getDraggedSheet() { return _LastDraggedSheet; } + //static CDBCtrlSheet *getDraggedSheet() { return _LastDraggedSheet; } /* Get the last selected sheet that have been draged or right clicked (should be use by menu to get their caller) * It is used by the item actions like destroy, move etc.. @@ -649,7 +643,6 @@ protected: /// Events - bool _Draging : 1; bool _CanDrop : 1; bool _Over : 1; @@ -753,7 +746,6 @@ private: mutable TSheetType _ActualType; static CDBCtrlSheet *_CurrSelection; - static CDBCtrlSheet *_LastDraggedSheet; static CDBCtrlSheet *_CurrMenuSheet; private: void updateActualType() const; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index b9ca8c283..83d29b76f 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -722,7 +722,7 @@ void CDBGroupListSheet::draw () (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); - if ((pCSSrc != NULL) && pCSSrc->isDraging()) + if ((pCSSrc != NULL) && pCSSrc->isDragged()) { string params = string("src=") + pCSSrc->getId(); if (!_CtrlInfo._AHCanDropParams.empty()) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 250f7adcc..02ee3fa14 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -632,7 +632,7 @@ void CDBGroupListSheetText::draw () (CWidgetManager::getInstance()->getPointer()->getY() <= (_YReal+ _HReal))) { CDBCtrlSheet *pCSSrc = dynamic_cast(CWidgetManager::getInstance()->getCapturePointerLeft()); - if ((pCSSrc != NULL) && pCSSrc->isDraging()) + if ((pCSSrc != NULL) && pCSSrc->isDragged()) { string params = string("src=") + pCSSrc->getId(); if (!_CtrlInfo._AHCanDropParams.empty()) @@ -683,7 +683,7 @@ bool CDBGroupListSheetText::handleEvent (const NLGUI::CEventDescriptor &event) // A button has been captured -> Transform the capture to the corresponding ctrlsheet sint pos = getIndexOf(pCB); if ((pos >= 0) && - _SheetChildren[pos]->Ctrl->isDragable() && (!_SheetChildren[pos]->Ctrl->getGrayed())) + _SheetChildren[pos]->Ctrl->isDraggable() && (!_SheetChildren[pos]->Ctrl->getGrayed())) { pDraggedSheet = _SheetChildren[pos]->Ctrl; CWidgetManager::getInstance()->setCapturePointerLeft(pDraggedSheet); diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 356ca8c38..23807a361 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -134,7 +134,7 @@ REGISTER_INTERFACE_USER_FCT("getSelectedItemPrice", getSelectedItemPrice) ///////////////////////////////////////////////// static DECLARE_INTERFACE_USER_FCT(getDraggedSheet) { - result.setUserType(new CDBCtrlSheetPtrUserType(CDBCtrlSheet::getDraggedSheet())); + result.setUserType(new CDBCtrlSheetPtrUserType( dynamic_cast< CDBCtrlSheet* >( CDBCtrlSheet::getDraggedSheet() ) )); return true; } REGISTER_INTERFACE_USER_FCT("getDraggedSheet", getDraggedSheet) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 3a16927ea..63406bcb3 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1941,7 +1941,7 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) if ( CWidgetManager::getInstance()->getPointer()->show()) { CDBCtrlSheet *pCS = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft() ); - if ((pCS != NULL) && (pCS->isDraging())) + if ((pCS != NULL) && (pCS->isDragged())) { sint x= CWidgetManager::getInstance()->getPointer()->getX() - pCS->getDeltaDragX(); sint y= CWidgetManager::getInstance()->getPointer()->getY() - pCS->getDeltaDragY(); diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index a27d674fd..740218e8b 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -20,7 +20,7 @@ #include "group_in_scene.h" #include "view_pointer.h" #include "group_editbox.h" -#include "dbctrl_sheet.h" +#include "ctrl_draggable.h" CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; @@ -1110,10 +1110,9 @@ void CWidgetManager::movePointerAbs(sint32 px, sint32 py) void CWidgetManager::setCapturePointerLeft(CCtrlBase *c) { // additionally, abort any dragging - if(CDBCtrlSheet::getDraggedSheet()) - { - CDBCtrlSheet::getDraggedSheet()->abortDraging(); - } + if( CCtrlDraggable::getDraggedSheet() != NULL ) + CCtrlDraggable::getDraggedSheet()->abortDragging(); + _CapturePointerLeft = c; notifyElementCaptured(c); } From 1e1888b47f36505183510ac867227c6ff8f3c810 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 6 Jun 2012 01:56:25 +0200 Subject: [PATCH 046/339] CHANGED: #1471 moved makeWindow and unMakeWindow methods to CWidgetManager from CInterfaceManager. So CInterfaceGroup no longer depends on CInterfaceManager. --- code/ryzom/client/src/character_cl.cpp | 2 +- code/ryzom/client/src/forage_source_cl.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 6 +- .../client/src/interface_v3/ctrl_base.cpp | 9 +-- .../src/interface_v3/flying_text_manager.cpp | 2 +- .../src/interface_v3/group_container.cpp | 4 +- .../interface_v3/group_in_scene_bubble.cpp | 20 +++--- .../src/interface_v3/interface_group.cpp | 23 +++--- .../src/interface_v3/interface_link.cpp | 10 +-- .../src/interface_v3/interface_manager.cpp | 68 ------------------ .../src/interface_v3/interface_manager.h | 8 --- .../client/src/interface_v3/view_base.cpp | 7 +- .../src/interface_v3/widget_manager.cpp | 70 +++++++++++++++++++ .../client/src/interface_v3/widget_manager.h | 6 ++ code/ryzom/client/src/r2/displayer_visual.cpp | 2 +- 15 files changed, 116 insertions(+), 123 deletions(-) diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index 55f1af798..8503e505b 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -452,7 +452,7 @@ void CCharacterCL::releaseInSceneInterfaces() { if (_InSceneUserInterface) { - CInterfaceManager::getInstance()->unMakeWindow(_InSceneUserInterface); + CWidgetManager::getInstance()->unMakeWindow(_InSceneUserInterface); if (_InSceneUserInterface->getParent()) { _InSceneUserInterface->getParent()->delGroup(_InSceneUserInterface); diff --git a/code/ryzom/client/src/forage_source_cl.cpp b/code/ryzom/client/src/forage_source_cl.cpp index a62509aab..b59a91d52 100644 --- a/code/ryzom/client/src/forage_source_cl.cpp +++ b/code/ryzom/client/src/forage_source_cl.cpp @@ -177,7 +177,7 @@ void CForageSourceCL::releaseInSceneInterfaces() { if (_InSceneUserInterface) { - CInterfaceManager::getInstance()->unMakeWindow(_InSceneUserInterface); + CWidgetManager::getInstance()->unMakeWindow(_InSceneUserInterface); if (_InSceneUserInterface->getParent()) { _InSceneUserInterface->getParent()->delGroup(_InSceneUserInterface); diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index b9824f115..c7d16f60b 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -294,7 +294,7 @@ void CChatWindow::deleteContainer() } else { - CInterfaceManager::getInstance()->unMakeWindow(_Chat); + CWidgetManager::getInstance()->unMakeWindow(_Chat); if (_Chat->getParent()) { _Chat->getParent()->delGroup(_Chat); @@ -772,7 +772,7 @@ CGroupContainer *CChatGroupWindow::createFreeTeller(const ucstring &winNameIn, c CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->addGroup (pGC); pGC->setParent(pRoot); // must be done before makeWindow - pIM->makeWindow(pGC); + CWidgetManager::getInstance()->makeWindow(pGC); pGC->open(); pGC->updateCoords(); pGC->center(); @@ -897,7 +897,7 @@ bool CChatGroupWindow::removeFreeTeller(const std::string &containerID) pIM->removeGroupContainerImage(_FreeTellers[i]->getId(), m); } CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); - pIM->unMakeWindow(_FreeTellers[i]); + CWidgetManager::getInstance()->unMakeWindow(_FreeTellers[i]); pRoot->delGroup (_FreeTellers[i]); _FreeTellers[i] = NULL; _FreeTellers.erase(_FreeTellers.begin()+i); diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_base.cpp index b68851a0f..1eea06182 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_base.cpp @@ -15,12 +15,10 @@ // along with this program. If not, see . - -#include "stdpch.h" - -#include "ctrl_base.h" #include "nel/misc/xml_auto_ptr.h" -#include "interface_manager.h" +#include "ctrl_base.h" +#include "interface_group.h" +#include "widget_manager.h" using namespace NLMISC; @@ -41,7 +39,6 @@ bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event) if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive()) { // the mouse capture should be lost when the ctrl is hidden - CInterfaceManager *manager = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { CWidgetManager::getInstance()->setCapturePointerLeft(NULL); diff --git a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp index 48bac19ab..f8ef9e29c 100644 --- a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -202,7 +202,7 @@ void CFlyingTextManager::unlinkToInterface(CGroupInfo &gi) // remove from group and window list CInterfaceManager *pIM= CInterfaceManager::getInstance(); - pIM->unMakeWindow(gi.GroupInScene); + CWidgetManager::getInstance()->unMakeWindow(gi.GroupInScene); // remove but don't delete gi.GroupInScene->getParent()->delGroup(gi.GroupInScene, true); gi.GroupInScene->setParent(NULL); diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 5a4820c71..6f48f5598 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -3289,7 +3289,7 @@ void CGroupContainer::popupCurrentPos() _ParentPos = parent; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->makeWindow(this); + CWidgetManager::getInstance()->makeWindow(this); CWidgetManager::getInstance()->setTopWindow(this); CWidgetManager::getInstance()->clearViewUnders(); CWidgetManager::getInstance()->clearCtrlsUnders(); @@ -3346,7 +3346,7 @@ void CGroupContainer::popin(sint32 insertPos /* = -1 */, bool putBackInFatherCon _MovingInParentList = false; CInterfaceManager *im = CInterfaceManager::getInstance(); - im->unMakeWindow(this); + CWidgetManager::getInstance()->unMakeWindow(this); CWidgetManager::getInstance()->clearViewUnders(); CWidgetManager::getInstance()->clearCtrlsUnders(); _Parent = NULL; diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index b5734ce35..2c8211619 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -124,7 +124,7 @@ bool CGroupInSceneBubbleManager::checkTimeOut(vector &rList) // Time out ? if (rList[i].timeOut ()) { - pIM->unMakeWindow(rList[i].Group); + CWidgetManager::getInstance()->unMakeWindow(rList[i].Group); if (rList[i].Group->getParent()) rList[i].Group->getParent()->delGroup(rList[i].Group); else @@ -155,7 +155,7 @@ void CGroupInSceneBubbleManager::alignMessagePopup (vector &rList, bool { CPopup popup = rList.front(); rList.erase (rList.begin()); - pIM->unMakeWindow(popup.Group); + CWidgetManager::getInstance()->unMakeWindow(popup.Group); if (popup.Group->getParent()) popup.Group->getParent()->delGroup(popup.Group); else @@ -264,7 +264,7 @@ void CGroupInSceneBubbleManager::release () for (i=0; i<_Bubbles.size(); i++) if (_Bubbles[i]) { - pIM->unMakeWindow(_Bubbles[i]); + CWidgetManager::getInstance()->unMakeWindow(_Bubbles[i]); if (_Bubbles[i]->getParent()) { _Bubbles[i]->getParent()->delGroup(_Bubbles[i]); @@ -279,7 +279,7 @@ void CGroupInSceneBubbleManager::release () // Remove messages for (i=0; i<_MessagePopup.size(); i++) { - pIM->unMakeWindow(_MessagePopup[i].Group); + CWidgetManager::getInstance()->unMakeWindow(_MessagePopup[i].Group); if (_MessagePopup[i].Group->getParent()) _MessagePopup[i].Group->getParent()->delGroup(_MessagePopup[i].Group); else @@ -290,7 +290,7 @@ void CGroupInSceneBubbleManager::release () // Remove messages for (i=0; i<_MessagePopupCentered.size(); i++) { - pIM->unMakeWindow(_MessagePopupCentered[i].Group); + CWidgetManager::getInstance()->unMakeWindow(_MessagePopupCentered[i].Group); if (_MessagePopupCentered[i].Group->getParent()) _MessagePopupCentered[i].Group->getParent()->delGroup(_MessagePopupCentered[i].Group); else @@ -301,7 +301,7 @@ void CGroupInSceneBubbleManager::release () // Remove messages for (i=0; i<_BubblePopup.size(); i++) { - pIM->unMakeWindow(_BubblePopup[i].Group); + CWidgetManager::getInstance()->unMakeWindow(_BubblePopup[i].Group); if (_BubblePopup[i].Group->getParent()) _BubblePopup[i].Group->getParent()->delGroup(_BubblePopup[i].Group); else @@ -344,7 +344,7 @@ void CGroupInSceneBubbleManager::update () // Time out ? if (_BubblePopup[i].timeOut ()) { - pIM->unMakeWindow(_BubblePopup[i].Group); + CWidgetManager::getInstance()->unMakeWindow(_BubblePopup[i].Group); if (_BubblePopup[i].Group->getParent()) _BubblePopup[i].Group->getParent()->delGroup(_BubblePopup[i].Group); else @@ -369,7 +369,7 @@ void CGroupInSceneBubbleManager::update () (target->getWReal() != _BubblePopup[i].TargetW) || (target->getHReal() != _BubblePopup[i].TargetH)) { - pIM->unMakeWindow(_BubblePopup[i].Group); + CWidgetManager::getInstance()->unMakeWindow(_BubblePopup[i].Group); if (_BubblePopup[i].Group->getParent()) _BubblePopup[i].Group->getParent()->delGroup(_BubblePopup[i].Group); else @@ -397,7 +397,7 @@ void CGroupInSceneBubbleManager::update () { if (_BubblePopup[j].Group == _GroupToDelete[i]) { - pIM->unMakeWindow(_BubblePopup[j].Group); + CWidgetManager::getInstance()->unMakeWindow(_BubblePopup[j].Group); if (_BubblePopup[j].Group->getParent()) _BubblePopup[j].Group->getParent()->delGroup(_BubblePopup[j].Group); else @@ -420,7 +420,7 @@ void CGroupInSceneBubbleManager::update () if (pChar != NULL) pChar->setBubble(NULL); - pIM->unMakeWindow(_DynBubbles[j].Bubble); + CWidgetManager::getInstance()->unMakeWindow(_DynBubbles[j].Bubble); if (_DynBubbles[j].Bubble->getParent()) _DynBubbles[j].Bubble->getParent()->delGroup(_DynBubbles[j].Bubble); else diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index fb3ce0052..50002fc9d 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -14,23 +14,22 @@ // 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/misc/xml_auto_ptr.h" +#include "nel/misc/stream.h" +#include "nel/gui/lua_manager.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/view_renderer.h" #include "interface_group.h" -#include "interface_manager.h" -#include "nel/misc/xml_auto_ptr.h" +#include "interface_link.h" +#include "view_text.h" +#include "ctrl_scroll.h" +#include "widget_manager.h" #include "group_container.h" #include "group_editbox.h" #include "group_scrolltext.h" -#include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" - -#include "nel/misc/stream.h" -#include "nel/gui/lua_manager.h" - using namespace std; using namespace NL3D; @@ -1112,7 +1111,7 @@ bool CInterfaceGroup::delElement (const std::string &id, bool noWarning) { // If this is a root window if (pIG->getRootWindow () == pIG) - CInterfaceManager::getInstance()->unMakeWindow(pIG, noWarning); + CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); delGroup (pIG, false); return true; } @@ -1129,7 +1128,7 @@ bool CInterfaceGroup::delElement (CInterfaceElement *pIE, bool noWarning) CInterfaceGroup *pIG= static_cast(pIE); // unmake window if it is if (pIG->getRootWindow () == pIG) - CInterfaceManager::getInstance()->unMakeWindow(pIG, noWarning); + CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); return delGroup(pIG); } else if(pIE->isCtrl()) diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index 2ef066363..1b0ee7619 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -14,16 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "action_handler.h" -#include "interface_link.h" -#include "interface_group.h" -#include "interface_element.h" -#include "widget_manager.h" #include "nel/gui/interface_expr.h" #include "nel/gui/interface_expr_node.h" #include "nel/gui/reflect.h" #include "nel/gui/db_manager.h" #include "nel/misc/cdb_branch.h" +#include "action_handler.h" +#include "interface_link.h" +#include "interface_element.h" +#include "interface_group.h" +#include "widget_manager.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 63406bcb3..40602c748 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -3504,74 +3504,6 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl) disableContextHelp(); } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::makeWindow(CInterfaceGroup *group) -{ - if (!group) return; - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - uint32 i = 0; - for (i = 0; i < _MasterGroups.size(); ++i) - { - if (_MasterGroups[i].Group == group->getParent()) - break; - } - - if (i == _MasterGroups.size()) - { - string stmp = string("not found master group for window: ")+group->getId(); - nlwarning (stmp.c_str()); - return; - } - else - { - // check if group hasn't been inserted twice. - if (_MasterGroups[i].isWindowPresent(group)) - { - nlwarning("Window inserted twice"); - } - else - { - _MasterGroups[i].addWindow(group,group->getPriority()); - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) -{ - if (!group) return; - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); - uint32 i = 0; - for (i = 0; i < _MasterGroups.size(); ++i) - { - if (_MasterGroups[i].Group == group->getParent()) - break; - } - - if (i == _MasterGroups.size()) - { - if (!noWarning) - { - string stmp = string("not found master group for window: ")+group->getId(); - nlwarning (stmp.c_str()); - } - return; - } - else - { - // check if group hasn't been inserted twice. - if (!_MasterGroups[i].isWindowPresent(group)) - { - if (!noWarning) - nlwarning("Window not inserted in master group"); - } - else - { - _MasterGroups[i].delWindow(group); - } - } -} - // *************************************************************************** void CInterfaceManager::enableMouseHandling(bool handle) { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 2a67fd038..20644ffd7 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -388,14 +388,6 @@ public: void setContextHelpActive(bool active); - - // Add a group into the windows list of its master goup - void makeWindow(CInterfaceGroup *group); - - // Remove a group from the windows list of its master group - void unMakeWindow(CInterfaceGroup *group, bool noWarning=false); - - bool isMouseOverWindow() const {return _MouseOverWindow;} // Enable mouse Events to interface. if false, release Captures. diff --git a/code/ryzom/client/src/interface_v3/view_base.cpp b/code/ryzom/client/src/interface_v3/view_base.cpp index a8cfb0213..70bf9255c 100644 --- a/code/ryzom/client/src/interface_v3/view_base.cpp +++ b/code/ryzom/client/src/interface_v3/view_base.cpp @@ -14,12 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "view_base.h" -#include "interface_manager.h" +#include "interface_group.h" +#include "widget_manager.h" CViewBase::~CViewBase() { diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 740218e8b..1c7da44b2 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -1238,6 +1238,76 @@ void CWidgetManager::notifyElementCaptured(CCtrlBase *c) } } +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::makeWindow(CInterfaceGroup *group) +{ + if(!group) + return; + + uint32 i = 0; + for (i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group == group->getParent()) + break; + } + + if (i == _MasterGroups.size()) + { + std::string stmp = std::string("not found master group for window: ")+group->getId(); + nlwarning (stmp.c_str()); + return; + } + else + { + // check if group hasn't been inserted twice. + if (_MasterGroups[i].isWindowPresent(group)) + { + nlwarning("Window inserted twice"); + } + else + { + _MasterGroups[i].addWindow(group,group->getPriority()); + } + } +} + +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) +{ + if (!group) + return; + + uint32 i = 0; + for (i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group == group->getParent()) + break; + } + + if (i == _MasterGroups.size()) + { + if (!noWarning) + { + std::string stmp = std::string("not found master group for window: ")+group->getId(); + nlwarning (stmp.c_str()); + } + return; + } + else + { + // check if group hasn't been inserted twice. + if (!_MasterGroups[i].isWindowPresent(group)) + { + if (!noWarning) + nlwarning("Window not inserted in master group"); + } + else + { + _MasterGroups[i].delWindow(group); + } + } +} + CWidgetManager::CWidgetManager() { diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index 68fb78a19..ba7cdbf6a 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -261,6 +261,12 @@ public: void notifyElementCaptured(CCtrlBase *c); + // Add a group into the windows list of its master goup + void makeWindow( CInterfaceGroup *group ); + + // Remove a group from the windows list of its master group + void unMakeWindow( CInterfaceGroup *group, bool noWarning = false ); + static IParser *parser; private: diff --git a/code/ryzom/client/src/r2/displayer_visual.cpp b/code/ryzom/client/src/r2/displayer_visual.cpp index 3e49d57fa..9eb8c0431 100644 --- a/code/ryzom/client/src/r2/displayer_visual.cpp +++ b/code/ryzom/client/src/r2/displayer_visual.cpp @@ -65,7 +65,7 @@ CDisplayerVisual::~CDisplayerVisual() { if (_IconInScene) { - getEditor().getUI().unMakeWindow(_IconInScene); + CWidgetManager::getInstance()->unMakeWindow(_IconInScene); if (_IconInScene->getParent()) { _IconInScene->getParent()->delGroup(_IconInScene); From 60c5ad2bfd819701127fe9c1debe157a32563d07 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 6 Jun 2012 04:10:34 +0200 Subject: [PATCH 047/339] CHANGED: #1471 CInterfaceGroup::InvalidateTexts is now implemented with a visitor, method removed. Also added CInterfaceGroup::visitGroupAndChildren, that only visits the group and it's sub-groups. --- .../client/src/interface_v3/ctrl_scroll.cpp | 15 ++------ .../client/src/interface_v3/ctrl_tooltip.cpp | 3 -- .../client/src/interface_v3/ctrl_tooltip.h | 1 - .../src/interface_v3/interface_group.cpp | 37 +++++++----------- .../client/src/interface_v3/interface_group.h | 6 ++- .../src/interface_v3/interface_manager.cpp | 38 +++++++++++++++++-- 6 files changed, 55 insertions(+), 45 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index f537561b0..da37c6764 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -15,9 +15,10 @@ // along with this program. If not, see . - -#include "stdpch.h" +/* +#include "stdpch.h"*/ #include "interface_manager.h" +#include "widget_manager.h" #include "ctrl_scroll.h" #include "nel/misc/xml_auto_ptr.h" #include "group_menu.h" @@ -68,7 +69,6 @@ void CCtrlScroll::runAH(const std::string &name, const std::string ¶ms) { if (name.empty()) return; if (_CallingAH) return; // avoid infinite loop - CInterfaceManager *pIM = CInterfaceManager::getInstance(); _CallingAH = true; CAHManager::getInstance()->runActionHandler(name, this, params); _CallingAH = false; @@ -166,7 +166,6 @@ bool CCtrlScroll::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) prop = (char*) xmlGetProp( node, (xmlChar*)"target" ); if (prop) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); if(group == NULL) group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop)); @@ -209,7 +208,6 @@ int CCtrlScroll::luaSetTarget(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); std::string targetId = ls.toString(1); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(targetId)); if(group != NULL) { @@ -226,7 +224,6 @@ void CCtrlScroll::updateCoords() // update only if visible if (_Target->getActive()) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId (_TxIdB, w, h); @@ -409,9 +406,8 @@ void CCtrlScroll::updateCoords() // ------------------------------------------------------------------------------------------------ void CCtrlScroll::draw() { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = pIM->getGlobalColorForContent(); + CRGBA col = CInterfaceManager::getInstance()->getGlobalColorForContent(); if (_Target) { @@ -693,7 +689,6 @@ sint32 CCtrlScroll::moveTrackY (sint32 dy) // ------------------------------------------------------------------------------------------------ void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdB = rVR.getTextureIdFromName(txName); } @@ -701,7 +696,6 @@ void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) // ------------------------------------------------------------------------------------------------ void CCtrlScroll::setTextureMiddle (const std::string &txName) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdM = rVR.getTextureIdFromName(txName); } @@ -709,7 +703,6 @@ void CCtrlScroll::setTextureMiddle (const std::string &txName) // ------------------------------------------------------------------------------------------------ void CCtrlScroll::setTextureTopOrRight (const std::string &txName) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); _TxIdT = rVR.getTextureIdFromName(txName); } diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp index 3d50931a5..8b17a7073 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp @@ -17,10 +17,7 @@ // ---------------------------------------------------------------------------- -#include "stdpch.h" - #include "ctrl_tooltip.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h index ddd0b42c1..5564a8e5c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h @@ -26,7 +26,6 @@ namespace NLGUI { class CEventDescriptor; } -class CInterfaceManager; /** * \author Matthieu 'Mr TRAP' Besson diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 50002fc9d..ebab56ed8 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -22,7 +22,6 @@ #include "interface_group.h" #include "interface_link.h" -#include "view_text.h" #include "ctrl_scroll.h" #include "widget_manager.h" #include "group_container.h" @@ -1007,29 +1006,6 @@ void CInterfaceGroup::evalChildrenBBox(bool resizeFromChildW, bool resizeFromChi height = yMax - yMin; } -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::invalidateTexts (bool resetTextIndex) -{ - vector::const_iterator itg; - for (itg = _ChildrenGroups.begin() ; itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pIG = *itg; - pIG->invalidateTexts(resetTextIndex); - } - - for (vector::const_iterator itv = _Views.begin() ; itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - CViewText *pVT = dynamic_cast(pVB); - if (pVT != NULL) - { - if (resetTextIndex) - pVT->resetTextIndex(); - pVT->updateTextContext (); - } - } -} - // ------------------------------------------------------------------------------------------------ CInterfaceElement* CInterfaceGroup::getElement (const std::string &id) { @@ -1716,6 +1692,19 @@ void CInterfaceGroup::visit(CInterfaceElementVisitor *visitor) CInterfaceElement::visit(visitor); } +// ------------------------------------------------------------------------------------------------ +void CInterfaceGroup::visitGroupAndChildren( CInterfaceElementVisitor *visitor ) +{ + nlassert( visitor != 0 ); + for( uint i = 0; i < _ChildrenGroups.size(); i++ ) + { + _ChildrenGroups[ i ]->visitGroupAndChildren( visitor ); + } + + visitor->visitGroup( this ); +} + + // ------------------------------------------------------------------------------------------------ void CInterfaceGroup::setUseCursor(bool use) diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index ee9357749..892fa0203 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -109,7 +109,6 @@ public: */ virtual void checkCoords(); virtual void updateCoords(); - void invalidateTexts (bool resetTextIndex); // Needed for static text to be reconstructed on screen size change /// remove all views virtual void clearViews(); @@ -272,7 +271,10 @@ public: virtual void dumpSize(uint depth = 0) const; // From CInterfaceElement - virtual void visit(CInterfaceElementVisitor *visitor); + virtual void visit(CInterfaceElementVisitor *visitor); + + /// Visits only this group's sub-groups and then the group itself + virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor ); // Check cursor void setUseCursor(bool use); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 40602c748..631dea206 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -3083,6 +3083,33 @@ void CInterfaceManager::moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 } } +class InvalidateTextVisitor : public CInterfaceElementVisitor +{ +public: + InvalidateTextVisitor( bool reset ) + { + this->reset = reset; + } + + void visitGroup( CInterfaceGroup *group ) + { + const std::vector< CViewBase* > &vs = group->getViews(); + for( std::vector< CViewBase* >::const_iterator itr = vs.begin(); itr != vs.end(); ++itr ) + { + CViewText *vt = dynamic_cast< CViewText* >( *itr ); + if( vt != NULL ) + { + if( reset ) + vt->resetTextIndex(); + vt->updateTextContext(); + } + } + } + +private: + bool reset; +}; + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::updateAllLocalisedElements() { @@ -3114,7 +3141,9 @@ void CInterfaceManager::updateAllLocalisedElements() { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - rMG.Group->invalidateTexts (false); + InvalidateTextVisitor inv( false ); + + rMG.Group->visitGroupAndChildren( &inv ); rMG.Group->invalidateCoords (); for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) { @@ -3123,7 +3152,7 @@ void CInterfaceManager::updateAllLocalisedElements() for (itw = rList.begin(); itw != rList.end(); itw++) { CInterfaceGroup *pIG = *itw; - pIG->invalidateTexts (false); + pIG->visitGroupAndChildren( &inv ); pIG->invalidateCoords (); } } @@ -4592,7 +4621,8 @@ void CInterfaceManager::resetTextIndex() { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - rMG.Group->invalidateTexts (true); + InvalidateTextVisitor inv( true ); + rMG.Group->visitGroupAndChildren( &inv ); for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) { list &rList = rMG.PrioritizedWindows[nPriority]; @@ -4600,7 +4630,7 @@ void CInterfaceManager::resetTextIndex() for (itw = rList.begin(); itw != rList.end(); itw++) { CInterfaceGroup *pIG = *itw; - pIG->invalidateTexts (true); + pIG->visitGroupAndChildren( &inv ); } } } From 2488cf5c15ef9ec3b41a8334bded886bfd968219 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 6 Jun 2012 05:48:51 +0200 Subject: [PATCH 048/339] CHANGED: #1471 CInterfaceGroup no longer depends on CGroupContainer. --- code/ryzom/client/src/interface_v3/chat_window.cpp | 3 ++- code/ryzom/client/src/interface_v3/group_editbox.cpp | 3 ++- code/ryzom/client/src/interface_v3/group_map.cpp | 3 ++- .../client/src/interface_v3/interface_group.cpp | 12 +++++++----- code/ryzom/client/src/interface_v3/interface_group.h | 4 +--- .../client/src/interface_v3/people_interraction.cpp | 3 ++- code/ryzom/client/src/interface_v3/people_list.cpp | 5 +++-- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index c7d16f60b..3351e59ff 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -1319,7 +1319,8 @@ public: } // Clear input string pEB->setInputString (ucstring("")); - CGroupContainer *gc = pEB->getEnclosingContainer(); + CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() ); + if (gc) { // Restore position of enclosing container if it hasn't been moved/scaled/poped by the user diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index d7be6bb33..de6f83e3a 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -1071,7 +1071,8 @@ void CGroupEditBox::updateCoords() if (_BackupFatherContainerPos) { - CGroupContainer *gc = getEnclosingContainer(); + CGroupContainer *gc = static_cast< CGroupContainer* >( getEnclosingContainer() ); + if (gc && !gc->getTouchFlag(true)) { diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 1ff4c3023..f6653d8ab 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -858,7 +858,8 @@ void CGroupMap::updateCoords() { updateSelectionAxisSize(); // - CGroupContainer *enclosingContainer = getEnclosingContainer(); + CGroupContainer *enclosingContainer = static_cast< CGroupContainer* >( getEnclosingContainer() ); + if (!enclosingContainer || !enclosingContainer->getActive()) return; // update position of landmarks updateScale(); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index ebab56ed8..ba59626ed 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -22,9 +22,9 @@ #include "interface_group.h" #include "interface_link.h" -#include "ctrl_scroll.h" #include "widget_manager.h" -#include "group_container.h" + +#include "ctrl_scroll.h" #include "group_editbox.h" #include "group_scrolltext.h" #include "lua_ihm_ryzom.h" @@ -1539,15 +1539,17 @@ void CInterfaceGroup::setRightClickHandler(const std::string &handler) } // ------------------------------------------------------------------------------------------------ -CGroupContainer *CInterfaceGroup::getEnclosingContainer() +CInterfaceGroup* CInterfaceGroup::getEnclosingContainer() { CInterfaceGroup *ig = this; do { - if (ig->isGroupContainer()) return static_cast(ig); + if( ig->isGroupContainer() ) + return ig; ig = ig->getParent(); } - while(ig); + while( ig != NULL ); + return NULL; } diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index 892fa0203..d2a93f49c 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -22,8 +22,6 @@ #include "ctrl_base.h" #include "action_handler.h" -class CGroupContainer; - // ---------------------------------------------------------------------------- class CInterfaceGroup : public CCtrlBase { @@ -251,7 +249,7 @@ public: // quick way to know if the group is a CGroupContainer bool isGroupContainer() const { return _IsGroupContainer; } - CGroupContainer *getEnclosingContainer(); + CInterfaceGroup* getEnclosingContainer(); sint getInsertionOrder(CViewBase *vb) const; diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index ffd8572e4..668c5f977 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2189,7 +2189,8 @@ class CHandlerTellContact : public IActionHandler if (!pCaller) return; CInterfaceGroup *ig = pCaller->getParent(); if (!ig) return; - CGroupContainer *gc = ig->getEnclosingContainer(); + CGroupContainer *gc = static_cast< CGroupContainer* >( ig->getEnclosingContainer() ); + if (!gc) return; CPeopleList *list; uint peopleIndex; diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 1b904bbeb..5c4821e72 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -572,7 +572,7 @@ void CPeopleList::reset() removeAllPeoples(); _BaseContainer->setContent(NULL); - CGroupContainer *father = dynamic_cast(_BaseContainer->getParent()->getEnclosingContainer()); + CGroupContainer *father = static_cast(_BaseContainer->getParent()->getEnclosingContainer()); if (father) { father->delGroup(_BaseContainer); @@ -894,7 +894,8 @@ class CHandlerContactEntry : public IActionHandler // Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now // it is simpler to keep it as it and to just use this action handler to manage user input. if (!pCaller || !pCaller->getParent()) return; - CGroupContainer *gc = pCaller->getParent()->getEnclosingContainer(); + CGroupContainer *gc = static_cast< CGroupContainer* >( pCaller->getParent()->getEnclosingContainer() ); + // title gives the name of the player ucstring playerName = gc->getUCTitle(); From f807707bb67f7895c0b6091e8569b3802b394cb1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 6 Jun 2012 22:31:47 +0200 Subject: [PATCH 049/339] CHANGED: #1471 CInterfaceElement no longer depends on CGroupContainer. --- code/ryzom/client/src/interface_v3/chat_window.cpp | 8 ++++---- code/ryzom/client/src/interface_v3/group_map.cpp | 2 +- code/ryzom/client/src/interface_v3/interface_element.cpp | 9 +++++---- code/ryzom/client/src/interface_v3/interface_element.h | 7 +------ code/ryzom/client/src/r2/tool.cpp | 5 +++-- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 3351e59ff..62548652e 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -1340,9 +1340,9 @@ static ucstring getFreeTellerName(CInterfaceElement *pCaller) if (!pCaller) return ucstring(); CChatGroupWindow *cgw = PeopleInterraction.getChatGroupWindow(); if (!cgw) return ucstring(); - CGroupContainer *freeTeller = pCaller->getParentContainer(); + CInterfaceGroup *freeTeller = pCaller->getParentContainer(); if (!freeTeller) return ucstring(); - return cgw->getFreeTellerName(freeTeller->getId()); + return cgw->getFreeTellerName( freeTeller->getId() ); } // *************************************************************************************** @@ -1394,10 +1394,10 @@ public: } if (pCaller) { - CGroupContainer *win = prevCaller->getParentContainer(); + CInterfaceGroup *win = prevCaller->getParentContainer(); if (win) { - win->setActive(false); + static_cast< CGroupContainer* >( win )->setActive(false); } } } diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index f6653d8ab..13588c436 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -2165,7 +2165,7 @@ void CGroupMap::setMap(SMap *map) _MapMaterial.setTexture(1, NULL); // disable the map_back button for islands (islands can't be seen on the world map) - CGroupContainer *gc = getParentContainer(); + CInterfaceGroup *gc = getParentContainer(); if (gc) { CCtrlBase *mapBack = gc->getCtrl("map_back"); diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/ryzom/client/src/interface_v3/interface_element.cpp index b0145363e..a66b5881b 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/ryzom/client/src/interface_v3/interface_element.cpp @@ -19,7 +19,6 @@ #include "nel/gui/view_renderer.h" #include "widget_manager.h" #include "nel/gui/db_manager.h" -#include "group_container.h" #include "interface_link.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" @@ -852,13 +851,15 @@ CInterfaceElement* CInterfaceElement::getMasterGroup() const } // ------------------------------------------------------------------------------------------------ -CGroupContainer *CInterfaceElement::getParentContainer() +CInterfaceGroup* CInterfaceElement::getParentContainer() { CInterfaceElement *parent = this; while (parent) { - CGroupContainer *gc = dynamic_cast(parent); - if (gc) return gc; + CInterfaceGroup *gc = dynamic_cast< CInterfaceGroup* >( parent ); + if( ( gc != NULL ) && gc->isGroupContainer() ) + return gc; + parent = parent->getParent(); } return NULL; diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 72663f09a..49c584462 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -28,11 +28,6 @@ using namespace NLGUI; -// ---------------------------------------------------------------------------- -class CInterfaceGroup; - -// ---------------------------------------------------------------------------- - class CInterfaceLink; class CInterfaceElement; class CInterfaceGroup; @@ -147,7 +142,7 @@ public: CInterfaceElement* getMasterGroup() const; // get a possible group container - CGroupContainer *getParentContainer(); + CInterfaceGroup* getParentContainer(); bool getActive() const { return _Active; } diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index fd42ca4ef..23706d9f2 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -225,8 +225,9 @@ CGroupContainer *CTool::isMouseOnContainer() if (groupsUnder.empty()) return NULL; for(uint k = 0; k < groupsUnder.size(); ++k) { - CGroupContainer *gc = groupsUnder[k]->getParentContainer(); - if (gc) return gc; + CInterfaceGroup* gc = groupsUnder[k]->getParentContainer(); + if (gc) + return static_cast< CGroupContainer* >( gc ); } return NULL; } From ecbdef6ab5ed7ba1deaef06e22f42aa1c17cbaa2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 02:54:14 +0200 Subject: [PATCH 050/339] CHANGED: #1471 CInterfaceGroup no longer depends on CCtrlScroll. Instead if depends on a new CCtrlScrollBase class. --- .../client/src/interface_v3/ctrl_draggable.h | 4 ++ .../client/src/interface_v3/ctrl_scroll.cpp | 4 +- .../client/src/interface_v3/ctrl_scroll.h | 12 ++-- .../src/interface_v3/ctrl_scroll_base.cpp | 66 +++++++++++++++++++ .../src/interface_v3/ctrl_scroll_base.h | 55 ++++++++++++++++ .../src/interface_v3/interface_group.cpp | 6 +- .../register_interface_elements.cpp | 11 ++-- 7 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll_base.h diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.h b/code/ryzom/client/src/interface_v3/ctrl_draggable.h index 6b59af553..120fabde6 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_draggable.h +++ b/code/ryzom/client/src/interface_v3/ctrl_draggable.h @@ -6,6 +6,8 @@ class CCtrlDraggable : public CCtrlBase { public: + DECLARE_UI_CLASS( CCtrlDraggable ) + CCtrlDraggable( const TCtorParam ¶m ); virtual ~CCtrlDraggable(){}; @@ -21,6 +23,8 @@ public: _LastDraggedSheet = NULL; } + // Necessary because of reflection, no other purpose + void draw(){} REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) REFLECT_BOOL("dragable", isDraggable, setDraggable); diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index da37c6764..dd25f3e28 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -15,8 +15,6 @@ // along with this program. If not, see . -/* -#include "stdpch.h"*/ #include "interface_manager.h" #include "widget_manager.h" #include "ctrl_scroll.h" @@ -33,7 +31,7 @@ NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); // ------------------------------------------------------------------------------------------------ CCtrlScroll::CCtrlScroll(const TCtorParam ¶m) -: CCtrlBase(param) +: CCtrlScrollBase(param) { _Vertical = true; _Aligned = 1; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h index f7aa19b72..e4f1b4db3 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.h @@ -20,7 +20,7 @@ #define RZ_CTRL_SCROLL_H #include "nel/misc/types_nl.h" -#include "ctrl_base.h" +#include "ctrl_scroll_base.h" /** * Class handling scollbar function @@ -28,11 +28,11 @@ * \author Nevrax France * \date 2002 */ -class CCtrlScroll : public CCtrlBase, public NLMISC::ICDBNode::IPropertyObserver +class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver { public: - + DECLARE_UI_CLASS( CCtrlScroll ) CCtrlScroll(const TCtorParam ¶m); ~CCtrlScroll(); @@ -43,9 +43,7 @@ public: virtual void draw(); virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - void setTarget (CInterfaceGroup *pIG); - CInterfaceGroup *getTarget () { return _Target; } // Return the delta value the track has moved sint32 moveTrackX (sint32 dx); sint32 moveTrackY (sint32 dy); @@ -97,7 +95,7 @@ public: void setMax(sint32 max) {_Max = max;} sint32 getMax() const {return _Max;} - REFLECT_EXPORT_START(CCtrlScroll, CCtrlBase) + REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase) REFLECT_LUA_METHOD("setTarget", luaSetTarget) REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible); REFLECT_SINT32("value", getValue, setValue); @@ -159,8 +157,6 @@ protected: sint32 _LastTargetMaxWReal; sint32 _LastTargetOfsX; - CInterfaceGroup *_Target; // If NULL the scroller is a value scroller - bool _Vertical : 1; // true if vertical track bar bool _IsDBLink : 1; bool _ObserverOn : 1; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp new file mode 100644 index 000000000..b0cff5373 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp @@ -0,0 +1,66 @@ +// Ryzom - MMORPG Framework +// 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 "ctrl_scroll_base.h" + +CCtrlScrollBase::CCtrlScrollBase( const TCtorParam ¶m ) : +CCtrlBase( param ) +{ + _Target = NULL; +} + +CCtrlScrollBase::~CCtrlScrollBase() +{ +} + +void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + +sint32 CCtrlScrollBase::moveTrackX( sint32 dx ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; +} + +sint32 CCtrlScrollBase::moveTrackY( sint32 dy ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; +} + +void CCtrlScrollBase::moveTargetX( sint32 dx ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + +void CCtrlScrollBase::moveTargetY( sint32 dy ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h new file mode 100644 index 000000000..43b82c05a --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h @@ -0,0 +1,55 @@ +// Ryzom - MMORPG Framework +// 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 CTRL_SCROLL_BASE_H +#define CTRL_SCROLL_BASE_H + +#include "ctrl_base.h" + +class CInterfaceGroup; + +class CCtrlScrollBase : public CCtrlBase +{ +public: + DECLARE_UI_CLASS( CCtrlScrollBase ) + + CCtrlScrollBase( const TCtorParam ¶m ); + virtual ~CCtrlScrollBase(); + + virtual void setTarget( CInterfaceGroup *pIG ); + CInterfaceGroup* getTarget(){ return _Target; } + virtual sint32 moveTrackX( sint32 dx ); + virtual sint32 moveTrackY( sint32 dy ); + + /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. + * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) + */ + virtual void moveTargetX( sint32 dx ); + virtual void moveTargetY( sint32 dy ); + + + // Necessary because of reflection, no other purpose + void draw(){} + +protected: + CInterfaceGroup *_Target; // If NULL the scroller is a value scroller + +private: + +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index ba59626ed..8050e3872 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -24,7 +24,7 @@ #include "interface_link.h" #include "widget_manager.h" -#include "ctrl_scroll.h" +#include "ctrl_scroll_base.h" #include "group_editbox.h" #include "group_scrolltext.h" #include "lua_ihm_ryzom.h" @@ -203,7 +203,7 @@ bool CInterfaceGroup::moveSBTrackY (CInterfaceGroup *target, sint32 dy) for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { CCtrlBase *pCB = *itc; - CCtrlScroll *pSB = dynamic_cast(pCB); + CCtrlScrollBase *pSB = dynamic_cast(pCB); if (pSB != NULL) { if (pSB->getTarget() == target) @@ -224,7 +224,7 @@ bool CInterfaceGroup::moveSBTargetY(CInterfaceGroup *target,sint32 dy) for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { CCtrlBase *pCB = *itc; - CCtrlScroll *pSB = dynamic_cast(pCB); + CCtrlScrollBase *pSB = dynamic_cast(pCB); if (pSB != NULL) { if (pSB->getTarget() == target) diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index e763f40ee..8848f5c41 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -34,6 +34,7 @@ #include "ctrl_button.h" #include "ctrl_text_button.h" #include "ctrl_col_pick.h" +#include "ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" #include "group_editbox.h" @@ -42,9 +43,9 @@ #include "dbview_bar.h" #include "dbview_bar3.h" #include "group_list.h" +#include "ctrl_scroll_base.h" #include "ctrl_scroll.h" #include "dbgroup_combo_box.h" -#include "ctrl_scroll.h" #include "group_tab.h" #include "group_html.h" #include "group_header.h" @@ -75,7 +76,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CCtrlButton, CCtrlBaseButton); REGISTER_REFLECTABLE_CLASS(CCtrlTextButton, CCtrlBaseButton); REGISTER_REFLECTABLE_CLASS(CCtrlColPick, CCtrlBase); - REGISTER_REFLECTABLE_CLASS(CDBCtrlSheet, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CCtrlDraggable, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CDBCtrlSheet, CCtrlDraggable); REGISTER_REFLECTABLE_CLASS(CInterfaceGroup, CCtrlBase); REGISTER_REFLECTABLE_CLASS(CGroupFrame, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupModal, CGroupFrame); @@ -84,8 +86,9 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(IListSheetBase, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupTree, CInterfaceGroup); - REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup) - REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlScrollBase); REGISTER_REFLECTABLE_CLASS(CGroupMenu, CGroupModal) REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupFrame) REGISTER_REFLECTABLE_CLASS(CGroupTab, CInterfaceGroup) From 617168c3b51f36b96874f15c7b43c555758f8d8a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 03:30:27 +0200 Subject: [PATCH 051/339] CHANGED: #1471 CInterfaceGroup no longer depends on CGroupScrollText. --- code/ryzom/client/src/interface_v3/group_scrolltext.cpp | 3 ++- code/ryzom/client/src/interface_v3/interface_group.cpp | 6 ++---- code/ryzom/client/src/interface_v3/interface_group.h | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index f9ddd85fd..2a0885133 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -43,8 +43,9 @@ CGroupScrollText::CGroupScrollText(const TCtorParam ¶m) : _InvertScrollBar(true), _ListHeight(0), _StartHeight(0), - _EllapsedTime(0) + _EllapsedTime(0) { + _IsGroupScrollText = true; } //======================================================================== diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 8050e3872..83cb0ca35 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -23,10 +23,7 @@ #include "interface_group.h" #include "interface_link.h" #include "widget_manager.h" - #include "ctrl_scroll_base.h" -#include "group_editbox.h" -#include "group_scrolltext.h" #include "lua_ihm_ryzom.h" using namespace std; @@ -57,6 +54,7 @@ CInterfaceGroup::CInterfaceGroup(const TCtorParam ¶m) : CCtrlBase(param) _Priority= WIN_PRIORITY_NORMAL; _UseCursor = true; _IsGroupContainer = false; + _IsGroupScrollText = false; _AHOnActive = NULL; _AHOnDeactive = NULL; _AHOnLeftClick = NULL; @@ -973,7 +971,7 @@ void CInterfaceGroup::evalChildrenBBox(bool resizeFromChildW, bool resizeFromChi // If it is a group, minimize with MaxHReal / MaxWReal const CInterfaceGroup *sonGroup= dynamic_cast(pIE); // \todo yoyo: do not know why but don't work if this==scroll_text - if(sonGroup && !dynamic_cast(this)) + if(sonGroup && !isGroupScrollText()) { sint32 oldSciX= -16384; sint32 oldSciY= -16384; diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index d2a93f49c..3b3a59e84 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -248,6 +248,7 @@ public: // quick way to know if the group is a CGroupContainer bool isGroupContainer() const { return _IsGroupContainer; } + bool isGroupScrollText() const{ return _IsGroupScrollText; } CInterfaceGroup* getEnclosingContainer(); @@ -345,6 +346,7 @@ protected: bool _Escapable : 1; bool _UseCursor : 1; bool _IsGroupContainer : 1; // faster than a virual call + bool _IsGroupScrollText : 1; bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene sint32 _ResizeFromChildWMargin; sint32 _ResizeFromChildHMargin; From 737f4f59d6e851eba41a48428cba0485711c29cc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 05:11:14 +0200 Subject: [PATCH 052/339] CHANGED: #1471 CWidgetManager no longer depends on CGroupEditBox, it depends on a new class CGroupEditBoxBase instead. --- .../src/interface_v3/action_handler_edit.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 4 +- .../client/src/interface_v3/group_editbox.h | 27 ++------ .../src/interface_v3/group_editbox_base.cpp | 14 ++++ .../src/interface_v3/group_editbox_base.h | 64 +++++++++++++++++++ .../register_interface_elements.cpp | 4 +- .../src/interface_v3/widget_manager.cpp | 9 +-- 7 files changed, 93 insertions(+), 31 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/group_editbox_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/group_editbox_base.h diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index 8ae94c30f..d16df8fa4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -145,7 +145,7 @@ protected: if (_GroupEdit) { // If selection active - CGroupEditBox *currSelection = CGroupEditBox::getCurrSelection(); + CGroupEditBox *currSelection = dynamic_cast< CGroupEditBox* >( CGroupEditBox::getCurrSelection() ); if (currSelection != NULL) { if (currSelection != _GroupEdit) diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index de6f83e3a..83ca1231f 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -40,7 +40,6 @@ using namespace NL3D; ///////////// sint32 CGroupEditBox::_SelectCursorPos = 0; -CGroupEditBox *CGroupEditBox::_CurrSelection = NULL; CGroupEditBox *CGroupEditBox::_MenuFather = NULL; @@ -48,7 +47,7 @@ CGroupEditBox *CGroupEditBox::_MenuFather = NULL; NLMISC_REGISTER_OBJECT(CViewBase, CGroupEditBox, std::string, "edit_box"); CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : - CInterfaceGroup(param), + CGroupEditBoxBase(param), _BlinkTime(0.f), _CursorPos(0), _MaxNumChar(std::numeric_limits::max()), @@ -68,7 +67,6 @@ CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : _BlinkState(false), _CursorAtPreviousLineEnd(false), _LooseFocusOnEnter(true), - _RecoverFocusOnEnter(true), _ResetFocusOnHide(false), _BackupFatherContainerPos(false), _WantReturn(false), diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index e86e2bdcd..e892b134a 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -20,6 +20,7 @@ #define RZ_CTRL_EDITBOX_H #include "interface_group.h" +#include "group_editbox_base.h" #include "nel/3d/u_texture.h" namespace NLGUI @@ -27,12 +28,14 @@ namespace NLGUI class CEventDescriptor; } class CViewText; + // ---------------------------------------------------------------------------- -class CGroupEditBox : public CInterfaceGroup +class CGroupEditBox : public CGroupEditBoxBase { public: enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with public: + DECLARE_UI_CLASS( CGroupEditBox ) /// Constructor CGroupEditBox(const TCtorParam ¶m); /// Dtor @@ -71,8 +74,6 @@ public: /// force the selection of all the text void setSelectionAll(); - // disable any current selection - static void disableSelection() { _CurrSelection = NULL; } virtual void checkCoords(); virtual void updateCoords(); @@ -99,10 +100,6 @@ public: static sint32 getSelectCursorPos () {return _SelectCursorPos;} static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;} - // Get / set current selection - static CGroupEditBox *getCurrSelection () {return _CurrSelection;} - static void setCurrSelection (CGroupEditBox *selection) {_CurrSelection=selection;} - // Get the view text const CViewText *getViewText () const {return _ViewText;} @@ -141,9 +138,6 @@ public: // True if the editBox loose the focus on enter bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;} - // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus - bool getRecoverFocusOnEnter() const {return _RecoverFocusOnEnter;} - void setRecoverFocusOnEnter(bool state) {_RecoverFocusOnEnter= state;} // virtual void clearAllEditBox(); // From CInterfaceElement @@ -161,10 +155,6 @@ public: // from CCtrlBase virtual void onKeyboardCaptureLost(); - std::string getAHOnFocus() { return _AHOnFocus; } - std::string getAHOnFocusParams() { return _AHOnFocusParams; } - - // set the input string as "default". will be reseted at first click (used for user information) void setDefaultInputString(const ucstring &str); @@ -180,14 +170,13 @@ public: int luaSetupDisplayText(CLuaState &ls); int luaSetFocusOnText(CLuaState &ls); int luaCancelFocusOnText(CLuaState &ls); - REFLECT_EXPORT_START(CGroupEditBox, CInterfaceGroup) + REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase) REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText); REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); - REFLECT_BOOL("enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter); REFLECT_EXPORT_END /** Restore the original value of the edit box. @@ -220,7 +209,6 @@ protected: // Text selection static sint32 _SelectCursorPos; - static CGroupEditBox *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none bool _SelectingText; NLMISC::CRGBA _TextSelectColor; NLMISC::CRGBA _BackSelectColor; @@ -249,10 +237,6 @@ protected: std::string _AHOnFocusLost; std::string _AHOnFocusLostParams; - std::string _AHOnFocus; - std::string _AHOnFocusParams; - - // entry type TEntryType _EntryType; @@ -263,7 +247,6 @@ protected: bool _BlinkState : 1; bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines) bool _LooseFocusOnEnter : 1; - bool _RecoverFocusOnEnter : 1; bool _ResetFocusOnHide : 1; bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed. // If the edit box is at the bottom of the screen and if it expands on y diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.cpp b/code/ryzom/client/src/interface_v3/group_editbox_base.cpp new file mode 100644 index 000000000..a7c968f97 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_editbox_base.cpp @@ -0,0 +1,14 @@ +#include "group_editbox_base.h" + +CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; + +CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam ¶m ) : +CInterfaceGroup( param ) +{ + _RecoverFocusOnEnter = true; +} + +CGroupEditBoxBase::~CGroupEditBoxBase() +{ +} + diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.h b/code/ryzom/client/src/interface_v3/group_editbox_base.h new file mode 100644 index 000000000..77aed7b08 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_editbox_base.h @@ -0,0 +1,64 @@ +// Ryzom - MMORPG Framework +// 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_BASE_H +#define GROUP_EDITBOX_BASE_H + +#include "interface_group.h" + +class CGroupEditBoxBase : public CInterfaceGroup +{ +public: + DECLARE_UI_CLASS( CGroupEditBoxBase ) + + CGroupEditBoxBase( const TCtorParam ¶m ); + ~CGroupEditBoxBase(); + + // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus + bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; } + void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; } + + std::string getAHOnFocus(){ return _AHOnFocus; } + std::string getAHOnFocusParams(){ return _AHOnFocusParams; } + + // disable any current selection + static void disableSelection(){ _CurrSelection = NULL; } + + // Get / set current selection + static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; } + static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; } + + void draw(){} + + REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup ) + REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter ); + REFLECT_EXPORT_END + +protected: + bool _RecoverFocusOnEnter : 1; + + std::string _AHOnFocus; + std::string _AHOnFocusParams; + + static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none + +private: + +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 8848f5c41..df6c77974 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -37,6 +37,7 @@ #include "ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" +#include "group_editbox_base.h" #include "group_editbox.h" #include "group_tree.h" #include "nel/gui/reflect.h" @@ -84,7 +85,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CGroupContainer, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CDBGroupSelectNumber, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(IListSheetBase, CInterfaceGroup); - REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupEditBoxBase, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CGroupEditBoxBase); REGISTER_REFLECTABLE_CLASS(CGroupTree, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase); diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 1c7da44b2..083e9c355 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -19,7 +19,8 @@ #include "group_container.h" #include "group_in_scene.h" #include "view_pointer.h" -#include "group_editbox.h" + +#include "group_editbox_base.h" #include "ctrl_draggable.h" CWidgetManager* CWidgetManager::instance = NULL; @@ -1127,8 +1128,8 @@ void CWidgetManager::setCapturePointerRight(CCtrlBase *c) // ------------------------------------------------------------------------------------------------ void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) { - CGroupEditBox *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); - CGroupEditBox *newEb= dynamic_cast(c); + CGroupEditBoxBase *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); + CGroupEditBoxBase *newEb= dynamic_cast(c); if (_CaptureKeyboard && _CaptureKeyboard != c) { @@ -1141,7 +1142,7 @@ void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) } if ( newEb ) { - CGroupEditBox::disableSelection(); + CGroupEditBoxBase::disableSelection(); if (!newEb->getAHOnFocus().empty()) { From d9e1fcad72701e473fe1a34c6310b0045f02f6ca Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 23:57:02 +0200 Subject: [PATCH 053/339] CHANGED: #1471 CWidgetManager no longer depends on CViewPointer. Instead it depends on the new class CViewPointerBase. --- code/ryzom/client/src/contextual_cursor.cpp | 2 +- code/ryzom/client/src/cursor_functions.cpp | 2 +- code/ryzom/client/src/input.cpp | 12 +- .../src/interface_v3/group_container.cpp | 4 +- .../interface_v3/input_handler_manager.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/view_bitmap_combo.cpp | 6 +- .../client/src/interface_v3/view_pointer.cpp | 113 +--------------- .../client/src/interface_v3/view_pointer.h | 37 +----- .../src/interface_v3/view_pointer_base.cpp | 122 ++++++++++++++++++ .../src/interface_v3/view_pointer_base.h | 55 ++++++++ .../src/interface_v3/widget_manager.cpp | 2 +- .../client/src/interface_v3/widget_manager.h | 8 +- code/ryzom/client/src/main_loop.cpp | 2 +- .../ryzom/client/src/motion/modes/ai_mode.cpp | 2 +- .../ryzom/client/src/motion/user_controls.cpp | 4 +- code/ryzom/client/src/r2/tool.cpp | 4 +- 17 files changed, 207 insertions(+), 172 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/view_pointer_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/view_pointer_base.h diff --git a/code/ryzom/client/src/contextual_cursor.cpp b/code/ryzom/client/src/contextual_cursor.cpp index ded0866e6..f19958ead 100644 --- a/code/ryzom/client/src/contextual_cursor.cpp +++ b/code/ryzom/client/src/contextual_cursor.cpp @@ -143,7 +143,7 @@ bool CContextualCursor::context(const std::string &contextName, float dist, cons CInterfaceManager *IM = CInterfaceManager::getInstance(); if(IM) { - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { if (!functions.isString) diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 10942ef3c..7ded55f53 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -239,7 +239,7 @@ void checkUnderCursor() return; // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor == 0) return; diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index 3d67c2455..6427529f8 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -124,7 +124,7 @@ bool InitMouseWithCursor (bool hardware) { Driver->showCursor(true); - CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); + CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (pointer) { float x = (float)pointer->getX()/(float)Driver->getWindowWidth(); @@ -145,7 +145,7 @@ bool InitMouseWithCursor (bool hardware) else { CInterfaceManager *pIm = CInterfaceManager::getInstance(); - CViewPointer *vp = CWidgetManager::getInstance()->getPointer(); + CViewPointer *vp = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); Driver->showCursor(false); SetMousePosFirstTime = false; if (vp) @@ -247,7 +247,7 @@ void SetMouseFreeLook () CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); + CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (pointer) pointer->show (false); } @@ -281,7 +281,7 @@ void SetMouseCursor (bool updatePos) if (instance) { // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (cursor) { sint32 ix, iy; @@ -319,7 +319,7 @@ void SetMouseCursor (bool updatePos) if (instance) { // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (cursor) { cursor->setPointerPos(ix, iy); @@ -342,7 +342,7 @@ void SetMouseCursor (bool updatePos) CInterfaceManager *im = CInterfaceManager::getInstance(); if (im) { - CViewPointer *pointer = CWidgetManager::getInstance()->getPointer(); + CViewPointer *pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (pointer) pointer->show (true); } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 6f48f5598..989275c2f 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -2194,7 +2194,7 @@ void CGroupContainer::draw () // manage rollover - CViewPointer *mousePointer = CWidgetManager::getInstance()->getPointer(); + CViewPointer *mousePointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if (mousePointer) { bool dontFade = false; @@ -3641,7 +3641,7 @@ void CGroupContainer::setOpenable(bool openable) void CGroupContainer::rollOverAlphaUp() { CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewPointer *vp = CWidgetManager::getInstance()->getPointer(); + CViewPointer *vp = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); float speed = im->getAlphaRolloverSpeed(); if (!isIn(vp->getX(), vp->getY())) { diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 9208f9472..6074f98e5 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -268,7 +268,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) { - CViewPointer &rIP = *CWidgetManager::getInstance()->getPointer(); + CViewPointer &rIP = *static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); NLGUI::CEventDescriptorMouse eventDesc; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 631dea206..961660c13 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2481,7 +2481,7 @@ uint CInterfaceManager::getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentW bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) { bool handled= false; - CViewPointer *_Pointer = CWidgetManager::getInstance()->getPointer(); + CViewPointer *_Pointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if( event.getType() == NLGUI::CEventDescriptor::system ) { diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index 45510d662..34aebfaf8 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -361,7 +361,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh) { overItem = true; - if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, texIndex); color = getCol(_ColPushed, texIndex); @@ -416,7 +416,7 @@ void CViewBitmapCombo::draw() // if (_CD.Unrolled.getBool()) { - if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + if (overItem && static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsId, selectedTexIndex); color = getCol(_Col, selectedTexIndex); @@ -436,7 +436,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh ) { - if (CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, selectedTexIndex); color = getCol(_ColPushed, selectedTexIndex); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index c6065f321..27966ffc3 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -16,10 +16,7 @@ -#include "stdpch.h" - #include "../input.h" -// #include "view_pointer.h" #include "interface_manager.h" #include "nel/gui/view_renderer.h" @@ -45,12 +42,9 @@ NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "pointer"); // -------------------------------------------------------------------------------------------------------------------- CViewPointer::CViewPointer (const TCtorParam ¶m) - : CViewBase(param), + : CViewPointerBase(param), _Buttons(NLMISC::noButton) { - _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; - _PointerDown = false; - _PointerVisible = true; _TxIdDefault = -2; _TxIdMoveWindow = -2; _TxIdResizeBRTL = -2; @@ -608,111 +602,6 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) // +++ SET +++ -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setPointerPos (sint32 x, sint32 y) -{ - if (_PointerDown) - { - if (!_PointerDrag) - { - if (((_PointerX - _PointerDownX) != 0) || - ((_PointerY - _PointerDownY) != 0)) - { - _PointerDrag = true; - } - } - } - - _PointerOldX = getX(); - _PointerOldY = getY(); - - _PointerX = x; - _PointerY = y; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setPointerDispPos (sint32 x, sint32 y) -{ - setX (x); - setY (y); - updateCoords (); -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::resetPointerPos () -{ - _PointerOldX = _PointerX; - _PointerOldY = _PointerY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setPointerDown (bool pd) -{ - _PointerDown = pd; - - if (_PointerDown == true) - { - _PointerDownX = _PointerX; - _PointerDownY = _PointerY; - } - - if (_PointerDown == false) - _PointerDrag = false; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setPointerDownString (const std::string &s) -{ - _PointerDownString = s; -} - -// +++ GET +++ - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::getPointerPos (sint32 &x, sint32 &y) -{ - x = _PointerX; - y = _PointerY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::getPointerDispPos (sint32 &x, sint32 &y) -{ - x = getX(); - y = getY(); -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::getPointerOldPos (sint32 &x, sint32 &y) -{ - x = _PointerOldX; - y = _PointerOldY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::getPointerDownPos (sint32 &x, sint32 &y) -{ - x = _PointerDownX; - y = _PointerDownY; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::getPointerDown () -{ - return _PointerDown; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::getPointerDrag () -{ - return _PointerDrag; -} - -// -------------------------------------------------------------------------------------------------------------------- -std::string CViewPointer::getPointerDownString () -{ - return _PointerDownString; -} // -------------------------------------------------------------------------------------------------------------------- void CViewPointer::setStringMode (bool stringCursor) diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index 42a20b0a0..8002f5e9d 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/events.h" -#include "view_base.h" +#include "view_pointer_base.h" class CGroupContainer; class CCtrlBase; @@ -33,35 +33,16 @@ class CCtrlBase; * \date 2002 */ -class CViewPointer : public CViewBase +class CViewPointer : public CViewPointerBase { friend void SetMouseFreeLook (); friend void SetMouseCursor (bool updateMousePos); public: + DECLARE_UI_CLASS( CViewPointerBase ) CViewPointer (const TCtorParam ¶m); bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); void draw (); - // Set the pointer position. - void setPointerPos (sint32 x, sint32 y); - void setPointerDispPos (sint32 x, sint32 y); - - void resetPointerPos (); - void setPointerDown (bool pd); - void setPointerDownString (const std::string &s); - - void getPointerPos (sint32 &x, sint32 &y); - void getPointerDispPos (sint32 &x, sint32 &y); - - void getPointerOldPos (sint32 &x, sint32 &y); - void getPointerDownPos (sint32 &x, sint32 &y); - bool getPointerDown (); - std::string getPointerDownString (); - bool getPointerDrag (); - - /// Is the pointer visible ? - bool show() const {return _PointerVisible;} - // Set cursor mode void setStringMode (bool stringCursor); bool getStringMode() const {return _StringMode;} @@ -135,18 +116,6 @@ private: sint32 _OffsetX; sint32 _OffsetY; - // (x,y) is from the TopLeft corner of the window - sint32 _PointerX; // Current pointer position (raw, before snapping) - sint32 _PointerY; - sint32 _PointerOldX; // Previous frame pointer position - sint32 _PointerOldY; - bool _PointerDown; // Is the pointer down ? - sint32 _PointerDownX; // Pointer down position - sint32 _PointerDownY; - std::string _PointerDownString; // What is under the pointer at the down position - bool _PointerDrag; // Is the pointer down and we have moved ? - bool _PointerVisible; // Is the pointer visible or hidden ? - NLMISC::TMouseButton _Buttons; CGroupContainer *_LastHightLight; diff --git a/code/ryzom/client/src/interface_v3/view_pointer_base.cpp b/code/ryzom/client/src/interface_v3/view_pointer_base.cpp new file mode 100644 index 000000000..e4b124dc3 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/view_pointer_base.cpp @@ -0,0 +1,122 @@ +#include "view_pointer_base.h" + +CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) : +CViewBase( param ) +{ + _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; + _PointerDown = false; + _PointerVisible = true; +} + +CViewPointerBase::~CViewPointerBase() +{ +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::setPointerPos (sint32 x, sint32 y) +{ + if (_PointerDown) + { + if (!_PointerDrag) + { + if (((_PointerX - _PointerDownX) != 0) || + ((_PointerY - _PointerDownY) != 0)) + { + _PointerDrag = true; + } + } + } + + _PointerOldX = getX(); + _PointerOldY = getY(); + + _PointerX = x; + _PointerY = y; +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y) +{ + setX (x); + setY (y); + updateCoords (); +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::resetPointerPos () +{ + _PointerOldX = _PointerX; + _PointerOldY = _PointerY; +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::setPointerDown (bool pd) +{ + _PointerDown = pd; + + if (_PointerDown == true) + { + _PointerDownX = _PointerX; + _PointerDownY = _PointerY; + } + + if (_PointerDown == false) + _PointerDrag = false; +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::setPointerDownString (const std::string &s) +{ + _PointerDownString = s; +} + +// +++ GET +++ + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y) +{ + x = _PointerX; + y = _PointerY; +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y) +{ + x = getX(); + y = getY(); +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y) +{ + x = _PointerOldX; + y = _PointerOldY; +} + +// -------------------------------------------------------------------------------------------------------------------- +void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) +{ + x = _PointerDownX; + y = _PointerDownY; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerBase::getPointerDown () +{ + return _PointerDown; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerBase::getPointerDrag () +{ + return _PointerDrag; +} + +// -------------------------------------------------------------------------------------------------------------------- +std::string CViewPointerBase::getPointerDownString () +{ + return _PointerDownString; +} + + + diff --git a/code/ryzom/client/src/interface_v3/view_pointer_base.h b/code/ryzom/client/src/interface_v3/view_pointer_base.h new file mode 100644 index 000000000..388180804 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/view_pointer_base.h @@ -0,0 +1,55 @@ +#ifndef VIEW_POINTER_BASE_H +#define VIEW_POINTER_BASE_H + +#include "view_base.h" + +class CViewPointerBase : public CViewBase +{ +public: + DECLARE_UI_CLASS( CViewPointerBase ) + + CViewPointerBase( const TCtorParam ¶m ); + virtual ~CViewPointerBase(); + + // Set the pointer position. + void setPointerPos (sint32 x, sint32 y); + void setPointerDispPos (sint32 x, sint32 y); + + void resetPointerPos (); + void setPointerDown (bool pd); + void setPointerDownString (const std::string &s); + + void getPointerPos (sint32 &x, sint32 &y); + void getPointerDispPos (sint32 &x, sint32 &y); + + void getPointerOldPos (sint32 &x, sint32 &y); + void getPointerDownPos (sint32 &x, sint32 &y); + bool getPointerDown (); + std::string getPointerDownString (); + bool getPointerDrag (); + + /// Is the pointer visible ? + bool show() const {return _PointerVisible;} + + void draw(){} + +protected: + // (x,y) is from the TopLeft corner of the window + sint32 _PointerX; // Current pointer position (raw, before snapping) + sint32 _PointerY; + sint32 _PointerOldX; // Previous frame pointer position + sint32 _PointerOldY; + bool _PointerDown; // Is the pointer down ? + sint32 _PointerDownX; // Pointer down position + sint32 _PointerDownY; + std::string _PointerDownString; // What is under the pointer at the down position + bool _PointerDrag; // Is the pointer down and we have moved ? + bool _PointerVisible; // Is the pointer visible or hidden ? + +private: + + +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 083e9c355..24ab84f42 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -18,7 +18,7 @@ #include "interface_group.h" #include "group_container.h" #include "group_in_scene.h" -#include "view_pointer.h" +#include "view_pointer_base.h" #include "group_editbox_base.h" #include "ctrl_draggable.h" diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index ba7cdbf6a..998709032 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -27,7 +27,7 @@ class CInterfaceElement; class CCtrlBase; class CViewBase; class CInterfaceGroup; -class CViewPointer; +class CViewPointerBase; class IParser { @@ -184,8 +184,8 @@ public: float _DeltaTimeStopingContextHelp; - CViewPointer* getPointer(){ return _Pointer; } - void setPointer( CViewPointer *pointer ){ _Pointer = pointer; } + CViewPointerBase* getPointer(){ return _Pointer; } + void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; } /** * get the window under a spot @@ -278,7 +278,7 @@ private: std::vector< SModalWndInfo > _ModalStack; static std::string _CtrlLaunchingModalId; NLMISC::CRefPtr< CCtrlBase > curContextHelp; - CViewPointer *_Pointer; + CViewPointerBase *_Pointer; NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder; diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 26329c055..d3cee7381 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1738,7 +1738,7 @@ bool mainLoop() if(!CViewRenderer::getInstance()->isMinimized()) { // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { // Get the pointer position (in pixel) diff --git a/code/ryzom/client/src/motion/modes/ai_mode.cpp b/code/ryzom/client/src/motion/modes/ai_mode.cpp index 775aff68c..1f5caafab 100644 --- a/code/ryzom/client/src/motion/modes/ai_mode.cpp +++ b/code/ryzom/client/src/motion/modes/ai_mode.cpp @@ -150,7 +150,7 @@ void CUserControls::aiMode() IM->enableMouseHandling(false); EventsListener.enableMouseSmoothing(true); // Get the cursor instance and hide. - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { // Freelook mode. diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index 4697a0d5e..6c7d5027a 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -507,7 +507,7 @@ void CUserControls::freeLook(bool fullMode) // disable interface mouse handling. IM->enableMouseHandling(false); // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { // Hide the Cursor. @@ -590,7 +590,7 @@ void CUserControls::cameraLook(bool fullMode) // disable interface mouse handling. IM->enableMouseHandling(false); // Get the cursor instance - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { // Hide the Cursor. diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index 23706d9f2..9b80311f5 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -155,7 +155,7 @@ uint32 CTool::getScreenHeight() void CTool::getMousePos(sint32 &x, sint32 &y) { //H_AUTO(R2_CTool_getMousePos) - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor == NULL) { x = y = -1; @@ -753,7 +753,7 @@ bool CTool::isMouseCaptured() void CTool::setMouseCursor(const char *cursorTexture) { //H_AUTO(R2_CTool_setMouseCursor) - CViewPointer *cursor = CWidgetManager::getInstance()->getPointer(); + CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) { cursor->setCursor(cursorTexture); From 9f09f4d08005a0b92e8dd0b1f4231bf76d3d7830 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 8 Jun 2012 00:28:47 +0200 Subject: [PATCH 054/339] CHANGED: #1471 CWidgetManager no longer depends on CGroupInScene. --- code/ryzom/client/src/interface_v3/group_in_scene.cpp | 2 +- code/ryzom/client/src/interface_v3/group_in_scene.h | 6 ------ code/ryzom/client/src/interface_v3/group_modal.cpp | 2 -- code/ryzom/client/src/interface_v3/interface_group.cpp | 2 ++ code/ryzom/client/src/interface_v3/interface_group.h | 8 ++++++++ code/ryzom/client/src/interface_v3/widget_manager.cpp | 9 +++++---- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.cpp b/code/ryzom/client/src/interface_v3/group_in_scene.cpp index 2e468acd9..9970d6227 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene.cpp @@ -59,7 +59,7 @@ CGroupInScene::CGroupInScene(const TCtorParam ¶m) Position= CVector::Null; _ProjCenter= CVector::Null; - _DepthForZSort= 0.f; + _IsGroupInScene = true; } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.h b/code/ryzom/client/src/interface_v3/group_in_scene.h index 76c0f03e7..ad2139d98 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene.h @@ -66,9 +66,6 @@ public: sint32 getOffsetY() const { return _OffsetY; } void setOffsetY(sint32 dmh) { _OffsetY = dmh; } - // Return the current Depth, with no ZBias applied. - float getDepthForZSort() const { return _DepthForZSort; } - // set/return the ZBias for this group in scene (default 0) void setZBias(float zbias) {_ZBias= zbias;} float getZBias() const {return _ZBias;} @@ -80,9 +77,6 @@ protected: // Projected Position memorized. x/y is in window coordinate, while z in is world/camera coordinate NLMISC::CVector _ProjCenter; - // Projected Depth with no ZBias applied - float _DepthForZSort; - // Offset sint32 _OffsetX, _OffsetY; diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/ryzom/client/src/interface_v3/group_modal.cpp index 78aad5ed4..611544b01 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal.cpp @@ -16,8 +16,6 @@ -#include "stdpch.h" - #include "group_modal.h" #include "interface_manager.h" #include "interface_element.h" diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index 83cb0ca35..bb0b0bbbf 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -55,6 +55,7 @@ CInterfaceGroup::CInterfaceGroup(const TCtorParam ¶m) : CCtrlBase(param) _UseCursor = true; _IsGroupContainer = false; _IsGroupScrollText = false; + _IsGroupInScene = false; _AHOnActive = NULL; _AHOnDeactive = NULL; _AHOnLeftClick = NULL; @@ -63,6 +64,7 @@ CInterfaceGroup::CInterfaceGroup(const TCtorParam ¶m) : CCtrlBase(param) _AHOnEscape = NULL; _NeedFrameUpdatePos= false; _LUAEnvTableCreated= false; + _DepthForZSort= 0.f; #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS CInterfaceManager::getInstance()->DebugTrackGroupsCreated( this ); diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/ryzom/client/src/interface_v3/interface_group.h index 3b3a59e84..5e1b1f716 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/ryzom/client/src/interface_v3/interface_group.h @@ -249,6 +249,7 @@ public: // quick way to know if the group is a CGroupContainer bool isGroupContainer() const { return _IsGroupContainer; } bool isGroupScrollText() const{ return _IsGroupScrollText; } + bool isGroupInScene() const{ return _IsGroupInScene; } CInterfaceGroup* getEnclosingContainer(); @@ -305,6 +306,9 @@ public: virtual CInterfaceElement *clone(); virtual void serial(NLMISC::IStream &f); + // Return the current Depth, with no ZBias applied. + float getDepthForZSort() const { return _DepthForZSort; } + protected: void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH); @@ -347,11 +351,15 @@ protected: bool _UseCursor : 1; bool _IsGroupContainer : 1; // faster than a virual call bool _IsGroupScrollText : 1; + bool _IsGroupInScene : 1; bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene sint32 _ResizeFromChildWMargin; sint32 _ResizeFromChildHMargin; sint32 _GroupSizeRef; + // Projected Depth with no ZBias applied + float _DepthForZSort; + // handler for activation IActionHandler *_AHOnActive; CStringShared _AHOnActiveParams; diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 24ab84f42..01b10580b 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -17,9 +17,10 @@ #include "widget_manager.h" #include "interface_group.h" #include "group_container.h" -#include "group_in_scene.h" -#include "view_pointer_base.h" +#include "group_modal.h" +#include "nel/gui/view_renderer.h" +#include "view_pointer_base.h" #include "group_editbox_base.h" #include "ctrl_draggable.h" @@ -38,7 +39,7 @@ void CWidgetManager::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio) // Priority WIN_PRIORITY_WORLD_SPACE is only for CGroupInScene ! // Add this group in another priority list - nlassert ((nPrio!=WIN_PRIORITY_MAX) || (dynamic_cast(pIG)!=NULL)); + nlassert ((nPrio!=WIN_PRIORITY_MAX) || pIG->isGroupInScene() ); for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { @@ -239,7 +240,7 @@ void CWidgetManager::SMasterGroup::sortWorldSpaceGroup () sortTable.push_back (CElementToSort ()); CElementToSort &elm = sortTable.back(); elm.pIG = *it; - elm.Distance = (static_cast(*it))->getDepthForZSort(); + elm.Distance = (*it)->getDepthForZSort(); it++; } From 7e19a57ae55b9dbe429fc362d743957a99fa7023 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 8 Jun 2012 02:43:20 +0200 Subject: [PATCH 055/339] CHANGED: #1471 Broke up CInterfaceOptions to two files, moved the options from CInterfaceParser to CWidgetManager, CGroupFrame no longer depends on CInterfaceManager. --- .../client/src/interface_v3/character_3d.cpp | 2 +- .../client/src/interface_v3/character_3d.h | 1 + .../client/src/interface_v3/ctrl_button.cpp | 2 +- .../client/src/interface_v3/ctrl_col_pick.cpp | 2 +- .../client/src/interface_v3/ctrl_polygon.cpp | 4 +- .../client/src/interface_v3/ctrl_quad.cpp | 4 +- .../client/src/interface_v3/ctrl_scroll.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 18 +- .../client/src/interface_v3/dbview_bar.cpp | 2 +- .../client/src/interface_v3/dbview_bar3.cpp | 2 +- .../src/interface_v3/group_container.cpp | 27 +- .../client/src/interface_v3/group_editbox.cpp | 4 +- .../client/src/interface_v3/group_frame.cpp | 14 +- .../client/src/interface_v3/group_list.cpp | 4 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../client/src/interface_v3/group_menu.cpp | 4 +- .../client/src/interface_v3/group_modal.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 4 +- .../client/src/interface_v3/group_table.cpp | 4 +- .../client/src/interface_v3/group_tree.cpp | 10 +- .../interface_expr_user_fct_game.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 79 +--- .../src/interface_v3/interface_manager.h | 16 +- .../src/interface_v3/interface_options.cpp | 386 +---------------- .../src/interface_v3/interface_options.h | 155 ------- .../interface_v3/interface_options_ryzom.cpp | 407 ++++++++++++++++++ .../interface_v3/interface_options_ryzom.h | 178 ++++++++ .../src/interface_v3/interface_parser.cpp | 21 +- .../src/interface_v3/interface_parser.h | 4 - .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../src/interface_v3/task_bar_manager.cpp | 4 +- .../client/src/interface_v3/view_bitmap.cpp | 4 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_polygon.cpp | 4 +- .../client/src/interface_v3/view_quad.cpp | 4 +- .../client/src/interface_v3/view_radar.cpp | 4 +- .../client/src/interface_v3/view_text.cpp | 6 +- .../src/interface_v3/widget_manager.cpp | 75 +++- .../client/src/interface_v3/widget_manager.h | 34 ++ 40 files changed, 795 insertions(+), 708 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp create mode 100644 code/ryzom/client/src/interface_v3/interface_options_ryzom.h diff --git a/code/ryzom/client/src/interface_v3/character_3d.cpp b/code/ryzom/client/src/interface_v3/character_3d.cpp index 2f9d71b40..dd3a5b22e 100644 --- a/code/ryzom/client/src/interface_v3/character_3d.cpp +++ b/code/ryzom/client/src/interface_v3/character_3d.cpp @@ -630,7 +630,7 @@ bool CCharacter3D::init (UScene *pScene) // ANIMATIONS CInterfaceManager *pIM = CInterfaceManager::getInstance(); - COptionsAnimationSet *pOAS= dynamic_cast(pIM->getOptions("character_animations")); + COptionsAnimationSet *pOAS= dynamic_cast(CWidgetManager::getInstance()->getOptions("character_animations")); if(!pOAS || !pOAS->AnimationSet) { nlwarning("Not found 'character_animations', or not of type 'animation_set'"); diff --git a/code/ryzom/client/src/interface_v3/character_3d.h b/code/ryzom/client/src/interface_v3/character_3d.h index e7b189fb6..d5cc5d8b0 100644 --- a/code/ryzom/client/src/interface_v3/character_3d.h +++ b/code/ryzom/client/src/interface_v3/character_3d.h @@ -24,6 +24,7 @@ #include "game_share/slot_types.h" #include "nel/3d/u_skeleton.h" #include "interface_options.h" +#include "interface_options_ryzom.h" #include "interface_element.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index 0dde15dc7..ec8db869d 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -108,7 +108,7 @@ void CCtrlButton::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA globalColor= pIM->getGlobalColorForContent(); + CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); // *** Detect Over bool lastOver = false; diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp index eb886c15d..b39c381a7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp @@ -98,7 +98,7 @@ void CCtrlColPick::draw() CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = CRGBA(255,255,255,(uint8)pIM->getGlobalColor().A); + CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp index bf404259b..1b28fea13 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp @@ -250,12 +250,12 @@ void CCtrlPolygon::draw() CRGBA col; if(getModulateGlobalColor()) { - col.modulateFromColor (_Color, im->getGlobalColorForContent()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)im->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); } diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp index 75886ef82..5269eaaf4 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp @@ -66,12 +66,12 @@ void CCtrlQuad::draw() CRGBA col; if(getModulateGlobalColor()) { - col.modulateFromColor (_Color, pIM->getGlobalColorForContent()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } /*if (_InheritGCAlpha) diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index dd25f3e28..58d099712 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -405,7 +405,7 @@ void CCtrlScroll::updateCoords() void CCtrlScroll::draw() { CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = CInterfaceManager::getInstance()->getGlobalColorForContent(); + CRGBA col = CWidgetManager::getInstance()->getGlobalColorForContent(); if (_Target) { diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index d3067a81c..3e2fd0a92 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -274,7 +274,7 @@ void CCtrlTextButton::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA globalColor= pIM->getGlobalColorForContent(); + CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); // *** Detect Over bool lastOver = false; diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 74a5bb132..7159c3987 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -1852,7 +1852,7 @@ void CDBCtrlSheet::draw() // Display slot if (_DrawSlot) - rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, 0, false, _DispSlotBmpId, pIM->getGlobalColorForContent()); + rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, 0, false, _DispSlotBmpId, CWidgetManager::getInstance()->getGlobalColorForContent()); // Drag'N'Drop : display the selected slot bitmap if this slot accept the currently dragged element _CanDrop = false; @@ -1893,7 +1893,7 @@ void CDBCtrlSheet::draw() if (_CanDrop) { // decal layer because must drawn after Items/Brick in DXTC - rVR.draw11RotFlipBitmap (_RenderLayer+1, _XReal, _YReal, 0, false, _DispSelSlotId, pIM->getGlobalColorForContent()); + rVR.draw11RotFlipBitmap (_RenderLayer+1, _XReal, _YReal, 0, false, _DispSelSlotId, CWidgetManager::getInstance()->getGlobalColorForContent()); } if (_RegenTickRange.EndTick != _RegenTickRange.StartTick) @@ -2099,13 +2099,13 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti // the sheet color is modulated by GlobalAlpha, but not by global RGB CRGBA curSheetColor= _SheetColor; - curSheetColor.A= ( (pIM->getGlobalColorForContent().A+1) * _SheetColor.A )>>8; + curSheetColor.A= ( (CWidgetManager::getInstance()->getGlobalColorForContent().A+1) * _SheetColor.A )>>8; // The "disp with no sheet" case is a bit different CRGBA curNoSheetColor; if(_InterfaceColor) - curNoSheetColor= pIM->getGlobalColorForContent(); + curNoSheetColor= CWidgetManager::getInstance()->getGlobalColorForContent(); else - curNoSheetColor= CRGBA(255,255,255, pIM->getGlobalColorForContent().A); + curNoSheetColor= CRGBA(255,255,255, CWidgetManager::getInstance()->getGlobalColorForContent().A); // The gray color CRGBA grayColor= pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetGrayColor).getValColor(); @@ -2117,12 +2117,12 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti { // do not modulate color for redifyed color numberColor= redifyColor; - numberColor.A= (uint8)(((uint32)redifyColor.A * (pIM->getGlobalColorForContent().A+1))>>8); + numberColor.A= (uint8)(((uint32)redifyColor.A * (CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } else if(_Grayed) - numberColor.modulateFromColor(grayColor, pIM->getGlobalColorForContent()); + numberColor.modulateFromColor(grayColor, CWidgetManager::getInstance()->getGlobalColorForContent()); else - numberColor= pIM->getGlobalColorForContent(); + numberColor= CWidgetManager::getInstance()->getGlobalColorForContent(); // Different draws according to Sheet Type. switch (_ActualType) @@ -2534,7 +2534,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti CRGBA color = ssg->getColor(); if (ssg->isGlobalColorEnabled()) { - color.modulateFromColor(color, pIM->getGlobalColorForContent()); + color.modulateFromColor(color, CWidgetManager::getInstance()->getGlobalColorForContent()); } // decal layer because must drawn after Items/Brick in DXTC rVR.draw11RotFlipBitmap (_RenderLayer+1, middleX - (tw >> 1), middleY - (th >> 1), 0, false, ssg->getTextureIndex(), color); diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index a9235b435..53984d0d1 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -182,7 +182,7 @@ void CDBViewBar::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - color.A = (uint8)(((sint32)color.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + color.A = (uint8)(((sint32)color.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); // compute the DeltaY: mean of dif. sint32 deltaY= (_H-_HBar)/2; diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp index 73f261dde..9b40ba06d 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp @@ -163,7 +163,7 @@ void CDBViewBar3::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA gColor = pIM->getGlobalColorForContent(); + CRGBA gColor = CWidgetManager::getInstance()->getGlobalColorForContent(); if (_Mini) { diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 989275c2f..f091df1e6 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -22,6 +22,7 @@ #include "group_container.h" #include "interface_manager.h" #include "interface_options.h" +#include "interface_options_ryzom.h" #include "nel/misc/xml_auto_ptr.h" #include "action_handler.h" #include "../time_client.h" @@ -469,7 +470,7 @@ COptionsContainerInsertion *CCtrlMover::getInsertionOptions() static NLMISC::CRefPtr insertionOptions; if (insertionOptions) return insertionOptions; CInterfaceManager *im = CInterfaceManager::getInstance(); - insertionOptions = (COptionsContainerInsertion *) im->getOptions("container_insertion_opt"); + insertionOptions = (COptionsContainerInsertion *) CWidgetManager::getInstance()->getOptions("container_insertion_opt"); return insertionOptions; } @@ -1798,8 +1799,8 @@ void CGroupContainer::draw () CInterfaceManager *pIM = CInterfaceManager::getInstance(); float speed = pIM->getAlphaRolloverSpeed(); - CRGBA oldGlobalColor = pIM->getGlobalColor(); - CRGBA oldGColForGrayed = pIM->getGlobalColor(); + CRGBA oldGlobalColor = CWidgetManager::getInstance()->getGlobalColor(); + CRGBA oldGColForGrayed = CWidgetManager::getInstance()->getGlobalColor(); if (_Blinking) { const uint blinkDuration = 300; @@ -1815,7 +1816,7 @@ void CGroupContainer::draw () if (abs(newCol.R - oldGlobalColor.R) < 64) newCol.R = 192; if (abs(newCol.G - oldGlobalColor.G) < 64) newCol.G = 192; if (abs(newCol.B - oldGlobalColor.B) < 64) newCol.B = 192; - pIM->setGlobalColor(newCol); + CWidgetManager::getInstance()->setGlobalColor(newCol); _BlinkState = true; } else @@ -1850,7 +1851,7 @@ void CGroupContainer::draw () // Draw the container CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = pIM->getGlobalColor(); + CRGBA col = CWidgetManager::getInstance()->getGlobalColor(); bool bGrayed = isGrayed(); if (bGrayed) @@ -1858,7 +1859,7 @@ void CGroupContainer::draw () col.R = col.R / 2; col.G = col.G / 2; col.B = col.B / 2; - pIM->setGlobalColor(col); + CWidgetManager::getInstance()->setGlobalColor(col); oldGlobalColor.R = oldGlobalColor.R / 2; oldGlobalColor.G = oldGlobalColor.G / 2; oldGlobalColor.B = oldGlobalColor.B / 2; @@ -2078,7 +2079,7 @@ void CGroupContainer::draw () if (_Blinking) { - pIM->setGlobalColor(oldGlobalColor); + CWidgetManager::getInstance()->setGlobalColor(oldGlobalColor); } // Top window : title is highlighted @@ -2117,7 +2118,7 @@ void CGroupContainer::draw () // Render inside window - uint8 oldAlphaContent = pIM->getContentAlpha(); + uint8 oldAlphaContent = CWidgetManager::getInstance()->getContentAlpha(); uint8 oldAlphaContainer = _CurrentContainerAlpha; if (parentGC) { @@ -2131,7 +2132,7 @@ void CGroupContainer::draw () _CurrentContainerAlpha = _UseGlobalAlpha ? pIM->getGlobalContainerAlpha() : _ContainerAlpha; } // set content alpha multiplied by rollover alpha - pIM->setContentAlpha((uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8)); + CWidgetManager::getInstance()->setContentAlpha((uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8)); // set content alpha multiplied by rollover alpha _CurrentContainerAlpha = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) _ICurrentRolloverAlphaContainer) >> 8); @@ -2189,7 +2190,7 @@ void CGroupContainer::draw () } - pIM->setContentAlpha(oldAlphaContent); + CWidgetManager::getInstance()->setContentAlpha(oldAlphaContent); _CurrentContainerAlpha = oldAlphaContainer; @@ -2252,7 +2253,7 @@ void CGroupContainer::draw () if (bGrayed) { - pIM->setGlobalColor(oldGColForGrayed); + CWidgetManager::getInstance()->setGlobalColor(oldGColForGrayed); } @@ -3084,7 +3085,7 @@ COptionsLayer *CGroupContainer::getContainerOptions(sint32 ls) sLayerName = &sTmp; } - COptionsLayer *pLayer = (COptionsLayer*)CInterfaceManager::getInstance()->getOptions(*sLayerName); + COptionsLayer *pLayer = (COptionsLayer*)CWidgetManager::getInstance()->getOptions(*sLayerName); nlassert(pLayer != NULL); return pLayer; } @@ -3445,7 +3446,7 @@ COptionsContainerMove *CGroupContainer::getMoveOptions() static NLMISC::CRefPtr moveOptions; if (moveOptions) return moveOptions; CInterfaceManager *im = CInterfaceManager::getInstance(); - moveOptions = (COptionsContainerMove *) im->getOptions("container_move_opt"); + moveOptions = (COptionsContainerMove *) CWidgetManager::getInstance()->getOptions("container_move_opt"); return moveOptions; } diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 83ca1231f..c49752dce 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -249,7 +249,7 @@ void CGroupEditBox::draw () { sint32 blankTextId= rVR.getBlankTextureId(); CRGBA col= _BackSelectColor; - col.A= pIM->getGlobalColorForContent().A; + col.A= CWidgetManager::getInstance()->getGlobalColorForContent().A; sint32 minPos= min(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); sint32 maxPos= max(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); @@ -1124,7 +1124,7 @@ void CGroupEditBox::setup() _ViewTextDeltaX= 0; // read options - CInterfaceOptions *pIO = CInterfaceManager::getInstance()->getOptions("text_selection"); + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("text_selection"); if (pIO != NULL) { _BackSelectColor= pIO->getValColor("back_select_color"); diff --git a/code/ryzom/client/src/interface_v3/group_frame.cpp b/code/ryzom/client/src/interface_v3/group_frame.cpp index 6b4782dab..f6978a959 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.cpp +++ b/code/ryzom/client/src/interface_v3/group_frame.cpp @@ -14,13 +14,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "group_frame.h" -#include "interface_manager.h" +#include "widget_manager.h" +#include "interface_options.h" #include "interface_element.h" +#include "nel/gui/view_renderer.h" #include "nel/misc/xml_auto_ptr.h" using namespace std; @@ -71,14 +69,13 @@ bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) // Get the borders texture _DispTypeDefined= false; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" ); CInterfaceOptions *pIO = NULL; if (ptr) - pIO = pIM->getOptions(ptr); + pIO = CWidgetManager::getInstance()->getOptions(ptr); // The first type in display type struct is the default display type if (_DispTypes.size() == 0) @@ -159,13 +156,12 @@ void CGroupFrame::draw () { if (_DisplayFrame) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); // get global color CRGBA col; if(getModulateGlobalColor()) - col.modulateFromColor (_Color, pIM->getGlobalColor()); + col.modulateFromColor( _Color, CWidgetManager::getInstance()->getGlobalColor() ); else col= _Color; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 756256dbd..b20f9d46e 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -643,12 +643,12 @@ void CGroupList::draw () CRGBA col = _OverColor; if(getModulateGlobalColor()) { - col.modulateFromColor (_OverColor, pIM->getGlobalColorForContent()); + col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 13588c436..fa197ef51 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -1472,7 +1472,7 @@ void CGroupMap::draw() makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); - uint8 alpha = im->getGlobalColorForContent().A; + uint8 alpha = CWidgetManager::getInstance()->getGlobalColorForContent().A; updateScale(); // No Op if screen minimized diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 2ffd1d95d..3ca9a7db3 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -75,7 +75,7 @@ void CViewTextMenu::setChecked(bool c) { if (_CheckBox) { - CInterfaceOptions *pIO = CInterfaceManager::getInstance()->getOptions("menu_checkbox"); + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); if (!pIO) return; _CheckBox->setTexture(pIO->getValStr(c ? "checked_bitmap" : "unchecked_bitmap")); } @@ -380,7 +380,7 @@ CViewBitmap *CGroupSubMenu::createCheckBox(bool checked) pVB->setParentPos (_GroupList); pVB->setParentPosRef (Hotspot_BR); pVB->setPosRef (Hotspot_BL); - CInterfaceOptions *pIO = CInterfaceManager::getInstance()->getOptions("menu_checkbox"); + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); if (pIO) { pVB->setTexture(pIO->getValStr(checked ? "checked_bitmap" : "unchecked_bitmap")); diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/ryzom/client/src/interface_v3/group_modal.cpp index 611544b01..555f6b4d5 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal.cpp @@ -17,9 +17,9 @@ #include "group_modal.h" -#include "interface_manager.h" #include "interface_element.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_renderer.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index 47791ed89..f75afccf0 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -823,12 +823,12 @@ void CGroupParagraph::draw () CRGBA col = _OverColor; if(getModulateGlobalColor()) { - col.modulateFromColor (_OverColor, pIM->getGlobalColorForContent()); + col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 1ead5f87e..347f0373f 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -247,7 +247,7 @@ void CGroupCell::draw () else { CRGBA finalColor; - finalColor.modulateFromColor (BgColor, pIM->getGlobalColor()); + finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); // Get the parent table if (getParent ()) @@ -946,7 +946,7 @@ void CGroupTable::draw () { CInterfaceManager *pIM = CInterfaceManager::getInstance(); CRGBA finalColor; - finalColor.modulateFromColor (BgColor, pIM->getGlobalColor()); + finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); finalColor.A = CurrentAlpha; // Draw the top and bottom lines diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 23c51c12d..46ce4434f 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -660,12 +660,12 @@ void CGroupTree::draw() CRGBA col = _OverColor; if(getModulateGlobalColor()) { - col.modulateFromColor (_OverColor, pIM->getGlobalColorForContent()); + col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } drawSelection( getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_OverLine-1)*_BmpH, @@ -680,7 +680,7 @@ void CGroupTree::draw() { // simulate alpha blend of the selection bitmap CRGBA sel= _SelectedColor; - sel.A= (uint8)((sel.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + sel.A= (uint8)((sel.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); col.blendFromuiRGBOnly(col, sel, sel.A); } @@ -696,12 +696,12 @@ void CGroupTree::draw() CRGBA col = _SelectedColor; if(getModulateGlobalColor()) { - col.modulateFromColor (_SelectedColor, pIM->getGlobalColorForContent()); + col.modulateFromColor (_SelectedColor, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _SelectedColor; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } drawSelection( getHrcIconXEnd(_Lines[_SelectedLine].Depth + _Lines[_SelectedLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_SelectedLine-1)*_BmpH, diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index 091c941cd..e2b782a1d 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -390,7 +390,7 @@ static DECLARE_INTERFACE_USER_FCT(getClientActionTypeColor) // To Color // Get the action_bar_color options - CInterfaceOptions *options= CInterfaceManager::getInstance()->getOptions("action_bar_color"); + CInterfaceOptions *options= CWidgetManager::getInstance()->getOptions("action_bar_color"); if(options) { const CInterfaceOptionValue &optVal= options->getValue(CLIENT_ACTION_TYPE::toString(actType)); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 961660c13..94b1bc3dd 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -271,9 +271,6 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; _DescTextTarget = NULL; - _GlobalColor = CRGBA(255,255,255,255); - _GlobalColorForContent = _GlobalColor; - _ContentAlpha = 255; _ContainerAlpha = 255; _GlobalContentAlpha = 255; _GlobalContainerAlpha = 255; @@ -284,10 +281,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _ConfigLoaded = false; _LogState = false; _KeysLoaded = false; - _RProp = NULL; - _GProp = NULL; - _BProp = NULL; - _AProp = NULL; + CWidgetManager::getInstance()->resetColorProps(); _AlphaRolloverSpeedDB = NULL; _NeutralColor = NULL; _WarningColor = NULL; @@ -388,10 +382,6 @@ void CInterfaceManager::reset() _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; - _RProp = NULL; - _GProp = NULL; - _BProp = NULL; - _AProp = NULL; _AlphaRolloverSpeedDB = NULL; } @@ -1197,10 +1187,7 @@ void CInterfaceManager::uninitInGame1 () _WarningColor = NULL; _ErrorColor = NULL; _AlphaRolloverSpeedDB = NULL; - _RProp = NULL; - _GProp = NULL; - _BProp = NULL; - _AProp = NULL; + CWidgetManager::getInstance()->resetColorProps(); #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS CInterfaceManager::getInstance()->DebugTrackGroupsDump(); @@ -1360,21 +1347,11 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) } -// ------------------------------------------------------------------------------------------------ -CInterfaceOptions *CInterfaceManager::getOptions(const string &name) -{ - map >::iterator it = _OptionsMap.find(name); - if (it == _OptionsMap.end()) - return NULL; - else - return it->second; -} - // ------------------------------------------------------------------------------------------------ void CInterfaceManager::setupOptions() { // After parsing options and templates node -> init system options. - CInterfaceOptions *opt= getOptions("system"); + CInterfaceOptions *opt= CWidgetManager::getInstance()->getOptions("system"); if(opt) { // List here all Special options @@ -1832,14 +1809,18 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) } // Update global color from database - _GlobalColor = CRGBA ( (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R")->getValue32(), + CWidgetManager::getInstance()->setGlobalColor( CRGBA ( (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R")->getValue32(), (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G")->getValue32(), (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B")->getValue32(), - (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A")->getValue32() ); - _GlobalColorForContent.R = _GlobalColor.R; - _GlobalColorForContent.G = _GlobalColor.G; - _GlobalColorForContent.B = _GlobalColor.B; - _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8); + (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A")->getValue32() ) ); + + CRGBA c = CWidgetManager::getInstance()->getGlobalColorForContent(); + CRGBA gc = CWidgetManager::getInstance()->getGlobalColor(); + c.R = gc.R; + c.G = gc.G; + c.B = gc.B; + c.A = (uint8) (( (uint16) c.A * (uint16) CWidgetManager::getInstance()->getContentAlpha() ) >> 8); + CWidgetManager::getInstance()->setGlobalColorForContent( c ); // Update global alphaS from database _GlobalContentAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); @@ -2421,28 +2402,6 @@ uint CInterfaceManager::adjustTooltipPosition(CCtrlBase *newCtrl, return clampCount; } -// ------------------------------------------------------------------------------------------------ -void CInterfaceManager::setGlobalColor (NLMISC::CRGBA col) -{ - if (!_RProp) - { - _RProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); - _GProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); - _BProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); - _AProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); - } - _RProp ->setValue32 (col.R); - _GProp ->setValue32 (col.G); - _BProp ->setValue32 (col.B); - _AProp ->setValue32 (col.A); - - _GlobalColor = col; - - // set the global color for content (the same with modulated alpha) - _GlobalColorForContent = _GlobalColor; - _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColorForContent.A * (uint16) _ContentAlpha) >> 8); -} - // ------------------------------------------------------------------------------------------------ bool CInterfaceManager::isControlInWindow (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentWnd) { @@ -3670,20 +3629,14 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) } } -// *************************************************************************** -void CInterfaceManager::setContentAlpha(uint8 alpha) -{ - _ContentAlpha = alpha; - // update alpha of global color - _GlobalColorForContent.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8);*/ -} - // *************************************************************************** void CInterfaceManager::setContainerAlpha(uint8 alpha) { _ContainerAlpha = alpha; // update alpha of global color - _GlobalColor.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContainerAlpha) >> 8); */ + CRGBA c = CWidgetManager::getInstance()->getGlobalColor(); + c.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContainerAlpha) >> 8); */ + CWidgetManager::getInstance()->setGlobalColor( c ); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 20644ffd7..92e32b6d1 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -291,13 +291,9 @@ public: void drawContextHelp (); //void drawContextMenu (); - void setGlobalColor (NLMISC::CRGBA col); - NLMISC::CRGBA getGlobalColor() { return _GlobalColor; } - void setContentAlpha(uint8 alpha); - uint8 getContentAlpha() const { return _ContentAlpha; } void setContainerAlpha(uint8 alpha); uint8 getContainerAlpha() const { return _ContainerAlpha; } - NLMISC::CRGBA getGlobalColorForContent() { return _GlobalColorForContent; } + // these values are updated from the DB uint8 getGlobalContentAlpha() const { return _GlobalContentAlpha; } uint8 getGlobalContainerAlpha() const { return _GlobalContainerAlpha; } @@ -318,9 +314,6 @@ public: /// \name Global Interface Options // @{ - /// Get options by name - CInterfaceOptions *getOptions (const std::string &optName); - // List of system options enum TSystemOption { @@ -696,9 +689,7 @@ private: uint8 _LocalSyncActionCounterMask; - uint8 _ContentAlpha; uint8 _ContainerAlpha; - NLMISC::CRGBA _GlobalColorForContent; // uint8 _GlobalContentAlpha; uint8 _GlobalContainerAlpha; @@ -737,7 +728,6 @@ private: std::vector _IDStringWaiters; uint32 _ScreenW, _ScreenH; // Change res detection - NLMISC::CRGBA _GlobalColor; sint32 _LastInGameScreenW, _LastInGameScreenH; // Resolution used for last InGame interface // List of active Anims @@ -775,10 +765,6 @@ private: NLMISC::CCDBNodeLeaf *_NeutralColor; NLMISC::CCDBNodeLeaf *_WarningColor; NLMISC::CCDBNodeLeaf *_ErrorColor; - NLMISC::CCDBNodeLeaf *_RProp; - NLMISC::CCDBNodeLeaf *_GProp; - NLMISC::CCDBNodeLeaf *_BProp; - NLMISC::CCDBNodeLeaf *_AProp; NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; // The next ViewText to draw for Over diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/ryzom/client/src/interface_v3/interface_options.cpp index eb85bdb42..a73d2c170 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options.cpp @@ -16,28 +16,13 @@ -// ---------------------------------------------------------------------------- -#include "stdpch.h" - -#include "interface_options.h" -#include "interface_manager.h" -#include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" -#include "../net_manager.h" -#include "../sheet_manager.h" -#include "../entity_animation_manager.h" -#include "../client_sheets/animation_set_list_sheet.h" -#include "../client_sheets/emot_list_sheet.h" -#include "nel/3d/u_animation_set.h" -#include "nel/misc/algo.h" +#include "interface_options.h" +#include "interface_element.h" -// ---------------------------------------------------------------------------- using namespace std; -using namespace NL3D; using namespace NLMISC; -extern CEntityAnimationManager *EAM; - // *************************************************************************** const CInterfaceOptionValue CInterfaceOptionValue::NullValue; @@ -138,370 +123,3 @@ bool CInterfaceOptions::getValBool(const std::string &sParamName) const return getValue(sParamName).getValBool(); } - - -// ---------------------------------------------------------------------------- -// CInterfaceLayer -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -COptionsLayer::COptionsLayer() -{ - TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2; - TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2; - Tile_Blank = 0; - Tile_M_Header = Tile_M_Scrollbar = 0; - Tile_T = Tile_B = Tile_L = Tile_R = 0; - Tile_B_Open = Tile_EM_Open = Tile_M_Open = 0; - Scrollbar_Offset_X = 4; - Scrollbar_W = 8; -} - -// ---------------------------------------------------------------------------- -COptionsLayer::~COptionsLayer() -{ -} - -// ---------------------------------------------------------------------------- -bool COptionsLayer::parse (xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - Tile_Blank = getValSInt32("tile_blank"); - Tile_M_Header = getValSInt32("tile_m_header"); - Tile_M_Scrollbar = getValSInt32("tile_m_scrollbar"); - Tile_T = getValSInt32("tile_t"); - Tile_B = getValSInt32("tile_b"); - Tile_L = getValSInt32("tile_l"); - Tile_R = getValSInt32("tile_r"); - Tile_B_Open = getValSInt32("tile_b_open"); - Tile_EM_Open = getValSInt32("tile_em_open"); - Tile_M_Open = getValSInt32("tile_m_open"); - - Scrollbar_Offset_X = getValSInt32("scrollbar_offset_x"); - Scrollbar_W = getValSInt32("scrollbar_size_w"); - TxId_B_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_b")); - rVR.getTextureSizeFromId(TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar); - TxId_M_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_m")); - rVR.getTextureSizeFromId(TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar); - TxId_T_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_t")); - rVR.getTextureSizeFromId(TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar); - - TxId_L_Header = rVR.getTextureIdFromName (getValStr("tx_l_header")); - rVR.getTextureSizeFromId(TxId_L_Header, W_L_Header, H_L_Header); - TxId_M_Header = rVR.getTextureIdFromName (getValStr("tx_m_header")); - rVR.getTextureSizeFromId(TxId_M_Header, W_M_Header, H_M_Header); - TxId_R_Header = rVR.getTextureIdFromName (getValStr("tx_r_header")); - rVR.getTextureSizeFromId(TxId_R_Header, W_R_Header, H_R_Header); - - TxId_TL = rVR.getTextureIdFromName (getValStr("tx_tl")); - rVR.getTextureSizeFromId(TxId_TL, W_TL, H_TL); - TxId_T = rVR.getTextureIdFromName (getValStr("tx_t")); - rVR.getTextureSizeFromId(TxId_T, W_T, H_T); - TxId_TR = rVR.getTextureIdFromName (getValStr("tx_tr")); - rVR.getTextureSizeFromId(TxId_TR, W_TR, H_TR); - TxId_L = rVR.getTextureIdFromName (getValStr("tx_l")); - rVR.getTextureSizeFromId(TxId_L, W_L, H_L); - TxId_R = rVR.getTextureIdFromName (getValStr("tx_r")); - rVR.getTextureSizeFromId(TxId_R, W_R, H_R); - TxId_Blank = rVR.getTextureIdFromName (getValStr("tx_blank")); - rVR.getTextureSizeFromId(TxId_Blank, W_Blank, H_Blank); - TxId_BL = rVR.getTextureIdFromName (getValStr("tx_bl")); - rVR.getTextureSizeFromId(TxId_BL, W_BL, H_BL); - TxId_B = rVR.getTextureIdFromName (getValStr("tx_b")); - rVR.getTextureSizeFromId(TxId_B, W_B, H_B); - TxId_BR = rVR.getTextureIdFromName (getValStr("tx_br")); - rVR.getTextureSizeFromId(TxId_BR, W_BR, H_BR); - // - TxId_BL_Open = rVR.getTextureIdFromName (getValStr("tx_bl_open")); - rVR.getTextureSizeFromId(TxId_BL_Open, W_BL_Open, H_BL_Open); - TxId_B_Open = rVR.getTextureIdFromName (getValStr("tx_b_open")); - rVR.getTextureSizeFromId(TxId_B_Open, W_B_Open, H_B_Open); - TxId_BR_Open = rVR.getTextureIdFromName (getValStr("tx_br_open")); - rVR.getTextureSizeFromId(TxId_BR_Open, W_BR_Open, H_BR_Open); - TxId_EL_Open = rVR.getTextureIdFromName (getValStr("tx_el_open")); - rVR.getTextureSizeFromId(TxId_EL_Open, W_EL_Open, H_EL_Open); - TxId_EM_Open = rVR.getTextureIdFromName (getValStr("tx_em_open")); - rVR.getTextureSizeFromId(TxId_EM_Open, W_EM_Open, H_EM_Open); - TxId_ER_Open = rVR.getTextureIdFromName (getValStr("tx_er_open")); - rVR.getTextureSizeFromId(TxId_ER_Open, W_ER_Open, H_ER_Open); - TxId_M_Open = rVR.getTextureIdFromName (getValStr("tx_m_open")); - rVR.getTextureSizeFromId(TxId_M_Open, W_M_Open, H_M_Open); - TxId_E_Open = rVR.getTextureIdFromName (getValStr("tx_e_open")); - rVR.getTextureSizeFromId(TxId_E_Open, W_E_Open, H_E_Open); - // - - TxId_TL_HighLight = rVR.getTextureIdFromName (getValStr("tx_tl_highlight")); - TxId_T_HighLight = rVR.getTextureIdFromName (getValStr("tx_t_highlight")); - TxId_TR_HighLight = rVR.getTextureIdFromName (getValStr("tx_tr_highlight")); - TxId_L_HighLight = rVR.getTextureIdFromName (getValStr("tx_l_highlight")); - TxId_R_HighLight = rVR.getTextureIdFromName (getValStr("tx_r_highlight")); - TxId_BL_HighLight = rVR.getTextureIdFromName (getValStr("tx_bl_highlight")); - TxId_B_HighLight = rVR.getTextureIdFromName (getValStr("tx_b_highlight")); - TxId_BR_HighLight = rVR.getTextureIdFromName (getValStr("tx_br_highlight")); - - // - HeaderH = getValSInt32("header_h"); - - return true; -} - -// ---------------------------------------------------------------------------- -COptionsContainerInsertion::COptionsContainerInsertion() -{ - TxId_R_Arrow = -2; - TxId_L_Arrow = -2; - TxId_T_Arrow = -2; - TxId_B_Arrow = -2; - TxId_InsertionBar = -2; -} - -// ---------------------------------------------------------------------------- -bool COptionsContainerInsertion::parse(xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - TxId_T_Arrow = rVR.getTextureIdFromName (getValStr("arrow_top")); - TxId_B_Arrow = rVR.getTextureIdFromName (getValStr("arrow_down")); - TxId_L_Arrow = rVR.getTextureIdFromName (getValStr("arrow_left")); - TxId_R_Arrow = rVR.getTextureIdFromName (getValStr("arrow_right")); - TxId_InsertionBar = rVR.getTextureIdFromName (getValStr("insertion_bar")); - - return true; -} - - -// *************************************************************************** -COptionsContainerMove::COptionsContainerMove() -{ - TrackW = -8; - TrackH = 22; - TrackY = -4; - TrackYWithTopResizer = -8; - TrackHWithTopResizer = 18; - ResizerSize = 8; -} - -// *************************************************************************** -bool COptionsContainerMove::parse(xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - fromString(getValStr("track_w"), TrackW); - fromString(getValStr("track_h"), TrackH); - fromString(getValStr("track_y"), TrackY); - fromString(getValStr("track_y_with_top_resizer"), TrackYWithTopResizer); - fromString(getValStr("track_h_with_top_resizer"), TrackHWithTopResizer); - fromString(getValStr("resizer_size"), ResizerSize); - return true; -} - -// *************************************************************************** -COptionsList::COptionsList() -{ - _NumParams= 0; -} - -// *************************************************************************** -bool COptionsList::parse (xmlNodePtr cur) -{ - cur = cur->children; - bool ok = true; - uint id= 0; - while (cur) - { - if ( !stricmp((char*)cur->name,"param") ) - { - CXMLAutoPtr ptr, val; - val = xmlGetProp (cur, (xmlChar*)"value"); - if (!val) - { - nlinfo("param with no name or no value"); - ok = false; - } - else - { - string value = (string((const char*)val)); - _ParamValue[toString(id)].init(value); - id++; - } - } - cur = cur->next; - } - - _NumParams= id; - - return ok; -} - - -// *************************************************************************** -const CInterfaceOptionValue &COptionsList::getValue(uint paramId) const -{ - return CInterfaceOptions::getValue(toString(paramId)); -} - - -// *************************************************************************** -bool CMissionIconList::parse(xmlNodePtr cur) -{ - bool result = CInterfaceOptions::parse(cur); - if (!result) return false; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = *CViewRenderer::getInstance(); - for(std::map::iterator it = _ParamValue.begin(); it != _ParamValue.end(); ++it) - { - int index; - if (fromString(it->first, index)) - { - if (index > 255) - { - nlwarning("bad index for texture"); - } - else - { - string sTmp = it->second.getValStr(); - string sBack, sIcon; - if (sTmp.find('|') != string::npos) - { - sBack = sTmp.substr(0,sTmp.find('|')); - sIcon = sTmp.substr(sTmp.find('|')+1,sTmp.size()); - } - else - { - sBack = sTmp; - } - - sint32 texID = vr.getTextureIdFromName(sBack); - if (texID != -1) - { - IconBackTexID.resize(std::max((int) IconBackTexID.size(), index + 1), -1); - IconBackTexID[index] = texID; - } - texID = vr.getTextureIdFromName(sIcon); - if (texID != -1) - { - IconTexID.resize(std::max((int) IconTexID.size(), index + 1), -1); - IconTexID[index] = texID; - } - } - } - } - NLMISC::contReset(_ParamValue); // not needed anymore - return true; -} - - -// *************************************************************************** -COptionsAnimationSet::COptionsAnimationSet() -{ - AnimationSet= NULL; -} - -// *************************************************************************** -COptionsAnimationSet::~COptionsAnimationSet() -{ - if(AnimationSet) - { - /* Important Note: this CInterfaceOptions is released BEFORE any CCharacter3d is released himself - BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList - (see deleteAnimationSet() doc) - */ - CViewRenderer::getInstance()->getDriver()->deleteAnimationSet(AnimationSet); - AnimationSet= NULL; - } -} - -// *************************************************************************** -bool COptionsAnimationSet::parse (xmlNodePtr cur) -{ - bool result = CInterfaceOptions::parse(cur); - if (!result) return false; - nlassert( CViewRenderer::getInstance()->getDriver() ); - - // create the animation set - AnimationSet= CViewRenderer::getInstance()->getDriver()->createAnimationSet(); - nlassert(AnimationSet); - - AnimMale.clear(); - AnimFemale.clear(); - - // Add all male/female animations - string sTmp; - for(uint gender=0; gender<2; gender++) - { - string prefix= (gender==0)?"m":"f"; - - uint i = 0; - do - { - sTmp = getValStr(prefix+toString(i)); - if (!sTmp.empty()) - { - // get params - vector params; - splitString(sTmp, "|", params); - // if error or first param empty, abort all - if(params.empty() || params[0].empty()) - { - sTmp.clear(); - } - else - { - string animName= params[0]; - animName += ".anim"; - uint animID = AnimationSet->addAnimation (animName.c_str(), animName.c_str()); - if (animID == UAnimationSet::NotFound) - nlwarning ("Character3D : not found anim : %s", animName.c_str()); - // try to add the Face animation for this one (not important if failed) - string faceAnimName= getFaceAnimName(animName); - AnimationSet->addAnimation (faceAnimName.c_str(), faceAnimName.c_str()); - - // append the new anim desc - CAnim newAnim; - newAnim.AnimId= animID; - newAnim.ApplyRaceScalePos= true; - // parse param - for(uint p=1;pbuild (); - - return true; -} - -// *************************************************************************** -string COptionsAnimationSet::getFaceAnimName(const std::string &animName) -{ - string faceAnimName= animName; - string::size_type extPos= faceAnimName.find(".anim"); - if(extPos!=string::npos) - faceAnimName= faceAnimName.substr(0, extPos); - faceAnimName+= "_face"; - if(extPos!=string::npos) - faceAnimName+= ".anim"; - return faceAnimName; -} - - diff --git a/code/ryzom/client/src/interface_v3/interface_options.h b/code/ryzom/client/src/interface_v3/interface_options.h index 3fdb82a97..e05d390f8 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.h +++ b/code/ryzom/client/src/interface_v3/interface_options.h @@ -92,161 +92,6 @@ protected: }; -// *************************************************************************** -class COptionsLayer : public CInterfaceOptions -{ - -public: - COptionsLayer(); - ~COptionsLayer(); - virtual bool parse (xmlNodePtr cur); - - // Container optimizer - - sint32 Tile_Blank; - sint32 Tile_M_Header, Tile_M_Scrollbar; - sint32 Tile_T, Tile_B, Tile_L, Tile_R; - sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open; - - sint32 Scrollbar_Offset_X; - sint32 Scrollbar_W; - sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar; - sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar; - sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar; - - sint32 TxId_L_Header, W_L_Header, H_L_Header; - sint32 TxId_M_Header, W_M_Header, H_M_Header; - sint32 TxId_R_Header, W_R_Header, H_R_Header; - - sint32 TxId_TL, W_TL, H_TL; - sint32 TxId_T, W_T, H_T; - sint32 TxId_TR, W_TR, H_TR; - sint32 TxId_L, W_L, H_L; - sint32 TxId_R, W_R, H_R; - sint32 TxId_Blank, W_Blank, H_Blank; - sint32 TxId_BL, W_BL, H_BL; - sint32 TxId_B, W_B, H_B; - sint32 TxId_BR, W_BR, H_BR; - - sint32 TxId_BL_Open, W_BL_Open, H_BL_Open; - sint32 TxId_B_Open, W_B_Open, H_B_Open; - sint32 TxId_BR_Open, W_BR_Open, H_BR_Open; - sint32 TxId_EL_Open, W_EL_Open, H_EL_Open; - sint32 TxId_EM_Open, W_EM_Open, H_EM_Open; - sint32 TxId_ER_Open, W_ER_Open, H_ER_Open; - sint32 TxId_E_Open, W_E_Open, H_E_Open; - sint32 TxId_M_Open, W_M_Open, H_M_Open; - - sint32 TxId_TL_HighLight; - sint32 TxId_T_HighLight; - sint32 TxId_TR_HighLight; - sint32 TxId_L_HighLight; - sint32 TxId_R_HighLight; - sint32 TxId_BL_HighLight; - sint32 TxId_B_HighLight; - sint32 TxId_BR_HighLight; - - sint32 HeaderH; -}; - -// *************************************************************************** -class COptionsContainerInsertion : public CInterfaceOptions -{ -public: - COptionsContainerInsertion(); - virtual bool parse (xmlNodePtr cur); - - sint32 TxId_R_Arrow; - sint32 TxId_L_Arrow; - sint32 TxId_T_Arrow; - sint32 TxId_B_Arrow; - sint32 TxId_InsertionBar; -}; - -// *************************************************************************** -class COptionsContainerMove : public CInterfaceOptions -{ -public: - COptionsContainerMove(); - virtual bool parse (xmlNodePtr cur); - - sint32 TrackW; - sint32 TrackH; - sint32 TrackY; - sint32 TrackYWithTopResizer; - sint32 TrackHWithTopResizer; - sint32 ResizerSize; -}; - - - -// *************************************************************************** -/** - * read a list of with no name. id auto incremented - */ -class COptionsList : public CInterfaceOptions -{ -public: - COptionsList(); - virtual bool parse (xmlNodePtr cur); - - uint getNumParams() const {return _NumParams;} - - // get a value by its index (from 0 to numParams) - const CInterfaceOptionValue &getValue(uint paramId) const; - -private: - uint _NumParams; -}; - -// *************************************************************************** -class CMissionIconList : public CInterfaceOptions -{ -public: - virtual bool parse (xmlNodePtr cur); - sint32 getBackTexID(uint index) const { return index >= IconBackTexID.size() ? -1 : IconBackTexID[index]; } - sint32 getTexID(uint index) const { return index >= IconTexID.size() ? -1 : IconTexID[index]; } -private: - std::vector IconBackTexID; - std::vector IconTexID; -}; - -// *************************************************************************** -/** Describe an animation Set container, used for multiple CCharacter3d for instance - */ -class COptionsAnimationSet : public CInterfaceOptions -{ -public: - COptionsAnimationSet(); - // see code for important release note - virtual ~COptionsAnimationSet(); - virtual bool parse (xmlNodePtr cur); - - // tool fct to get the face anim name from a name (append "_face" before .anim) - static std::string getFaceAnimName(const std::string &animName); - -public: - NL3D::UAnimationSet *AnimationSet; - - struct CAnim - { - // Indexes in this animation set - uint AnimId; - // true if must apply the race/gender scale to the position (not in rare case) - bool ApplyRaceScalePos; - CAnim() - { - AnimId= -1; - ApplyRaceScalePos= true; - } - }; - - // Male and female Animation - std::vector AnimMale; - std::vector AnimFemale; - -}; - #endif // NL_INTERFACE_LAYER_H /* End of interface_layer.h */ diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp new file mode 100644 index 000000000..9e9731c8c --- /dev/null +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp @@ -0,0 +1,407 @@ +// Ryzom - MMORPG Framework +// 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 "interface_options_ryzom.h" + +#include "stdpch.h" + +#include "interface_options.h" +#include "interface_manager.h" +#include "group_menu.h" +#include "nel/misc/xml_auto_ptr.h" +#include "../net_manager.h" +#include "../sheet_manager.h" +#include "../entity_animation_manager.h" +#include "../client_sheets/animation_set_list_sheet.h" +#include "../client_sheets/emot_list_sheet.h" +#include "nel/3d/u_animation_set.h" +#include "nel/misc/algo.h" + +// ---------------------------------------------------------------------------- +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +extern CEntityAnimationManager *EAM; + + +// ---------------------------------------------------------------------------- +// CInterfaceLayer +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +COptionsLayer::COptionsLayer() +{ + TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2; + TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2; + Tile_Blank = 0; + Tile_M_Header = Tile_M_Scrollbar = 0; + Tile_T = Tile_B = Tile_L = Tile_R = 0; + Tile_B_Open = Tile_EM_Open = Tile_M_Open = 0; + Scrollbar_Offset_X = 4; + Scrollbar_W = 8; +} + +// ---------------------------------------------------------------------------- +COptionsLayer::~COptionsLayer() +{ +} + +// ---------------------------------------------------------------------------- +bool COptionsLayer::parse (xmlNodePtr cur) +{ + if (!CInterfaceOptions::parse (cur)) + return false; + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + Tile_Blank = getValSInt32("tile_blank"); + Tile_M_Header = getValSInt32("tile_m_header"); + Tile_M_Scrollbar = getValSInt32("tile_m_scrollbar"); + Tile_T = getValSInt32("tile_t"); + Tile_B = getValSInt32("tile_b"); + Tile_L = getValSInt32("tile_l"); + Tile_R = getValSInt32("tile_r"); + Tile_B_Open = getValSInt32("tile_b_open"); + Tile_EM_Open = getValSInt32("tile_em_open"); + Tile_M_Open = getValSInt32("tile_m_open"); + + Scrollbar_Offset_X = getValSInt32("scrollbar_offset_x"); + Scrollbar_W = getValSInt32("scrollbar_size_w"); + TxId_B_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_b")); + rVR.getTextureSizeFromId(TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar); + TxId_M_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_m")); + rVR.getTextureSizeFromId(TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar); + TxId_T_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_t")); + rVR.getTextureSizeFromId(TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar); + + TxId_L_Header = rVR.getTextureIdFromName (getValStr("tx_l_header")); + rVR.getTextureSizeFromId(TxId_L_Header, W_L_Header, H_L_Header); + TxId_M_Header = rVR.getTextureIdFromName (getValStr("tx_m_header")); + rVR.getTextureSizeFromId(TxId_M_Header, W_M_Header, H_M_Header); + TxId_R_Header = rVR.getTextureIdFromName (getValStr("tx_r_header")); + rVR.getTextureSizeFromId(TxId_R_Header, W_R_Header, H_R_Header); + + TxId_TL = rVR.getTextureIdFromName (getValStr("tx_tl")); + rVR.getTextureSizeFromId(TxId_TL, W_TL, H_TL); + TxId_T = rVR.getTextureIdFromName (getValStr("tx_t")); + rVR.getTextureSizeFromId(TxId_T, W_T, H_T); + TxId_TR = rVR.getTextureIdFromName (getValStr("tx_tr")); + rVR.getTextureSizeFromId(TxId_TR, W_TR, H_TR); + TxId_L = rVR.getTextureIdFromName (getValStr("tx_l")); + rVR.getTextureSizeFromId(TxId_L, W_L, H_L); + TxId_R = rVR.getTextureIdFromName (getValStr("tx_r")); + rVR.getTextureSizeFromId(TxId_R, W_R, H_R); + TxId_Blank = rVR.getTextureIdFromName (getValStr("tx_blank")); + rVR.getTextureSizeFromId(TxId_Blank, W_Blank, H_Blank); + TxId_BL = rVR.getTextureIdFromName (getValStr("tx_bl")); + rVR.getTextureSizeFromId(TxId_BL, W_BL, H_BL); + TxId_B = rVR.getTextureIdFromName (getValStr("tx_b")); + rVR.getTextureSizeFromId(TxId_B, W_B, H_B); + TxId_BR = rVR.getTextureIdFromName (getValStr("tx_br")); + rVR.getTextureSizeFromId(TxId_BR, W_BR, H_BR); + // + TxId_BL_Open = rVR.getTextureIdFromName (getValStr("tx_bl_open")); + rVR.getTextureSizeFromId(TxId_BL_Open, W_BL_Open, H_BL_Open); + TxId_B_Open = rVR.getTextureIdFromName (getValStr("tx_b_open")); + rVR.getTextureSizeFromId(TxId_B_Open, W_B_Open, H_B_Open); + TxId_BR_Open = rVR.getTextureIdFromName (getValStr("tx_br_open")); + rVR.getTextureSizeFromId(TxId_BR_Open, W_BR_Open, H_BR_Open); + TxId_EL_Open = rVR.getTextureIdFromName (getValStr("tx_el_open")); + rVR.getTextureSizeFromId(TxId_EL_Open, W_EL_Open, H_EL_Open); + TxId_EM_Open = rVR.getTextureIdFromName (getValStr("tx_em_open")); + rVR.getTextureSizeFromId(TxId_EM_Open, W_EM_Open, H_EM_Open); + TxId_ER_Open = rVR.getTextureIdFromName (getValStr("tx_er_open")); + rVR.getTextureSizeFromId(TxId_ER_Open, W_ER_Open, H_ER_Open); + TxId_M_Open = rVR.getTextureIdFromName (getValStr("tx_m_open")); + rVR.getTextureSizeFromId(TxId_M_Open, W_M_Open, H_M_Open); + TxId_E_Open = rVR.getTextureIdFromName (getValStr("tx_e_open")); + rVR.getTextureSizeFromId(TxId_E_Open, W_E_Open, H_E_Open); + // + + TxId_TL_HighLight = rVR.getTextureIdFromName (getValStr("tx_tl_highlight")); + TxId_T_HighLight = rVR.getTextureIdFromName (getValStr("tx_t_highlight")); + TxId_TR_HighLight = rVR.getTextureIdFromName (getValStr("tx_tr_highlight")); + TxId_L_HighLight = rVR.getTextureIdFromName (getValStr("tx_l_highlight")); + TxId_R_HighLight = rVR.getTextureIdFromName (getValStr("tx_r_highlight")); + TxId_BL_HighLight = rVR.getTextureIdFromName (getValStr("tx_bl_highlight")); + TxId_B_HighLight = rVR.getTextureIdFromName (getValStr("tx_b_highlight")); + TxId_BR_HighLight = rVR.getTextureIdFromName (getValStr("tx_br_highlight")); + + // + HeaderH = getValSInt32("header_h"); + + return true; +} + +// ---------------------------------------------------------------------------- +COptionsContainerInsertion::COptionsContainerInsertion() +{ + TxId_R_Arrow = -2; + TxId_L_Arrow = -2; + TxId_T_Arrow = -2; + TxId_B_Arrow = -2; + TxId_InsertionBar = -2; +} + +// ---------------------------------------------------------------------------- +bool COptionsContainerInsertion::parse(xmlNodePtr cur) +{ + if (!CInterfaceOptions::parse (cur)) + return false; + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + TxId_T_Arrow = rVR.getTextureIdFromName (getValStr("arrow_top")); + TxId_B_Arrow = rVR.getTextureIdFromName (getValStr("arrow_down")); + TxId_L_Arrow = rVR.getTextureIdFromName (getValStr("arrow_left")); + TxId_R_Arrow = rVR.getTextureIdFromName (getValStr("arrow_right")); + TxId_InsertionBar = rVR.getTextureIdFromName (getValStr("insertion_bar")); + + return true; +} + + +// *************************************************************************** +COptionsContainerMove::COptionsContainerMove() +{ + TrackW = -8; + TrackH = 22; + TrackY = -4; + TrackYWithTopResizer = -8; + TrackHWithTopResizer = 18; + ResizerSize = 8; +} + +// *************************************************************************** +bool COptionsContainerMove::parse(xmlNodePtr cur) +{ + if (!CInterfaceOptions::parse (cur)) + return false; + fromString(getValStr("track_w"), TrackW); + fromString(getValStr("track_h"), TrackH); + fromString(getValStr("track_y"), TrackY); + fromString(getValStr("track_y_with_top_resizer"), TrackYWithTopResizer); + fromString(getValStr("track_h_with_top_resizer"), TrackHWithTopResizer); + fromString(getValStr("resizer_size"), ResizerSize); + return true; +} + +// *************************************************************************** +COptionsList::COptionsList() +{ + _NumParams= 0; +} + +// *************************************************************************** +bool COptionsList::parse (xmlNodePtr cur) +{ + cur = cur->children; + bool ok = true; + uint id= 0; + while (cur) + { + if ( !stricmp((char*)cur->name,"param") ) + { + CXMLAutoPtr ptr, val; + val = xmlGetProp (cur, (xmlChar*)"value"); + if (!val) + { + nlinfo("param with no name or no value"); + ok = false; + } + else + { + string value = (string((const char*)val)); + _ParamValue[toString(id)].init(value); + id++; + } + } + cur = cur->next; + } + + _NumParams= id; + + return ok; +} + + +// *************************************************************************** +const CInterfaceOptionValue &COptionsList::getValue(uint paramId) const +{ + return CInterfaceOptions::getValue(toString(paramId)); +} + + +// *************************************************************************** +bool CMissionIconList::parse(xmlNodePtr cur) +{ + bool result = CInterfaceOptions::parse(cur); + if (!result) return false; + CInterfaceManager *im = CInterfaceManager::getInstance(); + CViewRenderer &vr = *CViewRenderer::getInstance(); + for(std::map::iterator it = _ParamValue.begin(); it != _ParamValue.end(); ++it) + { + int index; + if (fromString(it->first, index)) + { + if (index > 255) + { + nlwarning("bad index for texture"); + } + else + { + string sTmp = it->second.getValStr(); + string sBack, sIcon; + if (sTmp.find('|') != string::npos) + { + sBack = sTmp.substr(0,sTmp.find('|')); + sIcon = sTmp.substr(sTmp.find('|')+1,sTmp.size()); + } + else + { + sBack = sTmp; + } + + sint32 texID = vr.getTextureIdFromName(sBack); + if (texID != -1) + { + IconBackTexID.resize(std::max((int) IconBackTexID.size(), index + 1), -1); + IconBackTexID[index] = texID; + } + texID = vr.getTextureIdFromName(sIcon); + if (texID != -1) + { + IconTexID.resize(std::max((int) IconTexID.size(), index + 1), -1); + IconTexID[index] = texID; + } + } + } + } + NLMISC::contReset(_ParamValue); // not needed anymore + return true; +} + + +// *************************************************************************** +COptionsAnimationSet::COptionsAnimationSet() +{ + AnimationSet= NULL; +} + +// *************************************************************************** +COptionsAnimationSet::~COptionsAnimationSet() +{ + if(AnimationSet) + { + /* Important Note: this CInterfaceOptions is released BEFORE any CCharacter3d is released himself + BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList + (see deleteAnimationSet() doc) + */ + CViewRenderer::getInstance()->getDriver()->deleteAnimationSet(AnimationSet); + AnimationSet= NULL; + } +} + +// *************************************************************************** +bool COptionsAnimationSet::parse (xmlNodePtr cur) +{ + bool result = CInterfaceOptions::parse(cur); + if (!result) return false; + nlassert( CViewRenderer::getInstance()->getDriver() ); + + // create the animation set + AnimationSet= CViewRenderer::getInstance()->getDriver()->createAnimationSet(); + nlassert(AnimationSet); + + AnimMale.clear(); + AnimFemale.clear(); + + // Add all male/female animations + string sTmp; + for(uint gender=0; gender<2; gender++) + { + string prefix= (gender==0)?"m":"f"; + + uint i = 0; + do + { + sTmp = getValStr(prefix+toString(i)); + if (!sTmp.empty()) + { + // get params + vector params; + splitString(sTmp, "|", params); + // if error or first param empty, abort all + if(params.empty() || params[0].empty()) + { + sTmp.clear(); + } + else + { + string animName= params[0]; + animName += ".anim"; + uint animID = AnimationSet->addAnimation (animName.c_str(), animName.c_str()); + if (animID == UAnimationSet::NotFound) + nlwarning ("Character3D : not found anim : %s", animName.c_str()); + // try to add the Face animation for this one (not important if failed) + string faceAnimName= getFaceAnimName(animName); + AnimationSet->addAnimation (faceAnimName.c_str(), faceAnimName.c_str()); + + // append the new anim desc + CAnim newAnim; + newAnim.AnimId= animID; + newAnim.ApplyRaceScalePos= true; + // parse param + for(uint p=1;pbuild (); + + return true; +} + +// *************************************************************************** +string COptionsAnimationSet::getFaceAnimName(const std::string &animName) +{ + string faceAnimName= animName; + string::size_type extPos= faceAnimName.find(".anim"); + if(extPos!=string::npos) + faceAnimName= faceAnimName.substr(0, extPos); + faceAnimName+= "_face"; + if(extPos!=string::npos) + faceAnimName+= ".anim"; + return faceAnimName; +} + + + diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h new file mode 100644 index 000000000..f5bf6bc97 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h @@ -0,0 +1,178 @@ +// Ryzom - MMORPG Framework +// 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 IF_OPTIONS_RZ +#define IP_OPTIONS_RZ + +#include "interface_options.h" + +// *************************************************************************** +class COptionsLayer : public CInterfaceOptions +{ + +public: + COptionsLayer(); + ~COptionsLayer(); + virtual bool parse (xmlNodePtr cur); + + // Container optimizer + + sint32 Tile_Blank; + sint32 Tile_M_Header, Tile_M_Scrollbar; + sint32 Tile_T, Tile_B, Tile_L, Tile_R; + sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open; + + sint32 Scrollbar_Offset_X; + sint32 Scrollbar_W; + sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar; + sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar; + sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar; + + sint32 TxId_L_Header, W_L_Header, H_L_Header; + sint32 TxId_M_Header, W_M_Header, H_M_Header; + sint32 TxId_R_Header, W_R_Header, H_R_Header; + + sint32 TxId_TL, W_TL, H_TL; + sint32 TxId_T, W_T, H_T; + sint32 TxId_TR, W_TR, H_TR; + sint32 TxId_L, W_L, H_L; + sint32 TxId_R, W_R, H_R; + sint32 TxId_Blank, W_Blank, H_Blank; + sint32 TxId_BL, W_BL, H_BL; + sint32 TxId_B, W_B, H_B; + sint32 TxId_BR, W_BR, H_BR; + + sint32 TxId_BL_Open, W_BL_Open, H_BL_Open; + sint32 TxId_B_Open, W_B_Open, H_B_Open; + sint32 TxId_BR_Open, W_BR_Open, H_BR_Open; + sint32 TxId_EL_Open, W_EL_Open, H_EL_Open; + sint32 TxId_EM_Open, W_EM_Open, H_EM_Open; + sint32 TxId_ER_Open, W_ER_Open, H_ER_Open; + sint32 TxId_E_Open, W_E_Open, H_E_Open; + sint32 TxId_M_Open, W_M_Open, H_M_Open; + + sint32 TxId_TL_HighLight; + sint32 TxId_T_HighLight; + sint32 TxId_TR_HighLight; + sint32 TxId_L_HighLight; + sint32 TxId_R_HighLight; + sint32 TxId_BL_HighLight; + sint32 TxId_B_HighLight; + sint32 TxId_BR_HighLight; + + sint32 HeaderH; +}; + +// *************************************************************************** +class COptionsContainerInsertion : public CInterfaceOptions +{ +public: + COptionsContainerInsertion(); + virtual bool parse (xmlNodePtr cur); + + sint32 TxId_R_Arrow; + sint32 TxId_L_Arrow; + sint32 TxId_T_Arrow; + sint32 TxId_B_Arrow; + sint32 TxId_InsertionBar; +}; + +// *************************************************************************** +class COptionsContainerMove : public CInterfaceOptions +{ +public: + COptionsContainerMove(); + virtual bool parse (xmlNodePtr cur); + + sint32 TrackW; + sint32 TrackH; + sint32 TrackY; + sint32 TrackYWithTopResizer; + sint32 TrackHWithTopResizer; + sint32 ResizerSize; +}; + + + +// *************************************************************************** +/** + * read a list of with no name. id auto incremented + */ +class COptionsList : public CInterfaceOptions +{ +public: + COptionsList(); + virtual bool parse (xmlNodePtr cur); + + uint getNumParams() const {return _NumParams;} + + // get a value by its index (from 0 to numParams) + const CInterfaceOptionValue &getValue(uint paramId) const; + +private: + uint _NumParams; +}; + +// *************************************************************************** +class CMissionIconList : public CInterfaceOptions +{ +public: + virtual bool parse (xmlNodePtr cur); + sint32 getBackTexID(uint index) const { return index >= IconBackTexID.size() ? -1 : IconBackTexID[index]; } + sint32 getTexID(uint index) const { return index >= IconTexID.size() ? -1 : IconTexID[index]; } +private: + std::vector IconBackTexID; + std::vector IconTexID; +}; + +// *************************************************************************** +/** Describe an animation Set container, used for multiple CCharacter3d for instance + */ +class COptionsAnimationSet : public CInterfaceOptions +{ +public: + COptionsAnimationSet(); + // see code for important release note + virtual ~COptionsAnimationSet(); + virtual bool parse (xmlNodePtr cur); + + // tool fct to get the face anim name from a name (append "_face" before .anim) + static std::string getFaceAnimName(const std::string &animName); + +public: + NL3D::UAnimationSet *AnimationSet; + + struct CAnim + { + // Indexes in this animation set + uint AnimId; + // true if must apply the race/gender scale to the position (not in rare case) + bool ApplyRaceScalePos; + CAnim() + { + AnimId= -1; + ApplyRaceScalePos= true; + } + }; + + // Male and female Animation + std::vector AnimMale; + std::vector AnimFemale; + +}; + +#endif diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 7ca6c77a6..1539a2d29 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -32,6 +32,7 @@ #include "interface_parser.h" #include "interface_observer.h" #include "interface_options.h" +#include "interface_options_ryzom.h" #include "interface_anim.h" #include "interface_3d_scene.h" // View @@ -1353,6 +1354,8 @@ bool CInterfaceParser::parseOptions (xmlNodePtr cur, CInterfaceGroup * /* parent options = new CInterfaceOptions; } + CWidgetManager *wm = CWidgetManager::getInstance(); + // get the name ptr = (char*) xmlGetProp( cur, (xmlChar*)"name" ); if (!ptr) @@ -1368,17 +1371,17 @@ bool CInterfaceParser::parseOptions (xmlNodePtr cur, CInterfaceGroup * /* parent if (ptr) { string optionsParentName = ptr; - std::map >::iterator it= _OptionsMap.find(optionsParentName); - if(it!=_OptionsMap.end()) - options->copyBasicMap(*it->second); + CInterfaceOptions *io = wm->getOptions( optionsParentName ); + if( io != NULL ) + options->copyBasicMap( *io ); } // parse parameters if (options->parse (cur)) { // Remove old one - _OptionsMap.erase(optionsName); - _OptionsMap.insert(map::value_type(optionsName,options)); + wm->removeOptions( optionsName ); + wm->addOptions( optionsName, options ); } else { @@ -3549,12 +3552,6 @@ void CInterfaceParser::removeAllLinks() _LinkMap.clear(); } -// *************************************************************************** -void CInterfaceParser::removeAllOptions() -{ - _OptionsMap.clear(); // options are holded by smart pointers .. -} - // *************************************************************************** void CInterfaceParser::removeAllProcedures() { @@ -3599,7 +3596,7 @@ void CInterfaceParser::removeAll() removeAllLinks(); //nlinfo ("%d seconds for removeAllLinks", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); - removeAllOptions(); + CWidgetManager::getInstance()->removeAllOptions(); //nlinfo ("%d seconds for removeAllOptions", (uint32)(ryzomGetLocalTime ()-initStart)/1000); initStart = ryzomGetLocalTime (); removeAllProcedures(); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 70cf5a200..135483d5c 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -218,7 +218,6 @@ public: /// \name Clearing mgt // @{ void removeAllLinks(); - void removeAllOptions(); void removeAllProcedures(); void removeAllDefines(); void removeAllTemplates(); @@ -248,9 +247,6 @@ protected: * Data of initialized interface */ - // Options description - std::map > _OptionsMap; - /// Define Variable list typedef std::map TVarMap; typedef TVarMap::iterator ItVarMap; diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index b87ecafda..b1b0d9e12 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -205,7 +205,7 @@ void CMacroCmdManager::initInGame() // Get all custom icon bitmaps CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - CInterfaceOptions *pIO = pIM->getOptions("macro_custom_icon"); + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("macro_custom_icon"); if (pIO != NULL) { string sTmp; diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp index de19fbdca..aa76e0fa8 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -29,6 +29,8 @@ #include "../actions_client.h" #include "ctrl_button.h" +#include "interface_options_ryzom.h" + using namespace std; using namespace NLMISC; @@ -160,7 +162,7 @@ public: const CActionsManager::TActionComboMap &acmap = pAM->getActionComboMap(); - COptionsList *pOL = dynamic_cast(pIM->getOptions("gestion_windows_key_binding")); + COptionsList *pOL = dynamic_cast(CWidgetManager::getInstance()->getOptions("gestion_windows_key_binding")); if (pOL == NULL) return; for (uint i = 0; i < pOL->getNumParams(); ++i) diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index 7372f9401..c2266bb3a 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -150,12 +150,12 @@ void CViewBitmap::draw () CRGBA col; if(getModulateGlobalColor()) { - col.modulateFromColor (_Color, pIM->getGlobalColorForContent()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } if (_InheritGCAlpha) diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 27966ffc3..ebfdafe1b 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -186,7 +186,7 @@ void CViewPointer::draw () CRGBA col; if(getModulateGlobalColor()) - col.modulateFromColor (_Color, pIM->getGlobalColor()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColor()); else col= _Color; diff --git a/code/ryzom/client/src/interface_v3/view_polygon.cpp b/code/ryzom/client/src/interface_v3/view_polygon.cpp index 06c34025d..089b6614e 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.cpp +++ b/code/ryzom/client/src/interface_v3/view_polygon.cpp @@ -168,12 +168,12 @@ void CViewPolygon::draw() CRGBA col; if(getModulateGlobalColor()) { - col.modulateFromColor (_Color, im->getGlobalColorForContent()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)im->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); } diff --git a/code/ryzom/client/src/interface_v3/view_quad.cpp b/code/ryzom/client/src/interface_v3/view_quad.cpp index 296643a2d..ca983cb92 100644 --- a/code/ryzom/client/src/interface_v3/view_quad.cpp +++ b/code/ryzom/client/src/interface_v3/view_quad.cpp @@ -63,12 +63,12 @@ void CViewQuad::draw() CRGBA col; if(getModulateGlobalColor()) { - col.modulateFromColor (_Color, pIM->getGlobalColorForContent()); + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); } else { col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } /*if (_InheritGCAlpha) diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 06382059d..0a4ee8113 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -153,9 +153,9 @@ void CViewRadar::draw () CRGBA col = entity->getColor(); if(getModulateGlobalColor()) - col.modulateFromColor (col, pIM->getGlobalColorForContent()); + col.modulateFromColor (col, CWidgetManager::getInstance()->getGlobalColorForContent()); else - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); // Select the icon to display and draw it uint spotId = CNPCIconCache::getInstance().getNPCIcon(entity).getSpotId(); diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 5563b3799..895aadda6 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -442,7 +442,7 @@ void CViewText::draw () CRGBA col, shcol; if(getModulateGlobalColor()) { - CRGBA gcfc = pIM->getGlobalColorForContent(); + CRGBA gcfc = CWidgetManager::getInstance()->getGlobalColorForContent(); col.modulateFromColor (_Color, gcfc); shcol.modulateFromColor (_ShadowColor, gcfc); } @@ -450,8 +450,8 @@ void CViewText::draw () { col = _Color; shcol = _ShadowColor; - col.A = (uint8)(((sint)col.A*((sint)pIM->getGlobalColorForContent().A+1))>>8); - shcol.A = (uint8)(((sint)shcol.A*((sint)pIM->getGlobalColorForContent().A+1))>>8); + col.A = (uint8)(((sint)col.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + shcol.A = (uint8)(((sint)shcol.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); } diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 01b10580b..47b1166ff 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -16,13 +16,16 @@ #include "widget_manager.h" #include "interface_group.h" -#include "group_container.h" #include "group_modal.h" +#include "group_container.h" + +#include "nel/gui/db_manager.h" #include "nel/gui/view_renderer.h" #include "view_pointer_base.h" #include "group_editbox_base.h" #include "ctrl_draggable.h" +#include "interface_options.h" CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; @@ -948,6 +951,8 @@ void CWidgetManager::reset() _OldCaptureKeyboard = NULL; setCapturePointerLeft(NULL); setCapturePointerRight(NULL); + + resetColorProps(); } @@ -1310,11 +1315,79 @@ void CWidgetManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) } } +// ------------------------------------------------------------------------------------------------ +void CWidgetManager::setGlobalColor (NLMISC::CRGBA col) +{ + if (!_RProp) + { + _RProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); + _GProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); + _BProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); + _AProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); + } + _RProp ->setValue32 (col.R); + _GProp ->setValue32 (col.G); + _BProp ->setValue32 (col.B); + _AProp ->setValue32 (col.A); + + _GlobalColor = col; + + // set the global color for content (the same with modulated alpha) + _GlobalColorForContent = _GlobalColor; + _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColorForContent.A * (uint16) _ContentAlpha) >> 8); +} + +// *************************************************************************** +void CWidgetManager::setContentAlpha(uint8 alpha) +{ + _ContentAlpha = alpha; + // update alpha of global color + _GlobalColorForContent.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8);*/ +} + +void CWidgetManager::resetColorProps() +{ + _RProp = NULL; + _GProp = NULL; + _BProp = NULL; + _AProp = NULL; +} + +// ------------------------------------------------------------------------------------------------ +CInterfaceOptions* CWidgetManager::getOptions( const std::string &name ) +{ + std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > >::iterator it = _OptionsMap.find( name ); + if( it == _OptionsMap.end() ) + return NULL; + else + return it->second; +} + +void CWidgetManager::addOptions( std::string name, CInterfaceOptions *options ) +{ + _OptionsMap.insert( std::map< std::string, CInterfaceOptions* >::value_type( name, options ) ); +} + +void CWidgetManager::removeOptions( std::string name ) +{ + _OptionsMap.erase( name ); +} + +void CWidgetManager::removeAllOptions() +{ + _OptionsMap.clear(); +} CWidgetManager::CWidgetManager() { _Pointer = NULL; curContextHelp = NULL; + + resetColorProps(); + + _GlobalColor = NLMISC::CRGBA(255,255,255,255); + _GlobalColorForContent = _GlobalColor; + _ContentAlpha = 255; } CWidgetManager::~CWidgetManager() diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/ryzom/client/src/interface_v3/widget_manager.h index 998709032..cf2716eed 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.h +++ b/code/ryzom/client/src/interface_v3/widget_manager.h @@ -28,6 +28,12 @@ class CCtrlBase; class CViewBase; class CInterfaceGroup; class CViewPointerBase; +class CInterfaceOptions; + +namespace NLMISC +{ + class CCDBNodeLeaf; +} class IParser { @@ -267,6 +273,22 @@ public: // Remove a group from the windows list of its master group void unMakeWindow( CInterfaceGroup *group, bool noWarning = false ); + void setGlobalColor( NLMISC::CRGBA col ); + NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; } + + void setContentAlpha( uint8 alpha ); + uint8 getContentAlpha() const{ return _ContentAlpha; } + + NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; } + void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; } + void resetColorProps(); + + /// Get options by name + CInterfaceOptions* getOptions( const std::string &optName ); + void addOptions( std::string name, CInterfaceOptions *options ); + void removeOptions( std::string name ); + void removeAllOptions(); + static IParser *parser; private: @@ -280,6 +302,9 @@ private: NLMISC::CRefPtr< CCtrlBase > curContextHelp; CViewPointerBase *_Pointer; + // Options description + std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap; + NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder; // Capture @@ -296,6 +321,15 @@ private: // view that should be notified from clock msg std::vector _ClockMsgTargets; + + NLMISC::CRGBA _GlobalColor; + NLMISC::CRGBA _GlobalColorForContent; + uint8 _ContentAlpha; + + NLMISC::CCDBNodeLeaf *_RProp; + NLMISC::CCDBNodeLeaf *_GProp; + NLMISC::CCDBNodeLeaf *_BProp; + NLMISC::CCDBNodeLeaf *_AProp; }; #endif From 3a9955178412cb0595d49869882fa13df92d46d5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 8 Jun 2012 03:45:43 +0200 Subject: [PATCH 056/339] CHANGED: #1471 CWidgetManager no longer depends on CGroupContainer, instead of depends on a new class CGroupContainerBase. --- .../src/interface_v3/dbgroup_list_sheet.h | 1 + .../interface_v3/dbgroup_list_sheet_text.h | 1 + .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_container.h | 8 ++-- .../src/interface_v3/group_container_base.cpp | 43 +++++++++++++++++++ .../src/interface_v3/group_container_base.h | 42 ++++++++++++++++++ .../src/interface_v3/interface_element.h | 1 - .../register_interface_elements.cpp | 4 +- .../src/interface_v3/widget_manager.cpp | 23 +++++----- code/ryzom/client/src/r2/tool.h | 2 + 10 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/group_container_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/group_container_base.h diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index 2af0ef02a..171152cfc 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -27,6 +27,7 @@ // *************************************************************************** class CCtrlBaseButton; class CCtrlScroll; +class CGroupContainer; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index bf6d6be67..ef1a00f9d 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -33,6 +33,7 @@ class CCtrlButton; class CCtrlScroll; class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; +class CGroupContainer; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index f091df1e6..da843ae0c 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -1195,7 +1195,7 @@ NLMISC_REGISTER_OBJECT(CViewBase, CGroupContainer, std::string, "container"); // *************************************************************************** CGroupContainer::CGroupContainer(const TCtorParam ¶m) -: CInterfaceGroup(param) +: CGroupContainerBase(param) { // faster than a virual call _IsGroupContainer = true; diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 94b00f9f3..48be495de 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -20,12 +20,14 @@ #define RZ_GROUP_CONTAINER_H #include "interface_group.h" +#include "group_container_base.h" #include "nel/misc/smart_ptr.h" namespace NLGUI { -class CEventDescriptorLocalised; + class CEventDescriptorLocalised; } + class CInterfaceList; class CCtrlButton; class CCtrlScroll; @@ -152,7 +154,7 @@ private: * \author Nevrax France * \date 2002 */ -class CGroupContainer : public CInterfaceGroup +class CGroupContainer : public CGroupContainerBase { public: enum { NumResizers = 8 }; @@ -267,7 +269,7 @@ public: int luaBlink(CLuaState &ls); int luaSetHeaderColor(CLuaState &ls); - REFLECT_EXPORT_START(CGroupContainer, CInterfaceGroup) + REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase) REFLECT_LUA_METHOD("blink", luaBlink); REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor); REFLECT_STRING("title", getTitle, setTitle); diff --git a/code/ryzom/client/src/interface_v3/group_container_base.cpp b/code/ryzom/client/src/interface_v3/group_container_base.cpp new file mode 100644 index 000000000..71deb661f --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_container_base.cpp @@ -0,0 +1,43 @@ +// Ryzom - MMORPG Framework +// 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 "group_container_base.h" + +CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : +CInterfaceGroup( param ) +{ +} + +CGroupContainerBase::~CGroupContainerBase() +{ +} + +void CGroupContainerBase::removeAllContainers() +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + +void CGroupContainerBase::setLocked( bool locked ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + + diff --git a/code/ryzom/client/src/interface_v3/group_container_base.h b/code/ryzom/client/src/interface_v3/group_container_base.h new file mode 100644 index 000000000..316e83cf9 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_container_base.h @@ -0,0 +1,42 @@ +// Ryzom - MMORPG Framework +// 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_CONTAINER_BASE_H +#define GROUP_CONTAINER_BASE_H + +#include "interface_group.h" + +class CGroupContainerBase : public CInterfaceGroup +{ +public: + DECLARE_UI_CLASS( CGroupContainerBase ) + CGroupContainerBase( const TCtorParam ¶m ); + virtual ~CGroupContainerBase(); + + virtual void removeAllContainers(); + virtual void setLocked( bool locked ); + + REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) + REFLECT_EXPORT_END + +protected: + +private: + +}; + +#endif diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 49c584462..7c7706ba7 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -33,7 +33,6 @@ class CInterfaceElement; class CInterfaceGroup; class CViewBase; class CCtrlBase; -class CGroupContainer; class IActionHandler; /** diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index df6c77974..227540244 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -28,6 +28,7 @@ #include "ctrl_base.h" #include "interface_group.h" #include "group_frame.h" +#include "group_container_base.h" #include "group_container.h" #include "group_list.h" #include "dbgroup_select_number.h" @@ -82,7 +83,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CInterfaceGroup, CCtrlBase); REGISTER_REFLECTABLE_CLASS(CGroupFrame, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupModal, CGroupFrame); - REGISTER_REFLECTABLE_CLASS(CGroupContainer, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupContainerBase, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupContainer, CGroupContainerBase); REGISTER_REFLECTABLE_CLASS(CDBGroupSelectNumber, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(IListSheetBase, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupEditBoxBase, CInterfaceGroup); diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 47b1166ff..c3ec5bc4e 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -14,19 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "widget_manager.h" -#include "interface_group.h" -#include "group_modal.h" - -#include "group_container.h" - #include "nel/gui/db_manager.h" #include "nel/gui/view_renderer.h" +#include "widget_manager.h" #include "view_pointer_base.h" -#include "group_editbox_base.h" #include "ctrl_draggable.h" +#include "interface_group.h" +#include "group_container_base.h" +#include "group_modal.h" +#include "group_editbox_base.h" #include "interface_options.h" + CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; IParser* CWidgetManager::parser = NULL; @@ -155,7 +154,7 @@ void CWidgetManager::SMasterGroup::setBackWindow(CInterfaceGroup *pIG) // ---------------------------------------------------------------------------- void CWidgetManager::SMasterGroup::deactiveAllContainers() { - std::vector gcs; + std::vector gcs; // Make first a list of all window (Warning: all group container are not window!) for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) @@ -163,7 +162,7 @@ void CWidgetManager::SMasterGroup::deactiveAllContainers() std::list::iterator it = PrioritizedWindows[i].begin(); while (it != PrioritizedWindows[i].end()) { - CGroupContainer *pGC = dynamic_cast(*it); + CGroupContainerBase *pGC = dynamic_cast(*it); if (pGC != NULL) gcs.push_back(pGC); it++; @@ -186,7 +185,7 @@ void CWidgetManager::SMasterGroup::centerAllContainers() std::list::iterator it = PrioritizedWindows[i].begin(); while (it != PrioritizedWindows[i].end()) { - CGroupContainer *pGC = dynamic_cast(*it); + CGroupContainerBase *pGC = dynamic_cast(*it); if ((pGC != NULL) && (pGC->getParent() != NULL)) { sint32 wParent = pGC->getParent()->getW(false); @@ -210,7 +209,7 @@ void CWidgetManager::SMasterGroup::unlockAllContainers() std::list::iterator it = PrioritizedWindows[i].begin(); while (it != PrioritizedWindows[i].end()) { - CGroupContainer *pGC = dynamic_cast(*it); + CGroupContainerBase *pGC = dynamic_cast(*it); if (pGC != NULL) pGC->setLocked(false); @@ -338,7 +337,7 @@ void unlinkAllContainers (CInterfaceGroup *pIG) for(uint i = 0; i < rG.size(); ++i) unlinkAllContainers (rG[i]); - CGroupContainer *pGC = dynamic_cast(pIG); + CGroupContainerBase *pGC = dynamic_cast(pIG); if (pGC != NULL) pGC->removeAllContainers(); } diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index e10e5002e..1152687bb 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -26,6 +26,8 @@ // class CInterfaceManager; +class CGroupContainer; + namespace NLGUI { class CEventDescriptor; From 7ddc76cc85b4adad3e80cacfec3232f3352c347f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 8 Jun 2012 04:41:33 +0200 Subject: [PATCH 057/339] CHANGED: #1471 Moved some code from CGroupContainer to CGroupContainerBase. CAHManager now depends on CGroupContainerBase instead of CGroupContainer. --- .../src/interface_v3/action_handler.cpp | 18 +++--- .../src/interface_v3/group_container.cpp | 55 ------------------- .../client/src/interface_v3/group_container.h | 54 +----------------- .../src/interface_v3/group_container_base.cpp | 49 +++++++++++++++++ .../src/interface_v3/group_container_base.h | 52 ++++++++++++++++++ 5 files changed, 112 insertions(+), 116 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/ryzom/client/src/interface_v3/action_handler.cpp index 6ec889ca4..1961a5315 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler.cpp @@ -15,7 +15,9 @@ // along with this program. If not, see . #include "action_handler.h" -#include "group_container.h" +//#include "group_container.h" +#include "group_container_base.h" +#include "nel/gui/interface_property.h" #include "nel/gui/interface_expr.h" #include "nel/gui/db_manager.h" #include "interface_link.h" @@ -481,7 +483,7 @@ REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w"); //////////////////////////////// // the container whose alpha is being edited -static CGroupContainer *AlphaChooserTarget = NULL; +static CGroupContainerBase *AlphaChooserTarget = NULL; static bool OldUseGlobalAlpha; static uint8 OldContentAlpha; static uint8 OldBgAlpha; @@ -518,11 +520,11 @@ class CAHChooseUIAlpha : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - CGroupContainer *gc = NULL; + CGroupContainerBase *gc = NULL; CCtrlBase *cb = pCaller; while (cb) { - gc = dynamic_cast(cb); + gc = dynamic_cast(cb); if (gc) break; cb = cb->getParent(); } @@ -635,11 +637,11 @@ class CAHLockUnlock : public IActionHandler { virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - CGroupContainer *gc = NULL; + CGroupContainerBase *gc = NULL; CCtrlBase *cb = pCaller; while (cb) { - gc = dynamic_cast(cb); + gc = dynamic_cast< CGroupContainerBase* >(cb); if (gc) break; cb = cb->getParent(); } @@ -655,7 +657,7 @@ class CAHSetTransparent : public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { - CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params)); + CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params)); if (pGC != NULL) { pGC->setUseGlobalAlpha(false); @@ -678,7 +680,7 @@ class CAHSetAlpha : public IActionHandler uint8 alpha; fromString(getParam (Params, "alpha"), alpha); - CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(ui)); + CGroupContainerBase *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(ui)); if (pGC != NULL) { pGC->setUseGlobalAlpha(false); diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index da843ae0c..0714dd2eb 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -1200,10 +1200,6 @@ CGroupContainer::CGroupContainer(const TCtorParam ¶m) // faster than a virual call _IsGroupContainer = true; - _ContentAlpha = 255; - _ContainerAlpha = 255; - _RolloverAlphaContainer = 0; - _RolloverAlphaContent = 0; _CurrentContainerAlpha = 255; _CurrentContentAlpha = 255; _CurrentRolloverAlphaContainer = 0.f; @@ -1250,7 +1246,6 @@ CGroupContainer::CGroupContainer(const TCtorParam ¶m) _OpenAtStart = false; _OpenedBeforePopup = false; - _Locked = false; _Lockable = true; _EnabledResizer = true; @@ -1265,7 +1260,6 @@ CGroupContainer::CGroupContainer(const TCtorParam ¶m) _MovingInParentList = false; _ActiveSavable = true; _Savable = true; - _UseGlobalAlpha = true; _TitleClass = TitleText; _TouchFlag = false; _PositionBackuped = false; @@ -4028,52 +4022,3 @@ void CGroupContainer::setContentYOffset(sint32 value) } - - -// *************************************************************************** -void CGroupContainer::triggerAlphaSettingsChangedAH() -{ - if (_AHOnAlphaSettingsChanged != NULL) - { - CInterfaceManager *im = CInterfaceManager::getInstance(); - CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); - } -} - - -// *************************************************************************** -void CGroupContainer::setUseGlobalAlpha(bool use) -{ - _UseGlobalAlpha = use; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainer::setContainerAlpha(uint8 alpha) -{ - _ContainerAlpha = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainer::setContentAlpha(uint8 alpha) -{ - _ContentAlpha = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainer::setRolloverAlphaContent(uint8 alpha) -{ - _RolloverAlphaContent = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainer::setRolloverAlphaContainer(uint8 alpha) -{ - _RolloverAlphaContainer = alpha; - triggerAlphaSettingsChangedAH(); -} - - diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 48be495de..c1268870c 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -289,13 +289,7 @@ public: REFLECT_BOOL("opened", isOpen, setOpen); REFLECT_BOOL("lockable", isLockable, setLockable); REFLECT_BOOL("locked", isLocked, setLocked); - REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha); - REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha); - REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent); - REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer); - REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha); - REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged); - REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); REFLECT_EXPORT_END @@ -372,33 +366,8 @@ public: sint32 getRefW() const { return _RefW; } - // alpha for content / container - void setUseGlobalAlpha(bool use); - void setContainerAlpha(uint8 alpha); - void setContentAlpha(uint8 alpha); - void setRolloverAlphaContent(uint8 alpha); - void setRolloverAlphaContainer(uint8 alpha); - - // sin32 versions for export - void setContainerAlpha(sint32 alpha) { setContainerAlpha((uint8) alpha); } - void setContentAlpha(sint32 alpha) { setContentAlpha((uint8) alpha); } - void setRolloverAlphaContent(sint32 alpha) { setRolloverAlphaContent((uint8) alpha); } - void setRolloverAlphaContainer(sint32 alpha) { setRolloverAlphaContainer((uint8) alpha); } - - bool isUsingGlobalAlpha() const { return _UseGlobalAlpha; } - - uint8 getContainerAlpha() const { return _ContainerAlpha; } - uint8 getContentAlpha() const { return _ContentAlpha; } uint8 getCurrentContainerAlpha() const { return _CurrentContainerAlpha; } uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; } - uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; } - uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; } - - // for export - sint32 getContainerAlphaAsSInt32() const { return (sint32) _ContainerAlpha; } - sint32 getContentAlphaAsSInt32() const { return (sint32) _ContentAlpha; } - sint32 getRolloverAlphaContentAsSInt32() const { return (sint32) _RolloverAlphaContent; } - sint32 getRolloverAlphaContainerAsSInt32() const { return (sint32) _RolloverAlphaContainer; } /** Increase the rollover alpha for the current frame. * Example of use : an edit box that has focus in a group container @@ -413,7 +382,6 @@ public: void setLockable(bool lockable); bool isLockable() const { return _Lockable; } void setLocked(bool locked); - bool isLocked() const { return _Locked; } // to be called by the 'deactive check' handler static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } @@ -439,17 +407,6 @@ public: void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } - - std::string getAHOnAlphaSettingsChanged() const { return CAHManager::getInstance()->getAHName(_AHOnAlphaSettingsChanged); } - std::string getAHOnAlphaSettingsChangedParams() const { return _AHOnAlphaSettingsChangedParams; } - - void setAHOnAlphaSettingsChanged(const std::string &h) { _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH(h, _AHOnAlphaSettingsChangedParams); } - void setAHOnAlphaSettingsChangedParams(const std::string &p) { _AHOnAlphaSettingsChangedParams = p; } - - - - - void setModalParentList (const std::string &name); bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) bool isGrayed() const; @@ -506,13 +463,9 @@ public: sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } protected: - uint8 _ContainerAlpha; - uint8 _ContentAlpha; uint8 _CurrentContainerAlpha; uint8 _CurrentContentAlpha; - uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it uint8 _ICurrentRolloverAlphaContainer; - uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it uint8 _HighLightedAlpha; float _CurrentRolloverAlphaContainer; float _CurrentRolloverAlphaContent; @@ -585,8 +538,6 @@ protected: CStringShared _AHOnMoveParams; IActionHandler *_AHOnResize; CStringShared _AHOnResizeParams; - IActionHandler *_AHOnAlphaSettingsChanged; - CStringShared _AHOnAlphaSettingsChangedParams; IActionHandler *_AHOnBeginMove; CStringShared _AHOnBeginMoveParams; @@ -612,7 +563,6 @@ protected: // Move management bool _Movable : 1; // Is the container movable ? bool _MovableInParentList: 1; - bool _Locked : 1; // Is the container locked (ie override movable, openable ...) bool _Lockable : 1; bool _MovingInParentList : 1; // Mgt : currently moving ? @@ -628,7 +578,6 @@ protected: bool _Savable : 1; bool _ActiveSavable : 1; - bool _UseGlobalAlpha : 1; // Display title background or not bool _HeaderActive : 1; @@ -694,7 +643,6 @@ private: enum {NumLayerName=10}; static const std::string _OptionLayerName[NumLayerName]; - void triggerAlphaSettingsChangedAH(); public: // for use by CCtrlMover // Tell that this group is moving in its parent list diff --git a/code/ryzom/client/src/interface_v3/group_container_base.cpp b/code/ryzom/client/src/interface_v3/group_container_base.cpp index 71deb661f..79144c787 100644 --- a/code/ryzom/client/src/interface_v3/group_container_base.cpp +++ b/code/ryzom/client/src/interface_v3/group_container_base.cpp @@ -20,6 +20,12 @@ CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : CInterfaceGroup( param ) { + _ContentAlpha = 255; + _ContainerAlpha = 255; + _RolloverAlphaContainer = 0; + _RolloverAlphaContent = 0; + _Locked = false; + _UseGlobalAlpha = true; } CGroupContainerBase::~CGroupContainerBase() @@ -41,3 +47,46 @@ void CGroupContainerBase::setLocked( bool locked ) } +// *************************************************************************** +void CGroupContainerBase::triggerAlphaSettingsChangedAH() +{ + if (_AHOnAlphaSettingsChanged != NULL) + CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); +} + + +// *************************************************************************** +void CGroupContainerBase::setUseGlobalAlpha(bool use) +{ + _UseGlobalAlpha = use; + triggerAlphaSettingsChangedAH(); +} + +// *************************************************************************** +void CGroupContainerBase::setContainerAlpha(uint8 alpha) +{ + _ContainerAlpha = alpha; + triggerAlphaSettingsChangedAH(); +} + +// *************************************************************************** +void CGroupContainerBase::setContentAlpha(uint8 alpha) +{ + _ContentAlpha = alpha; + triggerAlphaSettingsChangedAH(); +} + +// *************************************************************************** +void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha) +{ + _RolloverAlphaContent = alpha; + triggerAlphaSettingsChangedAH(); +} + +// *************************************************************************** +void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha) +{ + _RolloverAlphaContainer = alpha; + triggerAlphaSettingsChangedAH(); +} + diff --git a/code/ryzom/client/src/interface_v3/group_container_base.h b/code/ryzom/client/src/interface_v3/group_container_base.h index 316e83cf9..4e2e2f28e 100644 --- a/code/ryzom/client/src/interface_v3/group_container_base.h +++ b/code/ryzom/client/src/interface_v3/group_container_base.h @@ -20,20 +20,72 @@ #include "interface_group.h" + class CGroupContainerBase : public CInterfaceGroup { public: DECLARE_UI_CLASS( CGroupContainerBase ) + CGroupContainerBase( const TCtorParam ¶m ); virtual ~CGroupContainerBase(); virtual void removeAllContainers(); virtual void setLocked( bool locked ); + bool isLocked() const { return _Locked; } + + uint8 getContainerAlpha() const { return _ContainerAlpha; } + uint8 getContentAlpha() const { return _ContentAlpha; } + uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; } + uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; } + + void setContainerAlpha( uint8 alpha ); + void setContentAlpha( uint8 alpha ); + void setRolloverAlphaContent( uint8 alpha ); + void setRolloverAlphaContainer( uint8 alpha ); + + // for export + sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; } + sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; } + sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; } + sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; } + + // sin32 versions for export + void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); } + void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); } + void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); } + void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); } + + void setUseGlobalAlpha( bool use ); + bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; } + + std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); } + std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; } + + void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); } + void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; } REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) + REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha); + REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha); + REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent); + REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer); + REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha); + REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged); + REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); REFLECT_EXPORT_END protected: + void triggerAlphaSettingsChangedAH(); + + uint8 _ContainerAlpha; + uint8 _ContentAlpha; + uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it + uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it + bool _Locked : 1; // Is the container locked (ie override movable, openable ...) + bool _UseGlobalAlpha : 1; + + IActionHandler *_AHOnAlphaSettingsChanged; + CStringShared _AHOnAlphaSettingsChangedParams; private: From 529dd877fe357365bb17c4e703a18aacb30632da Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 9 Jun 2012 01:37:43 +0200 Subject: [PATCH 058/339] CHANGED: #1471 Finally moved some of the basic widget classes and the widget manager, action handler manager to the GUI lib. Also moved some GUI related methods back to CLuaIHM. --- .../include/nel/gui}/action_handler.h | 0 .../include/nel/gui}/ctrl_base.h | 2 +- .../include/nel/gui}/ctrl_draggable.h | 2 +- .../include/nel/gui}/ctrl_scroll_base.h | 2 +- code/nel/include/nel/gui/event_descriptor.h | 1 + .../include/nel/gui}/group_container_base.h | 2 +- .../include/nel/gui}/group_editbox_base.h | 2 +- .../include/nel/gui}/group_frame.h | 2 +- .../include/nel/gui}/group_modal.h | 2 +- .../include/nel/gui}/interface_element.h | 1 + .../include/nel/gui}/interface_group.h | 4 +- .../include/nel/gui}/interface_link.h | 0 .../include/nel/gui}/interface_options.h | 5 +- code/nel/include/nel/gui/lua_ihm.h | 22 +- .../include/nel/gui}/view_base.h | 2 +- .../include/nel/gui}/view_pointer_base.h | 2 +- .../include/nel/gui}/widget_manager.h | 0 .../src/gui}/action_handler.cpp | 9 +- .../src/gui}/ctrl_base.cpp | 10 +- .../src/gui}/ctrl_draggable.cpp | 2 +- .../src/gui}/ctrl_scroll_base.cpp | 2 +- .../src/gui}/group_container_base.cpp | 2 +- .../src/gui}/group_editbox_base.cpp | 2 +- .../src/gui}/group_frame.cpp | 8 +- .../src/gui}/group_modal.cpp | 4 +- .../src/gui}/interface_element.cpp | 10 +- .../src/gui}/interface_group.cpp | 23 +- .../src/gui}/interface_link.cpp | 11 +- .../src/gui}/interface_options.cpp | 4 +- code/nel/src/gui/lua_ihm.cpp | 432 ++++++++++++++- .../src/gui}/view_base.cpp | 6 +- .../src/gui}/view_pointer_base.cpp | 2 +- .../src/gui}/widget_manager.cpp | 16 +- code/ryzom/client/src/camera_recorder.cpp | 2 +- code/ryzom/client/src/client_chat_manager.cpp | 2 +- code/ryzom/client/src/connection.cpp | 2 +- code/ryzom/client/src/entity_cl.cpp | 2 +- code/ryzom/client/src/game_context_menu.h | 2 +- code/ryzom/client/src/init.cpp | 2 +- code/ryzom/client/src/init_main_loop.cpp | 2 +- .../src/interface_v3/action_handler_debug.cpp | 2 +- .../src/interface_v3/action_handler_edit.cpp | 2 +- .../src/interface_v3/action_handler_game.cpp | 4 +- .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/action_handler_misc.cpp | 2 +- .../src/interface_v3/action_handler_misc.h | 2 +- .../src/interface_v3/action_handler_move.cpp | 2 +- .../interface_v3/action_handler_outpost.cpp | 2 +- .../interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/action_handler_tools.cpp | 2 +- .../src/interface_v3/action_handler_ui.cpp | 2 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../src/interface_v3/bot_chat_manager.cpp | 4 +- .../client/src/interface_v3/bot_chat_page.cpp | 2 +- .../bot_chat_page_create_guild.cpp | 4 +- .../bot_chat_page_dynamic_mission.cpp | 4 +- .../interface_v3/bot_chat_page_mission.cpp | 4 +- .../bot_chat_page_mission_end.cpp | 2 +- .../src/interface_v3/bot_chat_page_news.cpp | 2 +- .../bot_chat_page_player_gift.cpp | 4 +- .../src/interface_v3/bot_chat_page_trade.cpp | 4 +- .../client/src/interface_v3/character_3d.h | 4 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../src/interface_v3/ctrl_base_button.h | 4 +- .../client/src/interface_v3/ctrl_col_pick.h | 2 +- .../client/src/interface_v3/ctrl_polygon.h | 2 +- .../client/src/interface_v3/ctrl_quad.cpp | 2 +- .../ryzom/client/src/interface_v3/ctrl_quad.h | 2 +- .../client/src/interface_v3/ctrl_scroll.cpp | 6 +- .../client/src/interface_v3/ctrl_scroll.h | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../client/src/interface_v3/ctrl_tooltip.h | 2 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 4 +- .../client/src/interface_v3/dbctrl_sheet.h | 4 +- .../src/interface_v3/dbgroup_build_phrase.h | 2 +- .../src/interface_v3/dbgroup_combo_box.cpp | 2 +- .../src/interface_v3/dbgroup_combo_box.h | 2 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../interface_v3/dbgroup_select_number.cpp | 2 +- .../src/interface_v3/dbgroup_select_number.h | 2 +- .../client/src/interface_v3/dbview_digit.h | 2 +- .../client/src/interface_v3/group_career.cpp | 2 +- .../client/src/interface_v3/group_compas.cpp | 2 +- .../src/interface_v3/group_container.cpp | 4 +- .../client/src/interface_v3/group_container.h | 4 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../client/src/interface_v3/group_editbox.h | 4 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_html.h | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 2 +- .../interface_v3/group_in_scene_user_info.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 18 +- .../client/src/interface_v3/group_list.h | 2 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../ryzom/client/src/interface_v3/group_map.h | 2 +- .../client/src/interface_v3/group_menu.cpp | 20 +- .../client/src/interface_v3/group_menu.h | 4 +- .../src/interface_v3/group_modal_get_key.h | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../client/src/interface_v3/group_paragraph.h | 2 +- .../interface_v3/group_phrase_skill_filter.h | 2 +- .../src/interface_v3/group_quick_help.cpp | 2 +- .../src/interface_v3/group_scrolltext.cpp | 2 +- .../src/interface_v3/group_scrolltext.h | 2 +- .../client/src/interface_v3/group_skills.h | 2 +- .../client/src/interface_v3/group_tab.cpp | 8 +- .../ryzom/client/src/interface_v3/group_tab.h | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/group_table.h | 2 +- .../client/src/interface_v3/group_tree.cpp | 6 +- .../client/src/interface_v3/group_tree.h | 2 +- .../client/src/interface_v3/group_wheel.h | 2 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_3d_scene.cpp | 2 +- .../src/interface_v3/interface_3d_scene.h | 2 +- .../src/interface_v3/interface_anim.cpp | 2 +- .../client/src/interface_v3/interface_anim.h | 4 +- .../client/src/interface_v3/interface_ddx.cpp | 4 +- .../client/src/interface_v3/interface_ddx.h | 2 +- .../interface_expr_user_fct_game.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 8 +- .../src/interface_v3/interface_manager.h | 10 +- .../interface_v3/interface_options_ryzom.cpp | 2 +- .../interface_v3/interface_options_ryzom.h | 2 +- .../src/interface_v3/interface_parser.cpp | 8 +- .../src/interface_v3/interface_parser.h | 4 +- .../src/interface_v3/inventory_manager.cpp | 2 +- .../client/src/interface_v3/list_sheet_base.h | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 494 ++---------------- .../client/src/interface_v3/lua_ihm_ryzom.h | 12 - .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../client/src/interface_v3/music_player.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../client/src/interface_v3/player_trade.cpp | 2 +- .../register_interface_elements.cpp | 18 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- .../client/src/interface_v3/sphrase_manager.h | 2 +- .../src/interface_v3/task_bar_manager.cpp | 2 +- .../client/src/interface_v3/view_bitmap.h | 2 +- .../src/interface_v3/view_bitmap_combo.h | 2 +- .../client/src/interface_v3/view_pointer.h | 2 +- .../client/src/interface_v3/view_polygon.h | 2 +- .../client/src/interface_v3/view_quad.cpp | 2 +- .../ryzom/client/src/interface_v3/view_quad.h | 2 +- .../client/src/interface_v3/view_radar.h | 2 +- .../ryzom/client/src/interface_v3/view_text.h | 2 +- code/ryzom/client/src/main_loop.cpp | 4 +- code/ryzom/client/src/r2/displayer_base.cpp | 2 +- code/ryzom/client/src/r2/displayer_base.h | 2 +- code/ryzom/client/src/r2/instance.h | 2 +- code/ryzom/client/src/r2/island_collision.h | 2 +- code/ryzom/client/src/r2/tool.h | 2 +- 157 files changed, 738 insertions(+), 728 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/action_handler.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_base.h (97%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_draggable.h (93%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_scroll_base.h (95%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/group_container_base.h (96%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/group_editbox_base.h (95%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/group_frame.h (94%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/group_modal.h (95%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/interface_element.h (96%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/interface_group.h (97%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/interface_link.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/interface_options.h (93%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_base.h (95%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_pointer_base.h (94%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/widget_manager.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/action_handler.cpp (96%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_base.cpp (93%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_draggable.cpp (79%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_scroll_base.cpp (94%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/group_container_base.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/group_editbox_base.cpp (81%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/group_frame.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/group_modal.cpp (94%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/interface_element.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/interface_group.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/interface_link.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/interface_options.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/view_base.cpp (91%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/view_pointer_base.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/widget_manager.cpp (95%) diff --git a/code/ryzom/client/src/interface_v3/action_handler.h b/code/nel/include/nel/gui/action_handler.h similarity index 100% rename from code/ryzom/client/src/interface_v3/action_handler.h rename to code/nel/include/nel/gui/action_handler.h diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h similarity index 97% rename from code/ryzom/client/src/interface_v3/ctrl_base.h rename to code/nel/include/nel/gui/ctrl_base.h index bc0caa7e4..44ad924ec 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -20,7 +20,7 @@ #define RZ_CTRL_BASE_H #include "nel/misc/types_nl.h" -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/gui/event_descriptor.h" class CCtrlBase : public CViewBase diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h similarity index 93% rename from code/ryzom/client/src/interface_v3/ctrl_draggable.h rename to code/nel/include/nel/gui/ctrl_draggable.h index 120fabde6..256ce345b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -1,7 +1,7 @@ #ifndef CTRL_DRAGGABLE_H #define CTRL_DRAGGABLE_H -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" class CCtrlDraggable : public CCtrlBase { diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h b/code/nel/include/nel/gui/ctrl_scroll_base.h similarity index 95% rename from code/ryzom/client/src/interface_v3/ctrl_scroll_base.h rename to code/nel/include/nel/gui/ctrl_scroll_base.h index 43b82c05a..16eee9c59 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h +++ b/code/nel/include/nel/gui/ctrl_scroll_base.h @@ -17,7 +17,7 @@ #ifndef CTRL_SCROLL_BASE_H #define CTRL_SCROLL_BASE_H -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" class CInterfaceGroup; diff --git a/code/nel/include/nel/gui/event_descriptor.h b/code/nel/include/nel/gui/event_descriptor.h index 54b561e6a..1c543d7ea 100644 --- a/code/nel/include/nel/gui/event_descriptor.h +++ b/code/nel/include/nel/gui/event_descriptor.h @@ -20,6 +20,7 @@ #define RZ_EVENT_DESCRIPTOR_H #include "nel/misc/types_nl.h" +#include "nel/misc/events.h" namespace NLGUI { diff --git a/code/ryzom/client/src/interface_v3/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h similarity index 96% rename from code/ryzom/client/src/interface_v3/group_container_base.h rename to code/nel/include/nel/gui/group_container_base.h index 4e2e2f28e..b3ed6e501 100644 --- a/code/ryzom/client/src/interface_v3/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -18,7 +18,7 @@ #ifndef GROUP_CONTAINER_BASE_H #define GROUP_CONTAINER_BASE_H -#include "interface_group.h" +#include "nel/gui/interface_group.h" class CGroupContainerBase : public CInterfaceGroup diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.h b/code/nel/include/nel/gui/group_editbox_base.h similarity index 95% rename from code/ryzom/client/src/interface_v3/group_editbox_base.h rename to code/nel/include/nel/gui/group_editbox_base.h index 77aed7b08..3f77fa8ba 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox_base.h +++ b/code/nel/include/nel/gui/group_editbox_base.h @@ -18,7 +18,7 @@ #ifndef GROUP_EDITBOX_BASE_H #define GROUP_EDITBOX_BASE_H -#include "interface_group.h" +#include "nel/gui/interface_group.h" class CGroupEditBoxBase : public CInterfaceGroup { diff --git a/code/ryzom/client/src/interface_v3/group_frame.h b/code/nel/include/nel/gui/group_frame.h similarity index 94% rename from code/ryzom/client/src/interface_v3/group_frame.h rename to code/nel/include/nel/gui/group_frame.h index 4f1663a9e..a8a1bca38 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.h +++ b/code/nel/include/nel/gui/group_frame.h @@ -20,7 +20,7 @@ #define NL_GROUP_FRAME_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_modal.h b/code/nel/include/nel/gui/group_modal.h similarity index 95% rename from code/ryzom/client/src/interface_v3/group_modal.h rename to code/nel/include/nel/gui/group_modal.h index 622a3051c..9fab37b2a 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.h +++ b/code/nel/include/nel/gui/group_modal.h @@ -20,7 +20,7 @@ #define NL_GROUP_MODAL_H #include "nel/misc/types_nl.h" -#include "group_frame.h" +#include "nel/gui/group_frame.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/nel/include/nel/gui/interface_element.h similarity index 96% rename from code/ryzom/client/src/interface_v3/interface_element.h rename to code/nel/include/nel/gui/interface_element.h index 7c7706ba7..fc876fa61 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -22,6 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" #include "nel/misc/smart_ptr.h" +#include "nel/misc/vector.h" #include "nel/gui/interface_property.h" #include "nel/gui/reflect.h" #include "nel/gui/interface_common.h" diff --git a/code/ryzom/client/src/interface_v3/interface_group.h b/code/nel/include/nel/gui/interface_group.h similarity index 97% rename from code/ryzom/client/src/interface_v3/interface_group.h rename to code/nel/include/nel/gui/interface_group.h index 5e1b1f716..09f248f00 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -19,8 +19,8 @@ #ifndef NL_INTERFACE_GROUP_H #define NL_INTERFACE_GROUP_H -#include "ctrl_base.h" -#include "action_handler.h" +#include "nel/gui/ctrl_base.h" +#include "nel/gui/action_handler.h" // ---------------------------------------------------------------------------- class CInterfaceGroup : public CCtrlBase diff --git a/code/ryzom/client/src/interface_v3/interface_link.h b/code/nel/include/nel/gui/interface_link.h similarity index 100% rename from code/ryzom/client/src/interface_v3/interface_link.h rename to code/nel/include/nel/gui/interface_link.h diff --git a/code/ryzom/client/src/interface_v3/interface_options.h b/code/nel/include/nel/gui/interface_options.h similarity index 93% rename from code/ryzom/client/src/interface_v3/interface_options.h rename to code/nel/include/nel/gui/interface_options.h index e05d390f8..990f1ab19 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.h +++ b/code/nel/include/nel/gui/interface_options.h @@ -19,12 +19,13 @@ #ifndef RZ_INTERFACE_LAYER_H #define RZ_INTERFACE_LAYER_H +#include "nel/misc/debug.h" #include "nel/misc/smart_ptr.h" - +#include "nel/misc/rgba.h" namespace NL3D { -class UAnimationSet; + class UAnimationSet; } diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index bd7b5627a..c19460b87 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/lua_helper.h" +#include "nel/gui/interface_element.h" #define IHM_LUA_METATABLE "__ui_metatable" #define IHM_LUA_ENVTABLE "__ui_envtable" @@ -122,14 +123,29 @@ namespace NLGUI // push a reflected property on the stack // NB : no check is done that 'property' is part of the class info of 'reflectedObject' static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property); - - - + private: + // Functions for the ui metatable + static class CInterfaceElement* getUIRelative( CInterfaceElement *pIE, const std::string &propName ); + static int luaUIIndex( CLuaState &ls ); + static int luaUINewIndex( CLuaState &ls ); + static int luaUIEq( CLuaState &ls ); + static int luaUINext( CLuaState &ls ); + static int luaUIDtor( CLuaState &ls ); + + static void registerBasics(CLuaState &ls); static void registerIHM(CLuaState &ls); static void createLuaEnumTable(CLuaState &ls, const std::string &str); + public: + static void pushUIOnStack(CLuaState &ls, CInterfaceElement *pIE); + static bool isUIOnStack(CLuaState &ls, sint index); + static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index); + static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index); + + private: + //////////////////////////////////////////// Exported functions ////////////////////////////////////////////////////// static uint32 getLocalTime(); diff --git a/code/ryzom/client/src/interface_v3/view_base.h b/code/nel/include/nel/gui/view_base.h similarity index 95% rename from code/ryzom/client/src/interface_v3/view_base.h rename to code/nel/include/nel/gui/view_base.h index f4faaa204..e8ab73680 100644 --- a/code/ryzom/client/src/interface_v3/view_base.h +++ b/code/nel/include/nel/gui/view_base.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/factory.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" class CViewBase : public CInterfaceElement { diff --git a/code/ryzom/client/src/interface_v3/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h similarity index 94% rename from code/ryzom/client/src/interface_v3/view_pointer_base.h rename to code/nel/include/nel/gui/view_pointer_base.h index 388180804..341ab4259 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer_base.h +++ b/code/nel/include/nel/gui/view_pointer_base.h @@ -1,7 +1,7 @@ #ifndef VIEW_POINTER_BASE_H #define VIEW_POINTER_BASE_H -#include "view_base.h" +#include "nel/gui/view_base.h" class CViewPointerBase : public CViewBase { diff --git a/code/ryzom/client/src/interface_v3/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h similarity index 100% rename from code/ryzom/client/src/interface_v3/widget_manager.h rename to code/nel/include/nel/gui/widget_manager.h diff --git a/code/ryzom/client/src/interface_v3/action_handler.cpp b/code/nel/src/gui/action_handler.cpp similarity index 96% rename from code/ryzom/client/src/interface_v3/action_handler.cpp rename to code/nel/src/gui/action_handler.cpp index 1961a5315..110fbb37c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -14,14 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "action_handler.h" -//#include "group_container.h" -#include "group_container_base.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/group_container_base.h" #include "nel/gui/interface_property.h" #include "nel/gui/interface_expr.h" #include "nel/gui/db_manager.h" -#include "interface_link.h" -#include "widget_manager.h" +#include "nel/gui/interface_link.h" +#include "nel/gui/widget_manager.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp similarity index 93% rename from code/ryzom/client/src/interface_v3/ctrl_base.cpp rename to code/nel/src/gui/ctrl_base.cpp index 1eea06182..2577fba21 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -14,11 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +#include "libxml/globals.h" +#include "nel/misc/debug.h" #include "nel/misc/xml_auto_ptr.h" -#include "ctrl_base.h" -#include "interface_group.h" -#include "widget_manager.h" +#include "nel/gui/ctrl_base.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/i18n.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.cpp b/code/nel/src/gui/ctrl_draggable.cpp similarity index 79% rename from code/ryzom/client/src/interface_v3/ctrl_draggable.cpp rename to code/nel/src/gui/ctrl_draggable.cpp index 7d98e7794..0e38d5c8f 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_draggable.cpp +++ b/code/nel/src/gui/ctrl_draggable.cpp @@ -1,4 +1,4 @@ -#include "ctrl_draggable.h" +#include "nel/gui/ctrl_draggable.h" CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp b/code/nel/src/gui/ctrl_scroll_base.cpp similarity index 94% rename from code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp rename to code/nel/src/gui/ctrl_scroll_base.cpp index b0cff5373..a3ed058ac 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp +++ b/code/nel/src/gui/ctrl_scroll_base.cpp @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "ctrl_scroll_base.h" +#include "nel/gui/ctrl_scroll_base.h" CCtrlScrollBase::CCtrlScrollBase( const TCtorParam ¶m ) : CCtrlBase( param ) diff --git a/code/ryzom/client/src/interface_v3/group_container_base.cpp b/code/nel/src/gui/group_container_base.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/group_container_base.cpp rename to code/nel/src/gui/group_container_base.cpp index 79144c787..9946f5e0c 100644 --- a/code/ryzom/client/src/interface_v3/group_container_base.cpp +++ b/code/nel/src/gui/group_container_base.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . -#include "group_container_base.h" +#include "nel/gui/group_container_base.h" CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : CInterfaceGroup( param ) diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.cpp b/code/nel/src/gui/group_editbox_base.cpp similarity index 81% rename from code/ryzom/client/src/interface_v3/group_editbox_base.cpp rename to code/nel/src/gui/group_editbox_base.cpp index a7c968f97..3c67d7d2f 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox_base.cpp +++ b/code/nel/src/gui/group_editbox_base.cpp @@ -1,4 +1,4 @@ -#include "group_editbox_base.h" +#include "nel/gui/group_editbox_base.h" CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; diff --git a/code/ryzom/client/src/interface_v3/group_frame.cpp b/code/nel/src/gui/group_frame.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/group_frame.cpp rename to code/nel/src/gui/group_frame.cpp index f6978a959..e8fbfa228 100644 --- a/code/ryzom/client/src/interface_v3/group_frame.cpp +++ b/code/nel/src/gui/group_frame.cpp @@ -14,10 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "group_frame.h" -#include "widget_manager.h" -#include "interface_options.h" -#include "interface_element.h" +#include "nel/gui/group_frame.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_options.h" +#include "nel/gui/interface_element.h" #include "nel/gui/view_renderer.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/group_modal.cpp b/code/nel/src/gui/group_modal.cpp similarity index 94% rename from code/ryzom/client/src/interface_v3/group_modal.cpp rename to code/nel/src/gui/group_modal.cpp index 555f6b4d5..1b763fad5 100644 --- a/code/ryzom/client/src/interface_v3/group_modal.cpp +++ b/code/nel/src/gui/group_modal.cpp @@ -16,8 +16,8 @@ -#include "group_modal.h" -#include "interface_element.h" +#include "nel/gui/group_modal.h" +#include "nel/gui/interface_element.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/interface_v3/interface_element.cpp b/code/nel/src/gui/interface_element.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/interface_element.cpp rename to code/nel/src/gui/interface_element.cpp index a66b5881b..a90e2639a 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -14,15 +14,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "nel/gui/interface_property.h" #include "nel/gui/view_renderer.h" -#include "widget_manager.h" +#include "nel/gui/widget_manager.h" #include "nel/gui/db_manager.h" -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" +#include "nel/gui/lua_ihm.h" #include "nel/misc/mem_stream.h" // @@ -1167,7 +1167,7 @@ int CInterfaceElement::luaSetPosRef(CLuaState &ls) int CInterfaceElement::luaSetParentPos(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "setParentPos", 1); - CInterfaceElement *ie = CLuaIHMRyzom::getUIOnStack(ls, 1); + CInterfaceElement *ie = CLuaIHM::getUIOnStack(ls, 1); if(ie) { setParentPos(ie); diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/nel/src/gui/interface_group.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/interface_group.cpp rename to code/nel/src/gui/interface_group.cpp index bb0b0bbbf..9b1ae75fb 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -14,17 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "libxml/globals.h" +#include "nel/misc/debug.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/misc/stream.h" #include "nel/gui/lua_manager.h" #include "nel/gui/lua_ihm.h" #include "nel/gui/view_renderer.h" - -#include "interface_group.h" -#include "interface_link.h" -#include "widget_manager.h" -#include "ctrl_scroll_base.h" -#include "lua_ihm_ryzom.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/interface_link.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/ctrl_scroll_base.h" +#include "nel/gui/lua_ihm.h" using namespace std; using namespace NL3D; @@ -444,7 +445,7 @@ void CInterfaceGroup::addGroup (CInterfaceGroup *child, sint eltOrder /*= -1*/) int CInterfaceGroup::luaAddGroup (CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::addTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if(group) { group->setParent(this); @@ -615,7 +616,7 @@ bool CInterfaceGroup::delGroup (CInterfaceGroup *child, bool dontDelete /* = fal int CInterfaceGroup::luaDelGroup (CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::delTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if(group) { delGroup(group); @@ -642,7 +643,7 @@ int CInterfaceGroup::luaGetGroup(CLuaState &ls) { CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size()); } - CLuaIHMRyzom::pushUIOnStack(ls, _ChildrenGroups[index]); + CLuaIHM::pushUIOnStack(ls, _ChildrenGroups[index]); return 1; } @@ -1851,7 +1852,7 @@ int CInterfaceGroup::luaFind(CLuaState &ls) } else { - CLuaIHMRyzom::pushUIOnStack(ls, element); + CLuaIHM::pushUIOnStack(ls, element); } return 1; } @@ -1870,7 +1871,7 @@ CInterfaceElement* CInterfaceGroup::findFromShortId(const std::string &id) int CInterfaceGroup::luaGetEnclosingContainer(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getEnclosingContainer", 0); - CLuaIHMRyzom::pushUIOnStack(ls, getEnclosingContainer()); + CLuaIHM::pushUIOnStack(ls, getEnclosingContainer()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/nel/src/gui/interface_link.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/interface_link.cpp rename to code/nel/src/gui/interface_link.cpp index 1b0ee7619..68e9a194c 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -19,11 +19,12 @@ #include "nel/gui/reflect.h" #include "nel/gui/db_manager.h" #include "nel/misc/cdb_branch.h" -#include "action_handler.h" -#include "interface_link.h" -#include "interface_element.h" -#include "interface_group.h" -#include "widget_manager.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/interface_link.h" +#include "nel/gui/interface_element.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/algo.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/interface_options.cpp b/code/nel/src/gui/interface_options.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/interface_options.cpp rename to code/nel/src/gui/interface_options.cpp index a73d2c170..2c9bd97d8 100644 --- a/code/ryzom/client/src/interface_v3/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -16,9 +16,9 @@ +#include "nel/gui/interface_element.h" #include "nel/misc/xml_auto_ptr.h" -#include "interface_options.h" -#include "interface_element.h" +#include "nel/gui/interface_options.h" using namespace std; using namespace NLMISC; diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 8cd1ea463..1194b48ec 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -16,6 +16,7 @@ #include "nel/gui/lua_helper.h" +#include "nel/gui/interface_group.h" #include @@ -258,6 +259,402 @@ namespace NLGUI namespace NLGUI { + static CLuaString lstr_Env("Env"); + static CLuaString lstr_isNil("isNil"); + + // *************************************************************************** + int CLuaIHM::luaUIIndex(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_luaUIIndex) + nlassert(ls.getTop()==2); + // get the userdata and key + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + + const char *propName = ls.toString(2); + CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); + // ** try to get the Env Table (interface group only) + if(propName==lstr_isNil) + { + ls.push(pRPT==NULL); + return 1; + } + + // Check the object is not NULL or freed + if(pRPT==NULL) + { + return 0; + } + + // ** try to get the Env Table (interface group only) + if(propName==lstr_Env) + { + // Env can be bound to a CInterfaceGroup only + CInterfaceGroup *group= dynamic_cast(pRPT); + if(group==NULL) + { + ls.pushNil(); + return 1; + } + else + { + group->pushLUAEnvTable(); + return 1; + } + } + + // ** try to get the property + const CReflectedProperty *prop = pRefElm->getProp(propName); + if (prop) + { + CLuaIHM::luaValueFromReflectedProperty(ls, *pRPT, *prop); + return 1; + } + + // ** try to get a UI relative + CInterfaceElement *uiRelative= getUIRelative(dynamic_cast(pRPT), propName); + if(uiRelative) + { + // push the UI onto the stack + pushUIOnStack(ls, uiRelative); + return 1; + } + + + // Fail to find any Attributes or elements + // Yoyo: don't write any message or warning because this may be a feature (if user want to test that something exit in the ui) + ls.pushNil(); + return 1; + } + + // *************************************************************************** + int CLuaIHM::luaUINewIndex(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_luaUINewIndex) + nlassert(ls.getTop()==3); + // get the userdata and key + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + nlassert(pRefElm); + CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); + // Check the UI is not NULL or freed + if(pRPT == NULL) + { + return 0; + } + + const char *propName = ls.toString(2); + // ** try to set the Env Table (interface group only) + if(propName == lstr_Env) + { + CInterfaceElement *pIE = dynamic_cast(pRPT); + std::string name ; + if (pIE) + { + name = pIE->getId(); + } + else + { + name = ""; + } + // Exception!!! not allowed + throw ELuaIHMException("You cannot change the Env Table of '%s'", name.c_str()); + } + + + // ** try to set the property + const CReflectedProperty *prop = pRefElm->getProp(propName); + if (prop) + { + CLuaIHM::luaValueToReflectedProperty(ls, 3, *pRPT, *prop); + return 0; + } + + CInterfaceElement *pIE = dynamic_cast(pRPT); + // ** try to get another UI (child or parent) + CInterfaceElement *uiRelative= getUIRelative(pIE, propName); + if(uiRelative) + { + // Exception!!! not allowed + throw ELuaIHMException("You cannot write into the UI '%s' of '%s'", propName, pIE->getId().c_str()); + } + + // ** Prop Not Found + throw ELuaIHMException("Property '%s' not found in '%s' of type %s", propName, pIE ? pIE->getId().c_str() : "", typeid(*pRPT).name()); + + // Fail to find any Attributes or elements + return 0; + } + + // *************************************************************************** + int CLuaIHM::luaUIEq(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_luaUIEq) + nlassert(ls.getTop() == 2); + // read lhs & rhs + // get the userdata and key + CReflectableLuaRef *lhs = (CReflectableLuaRef *) ls.toUserData(1); + CReflectableLuaRef *rhs = (CReflectableLuaRef *) ls.toUserData(2); + nlassert(lhs); + nlassert(rhs); + ls.push(lhs->Ptr == rhs->Ptr); + return 1; + } + + + // *************************************************************************** + int CLuaIHM::luaUIDtor(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_luaUIDtor) + nlassert(ls.getTop()==1); + // get the userdata + CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); + nlassert(pRefElm); + + // call dtor + pRefElm->~CReflectableLuaRef(); + + return 0; + } + + // *************************************************************************** + int CLuaIHM::luaUINext(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_luaUINext) + // Code below allow enumeration of properties of a reflectable object + // From lua standpoint, the object is seen as a table with (key, value) pairs + // If object is a CInterfaceGroup, iteration is also done on sons (groups, controls & view). + + if (ls.getTop() != 2) + { + CLuaIHM::fails(ls, "__next metamethod require 2 arguments (table & key)"); + } + CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "__next : require ui element as first arg"); + CReflectableRefPtrTarget *reflectedObject = CLuaIHM::getReflectableOnStack(ls, 1); + // To traverse all properties / field of the object, we must be able to determine the next key from a previous key + // (keys are ordered) + // We use the 'TValueType' enum to know which kind of property we are traversing, and an index in this group of properties + // The key which uniquely identify an element / property in the reflectable object + struct CKey + { + enum TValueType + { + VTGroup = 0, // children groups (If the object is a CInterfaceGroup) + VTView, // children views (If the object is a CInterfaceView) + VTCtrl, // children controls (If the object is a CInterfaceCtrl) + VTProp // List of exported proeprties (For all relfectable objects) + }; + TValueType ValueType; + sint Index; + const CClassInfo *ClassInfo; // if ValueType is "VTProp" -> give the class for which property are currently enumerated + // + static int tostring(CLuaState &ls) // '__print' metamathod + { + CLuaIHM::checkArgCount(ls, "reflected object metatable:__print", 1); + CKey key; + key.pop(ls); + switch(key.ValueType) + { + case VTGroup: ls.push(toString("_Group %d", key.Index)); break; + case VTView: ls.push(toString("_View %d", key.Index)); break; + case VTCtrl: ls.push(toString("_Ctrl %d", key.Index)); break; + case VTProp: ls.push(key.ClassInfo->Properties[key.Index].Name); break; + } + return 1; + } + // push the key on the lua stack + void push(CLuaState &ls) + { + void *ud = ls.newUserData(sizeof(*this)); + *(CKey *) ud = *this; + getMetaTable(ls).push(); + ls.setMetaTable(-2); + } + // pop the key from the lua stack + void pop(CLuaState &ls) + { + CLuaStackChecker lsc(&ls, -1); + if (!ls.isUserData(-1)) + { + CLuaIHM::fails(ls, "Can't pop object, not a user data"); + } + // check that metatable is good (it is share between all keys) + ls.getMetaTable(-1); + getMetaTable(ls).push(); + if (!ls.rawEqual(-1, -2)) + { + CLuaIHM::fails(ls, "Bad metatable for reflectable object key"); + } + ls.pop(2); + // retrieve key + *this = *(CKey *) ls.toUserData(-1); + ls.pop(); + } + // get the metatable for a CKey + CLuaObject &getMetaTable(CLuaState &ls) + { + static CLuaObject metatable; + if (!metatable.isValid()) + { + // first build + CLuaStackChecker lsc(&ls); + ls.newTable(); + ls.push("__tostring"); + ls.push(CKey::tostring); + ls.setTable(-3); + metatable.pop(ls); + } + return metatable; + } + }; + // Pop the current key to continue enumeration + CKey key; + if (ls.isNil(2)) + { + // no key -> start of table + key.ValueType = CKey::VTGroup; + key.Index = -1; + } + else + { + key.pop(ls); + } + // + CInterfaceGroup *group = dynamic_cast(reflectedObject); + bool enumerate = true; + while (enumerate) + { + switch(key.ValueType) + { + case CKey::VTGroup: + if (!group || (key.Index + 1) == (sint) group->getGroups().size()) + { + key.Index = -1; + key.ValueType = CKey::VTView; // continue enumeration with views + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getGroups()[key.Index]); + return 2; + } + break; + case CKey::VTView: + if (!group || (key.Index + 1) == (sint) group->getViews().size()) + { + key.Index = -1; + key.ValueType = CKey::VTCtrl; // continue enumeration with controls + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getViews()[key.Index]); + return 2; + } + break; + case CKey::VTCtrl: + if (!group || (key.Index + 1) == (sint) group->getControls().size()) + { + key.Index = -1; + key.ValueType = CKey::VTProp; // continue enumeration with properties + key.ClassInfo = reflectedObject->getClassInfo(); + } + else + { + ++ key.Index; + key.push(ls); + pushUIOnStack(ls, group->getControls()[key.Index]); + return 2; + } + break; + case CKey::VTProp: + if (!key.ClassInfo) + { + enumerate = false; + break; + } + if ((sint) key.ClassInfo->Properties.size() == (key.Index + 1)) + { + key.ClassInfo = key.ClassInfo->ParentClass; // continue enumeration in parent class + key.Index = -1; + } + else + { + ++ key.Index; + key.push(ls); + CLuaIHM::luaValueFromReflectedProperty(ls, *reflectedObject, key.ClassInfo->Properties[key.Index]); + return 2; + } + break; + default: + nlassert(0); + break; + } + } + ls.pushNil(); + return 0; + } + + // *************************************************************************** + void CLuaIHM::pushUIOnStack(CLuaState &ls, CInterfaceElement *pIE) + { + //H_AUTO(Lua_CLuaIHM_pushUIOnStack) + CLuaIHM::pushReflectableOnStack(ls, pIE); + } + + // *************************************************************************** + bool CLuaIHM::isUIOnStack(CLuaState &ls, sint index) + { + //H_AUTO(Lua_CLuaIHM_isUIOnStack) + return getUIOnStack(ls, index) != NULL; + } + + // *************************************************************************** + CInterfaceElement *CLuaIHM::getUIOnStack(CLuaState &ls, sint index) + { + //H_AUTO(Lua_CLuaIHM_getUIOnStack) + return dynamic_cast(CLuaIHM::getReflectableOnStack(ls, index)); + } + + // *************************************************************************** + void CLuaIHM::checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index) + { + //H_AUTO(Lua_CLuaIHM_checkArgTypeUIElement) + nlassert(index > 0); + if (ls.getTop() < (int) index) + { + CLuaIHM::fails(ls, "%s : argument %d of expected type ui element was not defined", funcName, index); + } + if (!isUIOnStack(ls, index)) + { + CLuaIHM::fails(ls, "%s : argument %d of expected type ui element has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); + } + } + + + // *************************************************************************** + CInterfaceElement *CLuaIHM::getUIRelative(CInterfaceElement *pIE, const std::string &propName) + { + //H_AUTO(Lua_CLuaIHM_getUIRelative) + if (pIE == NULL) return NULL; + // If the prop is "parent", then return the parent of the ui + if(propName=="parent") + { + return pIE->getParent(); + } + // else try to get a child (if group/exist) + else + { + CInterfaceGroup *group= dynamic_cast(pIE); + if(group) + { + return group->getElement(group->getId()+":"+propName); + } + } + + return NULL; + } + // *************************************************************************** void CLuaIHM::registerBasics(CLuaState &ls) @@ -420,9 +817,6 @@ namespace NLGUI } } - static CLuaString lstr_Env("Env"); - static CLuaString lstr_isNil("isNil"); - // *************************************************************************** void CLuaIHM::luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException) { @@ -545,6 +939,38 @@ namespace NLGUI ls.setTable(LUA_REGISTRYINDEX); + // *** Register the MetaTable for UI userdata + ls.push(IHM_LUA_METATABLE); // "__ui_metatable" + ls.newTable(); // "__ui_metatable" {} + // set the '__index' method + ls.push("__index"); + ls.push(luaUIIndex); + nlassert(ls.isCFunction()); + ls.setTable(-3); // "__ui_metatable" {"__index"= CFunc_luaUIIndex} + // set the '__newindex' method + ls.push("__newindex"); + ls.push(luaUINewIndex); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the '__newindex' method + ls.push("__gc"); + ls.push(luaUIDtor); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the '__eq' method + ls.push("__eq"); + ls.push(luaUIEq); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set the custom '__next' method + ls.push("__next"); + ls.push(luaUINext); + nlassert(ls.isCFunction()); + ls.setTable(-3); + // set registry + ls.setTable(LUA_REGISTRYINDEX); + + // *** Register Functions // Through LUABind API diff --git a/code/ryzom/client/src/interface_v3/view_base.cpp b/code/nel/src/gui/view_base.cpp similarity index 91% rename from code/ryzom/client/src/interface_v3/view_base.cpp rename to code/nel/src/gui/view_base.cpp index 70bf9255c..56761c571 100644 --- a/code/ryzom/client/src/interface_v3/view_base.cpp +++ b/code/nel/src/gui/view_base.cpp @@ -14,9 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "view_base.h" -#include "interface_group.h" -#include "widget_manager.h" +#include "nel/gui/view_base.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" CViewBase::~CViewBase() { diff --git a/code/ryzom/client/src/interface_v3/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/view_pointer_base.cpp rename to code/nel/src/gui/view_pointer_base.cpp index e4b124dc3..b89febad9 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer_base.cpp +++ b/code/nel/src/gui/view_pointer_base.cpp @@ -1,4 +1,4 @@ -#include "view_pointer_base.h" +#include "nel/gui/view_pointer_base.h" CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) : CViewBase( param ) diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp similarity index 95% rename from code/ryzom/client/src/interface_v3/widget_manager.cpp rename to code/nel/src/gui/widget_manager.cpp index c3ec5bc4e..aaf0813ef 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -16,14 +16,14 @@ #include "nel/gui/db_manager.h" #include "nel/gui/view_renderer.h" -#include "widget_manager.h" -#include "view_pointer_base.h" -#include "ctrl_draggable.h" -#include "interface_group.h" -#include "group_container_base.h" -#include "group_modal.h" -#include "group_editbox_base.h" -#include "interface_options.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" +#include "nel/gui/ctrl_draggable.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/group_modal.h" +#include "nel/gui/group_editbox_base.h" +#include "nel/gui/interface_options.h" CWidgetManager* CWidgetManager::instance = NULL; diff --git a/code/ryzom/client/src/camera_recorder.cpp b/code/ryzom/client/src/camera_recorder.cpp index 309eee039..68c0ddf4e 100644 --- a/code/ryzom/client/src/camera_recorder.cpp +++ b/code/ryzom/client/src/camera_recorder.cpp @@ -20,7 +20,7 @@ #include "nel/misc/command.h" #include "nel/misc/file.h" #include "nel/3d/u_camera.h" -#include "interface_v3/action_handler.h" +#include "nel/gui/action_handler.h" #include "client_cfg.h" #include "view.h" // diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index b9ed783b3..ed4d5948f 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -28,7 +28,7 @@ #include "interface_v3/people_interraction.h" #include "string_manager_client.h" #include "entity_cl.h" -#include "interface_v3/action_handler.h" +#include "nel/gui/action_handler.h" #include "entities.h" #include "interface_v3/group_editbox.h" #include "permanent_ban.h" diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 86f26961f..1da19926a 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -45,7 +45,7 @@ #include // Client #include "connection.h" -#include "interface_v3/action_handler.h" +#include "nel/gui/action_handler.h" #include "sound_manager.h" #include "input.h" #include "login.h" diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index b05c8ae69..da31caebc 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -52,7 +52,7 @@ #include "debug_client.h" #include "misc.h" #include "client_cfg.h" -#include "interface_v3/action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_v3/interface_manager.h" #include "interface_v3/group_container.h" #include "interface_v3/guild_manager.h" diff --git a/code/ryzom/client/src/game_context_menu.h b/code/ryzom/client/src/game_context_menu.h index e1a854507..0e5dde414 100644 --- a/code/ryzom/client/src/game_context_menu.h +++ b/code/ryzom/client/src/game_context_menu.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "main_loop.h" #include "interface_v3/ctrl_text_button.h" -#include "interface_v3/interface_group.h" +#include "nel/gui/interface_group.h" #include "interface_v3/interface_pointer.h" #include "game_share/bot_chat_types.h" diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 531b8ed61..075a17dcc 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -69,7 +69,7 @@ #include "sheet_manager.h" #include "interface_v3/sbrick_manager.h" -#include "interface_v3/widget_manager.h" +#include "nel/gui/widget_manager.h" // #include "gabarit.h" #include "hair_set.h" diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index 4b2247566..d35d00561 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -55,7 +55,7 @@ #include "interface_v3/view_bitmap.h" -#include "interface_v3/interface_link.h" +#include "nel/gui/interface_link.h" #include "cursor_functions.h" #include "pacs_client.h" #include "ig_client.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp index eaa24e354..8f74e3076 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp @@ -20,7 +20,7 @@ using namespace std; using namespace NLMISC; using namespace NL3D; -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../misc.h" #include "../prim_file.h" #include "../graph.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index d16df8fa4..72931f511 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -22,7 +22,7 @@ using namespace std; using namespace NLMISC; -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_editbox.h" #include "interface_manager.h" #include "../client_chat_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 39fff2c6d..ddaad5b5e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -21,7 +21,7 @@ // Interface includes #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "action_handler_base.h" #include "action_handler_misc.h" #include "bot_chat_manager.h" @@ -61,7 +61,7 @@ #include "../game_context_menu.h" #include "../sound_manager.h" #include "../far_tp.h" -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "../npc_icon.h" // Game Share diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 7812df510..04bc833e7 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_manager.h" #include "bot_chat_manager.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index e86c0691e..0066dd948 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "action_handler_item.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_manager.h" #include "../sheet_manager.h" #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 082669574..5c3fb746a 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -23,7 +23,7 @@ #include "people_interraction.h" #include "nel/misc/algo.h" #include "nel/gui/interface_expr.h" -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "../client_chat_manager.h" #include "../motion/user_controls.h" #include "../entity_cl.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.h b/code/ryzom/client/src/interface_v3/action_handler_misc.h index 5e9328832..d0fabdcfc 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.h +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.h @@ -20,7 +20,7 @@ #define NL_ACTION_HANDLER_MISC_H #include "nel/misc/types_nl.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_manager.h" class CInterfaceGroup; diff --git a/code/ryzom/client/src/interface_v3/action_handler_move.cpp b/code/ryzom/client/src/interface_v3/action_handler_move.cpp index 67d0c7b72..782617ac3 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -22,7 +22,7 @@ using namespace std; using namespace NLMISC; -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../motion/user_controls.h" #include "../view.h" #include "../misc.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp index f38ecdfe7..125836a2f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_outpost.cpp @@ -18,7 +18,7 @@ // Interface includes #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "action_handler_tools.h" #include "game_share/outpost.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 2eda5c560..d702689dd 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -20,7 +20,7 @@ #include "stdpch.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../motion/user_controls.h" #include "../view.h" #include "../misc.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_tools.cpp b/code/ryzom/client/src/interface_v3/action_handler_tools.cpp index 19da51db6..06019f5da 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_tools.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_tools.cpp @@ -20,7 +20,7 @@ // Interface includes #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index 94bd9e9b3..fd5d58329 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -22,7 +22,7 @@ // Interface #include "interface_manager.h" #include "bot_chat_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_container.h" #include "macrocmd_manager.h" #include "chat_window.h" diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index f469e53b1..d7fc952ed 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "../sheet_manager.h" #include "inventory_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../client_cfg.h" #include "ctrl_base_button.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index 1e1f123db..9e96fb602 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -20,11 +20,11 @@ #include "bot_chat_manager.h" #include "bot_chat_page.h" #include "../net_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../user_entity.h" #include "interface_manager.h" #include "view_text_id.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "game_share/prerequisit_infos.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page.cpp index 1194c649f..b7624b365 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "bot_chat_page.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index 2e7c95ca2..ec3ff4d64 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -20,8 +20,8 @@ #include "bot_chat_page_create_guild.h" #include "interface_manager.h" #include "guild_manager.h" -#include "interface_group.h" -#include "action_handler.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/action_handler.h" #include "group_editbox.h" #include "dbctrl_sheet.h" #include "bot_chat_manager.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 15f3dc6aa..2d744f4ad 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -19,9 +19,9 @@ #include "stdpch.h" #include "bot_chat_page_dynamic_mission.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "../string_manager_client.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "dbgroup_combo_box.h" #include "bot_chat_page_all.h" #include "bot_chat_manager.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index fc84aedde..6a8f75e8c 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -19,11 +19,11 @@ #include "stdpch.h" #include "bot_chat_page_mission.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "bot_chat_manager.h" #include "bot_chat_page_all.h" #include "dbgroup_list_sheet_trade.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_container.h" #include "dbctrl_sheet.h" #include "view_text_id.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp index acc65410b..c27997d4f 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission_end.cpp @@ -20,7 +20,7 @@ #include "stdpch.h" #include "bot_chat_page_mission_end.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "bot_chat_manager.h" #include "interface_manager.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp index da960c5a5..e5555b44c 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_news.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "bot_chat_page_news.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" static const char *WIN_BOT_CHAT_PAGE_NEWS = "ui:interface:bot_chat_news"; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp index 0a310db57..c21d3cc13 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_player_gift.cpp @@ -19,8 +19,8 @@ #include "stdpch.h" #include "bot_chat_page_player_gift.h" #include "interface_manager.h" -#include "interface_group.h" -#include "action_handler.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/action_handler.h" #include "../net_manager.h" #include "bot_chat_manager.h" #include "bot_chat_page_all.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 809a433e9..7085a1c55 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -27,10 +27,10 @@ // #include "bot_chat_page_trade.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "inventory_manager.h" #include "../net_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "bot_chat_page_all.h" #include "bot_chat_manager.h" #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/character_3d.h b/code/ryzom/client/src/interface_v3/character_3d.h index d5cc5d8b0..526816f1b 100644 --- a/code/ryzom/client/src/interface_v3/character_3d.h +++ b/code/ryzom/client/src/interface_v3/character_3d.h @@ -23,9 +23,9 @@ #include "game_share/character_summary.h" #include "game_share/slot_types.h" #include "nel/3d/u_skeleton.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "interface_options_ryzom.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" // ------------------------------------------------------------------------------------------------ diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 62548652e..d1f376b17 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -34,7 +34,7 @@ #include "group_editbox.h" #include "group_tab.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../client_chat_manager.h" // #include "../session_browser_impl.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.h b/code/ryzom/client/src/interface_v3/ctrl_base_button.h index 25d3dddf7..3f202dcf7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_base_button.h @@ -19,8 +19,8 @@ #ifndef NL_CTRL_BASE_BUTTON_H #define NL_CTRL_BASE_BUTTON_H -#include "ctrl_base.h" -#include "action_handler.h" +#include "nel/gui/ctrl_base.h" +#include "nel/gui/action_handler.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h b/code/ryzom/client/src/interface_v3/ctrl_col_pick.h index 741341b5f..956f077a7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h +++ b/code/ryzom/client/src/interface_v3/ctrl_col_pick.h @@ -20,7 +20,7 @@ #define RZ_CTRL_COL_PICK_H #include "nel/misc/types_nl.h" -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" /** * Class handling a Color Picker diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.h b/code/ryzom/client/src/interface_v3/ctrl_polygon.h index 4ad4cd34e..78b852ba4 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.h +++ b/code/ryzom/client/src/interface_v3/ctrl_polygon.h @@ -18,7 +18,7 @@ #ifndef RZ_CTRL_POLYGON_H #define RZ_CTRL_POLYGON_H -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" #include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" #include "nel/misc/polygon.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp index 5269eaaf4..f1da0754b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "ctrl_quad.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "interface_manager.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.h b/code/ryzom/client/src/interface_v3/ctrl_quad.h index 1f3f5328c..2e4ec17ca 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.h +++ b/code/ryzom/client/src/interface_v3/ctrl_quad.h @@ -18,7 +18,7 @@ #ifndef RZ_CTRL_QUAD_H #define RZ_CTRL_QUAD_H -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" #include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index 58d099712..834d3ee5e 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -16,7 +16,7 @@ #include "interface_manager.h" -#include "widget_manager.h" +#include "nel/gui/widget_manager.h" #include "ctrl_scroll.h" #include "nel/misc/xml_auto_ptr.h" #include "group_menu.h" @@ -908,7 +908,7 @@ int CCtrlScroll::luaEnsureVisible(CLuaState &ls) { const char *funcName = "ensureVisible"; CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHMRyzom::checkArgTypeUIElement(ls, funcName, 1); + CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); THotSpot hs[2]; @@ -959,7 +959,7 @@ int CCtrlScroll::luaEnsureVisible(CLuaState &ls) } } } - ensureVisible(CLuaIHMRyzom::getUIOnStack(ls, 1), hs[0], hs[1]); + ensureVisible(CLuaIHM::getUIOnStack(ls, 1), hs[0], hs[1]); return 0; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h index e4f1b4db3..d1e6fe2d3 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.h @@ -20,7 +20,7 @@ #define RZ_CTRL_SCROLL_H #include "nel/misc/types_nl.h" -#include "ctrl_scroll_base.h" +#include "nel/gui/ctrl_scroll_base.h" /** * Class handling scollbar function diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 3e2fd0a92..efa54d33c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -549,7 +549,7 @@ int CCtrlTextButton::luaGetViewText(CLuaState &ls) { const char *funcName = "getViewText"; CLuaIHM::checkArgCount(ls, funcName, 0); - CLuaIHMRyzom::pushUIOnStack(ls, getViewText()); + CLuaIHM::pushUIOnStack(ls, getViewText()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h index 5564a8e5c..67fa2ccd3 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h +++ b/code/ryzom/client/src/interface_v3/ctrl_tooltip.h @@ -19,7 +19,7 @@ #ifndef RZ_CTRL_TOOLTIP_H #define RZ_CTRL_TOOLTIP_H -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" #include "nel/3d/u_texture.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 7159c3987..586817ac4 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -30,7 +30,7 @@ #include "game_share/inventories.h" #include "list_sheet_base.h" #include "../string_manager_client.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "inventory_manager.h" #include "skill_manager.h" #include "../user_entity.h" @@ -130,7 +130,7 @@ ucstring CControlSheetTooltipInfoWaiter::infoValidated(CDBCtrlSheet* ctrlSheet, // *************************************************************************** int CDBCtrlSheet::luaGetDraggedSheet(CLuaState &ls) { - CLuaIHMRyzom::pushUIOnStack(ls, dynamic_cast( dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) )); + CLuaIHM::pushUIOnStack(ls, dynamic_cast( dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) )); return 1; } diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index 3071d78df..c055ac8d0 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -24,9 +24,9 @@ #include "nel/misc/smart_ptr.h" // client #include "nel/gui/reflect.h" -#include "ctrl_draggable.h" +#include "nel/gui/ctrl_draggable.h" #include "nel/gui/interface_expr.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "sphrase_manager.h" // game share #include "game_share/brick_types.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h index e828c56e6..bcbd1e972 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h @@ -20,7 +20,7 @@ #define NL_DBGROUP_BUILD_PHRASE_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "game_share/sphrase_com.h" #include "game_share/brick_types.h" #include "game_share/skills.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index f376c306a..5dfa3810e 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -22,7 +22,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "ctrl_button.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h index 62be81037..69c1754c0 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h @@ -20,7 +20,7 @@ #define NL_DBGROUP_COMBO_BOX_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 83d29b76f..77d234b12 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -24,7 +24,7 @@ #include "ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../sheet_manager.h" #include "game_share/animal_status.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 02ee3fa14..61687b4f7 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -24,7 +24,7 @@ #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../time_client.h" #include "game_share/animal_status.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 24efaaa88..04c40f9d5 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -24,7 +24,7 @@ #include "../sheet_manager.h" #include "ctrl_button.h" #include "view_text.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "sphrase_manager.h" #include "game_share/time_weather_season/time_and_season.h" #include "game_share/pvp_clan.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index 3e99469fd..69440ff5a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -26,7 +26,7 @@ #include "ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h index 0375e920d..4a103161b 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h @@ -20,7 +20,7 @@ #define NL_DBGROUP_SELECT_NUMBER_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.h b/code/ryzom/client/src/interface_v3/dbview_digit.h index c24b5c69f..0589e38d8 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.h +++ b/code/ryzom/client/src/interface_v3/dbview_digit.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" -#include "view_base.h" +#include "nel/gui/view_base.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_career.cpp b/code/ryzom/client/src/interface_v3/group_career.cpp index 04916f007..b50e1ab36 100644 --- a/code/ryzom/client/src/interface_v3/group_career.cpp +++ b/code/ryzom/client/src/interface_v3/group_career.cpp @@ -20,7 +20,7 @@ #include "group_career.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" //#include "game_share/jobs.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/group_compas.cpp b/code/ryzom/client/src/interface_v3/group_compas.cpp index 356393fe2..d6e883b64 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.cpp +++ b/code/ryzom/client/src/interface_v3/group_compas.cpp @@ -23,7 +23,7 @@ #include "group_compas.h" #include "interface_3d_scene.h" #include "../entities.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_map.h" #include "../continent.h" #include "../continent_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 0714dd2eb..ce5499c11 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -21,10 +21,10 @@ #include "group_container.h" #include "interface_manager.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "interface_options_ryzom.h" #include "nel/misc/xml_auto_ptr.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../time_client.h" #include "group_editbox.h" #include "view_text_formated.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index c1268870c..330342ed1 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -19,8 +19,8 @@ #ifndef RZ_GROUP_CONTAINER_H #define RZ_GROUP_CONTAINER_H -#include "interface_group.h" -#include "group_container_base.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" #include "nel/misc/smart_ptr.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index c49752dce..7d51be171 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -24,7 +24,7 @@ #include "nel/misc/command.h" #include "view_text.h" #include "nel/misc/xml_auto_ptr.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "dbctrl_sheet.h" #include "group_container.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index e892b134a..99a07c093 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -19,8 +19,8 @@ #ifndef RZ_CTRL_EDITBOX_H #define RZ_CTRL_EDITBOX_H -#include "interface_group.h" -#include "group_editbox_base.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_editbox_base.h" #include "nel/3d/u_texture.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 82c543ac6..950990e82 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -36,7 +36,7 @@ extern "C" #include "ctrl_button.h" #include "dbctrl_sheet.h" #include "ctrl_text_button.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_paragraph.h" #include "group_editbox.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index f8e3e09f9..5d5fc9041 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -24,7 +24,7 @@ #include #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "group_scrolltext.h" #include "group_tree.h" #include "ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 2c8211619..32ab05086 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "skill_manager.h" #include "../character_cl.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../entities.h" #include "group_paragraph.h" // For CCtrlLink #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index 7d0253978..16a16393b 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -20,7 +20,7 @@ #include "interface_manager.h" #include "view_bitmap.h" #include "group_in_scene_user_info.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../entities.h" #include "../user_entity.h" #include "../forage_source_cl.h" diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index b20f9d46e..e77f675d6 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -20,7 +20,7 @@ #include "group_list.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" #include "view_text_id.h" @@ -915,7 +915,7 @@ sint32 CGroupList::getElementIndex(CViewBase* child) const int CGroupList::luaGetElementIndex(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getElementIndex", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); ls.push((double) getElementIndex(viewBase)); return 1; } @@ -967,7 +967,7 @@ void CGroupList::swapChildren(uint index1, uint index2) int CGroupList::luaUpChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "upChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); sint32 indexUpChild = getElementIndex(viewBase); if(indexUpChild > 0) { @@ -980,7 +980,7 @@ int CGroupList::luaUpChild(CLuaState &ls) int CGroupList::luaDownChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "downChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); sint32 indexDownChild = getElementIndex(viewBase); if(indexDownChild < (sint32) (_Elements.size()-1)) { @@ -1001,7 +1001,7 @@ int CGroupList::luaGetChild(CLuaState &ls) CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements", index, getId().c_str(), (int) _Elements.size()); } - CLuaIHMRyzom::pushUIOnStack(ls, getChild((uint) index)); + CLuaIHM::pushUIOnStack(ls, getChild((uint) index)); return 1; } @@ -1090,7 +1090,7 @@ int CGroupList::luaAddChild(CLuaState &ls) { const char *funcName = "addChild"; CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (!vb) { CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); @@ -1108,7 +1108,7 @@ int CGroupList::luaAddChildAtIndex(CLuaState &ls) const char *funcName = "addChildAtIndex"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (!vb) { CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); @@ -1125,7 +1125,7 @@ int CGroupList::luaDetachChild(CLuaState &ls) { const char *funcName = "detachChild"; CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (!vb) { nlwarning("%s requires a view, group or control", funcName); @@ -1142,7 +1142,7 @@ int CGroupList::luaDetachChild(CLuaState &ls) int CGroupList::luaDelChild(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CGroupList::delChild", 1); - CViewBase *vb = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (vb) delChild(vb); updateCoords(); return 0; diff --git a/code/ryzom/client/src/interface_v3/group_list.h b/code/ryzom/client/src/interface_v3/group_list.h index 1053a2241..b7fe975d2 100644 --- a/code/ryzom/client/src/interface_v3/group_list.h +++ b/code/ryzom/client/src/interface_v3/group_list.h @@ -20,7 +20,7 @@ #define NL_GROUP_LIST_H #include "nel/misc/types_nl.h" -#include "group_frame.h" +#include "nel/gui/group_frame.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index fa197ef51..99bf1edf6 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -28,7 +28,7 @@ #include "group_editbox.h" #include "../string_manager_client.h" #include "group_container.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../dummy_progress.h" #include "group_compas.h" #include "../connection.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index 30a8b9ded..a4d162068 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -25,7 +25,7 @@ #include "../client_sheets/world_sheet.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "ctrl_button.h" #include "view_bitmap.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index 3ca9a7db3..bd2f44088 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -23,7 +23,7 @@ #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "view_bitmap.h" -#include "action_handler.h" // Just for getAllParams +#include "nel/gui/action_handler.h" // Just for getAllParams #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" @@ -1693,7 +1693,7 @@ int CGroupSubMenu::luaGetSubMenu(CLuaState &ls) const char *funcName = "getSubMenu"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHMRyzom::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); return 1; } @@ -1704,7 +1704,7 @@ int CGroupSubMenu::luaAddSubMenu(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam())); - CLuaIHMRyzom::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); return 1; } @@ -1804,11 +1804,11 @@ int CGroupSubMenu::luaSetUserGroupRight(CLuaState &ls) const char *funcName = "setUserGroupRight"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHMRyzom::isUIOnStack(ls, 2) || ls.isNil(2))) + if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - CInterfaceElement *el = CLuaIHMRyzom::getUIOnStack(ls, 2); + CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); CInterfaceGroup *group = dynamic_cast(el); if (el && !group) { @@ -1824,11 +1824,11 @@ int CGroupSubMenu::luaSetUserGroupLeft(CLuaState &ls) const char *funcName = "setUserGroupLeft"; CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHMRyzom::isUIOnStack(ls, 2) || ls.isNil(2))) + if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) { CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); } - CInterfaceElement *el = CLuaIHMRyzom::getUIOnStack(ls, 2); + CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); CInterfaceGroup *group = dynamic_cast(el); if (el && !group) { @@ -1845,7 +1845,7 @@ int CGroupSubMenu::luaGetUserGroupRight(CLuaState &ls) const char *funcName = "getUserGroupRight"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHMRyzom::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); + CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); return 1; } @@ -1859,7 +1859,7 @@ int CGroupSubMenu::luaGetUserGroupLeft(CLuaState &ls) CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1)); if (pIE) { - CLuaIHMRyzom::pushUIOnStack(ls, pIE); + CLuaIHM::pushUIOnStack(ls, pIE); return 1; } else return 0; @@ -2282,7 +2282,7 @@ void CGroupMenu::setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip int CGroupMenu::luaGetRootMenu(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "getRootMenu", 0); - CLuaIHMRyzom::pushUIOnStack(ls, getRootMenu()); + CLuaIHM::pushUIOnStack(ls, getRootMenu()); return 1; } diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index d0ec9f82c..8f3098996 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -19,8 +19,8 @@ #ifndef RZ_GROUP_MENU_H #define RZ_GROUP_MENU_H -#include "interface_group.h" -#include "group_modal.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_modal.h" #include "view_text.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.h b/code/ryzom/client/src/interface_v3/group_modal_get_key.h index 54a594e7e..afa789917 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.h +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "../actions.h" // CLIENT -#include "group_modal.h" +#include "nel/gui/group_modal.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index f75afccf0..2ac417734 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -21,7 +21,7 @@ #include "group_paragraph.h" #include "group_html.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" #include "view_text_id.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index ab37a1814..f2c38bd05 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -20,7 +20,7 @@ #define NL_GROUP_PARAGRAPH_H #include "nel/misc/types_nl.h" -#include "group_frame.h" +#include "nel/gui/group_frame.h" #include "view_text.h" #include "view_link.h" #include "ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h index 26099f8e3..8da02ee10 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "game_share/brick_families.h" #include "game_share/skills.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "group_tree.h" diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 5de2f530d..108d07a9b 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -26,7 +26,7 @@ #include "group_paragraph.h" #include "../libwww.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "nel/misc/xml_auto_ptr.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index 2a0885133..c3321e185 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -25,7 +25,7 @@ #include "view_text.h" #include "ctrl_scroll.h" #include "ctrl_button.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../time_client.h" #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h index c9baa1889..520a416af 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.h @@ -21,7 +21,7 @@ #define CL_GROUP_SCROLLTEXT_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" class CGroupList; class CCtrlScroll; diff --git a/code/ryzom/client/src/interface_v3/group_skills.h b/code/ryzom/client/src/interface_v3/group_skills.h index e486ae098..a29af8a03 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.h +++ b/code/ryzom/client/src/interface_v3/group_skills.h @@ -20,7 +20,7 @@ #define NL_GROUP_SKILLS_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "group_tree.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index af6ea1fae..f5b05c5ed 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -235,7 +235,7 @@ void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) int CGroupTab::luaAddTab(CLuaState &ls) { CLuaIHM::checkArgCount(ls, "CGroupTab::addTab", 1); - CCtrlTabButton *tabB = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (tabB) { // don't use addTab to avoid selection of new tab @@ -260,7 +260,7 @@ int CGroupTab::luaAddTabWithOrder(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CCtrlTabButton *tabB = dynamic_cast(CLuaIHMRyzom::getUIOnStack(ls, 1)); + CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); if (tabB) { // don't use addTab to avoid selection of new tab @@ -395,7 +395,7 @@ int CGroupTab::luaGetTabButton(CLuaState &ls) CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1)); if(tab != NULL) { - CLuaIHMRyzom::pushUIOnStack(ls, tab); + CLuaIHM::pushUIOnStack(ls, tab); return 1; } return 0; @@ -726,7 +726,7 @@ int CGroupTab::luaGetGroup(CLuaState &ls) CInterfaceGroup* group = getGroup((uint) ls.toNumber(1)); if(group != NULL) { - CLuaIHMRyzom::pushUIOnStack(ls, group); + CLuaIHM::pushUIOnStack(ls, group); return 1; } return 0; diff --git a/code/ryzom/client/src/interface_v3/group_tab.h b/code/ryzom/client/src/interface_v3/group_tab.h index 42914506e..1e8e8c792 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.h +++ b/code/ryzom/client/src/interface_v3/group_tab.h @@ -20,7 +20,7 @@ #define NL_GROUP_TAB_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 347f0373f..09d3b9283 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -20,7 +20,7 @@ #include "group_table.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" #include "view_text_id.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.h b/code/ryzom/client/src/interface_v3/group_table.h index 888d6dbe3..f4aa0b8fd 100644 --- a/code/ryzom/client/src/interface_v3/group_table.h +++ b/code/ryzom/client/src/interface_v3/group_table.h @@ -20,7 +20,7 @@ #define NL_GROUP_TABLE_H #include "nel/misc/types_nl.h" -#include "group_frame.h" +#include "nel/gui/group_frame.h" #include "view_text.h" #include "view_link.h" #include "ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 46ce4434f..1d6282ffd 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -20,11 +20,11 @@ #include "group_tree.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "view_bitmap.h" #include "view_text.h" #include "group_container.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" @@ -1491,7 +1491,7 @@ int CGroupTree::SNode::luaGetParentTree(CLuaState &ls) CLuaIHM::checkArgCount(ls, "getParentTree", 0); if (ParentTree) { - CLuaIHMRyzom::pushUIOnStack(ls, ParentTree); + CLuaIHM::pushUIOnStack(ls, ParentTree); } else { diff --git a/code/ryzom/client/src/interface_v3/group_tree.h b/code/ryzom/client/src/interface_v3/group_tree.h index 444a0fe4d..038db0cf0 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.h +++ b/code/ryzom/client/src/interface_v3/group_tree.h @@ -20,7 +20,7 @@ #define NL_GROUP_TREE_H #include "nel/misc/types_nl.h" -#include "group_frame.h" +#include "nel/gui/group_frame.h" #include "nel/misc/smart_ptr.h" class CViewBitmap; diff --git a/code/ryzom/client/src/interface_v3/group_wheel.h b/code/ryzom/client/src/interface_v3/group_wheel.h index a3b3f7c23..d2f12ca3c 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.h +++ b/code/ryzom/client/src/interface_v3/group_wheel.h @@ -19,7 +19,7 @@ #ifndef RZ_GROUP_CONTAINER_H #define RZ_GROUP_CONTAINER_H -#include "interface_group.h" +#include "nel/gui/interface_group.h" diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 9271753f9..3e880bb22 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "../string_manager_client.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "view_text.h" #include "dbctrl_sheet.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp index 589b9bf18..5df5b61eb 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.cpp @@ -30,7 +30,7 @@ #include "nel/3d/u_animation_set.h" #include "nel/misc/xml_auto_ptr.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/interface_3d_scene.h b/code/ryzom/client/src/interface_v3/interface_3d_scene.h index 339497f43..28daa87af 100644 --- a/code/ryzom/client/src/interface_v3/interface_3d_scene.h +++ b/code/ryzom/client/src/interface_v3/interface_3d_scene.h @@ -19,7 +19,7 @@ #ifndef RZ_INTERFACE_SCENE_3D_H #define RZ_INTERFACE_SCENE_3D_H -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "nel/3d/u_point_light.h" #include "nel/3d/u_particle_system_instance.h" diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index a27c248d6..be39bc9b1 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "nel/gui/interface_expr.h" #include "nel/misc/xml_auto_ptr.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../time_client.h" // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/interface_anim.h b/code/ryzom/client/src/interface_v3/interface_anim.h index 9965d3723..c8b06df5e 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.h +++ b/code/ryzom/client/src/interface_v3/interface_anim.h @@ -20,8 +20,8 @@ #define RZ_INTERFACE_ANIM_H #include "nel/gui/interface_property.h" -#include "interface_group.h" -#include "interface_link.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/interface_link.h" #include "nel/3d/u_track.h" diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index 73f4873b4..5447ea2cd 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -20,9 +20,9 @@ #include "interface_manager.h" #include "interface_ddx.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "ctrl_button.h" -#include "group_modal.h" +#include "nel/gui/group_modal.h" #include "../client_cfg.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.h b/code/ryzom/client/src/interface_v3/interface_ddx.h index fbf05920e..3957ab459 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.h +++ b/code/ryzom/client/src/interface_v3/interface_ddx.h @@ -20,7 +20,7 @@ #define NL_INTERFACE_DDX_H #include "nel/misc/types_nl.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "interface_pointer.h" // Values for float (scrollbar float) must not exceed 200,00 this is due to storing on diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index e2b782a1d..f08d99672 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -20,7 +20,7 @@ // Interface #include "nel/gui/interface_expr.h" #include "interface_manager.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "chat_window.h" #include "group_container.h" // client diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 94b1bc3dd..7feafadbe 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -38,7 +38,7 @@ #include "nel/gui/interface_expr.h" #include "register_interface_elements.h" // Action / Observers -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_observer.h" #include "interface_anim.h" #include "interface_ddx.h" @@ -60,7 +60,7 @@ #include "group_list.h" #include "group_menu.h" #include "group_container.h" -#include "group_modal.h" +#include "nel/gui/group_modal.h" #include "group_editbox.h" #include "group_in_scene_bubble.h" #include "group_skills.h" @@ -4815,9 +4815,9 @@ void CInterfaceManager::getLuaValueInfo(std::string &str, sint index) // If its a Userdata, try to display UI info else if(type==LUA_TUSERDATA) { - if(CLuaIHMRyzom::isUIOnStack(ls, index)) + if(CLuaIHM::isUIOnStack(ls, index)) { - CInterfaceElement *ui= CLuaIHMRyzom::getUIOnStack(ls, index); + CInterfaceElement *ui= CLuaIHM::getUIOnStack(ls, index); str+= NLMISC::toString(" (ui=%p)", ui); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 92e32b6d1..93b72c97e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -23,13 +23,13 @@ #include "nel/misc/cdb_manager.h" #include "nel/3d/u_texture.h" #include "nel/3d/u_text_context.h" -#include "interface_group.h" -#include "interface_link.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/interface_link.h" #include "group_list.h" -#include "view_base.h" +#include "nel/gui/view_base.h" #include "view_pointer.h" -#include "ctrl_base.h" +#include "nel/gui/ctrl_base.h" #include "ctrl_scroll.h" #include "nel/gui/view_renderer.h" @@ -37,7 +37,7 @@ // InterfaceV3 #include "interface_parser.h" #include "ctrl_sheet_selection.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "interface_config.h" #include "interface_pointer.h" #include "flying_text_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp index 9e9731c8c..8e29004fa 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "interface_manager.h" #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h index f5bf6bc97..2d830c1fb 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h @@ -18,7 +18,7 @@ #ifndef IF_OPTIONS_RZ #define IP_OPTIONS_RZ -#include "interface_options.h" +#include "nel/gui/interface_options.h" // *************************************************************************** class COptionsLayer : public CInterfaceOptions diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 1539a2d29..a8b42df12 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -31,7 +31,7 @@ #include "interface_parser.h" #include "interface_observer.h" -#include "interface_options.h" +#include "nel/gui/interface_options.h" #include "interface_options_ryzom.h" #include "interface_anim.h" #include "interface_3d_scene.h" @@ -61,9 +61,9 @@ // DBCtrl #include "dbctrl_sheet.h" // Group -#include "group_frame.h" +#include "nel/gui/group_frame.h" #include "group_career.h" -#include "group_modal.h" +#include "nel/gui/group_modal.h" #include "group_modal_get_key.h" #include "group_list.h" #include "group_tree.h" @@ -99,7 +99,7 @@ #include "dbgroup_list_sheet_bonus_malus.h" #include "dbgroup_list_sheet_icon_phrase.h" // Misc. -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "interface_ddx.h" #include "../actions.h" #include "macrocmd_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 135483d5c..b94ffaa70 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -22,11 +22,11 @@ #include "nel/misc/types_nl.h" #include "nel/3d/u_texture.h" #include "ctrl_sheet_selection.h" -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "nel/misc/smart_ptr.h" #include "game_share/brick_types.h" #include "nel/gui/lua_helper.h" -#include "widget_manager.h" +#include "nel/gui/widget_manager.h" using namespace NLGUI; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index 2756e6391..15dbc354c 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -38,7 +38,7 @@ #include "sphrase_manager.h" // For handlers -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "dbctrl_sheet.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/list_sheet_base.h b/code/ryzom/client/src/interface_v3/list_sheet_base.h index bc4207ca5..1ef13e4ca 100644 --- a/code/ryzom/client/src/interface_v3/list_sheet_base.h +++ b/code/ryzom/client/src/interface_v3/list_sheet_base.h @@ -20,7 +20,7 @@ #define NL_LIST_SHEET_BASE_H #include "nel/misc/types_nl.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" class CDBCtrlSheet; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index eecd9afe8..505bc1fd2 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -45,14 +45,14 @@ #include "nel/gui/lua_ihm.h" #include "nel/gui/reflect.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "action_handler_tools.h" #include "interface_manager.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "view_text.h" #include "game_share/people_pd.h" #include "group_tree.h" -#include "interface_link.h" +#include "nel/gui/interface_link.h" #include "nel/gui/interface_expr.h" #include "people_interraction.h" #include "nel/misc/algo.h" @@ -310,403 +310,9 @@ int CLuaIHMRyzom::luaClientCfgNewIndex(CLuaState &ls) throw ELuaWrappedFunctionException(&ls, "Can't write into config file from lua."); } -// *************************************************************************** -CInterfaceElement *CLuaIHMRyzom::getUIRelative(CInterfaceElement *pIE, const std::string &propName) -{ - //H_AUTO(Lua_CLuaIHM_getUIRelative) - if (pIE == NULL) return NULL; - // If the prop is "parent", then return the parent of the ui - if(propName=="parent") - { - return pIE->getParent(); - } - // else try to get a child (if group/exist) - else - { - CInterfaceGroup *group= dynamic_cast(pIE); - if(group) - { - return group->getElement(group->getId()+":"+propName); - } - } - - return NULL; -} - static CLuaString lstr_Env("Env"); static CLuaString lstr_isNil("isNil"); -// *************************************************************************** -int CLuaIHMRyzom::luaUIIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIIndex) - nlassert(ls.getTop()==2); - // get the userdata and key - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - - const char *propName = ls.toString(2); - CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); - // ** try to get the Env Table (interface group only) - if(propName==lstr_isNil) - { - ls.push(pRPT==NULL); - return 1; - } - - // Check the object is not NULL or freed - if(pRPT==NULL) - { - return 0; - } - - // ** try to get the Env Table (interface group only) - if(propName==lstr_Env) - { - // Env can be bound to a CInterfaceGroup only - CInterfaceGroup *group= dynamic_cast(pRPT); - if(group==NULL) - { - ls.pushNil(); - return 1; - } - else - { - group->pushLUAEnvTable(); - return 1; - } - } - - // ** try to get the property - const CReflectedProperty *prop = pRefElm->getProp(propName); - if (prop) - { - CLuaIHM::luaValueFromReflectedProperty(ls, *pRPT, *prop); - return 1; - } - - // ** try to get a UI relative - CInterfaceElement *uiRelative= getUIRelative(dynamic_cast(pRPT), propName); - if(uiRelative) - { - // push the UI onto the stack - pushUIOnStack(ls, uiRelative); - return 1; - } - - - // Fail to find any Attributes or elements - // Yoyo: don't write any message or warning because this may be a feature (if user want to test that something exit in the ui) - ls.pushNil(); - return 1; -} - -// *************************************************************************** -int CLuaIHMRyzom::luaUINewIndex(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUINewIndex) - nlassert(ls.getTop()==3); - // get the userdata and key - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - nlassert(pRefElm); - CReflectableRefPtrTarget *pRPT= (CReflectableRefPtrTarget*)(pRefElm->Ptr); - // Check the UI is not NULL or freed - if(pRPT == NULL) - { - return 0; - } - - const char *propName = ls.toString(2); - // ** try to set the Env Table (interface group only) - if(propName == lstr_Env) - { - CInterfaceElement *pIE = dynamic_cast(pRPT); - std::string name ; - if (pIE) - { - name = pIE->getId(); - } - else - { - name = ""; - } - // Exception!!! not allowed - throw ELuaIHMException("You cannot change the Env Table of '%s'", name.c_str()); - } - - - // ** try to set the property - const CReflectedProperty *prop = pRefElm->getProp(propName); - if (prop) - { - CLuaIHM::luaValueToReflectedProperty(ls, 3, *pRPT, *prop); - return 0; - } - - CInterfaceElement *pIE = dynamic_cast(pRPT); - // ** try to get another UI (child or parent) - CInterfaceElement *uiRelative= getUIRelative(pIE, propName); - if(uiRelative) - { - // Exception!!! not allowed - throw ELuaIHMException("You cannot write into the UI '%s' of '%s'", propName, pIE->getId().c_str()); - } - - // ** Prop Not Found - throw ELuaIHMException("Property '%s' not found in '%s' of type %s", propName, pIE ? pIE->getId().c_str() : "", typeid(*pRPT).name()); - - // Fail to find any Attributes or elements - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::luaUIEq(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIEq) - nlassert(ls.getTop() == 2); - // read lhs & rhs - // get the userdata and key - CReflectableLuaRef *lhs = (CReflectableLuaRef *) ls.toUserData(1); - CReflectableLuaRef *rhs = (CReflectableLuaRef *) ls.toUserData(2); - nlassert(lhs); - nlassert(rhs); - ls.push(lhs->Ptr == rhs->Ptr); - return 1; -} - - -// *************************************************************************** -int CLuaIHMRyzom::luaUIDtor(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUIDtor) - nlassert(ls.getTop()==1); - // get the userdata - CReflectableLuaRef *pRefElm = (CReflectableLuaRef *) ls.toUserData(1); - nlassert(pRefElm); - - // call dtor - pRefElm->~CReflectableLuaRef(); - - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::luaUINext(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_luaUINext) - // Code below allow enumeration of properties of a reflectable object - // From lua standpoint, the object is seen as a table with (key, value) pairs - // If object is a CInterfaceGroup, iteration is also done on sons (groups, controls & view). - - if (ls.getTop() != 2) - { - CLuaIHM::fails(ls, "__next metamethod require 2 arguments (table & key)"); - } - CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "__next : require ui element as first arg"); - CReflectableRefPtrTarget *reflectedObject = CLuaIHM::getReflectableOnStack(ls, 1); - // To traverse all properties / field of the object, we must be able to determine the next key from a previous key - // (keys are ordered) - // We use the 'TValueType' enum to know which kind of property we are traversing, and an index in this group of properties - // The key which uniquely identify an element / property in the reflectable object - struct CKey - { - enum TValueType - { - VTGroup = 0, // children groups (If the object is a CInterfaceGroup) - VTView, // children views (If the object is a CInterfaceView) - VTCtrl, // children controls (If the object is a CInterfaceCtrl) - VTProp // List of exported proeprties (For all relfectable objects) - }; - TValueType ValueType; - sint Index; - const CClassInfo *ClassInfo; // if ValueType is "VTProp" -> give the class for which property are currently enumerated - // - static int tostring(CLuaState &ls) // '__print' metamathod - { - CLuaIHM::checkArgCount(ls, "reflected object metatable:__print", 1); - CKey key; - key.pop(ls); - switch(key.ValueType) - { - case VTGroup: ls.push(toString("_Group %d", key.Index)); break; - case VTView: ls.push(toString("_View %d", key.Index)); break; - case VTCtrl: ls.push(toString("_Ctrl %d", key.Index)); break; - case VTProp: ls.push(key.ClassInfo->Properties[key.Index].Name); break; - } - return 1; - } - // push the key on the lua stack - void push(CLuaState &ls) - { - void *ud = ls.newUserData(sizeof(*this)); - *(CKey *) ud = *this; - getMetaTable(ls).push(); - ls.setMetaTable(-2); - } - // pop the key from the lua stack - void pop(CLuaState &ls) - { - CLuaStackChecker lsc(&ls, -1); - if (!ls.isUserData(-1)) - { - CLuaIHM::fails(ls, "Can't pop object, not a user data"); - } - // check that metatable is good (it is share between all keys) - ls.getMetaTable(-1); - getMetaTable(ls).push(); - if (!ls.rawEqual(-1, -2)) - { - CLuaIHM::fails(ls, "Bad metatable for reflectable object key"); - } - ls.pop(2); - // retrieve key - *this = *(CKey *) ls.toUserData(-1); - ls.pop(); - } - // get the metatable for a CKey - CLuaObject &getMetaTable(CLuaState &ls) - { - static CLuaObject metatable; - if (!metatable.isValid()) - { - // first build - CLuaStackChecker lsc(&ls); - ls.newTable(); - ls.push("__tostring"); - ls.push(CKey::tostring); - ls.setTable(-3); - metatable.pop(ls); - } - return metatable; - } - }; - // Pop the current key to continue enumeration - CKey key; - if (ls.isNil(2)) - { - // no key -> start of table - key.ValueType = CKey::VTGroup; - key.Index = -1; - } - else - { - key.pop(ls); - } - // - CInterfaceGroup *group = dynamic_cast(reflectedObject); - bool enumerate = true; - while (enumerate) - { - switch(key.ValueType) - { - case CKey::VTGroup: - if (!group || (key.Index + 1) == (sint) group->getGroups().size()) - { - key.Index = -1; - key.ValueType = CKey::VTView; // continue enumeration with views - } - else - { - ++ key.Index; - key.push(ls); - pushUIOnStack(ls, group->getGroups()[key.Index]); - return 2; - } - break; - case CKey::VTView: - if (!group || (key.Index + 1) == (sint) group->getViews().size()) - { - key.Index = -1; - key.ValueType = CKey::VTCtrl; // continue enumeration with controls - } - else - { - ++ key.Index; - key.push(ls); - pushUIOnStack(ls, group->getViews()[key.Index]); - return 2; - } - break; - case CKey::VTCtrl: - if (!group || (key.Index + 1) == (sint) group->getControls().size()) - { - key.Index = -1; - key.ValueType = CKey::VTProp; // continue enumeration with properties - key.ClassInfo = reflectedObject->getClassInfo(); - } - else - { - ++ key.Index; - key.push(ls); - pushUIOnStack(ls, group->getControls()[key.Index]); - return 2; - } - break; - case CKey::VTProp: - if (!key.ClassInfo) - { - enumerate = false; - break; - } - if ((sint) key.ClassInfo->Properties.size() == (key.Index + 1)) - { - key.ClassInfo = key.ClassInfo->ParentClass; // continue enumeration in parent class - key.Index = -1; - } - else - { - ++ key.Index; - key.push(ls); - CLuaIHM::luaValueFromReflectedProperty(ls, *reflectedObject, key.ClassInfo->Properties[key.Index]); - return 2; - } - break; - default: - nlassert(0); - break; - } - } - ls.pushNil(); - return 0; -} - -// *************************************************************************** -void CLuaIHMRyzom::pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE) -{ - //H_AUTO(Lua_CLuaIHM_pushUIOnStack) - CLuaIHM::pushReflectableOnStack(ls, pIE); -} - -// *************************************************************************** -bool CLuaIHMRyzom::isUIOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_isUIOnStack) - return getUIOnStack(ls, index) != NULL; -} - -// *************************************************************************** -CInterfaceElement *CLuaIHMRyzom::getUIOnStack(CLuaState &ls, sint index) -{ - //H_AUTO(Lua_CLuaIHM_getUIOnStack) - return dynamic_cast(CLuaIHM::getReflectableOnStack(ls, index)); -} - -// *************************************************************************** -void CLuaIHMRyzom::checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index) -{ - //H_AUTO(Lua_CLuaIHM_checkArgTypeUIElement) - nlassert(index > 0); - if (ls.getTop() < (int) index) - { - CLuaIHM::fails(ls, "%s : argument %d of expected type ui element was not defined", funcName, index); - } - if (!isUIOnStack(ls, index)) - { - CLuaIHM::fails(ls, "%s : argument %d of expected type ui element has bad type : %s", funcName, index, ls.getTypename(ls.type(index)), ls.type(index)); - } -} - - - // *************************************************************************** void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str) { @@ -755,38 +361,6 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) mt.setValue("__newindex", luaClientCfgNewIndex); globals.setNil("__cfmt"); // remove temp metatable - // *** Register the MetaTable for UI userdata - ls.push(IHM_LUA_METATABLE); // "__ui_metatable" - ls.newTable(); // "__ui_metatable" {} - // set the '__index' method - ls.push("__index"); - ls.push(luaUIIndex); - nlassert(ls.isCFunction()); - ls.setTable(-3); // "__ui_metatable" {"__index"= CFunc_luaUIIndex} - // set the '__newindex' method - ls.push("__newindex"); - ls.push(luaUINewIndex); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the '__newindex' method - ls.push("__gc"); - ls.push(luaUIDtor); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the '__eq' method - ls.push("__eq"); - ls.push(luaUIEq); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set the custom '__next' method - ls.push("__next"); - ls.push(luaUINext); - nlassert(ls.isCFunction()); - ls.setTable(-3); - // set registry - ls.setTable(LUA_REGISTRYINDEX); - - ls.registerFunc( "getUI", getUI ); ls.registerFunc("setOnDraw", setOnDraw); ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); @@ -1032,7 +606,7 @@ int CLuaIHMRyzom::getUI(CLuaState &ls) } else { - pushUIOnStack(ls, pIE); + CLuaIHM::pushUIOnStack(ls, pIE); } return 1; } @@ -1043,8 +617,8 @@ int CLuaIHMRyzom::setCaptureKeyboard(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) const char *funcName = "setCaptureKeyboard"; CLuaIHM::checkArgCount(ls, funcName, 1); - checkArgTypeUIElement(ls, funcName, 1); - CCtrlBase *ctrl = dynamic_cast( getUIOnStack(ls, 1)); + CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); + CCtrlBase *ctrl = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); if (!ctrl) { CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); @@ -1074,11 +648,11 @@ int CLuaIHMRyzom::setOnDraw(CLuaState &ls) // params: CInterfaceGroup*, "script". // return: none CLuaIHM::checkArgCount(ls, "setOnDraw", 2); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string script; ls.toString(2, script); @@ -1101,12 +675,12 @@ int CLuaIHMRyzom::addOnDbChange(CLuaState &ls) // params: CInterfaceGroup*, "dblist", "script". // return: none CLuaIHM::checkArgCount(ls, "addOnDbChange", 3); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); CLuaIHM::check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string dbList, script; ls.toString(2, dbList); ls.toString(3, script); @@ -1131,11 +705,11 @@ int CLuaIHMRyzom::removeOnDbChange(CLuaState &ls) // params: CInterfaceGroup*, "dbList" // return: none CLuaIHM::checkArgCount(ls, "removeOnDbChange", 2); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); CLuaIHM::check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string dbList; ls.toString(2, dbList); @@ -1159,12 +733,12 @@ int CLuaIHMRyzom::runAH(CLuaState &ls) // params: CInterfaceElement *, "ah", "params". // return: none CLuaIHM::checkArgCount(ls, "runAH", 3); - CLuaIHM::check(ls, isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); CLuaIHM::check(ls, ls.isString(2), "runAH() requires a string in param 2"); CLuaIHM::check(ls, ls.isString(3), "runAH() requires a string in param 3"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string ah, params; ls.toString(2, ah); ls.toString(3, params); @@ -1374,10 +948,10 @@ int CLuaIHMRyzom::deleteUI(CLuaState &ls) // params: CInterfaceElement * // return: none CLuaIHM::checkArgCount(ls, "deleteUI", 1); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); if(!pIE) return 0; @@ -1442,10 +1016,10 @@ int CLuaIHMRyzom::dumpUI(CLuaState &ls) // params: CInterfaceElement * // return: none CLuaIHM::checkArgCount(ls, "dumpUI", 1); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); if(!pIE) debugInfo("UI: NULL"); else @@ -1498,7 +1072,7 @@ int CLuaIHMRyzom::setTopWindow(CLuaState &ls) //H_AUTO(Lua_CLuaIHM_setTopWindow) const char *funcName = "setTopWindow"; CLuaIHM::checkArgCount(ls, funcName, 1); - CInterfaceGroup *wnd = dynamic_cast( getUIOnStack(ls, 1)); + CInterfaceGroup *wnd = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); if (!wnd) { CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); @@ -1624,8 +1198,8 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) CLuaIHM::checkArgCount(ls, "setTextFormatTaged", 2); // *** check and retrieve param 1 - CLuaIHM::check(ls, isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1"); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); // *** check and retrieve param 2. must be a string or a ucstring ucstring text; @@ -1986,10 +1560,10 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) const char *funcName = "enableModalWindow"; CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1"); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); std::string modalId = ls.toString(2); // convert to id @@ -2206,10 +1780,10 @@ int CLuaIHMRyzom::disableContextHelpForControl(CLuaState &ls) // params: CCtrlBase* // return: none CLuaIHM::checkArgCount(ls, "disableContextHelpForControl", 1); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); // go CInterfaceManager *pIM= CInterfaceManager::getInstance(); @@ -2409,7 +1983,7 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls) } else { - pushUIOnStack(ls, pIE); + CLuaIHM::pushUIOnStack(ls, pIE); } return 1; } @@ -2427,7 +2001,7 @@ int CLuaIHMRyzom::getCurrentWindowUnder(CLuaState &ls) } else { - pushUIOnStack(ls, pIE); + CLuaIHM::pushUIOnStack(ls, pIE); } return 1; } @@ -2441,10 +2015,10 @@ int CLuaIHMRyzom::getUIId(CLuaState &ls) // params: CInterfaceElement* // return: "ui:interface:...". (empty if error) CLuaIHM::checkArgCount(ls, "getUIId", 1); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); // convert to id if(pIE) @@ -2464,10 +2038,10 @@ int CLuaIHMRyzom::getIndexInDB(CLuaState &ls) // params: CDBCtrlSheet* // return: index in DB of a dbctrlsheet (empty if error) CLuaIHM::checkArgCount(ls, "getIndexInDB", 1); - CLuaIHM::check(ls, isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1"); // retrieve args - CInterfaceElement *pIE= getUIOnStack(ls, 1); + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); CDBCtrlSheet *pCS= dynamic_cast(pIE); // get the index in db @@ -2513,7 +2087,7 @@ int CLuaIHMRyzom::createGroupInstance(CLuaState &ls) } else { - pushUIOnStack(ls, result); + CLuaIHM::pushUIOnStack(ls, result); } return 1; } @@ -2560,7 +2134,7 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls) if (pRoot) pRoot->addGroup(result); result->setActive(true); - pushUIOnStack(ls, result); + CLuaIHM::pushUIOnStack(ls, result); } return 1; } @@ -2599,7 +2173,7 @@ int CLuaIHMRyzom::createUIElement(CLuaState &ls) } else { - pushUIOnStack(ls, result); + CLuaIHM::pushUIOnStack(ls, result); } return 1; } diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 71fe3f398..3d7c32860 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -16,20 +16,8 @@ private: static int luaClientCfgIndex(CLuaState &ls); static int luaClientCfgNewIndex(CLuaState &ls); - // Functions for the ui metatable - static class CInterfaceElement *getUIRelative(class CInterfaceElement *pIE, const std::string &propName); - static int luaUIIndex(CLuaState &ls); - static int luaUINewIndex(CLuaState &ls); - static int luaUIEq(CLuaState &ls); - static int luaUINext(CLuaState &ls); - static int luaUIDtor(CLuaState &ls); - // CInterfaceElement management on stack, stored by a CRefPtr. public: - static void pushUIOnStack(CLuaState &ls, class CInterfaceElement *pIE); - static bool isUIOnStack(CLuaState &ls, sint index); - static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index); - static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index); private: diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index d7b2bdb4b..1b91b3dd4 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -23,7 +23,7 @@ #include "macrocmd_manager.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "ctrl_button.h" #include "group_editbox.h" #include "group_list.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index b1b0d9e12..679fa5900 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -23,7 +23,7 @@ #include "macrocmd_key.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "dbctrl_sheet.h" #include "ctrl_button.h" #include "group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 1aeabb9cb..10309a211 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "music_player.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "../input.h" #include "../sound_manager.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 668c5f977..ead0fe307 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -22,7 +22,7 @@ #include "people_interraction.h" #include "nel/gui/interface_expr.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "action_handler_misc.h" #include "chat_window.h" #include "../entity_animation_manager.h" diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 5c4821e72..a5ddacdbf 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -22,7 +22,7 @@ #include "group_list.h" #include "view_bitmap.h" #include "interface_manager.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_editbox.h" #include "../client_chat_manager.h" #include "chat_text_manager.h" diff --git a/code/ryzom/client/src/interface_v3/player_trade.cpp b/code/ryzom/client/src/interface_v3/player_trade.cpp index 1e4c4a172..799b3ec43 100644 --- a/code/ryzom/client/src/interface_v3/player_trade.cpp +++ b/code/ryzom/client/src/interface_v3/player_trade.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "inventory_manager.h" // #include "game_share/inventories.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 227540244..196497e65 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -17,35 +17,35 @@ #include "stdpch.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "interface_3d_scene.h" -#include "view_base.h" +#include "nel/gui/view_base.h" #include "view_text.h" #include "view_text_id.h" #include "view_bitmap.h" #include "view_radar.h" #include "group_menu.h" -#include "ctrl_base.h" -#include "interface_group.h" -#include "group_frame.h" -#include "group_container_base.h" +#include "nel/gui/ctrl_base.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_frame.h" +#include "nel/gui/group_container_base.h" #include "group_container.h" #include "group_list.h" #include "dbgroup_select_number.h" #include "ctrl_button.h" #include "ctrl_text_button.h" #include "ctrl_col_pick.h" -#include "ctrl_draggable.h" +#include "nel/gui/ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" -#include "group_editbox_base.h" +#include "nel/gui/group_editbox_base.h" #include "group_editbox.h" #include "group_tree.h" #include "nel/gui/reflect.h" #include "dbview_bar.h" #include "dbview_bar3.h" #include "group_list.h" -#include "ctrl_scroll_base.h" +#include "nel/gui/ctrl_scroll_base.h" #include "ctrl_scroll.h" #include "dbgroup_combo_box.h" #include "group_tab.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index 832b23f2b..d31a4d034 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -25,7 +25,7 @@ #include "game_share/fame.h" #include "../sheet_manager.h" #include "nel/misc/cdb_leaf.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "sbrick_manager.h" #include "dbgroup_combo_box.h" #include "view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/sphrase_manager.h b/code/ryzom/client/src/interface_v3/sphrase_manager.h index f14dfcf0d..8673f650c 100644 --- a/code/ryzom/client/src/interface_v3/sphrase_manager.h +++ b/code/ryzom/client/src/interface_v3/sphrase_manager.h @@ -26,7 +26,7 @@ #include "brick_learned_callback.h" #include "skill_change_callback.h" #include "trade_common.h" -#include "interface_element.h" +#include "nel/gui/interface_element.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp index aa76e0fa8..5b780aa9f 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -24,7 +24,7 @@ #include "macrocmd_manager.h" #include "dbgroup_list_sheet.h" -#include "action_handler.h" +#include "nel/gui/action_handler.h" #include "group_container.h" #include "../actions_client.h" #include "ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.h b/code/ryzom/client/src/interface_v3/view_bitmap.h index ce3be1d6a..3d63cbfe8 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap.h @@ -19,7 +19,7 @@ #ifndef NL_VIEW_BITMAP_H #define NL_VIEW_BITMAP_H -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/3d/u_texture.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h b/code/ryzom/client/src/interface_v3/view_bitmap_combo.h index 767499c95..1d4c34a0b 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.h @@ -21,7 +21,7 @@ #define NL_VIEW_BITMAP_COMBO_H #include "nel/misc/cdb.h" -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/3d/u_texture.h" #include #include diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index 8002f5e9d..ebaa84225 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/events.h" -#include "view_pointer_base.h" +#include "nel/gui/view_pointer_base.h" class CGroupContainer; class CCtrlBase; diff --git a/code/ryzom/client/src/interface_v3/view_polygon.h b/code/ryzom/client/src/interface_v3/view_polygon.h index 581f96f4e..1c9c97463 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.h +++ b/code/ryzom/client/src/interface_v3/view_polygon.h @@ -18,7 +18,7 @@ #ifndef RZ_VIEW_POLYGON_H #define RZ_VIEW_POLYGON_H -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/gui/view_renderer.h" // #include "nel/misc/geom_ext.h" diff --git a/code/ryzom/client/src/interface_v3/view_quad.cpp b/code/ryzom/client/src/interface_v3/view_quad.cpp index ca983cb92..424868331 100644 --- a/code/ryzom/client/src/interface_v3/view_quad.cpp +++ b/code/ryzom/client/src/interface_v3/view_quad.cpp @@ -16,7 +16,7 @@ #include "stdpch.h" #include "view_quad.h" -#include "interface_group.h" +#include "nel/gui/interface_group.h" #include "interface_manager.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/view_quad.h b/code/ryzom/client/src/interface_v3/view_quad.h index 3d6b82923..e16becb69 100644 --- a/code/ryzom/client/src/interface_v3/view_quad.h +++ b/code/ryzom/client/src/interface_v3/view_quad.h @@ -18,7 +18,7 @@ #ifndef RZ_VIEW_QUAD_H #define RZ_VIEW_QUAD_H -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/gui/view_renderer.h" #include "nel/misc/geom_ext.h" diff --git a/code/ryzom/client/src/interface_v3/view_radar.h b/code/ryzom/client/src/interface_v3/view_radar.h index accad18d2..74d99c065 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.h +++ b/code/ryzom/client/src/interface_v3/view_radar.h @@ -19,7 +19,7 @@ #ifndef RY_VIEW_RADAR_H #define RY_VIEW_RADAR_H -#include "view_base.h" +#include "nel/gui/view_base.h" #include "nel/3d/u_texture.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/interface_v3/view_text.h b/code/ryzom/client/src/interface_v3/view_text.h index 0f75ea3ba..3620bbe77 100644 --- a/code/ryzom/client/src/interface_v3/view_text.h +++ b/code/ryzom/client/src/interface_v3/view_text.h @@ -19,7 +19,7 @@ #ifndef NL_VIEW_TEXT_H #define NL_VIEW_TEXT_H -#include "view_base.h" +#include "nel/gui/view_base.h" #include "../misc.h" #include "nel/3d/u_text_context.h" diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index d3cee7381..ab53744c3 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -91,7 +91,7 @@ #include "misc.h" #include "interface_v3/people_interraction.h" #include "debug_client.h" -#include "interface_v3/action_handler.h" +#include "nel/gui/action_handler.h" #include "interface_v3/action_handler_misc.h" #include "interface_v3/action_handler_item.h" #include "fx_manager.h" @@ -3234,7 +3234,7 @@ class CHandlerDebugUiDumpElementUnderMouse : public IActionHandler CLuaState *lua = CLuaManager::getInstance().getLuaState(); if (!lua) return; CLuaStackRestorer lsr(lua, 0); - CLuaIHMRyzom::pushUIOnStack(*lua, HighlightedDebugUI); + CLuaIHM::pushUIOnStack(*lua, HighlightedDebugUI); lua->pushValue(LUA_GLOBALSINDEX); CLuaObject env(*lua); env["inspect"].callNoThrow(1, 0); diff --git a/code/ryzom/client/src/r2/displayer_base.cpp b/code/ryzom/client/src/r2/displayer_base.cpp index 941081169..38b80f626 100644 --- a/code/ryzom/client/src/r2/displayer_base.cpp +++ b/code/ryzom/client/src/r2/displayer_base.cpp @@ -21,7 +21,7 @@ #include "game_share/object.h" // #include "nel/gui/lua_ihm.h" -#include "../interface_v3/interface_element.h" +#include "nel/gui/interface_element.h" namespace R2 { diff --git a/code/ryzom/client/src/r2/displayer_base.h b/code/ryzom/client/src/r2/displayer_base.h index 40f077af2..4d60a9f59 100644 --- a/code/ryzom/client/src/r2/displayer_base.h +++ b/code/ryzom/client/src/r2/displayer_base.h @@ -19,7 +19,7 @@ #include "nel/misc/smart_ptr.h" #include "nel/misc/class_registry.h" -#include "../interface_v3/interface_element.h" +#include "nel/gui/interface_element.h" namespace NLGUI { diff --git a/code/ryzom/client/src/r2/instance.h b/code/ryzom/client/src/r2/instance.h index cc71b28ae..d31641419 100644 --- a/code/ryzom/client/src/r2/instance.h +++ b/code/ryzom/client/src/r2/instance.h @@ -23,7 +23,7 @@ // #include "game_share/object.h" #include "displayer_base.h" -#include "../interface_v3/interface_element.h" +#include "nel/gui/interface_element.h" #include "lua_event_forwarder.h" class CEntityCL; diff --git a/code/ryzom/client/src/r2/island_collision.h b/code/ryzom/client/src/r2/island_collision.h index f1c8de182..3b9c5f473 100644 --- a/code/ryzom/client/src/r2/island_collision.h +++ b/code/ryzom/client/src/r2/island_collision.h @@ -27,7 +27,7 @@ #include "nel/3d/packed_world.h" // #include "nel/gui/view_renderer.h" -#include "../interface_v3/interface_element.h" +#include "nel/gui/interface_element.h" namespace NL3D { diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index 1152687bb..9b82fc724 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -21,7 +21,7 @@ #include "nel/misc/smart_ptr.h" #include "nel/misc/array_2d.h" // -#include "../interface_v3/interface_element.h" +#include "nel/gui/interface_element.h" #include "game_share/scenario_entry_points.h" // From 3db1f3cc482535fcb17e89c00beb382022867eac Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 9 Jun 2012 03:57:40 +0200 Subject: [PATCH 059/339] CHANGED: #1471 The classes moved in the previous commit are now under the NLGUI namespace. --- code/nel/include/nel/gui/action_handler.h | 204 +- code/nel/include/nel/gui/ctrl_base.h | 263 +- code/nel/include/nel/gui/ctrl_draggable.h | 78 +- code/nel/include/nel/gui/ctrl_scroll_base.h | 51 +- .../include/nel/gui/group_container_base.h | 115 +- code/nel/include/nel/gui/group_editbox_base.h | 57 +- code/nel/include/nel/gui/group_frame.h | 145 +- code/nel/include/nel/gui/group_modal.h | 73 +- code/nel/include/nel/gui/interface_element.h | 1132 +++--- code/nel/include/nel/gui/interface_group.h | 734 ++-- code/nel/include/nel/gui/interface_link.h | 305 +- code/nel/include/nel/gui/interface_options.h | 93 +- code/nel/include/nel/gui/view_base.h | 74 +- code/nel/include/nel/gui/view_pointer_base.h | 92 +- code/nel/include/nel/gui/widget_manager.h | 589 +-- code/nel/src/gui/action_handler.cpp | 1209 +++--- code/nel/src/gui/ctrl_base.cpp | 346 +- code/nel/src/gui/ctrl_draggable.cpp | 35 +- code/nel/src/gui/ctrl_scroll_base.cpp | 96 +- code/nel/src/gui/group_container_base.cpp | 145 +- code/nel/src/gui/group_editbox_base.cpp | 40 +- code/nel/src/gui/group_frame.cpp | 384 +- code/nel/src/gui/group_modal.cpp | 279 +- code/nel/src/gui/interface_element.cpp | 2236 +++++----- code/nel/src/gui/interface_group.cpp | 3595 +++++++++-------- code/nel/src/gui/interface_link.cpp | 1155 +++--- code/nel/src/gui/interface_options.cpp | 185 +- code/nel/src/gui/view_base.cpp | 47 +- code/nel/src/gui/view_pointer_base.cpp | 232 +- code/nel/src/gui/widget_manager.cpp | 2325 +++++------ code/ryzom/client/src/camera_recorder.cpp | 1 + .../src/interface_v3/action_handler_debug.cpp | 2 + .../src/interface_v3/action_handler_misc.h | 5 +- .../src/interface_v3/bot_chat_manager.h | 6 +- .../src/interface_v3/chat_text_manager.h | 8 +- .../client/src/interface_v3/chat_window.h | 9 +- .../src/interface_v3/ctrl_sheet_selection.h | 6 +- .../src/interface_v3/interface_manager.cpp | 11 +- .../src/interface_v3/interface_manager.h | 6 +- .../interface_v3/interface_options_ryzom.h | 2 + .../src/interface_v3/interface_parser.h | 15 +- .../src/interface_v3/interface_pointer.h | 18 +- .../client/src/interface_v3/view_pointer.h | 6 +- code/ryzom/client/src/r2/displayer_base.h | 2 +- 44 files changed, 8337 insertions(+), 8074 deletions(-) diff --git a/code/nel/include/nel/gui/action_handler.h b/code/nel/include/nel/gui/action_handler.h index b4234335c..d7bda1bda 100644 --- a/code/nel/include/nel/gui/action_handler.h +++ b/code/nel/include/nel/gui/action_handler.h @@ -24,113 +24,119 @@ #include "nel/misc/xml_auto_ptr.h" #include -/** - * interface for action handlers - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 - */ - -class CCtrlBase; - -class IActionHandler +namespace NLGUI { -public: - // Execute the answer to the action - // Params has the following form : paramName=theParam|paramName2=theParam2|... - virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { } - virtual ~IActionHandler() {} - - static std::string getParam (const std::string &Params, const std::string &ParamName); - - static void getAllParams (const std::string &Params, std::vector< std::pair > &AllParams); -}; + class CCtrlBase; -/** - interface for action handlers factory - no release in this factory : a handler must be destroyed by the control that created it - */ -class CAHManager -{ -public: - typedef std::map< std::string, IActionHandler* > TFactoryMap; - typedef std::map< IActionHandler*, std::string > TNameMap; - - static CAHManager* getInstance() - { - if (_GlobalInstance == NULL) - _GlobalInstance = new CAHManager; - return _GlobalInstance; - } - - /// return pointer to action handler or null if it doesn't exist - IActionHandler *getActionHandler(const std::string &name) const - { - TFactoryMap::const_iterator it = FactoryMap.find(name); - return it != FactoryMap.end() ? it->second : NULL; - } - - /// Return the name of the action handler given its pointer - const std::string &getActionHandlerName(IActionHandler *pAH) const - { - TNameMap::const_iterator it = NameMap.find(pAH); - return it != NameMap.end() ? it->second : EmptyName; - } - - /// map of action handler factories - TFactoryMap FactoryMap; - TNameMap NameMap; - std::string EmptyName; - - /// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed) - IActionHandler *getAH(const std::string &name, std::string ¶ms); - IActionHandler *getAH(const std::string &name, class CStringShared ¶ms); - - /** common method to parse Action Handler from a xml node - * \param ahId eg: "onclick_l" - * \param paramId eg: "params_l". - * \param params returned parameters. - * NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book") - * is taken - * NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed + /** + * interface for action handlers + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 */ - void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶ms); - void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); - - /// Get the AH name from ptr - const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); } + class IActionHandler + { + public: + // Execute the answer to the action + // Params has the following form : paramName=theParam|paramName2=theParam2|... + virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { } - void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") ); - void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + virtual ~IActionHandler() {} -private: - CAHManager(){} - static CAHManager *_GlobalInstance; + static std::string getParam (const std::string &Params, const std::string &ParamName); -}; + static void getAllParams (const std::string &Params, std::vector< std::pair > &AllParams); + }; -/// Ah name must all be lower case -#define REGISTER_ACTION_HANDLER(handler ,name) \ -class handler##Factory : public handler \ -{ \ -public: \ - handler##Factory () \ - { \ - nlassert(name!=NULL); \ - const char *c= name; \ - while(*c!='\0') \ - { \ - nlassert(islower(*c) || !isalpha(*c)); \ - c++; \ - } \ - CAHManager *pAHFM = CAHManager::getInstance(); \ - pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \ - pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \ - }; \ -}; \ - handler##Factory handler##FactoryInstance ; \ - \ + + /** + interface for action handlers factory + no release in this factory : a handler must be destroyed by the control that created it + */ + class CAHManager + { + public: + typedef std::map< std::string, IActionHandler* > TFactoryMap; + typedef std::map< IActionHandler*, std::string > TNameMap; + + static CAHManager* getInstance() + { + if (_GlobalInstance == NULL) + _GlobalInstance = new CAHManager; + return _GlobalInstance; + } + + /// return pointer to action handler or null if it doesn't exist + IActionHandler *getActionHandler(const std::string &name) const + { + TFactoryMap::const_iterator it = FactoryMap.find(name); + return it != FactoryMap.end() ? it->second : NULL; + } + + /// Return the name of the action handler given its pointer + const std::string &getActionHandlerName(IActionHandler *pAH) const + { + TNameMap::const_iterator it = NameMap.find(pAH); + return it != NameMap.end() ? it->second : EmptyName; + } + + /// map of action handler factories + TFactoryMap FactoryMap; + TNameMap NameMap; + std::string EmptyName; + + /// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed) + IActionHandler *getAH(const std::string &name, std::string ¶ms); + IActionHandler *getAH(const std::string &name, class CStringShared ¶ms); + + /** common method to parse Action Handler from a xml node + * \param ahId eg: "onclick_l" + * \param paramId eg: "params_l". + * \param params returned parameters. + * NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book") + * is taken + * NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed + */ + void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶ms); + void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); + + /// Get the AH name from ptr + const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); } + + void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + + private: + CAHManager(){} + static CAHManager *_GlobalInstance; + + }; + + /// Ah name must all be lower case + #define REGISTER_ACTION_HANDLER(handler ,name) \ + class handler##Factory : public handler \ + { \ + public: \ + handler##Factory () \ + { \ + nlassert(name!=NULL); \ + const char *c= name; \ + while(*c!='\0') \ + { \ + nlassert(islower(*c) || !isalpha(*c)); \ + c++; \ + } \ + CAHManager *pAHFM = CAHManager::getInstance(); \ + pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \ + pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \ + }; \ + }; \ + handler##Factory handler##FactoryInstance ; \ + \ + + +} #endif //NL_ACTION_HANDLER_H diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index 44ad924ec..b22148b88 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -23,141 +23,144 @@ #include "nel/gui/view_base.h" #include "nel/gui/event_descriptor.h" -class CCtrlBase : public CViewBase +namespace NLGUI { -public: - - // Tooltip mode - enum TToolTipParentType + class CCtrlBase : public CViewBase { - TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears - TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears - TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies. - TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window + public: - NumToolTipParentRef + // Tooltip mode + enum TToolTipParentType + { + TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears + TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears + TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies. + TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window + + NumToolTipParentRef + }; + + public: + + /// Constructor + CCtrlBase(const TCtorParam ¶m) : CViewBase(param) + { + _ToolTipInstant= true; + _ToolTipParent= TTCtrl; + // see interface.txt for meaning of auto + _ToolTipParentPosRef= Hotspot_TTAuto; + _ToolTipPosRef= Hotspot_TTAuto; + } + + /// Destructor + virtual ~CCtrlBase(); + + // special parse + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + + /// Handle all events (implemented by derived classes) (return true to signal event handled) + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; } + + /// Debug + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + + /// Get the ContextHelp for this control. Default is to return _ContextHelp + virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} + /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. + virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } + // Get the name of the context help window. Default to "context_help" + virtual std::string getContextHelpWindowName() const; + /// Get the ContextHelp ActionHandler. If "", noop + const std::string &getContextHelpActionHandler() const {return _OnContextHelp;} + /// Get the ContextHelp ActionHandler Params + const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;} + /// true if both are empty + bool emptyContextHelp() const; + // Should return true if the context help should be displayed instantly + bool wantInstantContextHelp() const { return _ToolTipInstant; } + /// Set true if ToolTip should be displayed instantly + void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;} + + /** If ctrl has a non rectangle shape, perform further test to know + * if control should be taken in account for context help + */ + virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; } + + + /// return the type of anchor for the tooltip of this control + TToolTipParentType getToolTipParent() const { return _ToolTipParent;} + const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();} + /// Set the type of anchor for the tooltip of this control + void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; } + void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; } + /// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) + THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;} + THotSpot getToolTipPosRef() const { return _ToolTipPosRef;} + THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;} + THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;} + /// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) + void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;} + void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} + + /// replace the default contextHelp + ucstring getDefaultContextHelp() const {return _ContextHelp;} + void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} + void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} + void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} + + + + // called when this element or a son has been captured + virtual void elementCaptured(CCtrlBase * /* capturedElement */) {} + + virtual bool isCtrl() const { return true; } + + // Made for CtrlResizer to take the precedence over son controls. + virtual uint getDeltaDepth() const { return 0; } + + // true if this ctrl is capturable (true by default, false for tooltip) + virtual bool isCapturable() const {return true;} + + // from CInterfaceElement + virtual void visit(CInterfaceElementVisitor *visitor); + + /** test if virtual desktop change is possible while this element is captured by the mouse + * Useful for resizers + */ + virtual bool canChangeVirtualDesktop() const { return true; } + + // called when keyboard capture has been lost + virtual void onKeyboardCaptureLost() {} + + REFLECT_EXPORT_START(CCtrlBase, CViewBase) + REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); + REFLECT_EXPORT_END + + // special for mouse over : return true and fill the name of the cursor to display + virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; } + + virtual void serial(NLMISC::IStream &f); + protected: + // This is the ContextHelp filled by default in parse() + ucstring _ContextHelp; + CStringShared _OnContextHelp; + CStringShared _OnContextHelpParams; + CStringShared _ToolTipSpecialParent; + TToolTipParentType _ToolTipParent; + bool _ToolTipInstant : 1; + THotSpot _ToolTipParentPosRef : 6; + THotSpot _ToolTipPosRef : 6; + THotSpot _ToolTipParentPosRefAlt : 6; + THotSpot _ToolTipPosRefAlt : 6; + protected: + void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS); }; -public: - - /// Constructor - CCtrlBase(const TCtorParam ¶m) : CViewBase(param) - { - _ToolTipInstant= true; - _ToolTipParent= TTCtrl; - // see interface.txt for meaning of auto - _ToolTipParentPosRef= Hotspot_TTAuto; - _ToolTipPosRef= Hotspot_TTAuto; - } - - /// Destructor - virtual ~CCtrlBase(); - - // special parse - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - - /// Handle all events (implemented by derived classes) (return true to signal event handled) - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; } - - /// Debug - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - - /// Get the ContextHelp for this control. Default is to return _ContextHelp - virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} - /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. - virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } - // Get the name of the context help window. Default to "context_help" - virtual std::string getContextHelpWindowName() const; - /// Get the ContextHelp ActionHandler. If "", noop - const std::string &getContextHelpActionHandler() const {return _OnContextHelp;} - /// Get the ContextHelp ActionHandler Params - const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;} - /// true if both are empty - bool emptyContextHelp() const; - // Should return true if the context help should be displayed instantly - bool wantInstantContextHelp() const { return _ToolTipInstant; } - /// Set true if ToolTip should be displayed instantly - void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;} - - /** If ctrl has a non rectangle shape, perform further test to know - * if control should be taken in account for context help - */ - virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; } - - - /// return the type of anchor for the tooltip of this control - TToolTipParentType getToolTipParent() const { return _ToolTipParent;} - const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();} - /// Set the type of anchor for the tooltip of this control - void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; } - void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; } - /// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) - THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;} - THotSpot getToolTipPosRef() const { return _ToolTipPosRef;} - THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;} - THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;} - /// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) - void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;} - void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} - - /// replace the default contextHelp - ucstring getDefaultContextHelp() const {return _ContextHelp;} - void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} - void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} - void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} - - - - // called when this element or a son has been captured - virtual void elementCaptured(CCtrlBase * /* capturedElement */) {} - - virtual bool isCtrl() const { return true; } - - // Made for CtrlResizer to take the precedence over son controls. - virtual uint getDeltaDepth() const { return 0; } - - // true if this ctrl is capturable (true by default, false for tooltip) - virtual bool isCapturable() const {return true;} - - // from CInterfaceElement - virtual void visit(CInterfaceElementVisitor *visitor); - - /** test if virtual desktop change is possible while this element is captured by the mouse - * Useful for resizers - */ - virtual bool canChangeVirtualDesktop() const { return true; } - - // called when keyboard capture has been lost - virtual void onKeyboardCaptureLost() {} - - REFLECT_EXPORT_START(CCtrlBase, CViewBase) - REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); - REFLECT_EXPORT_END - - // special for mouse over : return true and fill the name of the cursor to display - virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; } - - virtual void serial(NLMISC::IStream &f); -protected: - // This is the ContextHelp filled by default in parse() - ucstring _ContextHelp; - CStringShared _OnContextHelp; - CStringShared _OnContextHelpParams; - CStringShared _ToolTipSpecialParent; - TToolTipParentType _ToolTipParent; - bool _ToolTipInstant : 1; - THotSpot _ToolTipParentPosRef : 6; - THotSpot _ToolTipPosRef : 6; - THotSpot _ToolTipParentPosRefAlt : 6; - THotSpot _ToolTipPosRefAlt : 6; -protected: - void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS); -}; - +} #endif // RZ_VIEW_BASE_H diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h index 256ce345b..de2432137 100644 --- a/code/nel/include/nel/gui/ctrl_draggable.h +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -1,42 +1,64 @@ +// Ryzom - MMORPG Framework +// 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 CTRL_DRAGGABLE_H #define CTRL_DRAGGABLE_H #include "nel/gui/ctrl_base.h" -class CCtrlDraggable : public CCtrlBase +namespace NLGUI { -public: - DECLARE_UI_CLASS( CCtrlDraggable ) - CCtrlDraggable( const TCtorParam ¶m ); - virtual ~CCtrlDraggable(){}; - - static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } - bool isDragged() const{ return dragged; } - void setDragged( bool dragged ){ this->dragged = dragged; } - bool isDraggable() const{ return draggable; } - void setDraggable( bool draggable ){ this->draggable = draggable; } - - void abortDragging() + class CCtrlDraggable : public CCtrlBase { - dragged = false; - _LastDraggedSheet = NULL; - } + public: + DECLARE_UI_CLASS( CCtrlDraggable ) - // Necessary because of reflection, no other purpose - void draw(){} + CCtrlDraggable( const TCtorParam ¶m ); + virtual ~CCtrlDraggable(){}; - REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) - REFLECT_BOOL("dragable", isDraggable, setDraggable); - REFLECT_EXPORT_END + static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } + bool isDragged() const{ return dragged; } + void setDragged( bool dragged ){ this->dragged = dragged; } + bool isDraggable() const{ return draggable; } + void setDraggable( bool draggable ){ this->draggable = draggable; } + + void abortDragging() + { + dragged = false; + _LastDraggedSheet = NULL; + } -protected: - static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; } + // Necessary because of reflection, no other purpose + void draw(){} -private: - static CCtrlDraggable *_LastDraggedSheet; - bool dragged; - bool draggable; -}; + REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) + REFLECT_BOOL("dragable", isDraggable, setDraggable); + REFLECT_EXPORT_END + + protected: + static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; } + + private: + static CCtrlDraggable *_LastDraggedSheet; + bool dragged; + bool draggable; + }; + +} #endif diff --git a/code/nel/include/nel/gui/ctrl_scroll_base.h b/code/nel/include/nel/gui/ctrl_scroll_base.h index 16eee9c59..8e3d6de2f 100644 --- a/code/nel/include/nel/gui/ctrl_scroll_base.h +++ b/code/nel/include/nel/gui/ctrl_scroll_base.h @@ -19,37 +19,42 @@ #include "nel/gui/ctrl_base.h" -class CInterfaceGroup; - -class CCtrlScrollBase : public CCtrlBase +namespace NLGUI { -public: - DECLARE_UI_CLASS( CCtrlScrollBase ) - CCtrlScrollBase( const TCtorParam ¶m ); - virtual ~CCtrlScrollBase(); - - virtual void setTarget( CInterfaceGroup *pIG ); - CInterfaceGroup* getTarget(){ return _Target; } - virtual sint32 moveTrackX( sint32 dx ); - virtual sint32 moveTrackY( sint32 dy ); + class CInterfaceGroup; - /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. - * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) - */ - virtual void moveTargetX( sint32 dx ); - virtual void moveTargetY( sint32 dy ); + class CCtrlScrollBase : public CCtrlBase + { + public: + DECLARE_UI_CLASS( CCtrlScrollBase ) + + CCtrlScrollBase( const TCtorParam ¶m ); + virtual ~CCtrlScrollBase(); + + virtual void setTarget( CInterfaceGroup *pIG ); + CInterfaceGroup* getTarget(){ return _Target; } + virtual sint32 moveTrackX( sint32 dx ); + virtual sint32 moveTrackY( sint32 dy ); + + /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. + * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) + */ + virtual void moveTargetX( sint32 dx ); + virtual void moveTargetY( sint32 dy ); - // Necessary because of reflection, no other purpose - void draw(){} + // Necessary because of reflection, no other purpose + void draw(){} -protected: - CInterfaceGroup *_Target; // If NULL the scroller is a value scroller + protected: + CInterfaceGroup *_Target; // If NULL the scroller is a value scroller -private: + private: -}; + }; + +} #endif diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index b3ed6e501..9122f1027 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -20,75 +20,82 @@ #include "nel/gui/interface_group.h" - -class CGroupContainerBase : public CInterfaceGroup +namespace NLGUI { -public: - DECLARE_UI_CLASS( CGroupContainerBase ) - CGroupContainerBase( const TCtorParam ¶m ); - virtual ~CGroupContainerBase(); + class CGroupContainerBase : public CInterfaceGroup + { + public: + DECLARE_UI_CLASS( CGroupContainerBase ) - virtual void removeAllContainers(); - virtual void setLocked( bool locked ); - bool isLocked() const { return _Locked; } + CGroupContainerBase( const TCtorParam ¶m ); + virtual ~CGroupContainerBase(); - uint8 getContainerAlpha() const { return _ContainerAlpha; } - uint8 getContentAlpha() const { return _ContentAlpha; } - uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; } - uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; } + virtual void removeAllContainers(); + virtual void setLocked( bool locked ); + bool isLocked() const { return _Locked; } - void setContainerAlpha( uint8 alpha ); - void setContentAlpha( uint8 alpha ); - void setRolloverAlphaContent( uint8 alpha ); - void setRolloverAlphaContainer( uint8 alpha ); + uint8 getContainerAlpha() const { return _ContainerAlpha; } + uint8 getContentAlpha() const { return _ContentAlpha; } + uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; } + uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; } - // for export - sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; } - sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; } - sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; } - sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; } + void setContainerAlpha( uint8 alpha ); + void setContentAlpha( uint8 alpha ); + void setRolloverAlphaContent( uint8 alpha ); + void setRolloverAlphaContainer( uint8 alpha ); - // sin32 versions for export - void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); } - void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); } - void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); } - void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); } + // for export + sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; } + sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; } + sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; } + sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; } - void setUseGlobalAlpha( bool use ); - bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; } + // sin32 versions for export + void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); } + void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); } + void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); } + void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); } - std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); } - std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; } + void setUseGlobalAlpha( bool use ); + bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; } - void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); } - void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; } + std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); } + std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; } - REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) - REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha); - REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha); - REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent); - REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer); - REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha); - REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged); - REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); - REFLECT_EXPORT_END + void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); } + void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; } -protected: - void triggerAlphaSettingsChangedAH(); + REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) + REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha); + REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha); + REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent); + REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer); + REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha); + REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged); + REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); + REFLECT_EXPORT_END - uint8 _ContainerAlpha; - uint8 _ContentAlpha; - uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it - uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it - bool _Locked : 1; // Is the container locked (ie override movable, openable ...) - bool _UseGlobalAlpha : 1; + protected: + void triggerAlphaSettingsChangedAH(); - IActionHandler *_AHOnAlphaSettingsChanged; - CStringShared _AHOnAlphaSettingsChangedParams; + uint8 _ContainerAlpha; + uint8 _ContentAlpha; + uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it + uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it + bool _Locked : 1; // Is the container locked (ie override movable, openable ...) + bool _UseGlobalAlpha : 1; -private: + IActionHandler *_AHOnAlphaSettingsChanged; + CStringShared _AHOnAlphaSettingsChangedParams; + + private: + + }; + + + +} -}; #endif diff --git a/code/nel/include/nel/gui/group_editbox_base.h b/code/nel/include/nel/gui/group_editbox_base.h index 3f77fa8ba..fa7b6e236 100644 --- a/code/nel/include/nel/gui/group_editbox_base.h +++ b/code/nel/include/nel/gui/group_editbox_base.h @@ -20,45 +20,50 @@ #include "nel/gui/interface_group.h" -class CGroupEditBoxBase : public CInterfaceGroup +namespace NLGUI { -public: - DECLARE_UI_CLASS( CGroupEditBoxBase ) - CGroupEditBoxBase( const TCtorParam ¶m ); - ~CGroupEditBoxBase(); + class CGroupEditBoxBase : public CInterfaceGroup + { + public: + DECLARE_UI_CLASS( CGroupEditBoxBase ) - // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus - bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; } - void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; } + CGroupEditBoxBase( const TCtorParam ¶m ); + ~CGroupEditBoxBase(); - std::string getAHOnFocus(){ return _AHOnFocus; } - std::string getAHOnFocusParams(){ return _AHOnFocusParams; } + // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus + bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; } + void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; } - // disable any current selection - static void disableSelection(){ _CurrSelection = NULL; } + std::string getAHOnFocus(){ return _AHOnFocus; } + std::string getAHOnFocusParams(){ return _AHOnFocusParams; } - // Get / set current selection - static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; } - static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; } + // disable any current selection + static void disableSelection(){ _CurrSelection = NULL; } - void draw(){} + // Get / set current selection + static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; } + static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; } - REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup ) - REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter ); - REFLECT_EXPORT_END + void draw(){} -protected: - bool _RecoverFocusOnEnter : 1; + REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup ) + REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter ); + REFLECT_EXPORT_END - std::string _AHOnFocus; - std::string _AHOnFocusParams; + protected: + bool _RecoverFocusOnEnter : 1; - static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none + std::string _AHOnFocus; + std::string _AHOnFocusParams; -private: + static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none -}; + private: + + }; + +} #endif diff --git a/code/nel/include/nel/gui/group_frame.h b/code/nel/include/nel/gui/group_frame.h index a8a1bca38..220acb5cd 100644 --- a/code/nel/include/nel/gui/group_frame.h +++ b/code/nel/include/nel/gui/group_frame.h @@ -23,83 +23,88 @@ #include "nel/gui/interface_group.h" -// *************************************************************************** -/** A Group with a background and a frame displayed - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CGroupFrame : public CInterfaceGroup +namespace NLGUI { -public: + - /// Constructor - CGroupFrame(const TCtorParam ¶m); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void draw (); - - void copyOptionFrom(const CGroupFrame &other); - - - void setColorAsString(const std::string & col); - std::string getColorAsString() const; - - REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup) - REFLECT_STRING ("color", getColorAsString, setColorAsString); - REFLECT_EXPORT_END - - - static void resetDisplayTypes() { _DispTypes.clear(); } - -// ****************** -protected: - - bool _DisplayFrame; - - NLMISC::CRGBA _Color; - - uint8 _DispType; - - // Fields Defined in the XML => must not herit them from extends="" - bool _DisplayFrameDefined : 1; - bool _ColorDefined : 1; - bool _DispTypeDefined : 1; - - // Static stuff - enum + // *************************************************************************** + /** A Group with a background and a frame displayed + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CGroupFrame : public CInterfaceGroup { - TextTL= 0, - TextTM, - TextTR, - TextML, - TextMM, - TextMR, - TextBL, - TextBM, - TextBR - }; + public: - struct SDisplayType - { - std::string Name; - sint32 BorderIds[9]; - uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR - sint32 LeftBorder; // enum - sint32 RightBorder; - sint32 TopBorder; - sint32 BottomBorder; + /// Constructor + CGroupFrame(const TCtorParam ¶m); - // ----------------------- - SDisplayType() + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void draw (); + + void copyOptionFrom(const CGroupFrame &other); + + + void setColorAsString(const std::string & col); + std::string getColorAsString() const; + + REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup) + REFLECT_STRING ("color", getColorAsString, setColorAsString); + REFLECT_EXPORT_END + + + static void resetDisplayTypes() { _DispTypes.clear(); } + + // ****************** + protected: + + bool _DisplayFrame; + + NLMISC::CRGBA _Color; + + uint8 _DispType; + + // Fields Defined in the XML => must not herit them from extends="" + bool _DisplayFrameDefined : 1; + bool _ColorDefined : 1; + bool _DispTypeDefined : 1; + + // Static stuff + enum { - for (uint i = 0; i < 9; ++i) - TileBorder[i] = 0; - } - }; - static std::vector _DispTypes; -}; + TextTL= 0, + TextTM, + TextTR, + TextML, + TextMM, + TextMR, + TextBL, + TextBM, + TextBR + }; + struct SDisplayType + { + std::string Name; + sint32 BorderIds[9]; + uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR + sint32 LeftBorder; // enum + sint32 RightBorder; + sint32 TopBorder; + sint32 BottomBorder; + + // ----------------------- + SDisplayType() + { + for (uint i = 0; i < 9; ++i) + TileBorder[i] = 0; + } + }; + static std::vector _DispTypes; + }; + +} #endif // NL_GROUP_FRAME_H diff --git a/code/nel/include/nel/gui/group_modal.h b/code/nel/include/nel/gui/group_modal.h index 9fab37b2a..bf8690cb9 100644 --- a/code/nel/include/nel/gui/group_modal.h +++ b/code/nel/include/nel/gui/group_modal.h @@ -22,48 +22,51 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_frame.h" - -// *************************************************************************** -/** - * A group with special modal options - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CGroupModal : public CGroupFrame +namespace NLGUI { -public: - bool SpawnOnMousePos : 1; - bool ExitClickOut : 1; - bool ExitClickL : 1; - bool ExitClickR : 1; - bool ForceInsideScreen : 1; - bool ExitKeyPushed : 1; - sint32 SpawnMouseX, SpawnMouseY; - std::string Category; - std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured - std::string OnClickOutParams; - std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured - std::string OnPostClickOutParams; -public: + // *************************************************************************** + /** + * A group with special modal options + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CGroupModal : public CGroupFrame + { + public: + bool SpawnOnMousePos : 1; + bool ExitClickOut : 1; + bool ExitClickL : 1; + bool ExitClickR : 1; + bool ForceInsideScreen : 1; + bool ExitKeyPushed : 1; + sint32 SpawnMouseX, SpawnMouseY; + std::string Category; - /// Constructor - CGroupModal(const TCtorParam ¶m); + std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured + std::string OnClickOutParams; + std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured + std::string OnPostClickOutParams; + public: - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void updateCoords (); - void setBaseX(sint32 x) { _MouseDeltaX = x;} - void setBaseY(sint32 y) { _MouseDeltaY = y;} + /// Constructor + CGroupModal(const TCtorParam ¶m); - REFLECT_EXPORT_START(CGroupModal, CGroupFrame) - REFLECT_EXPORT_END + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + void setBaseX(sint32 x) { _MouseDeltaX = x;} + void setBaseY(sint32 y) { _MouseDeltaY = y;} -// ****************** -protected: - sint32 _MouseDeltaX, _MouseDeltaY; -}; + REFLECT_EXPORT_START(CGroupModal, CGroupFrame) + REFLECT_EXPORT_END + // ****************** + protected: + sint32 _MouseDeltaX, _MouseDeltaY; + }; + +} #endif // NL_GROUP_MODAL_H diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index fc876fa61..380e81b5b 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -27,570 +27,578 @@ #include "nel/gui/reflect.h" #include "nel/gui/interface_common.h" +class CGroupList; +class CGroupParagraph; + +namespace NLGUI +{ + + class CInterfaceLink; + class CInterfaceElement; + class CInterfaceGroup; + class CViewBase; + class CCtrlBase; + class IActionHandler; + + /** + * A visitor to walk a tree of interface elements and apply a teartment on them. + * + * For each vsited element, visitElement() is called + * If the element is a control, then visitCtrl() is called, and then visitElement() + * If the element is a view, then visitView() is called, and then visitElement() + * If the element is a group, then visitGoup() is called, and then visitElement() + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2003 + */ + class CInterfaceElementVisitor + { + public: + virtual void visit(CInterfaceElement * /* elem */) {} + virtual void visitGroup(CInterfaceGroup * /* group */) {} + virtual void visitView(CViewBase * /* view */) {} + virtual void visitCtrl(CCtrlBase * /* ctrl */) {} + }; + + + /** + * class describing a localisable interface element, i.e. : an element with coordinates + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable + { + public: + + + enum EStrech + { + none=0, + width=1, + height=2 + }; + + /// Constructor + CInterfaceElement() + { + _Parent = NULL; + + _XReal = _YReal = _WReal = _HReal = 0; + _X = _Y = _W = _H = 0; + //_Snap = 1; + + _PosRef = Hotspot_BL; + _ParentPosRef = Hotspot_BL; + _ParentPos = NULL; + + _SizeRef = 0; + _SizeDivW = 10; + _SizeDivH = 10; + _ParentSize = NULL; + + _Links = NULL; + _Active= true; + // default to 3 pass + _InvalidCoords= 3; + + _ModulateGlobalColor= true; + _RenderLayer= 0; + + _AvoidResizeParent= false; + } + + // dtor + virtual ~CInterfaceElement(); + + /** Cloning + * Cloning is actually performed using a serial / unserial in a memory stream + * NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only + */ + virtual CInterfaceElement *clone(); + + // help to serialize an action handler + static void serialAH(NLMISC::IStream &f, IActionHandler *&ah); + + + /// Parse the element and initalize it + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + /// Debug info on memory + virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); } + + /// helper: display a parse error with the id of the lement + void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL); + + /// Accessors : GET + const std::string& getId() const { return _Id; } + std::string getShortId() const; + std::string getIdByValue() const { return _Id; } + + CInterfaceGroup* getParent() const { return _Parent; } + + CInterfaceElement* getParentPos() const { return _ParentPos; } + + CInterfaceElement* getParentSize() const { return _ParentSize; } + + /// Get the master group of this element (recurs call. + CInterfaceElement* getMasterGroup() const; + + // get a possible group container + CInterfaceGroup* getParentContainer(); + + bool getActive() const { return _Active; } + + sint32 getX() const { return _X; } + + sint32 getY() const { return _Y; } + + sint32 getW() const { return (_Active?_W:0); } + sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); } + + sint32 getH() const { return (_Active?_H:0); } + sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); } + + /** + * Get the max width used by the window. + * + * The view must return the largest width its content can take if it will be resized at maximum. + * Typical use : for a CTextView multiline, it returns the size of the whole string. + * + * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm. + */ + virtual sint32 getMaxUsedW() const { return INT_MAX; }; + + /** + * Get the min width used by the window. + * + * The view must return the smallest width its content can take if it will be resized at minimum. + * Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word. + * + * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm. + */ + virtual sint32 getMinUsedW() const { return 0; }; + + //bool isSnapped() const { return (_Snap>1); } + + //sint32 getSnapping() const { return _Snap; } + + sint32 getXReal() const { return _XReal; } + + sint32 getYReal() const { return _YReal; } + + sint32 getWReal() const { return (_Active?_WReal:0); } + + sint32 getHReal() const { return (_Active?_HReal:0); } + + THotSpot getPosRef () const { return _PosRef; } + + THotSpot getParentPosRef () const { return _ParentPosRef; } + + sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3 + + void setSizeRef(sint32 value) { _SizeRef = value; } + + /// Accessors : SET + void setId (const std::string &newID) { _Id = newID; } + + inline void setName(const std::string &name) { _Name = name; } + inline const std::string& getName() { return _Name; } + + virtual void setIdRecurse(const std::string &newID); + + void setParent (CInterfaceGroup *pIG) { _Parent = pIG; } + + void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; } + + void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; } + + virtual void setActive (bool state); + + void setX (sint32 x) { _X = x; } + void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); } + + void setY (sint32 y) { _Y = y; } + void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); } + + void setW (sint32 w); + void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); } + + void setH (sint32 h); + void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); } + + void setPosRef (THotSpot hs) { _PosRef = hs; } + + void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; } + + // Get the coordinate of a corner on screen + void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot); + + /** Test if the given coordinates are inside this element + */ + bool isIn(sint x, sint y) const; + + /** Test if the given box intersect the element + */ + bool isIn(sint x, sint y, uint width, uint height) const; + + /** Test if another interface element intersect this one + */ + bool isIn(const CInterfaceElement &other) const; + + /** + * get the window containing the element + * \return NULL if the element is not on the window, otherwise returns a pointer to the window + */ + CInterfaceGroup* getRootWindow(); + + /** get the element Depth, ie the number of parent he has (0 if _Parent==NULL) + * \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual) + */ + uint getParentDepth() const; + + /** + * true if the element and all its parents are active (recurs up to the root window) + */ + bool isActiveThroughParents() const; + + /** + * move the element (add dx and dy to its coords) + * \param dx : value added to _X + * \param dy : value added to _Y + */ + virtual void move (sint32 dx, sint32 dy); + + //void resizeBR (sint32 sizex, sint32 sizey); + //void stopResizeBR(); + //void startResizeBR(); + + // Some tools + + void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val, + const std::string &defVal); + void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val, + const std::string &defVal); + void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val, + const std::string &defVal); + void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val, + const std::string &defVal); + + // Parse tools + static THotSpot convertHotSpot (const char *ptr); // + static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef); + static NLMISC::CRGBA convertColor (const char *ptr); + static bool convertBool (const char *ptr); + static NLMISC::CVector convertVector (const char *ptr); + /** Convert a value that is in the form like width="50" or width="10%" + * if the value is absolute like '50' then 'pixels' is filled, else + * the ratio is remapped to the [0, 1] range and is copied in 'ratio' + */ + static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio); + + // add an interface link to that element (kept in a smart ptr) + void addLink(CInterfaceLink *link); + + // remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr) + void removeLink(CInterfaceLink *link); + + /** Update all links for this instance and its sons. + * Derivers should override this to update their sons. + */ + virtual void updateAllLinks(); + + + /** This allow to force opening an element. By default it just activate the element. + * It allow to have different behaviour on more complex containers + */ + virtual void forceOpen() { setActive(true); } + + virtual void enableBlink(uint /* numBlinks */ = 0) {} + virtual void disableBlink() {} + virtual bool getBlink() const { return false; } + + // Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true + void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;} + bool getModulateGlobalColor() const {return _ModulateGlobalColor;} + + + void dummySet(sint32 value); + void dummySet(const std::string &value); + + // lua methods + int luaUpdateCoords(CLuaState &ls); + int luaInvalidateCoords(CLuaState &ls); + int luaInvalidateContent(CLuaState &ls); + int luaCenter(CLuaState &ls); + int luaSetPosRef(CLuaState &ls); + int luaSetParentPos(CLuaState &ls); + + // set sizeref as a string, like "wh", "wh5" .... + void setSizeRef(const std::string &sizeref); + std::string getSizeRefAsString() const; + + // export some properties + REFLECT_EXPORT_START(CInterfaceElement, CReflectable) + REFLECT_BOOL ("active", getActive, setActive); + REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor); + REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords); + REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords); + REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords); + REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords); + REFLECT_SINT32 ("x_real", getXReal, dummySet); + REFLECT_SINT32 ("y_real", getYReal, dummySet); + REFLECT_SINT32 ("w_real", getWReal, dummySet); + REFLECT_SINT32 ("h_real", getHReal, dummySet); + REFLECT_STRING ("id", getIdByValue, dummySet); + REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef); + REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords); + REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords); + REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent); + REFLECT_LUA_METHOD("center", luaCenter); + REFLECT_LUA_METHOD("setPosRef", luaSetPosRef); + REFLECT_LUA_METHOD("setParentPos", luaSetParentPos); + REFLECT_EXPORT_END + + + /* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated + * Default 3 is needed for: + * 1: update _W/_H and _WReal/_HReal according to Sons + * 2: update XReal/YReal (eg: according to Scroll offset) + */ + void invalidateCoords(uint8 numPass= 2); + uint8 getInvalidCoords() const {return _InvalidCoords;} + + /* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable). + * It invalidates the content of the parent too. + */ + void invalidateContent(); + + /* This call back is called when the content or the content of a child is been invalidated. + */ + virtual void onInvalidateContent() {} + + // called by interfaceManager for master window only + void resetInvalidCoords(); + + /// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord) + virtual void updateCoords(); + /// Called each frame before draw to possibly invalidateCoords(). + virtual void checkCoords(); + + /// Test if this element is son of the given element + bool isSonOf(const CInterfaceElement *other) const; + + /// Called after first frame initialised + virtual void launch () {} + + void setRenderLayer(sint8 rl) {_RenderLayer= rl;} + sint8 getRenderLayer() const { return _RenderLayer; } + + void copyOptionFrom(const CInterfaceElement &other); + + // center the element in middle of screen + void center(); + + // for debug only: draw wired quad to see where groups and hotspots are + enum TRenderWired + { + RenderView, + RenderCtrl, + RenderGroup + }; + // if uiFilter is not empty, draw a quad only if the element id match + virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter); + + void drawHotSpot(THotSpot hs, NLMISC::CRGBA col); + + // Returns 'true' if that element can be downcasted to a view + virtual bool isView() const { return false; } + + // Returns 'true' if that element can be downcasted to a ctrl + virtual bool isCtrl() const { return false; } + + // Returns 'true' if that element can be downcasted to an interface group + virtual bool isGroup() const { return false; } + + + /** This is called before the config loading begins. This is the place to restore default state for config info. + */ + virtual void onLoadConfig() {} + /** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig + * is called. + */ + virtual bool wantSerialConfig() const { return false; } + // Serial config info about that element. This is called only if wantSerialConfig() returns true + virtual void serialConfig(NLMISC::IStream &f); + + // visit the node of the ui tree + virtual void visit(CInterfaceElementVisitor *visitor); + + /** When user is quitting the interface, this is called. Then the interface config is saved + * This is where the element get the opportunity to do some cleanup. + */ + virtual void onQuit() {} + + /// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add. + virtual void onAddToGroup() {} + + /** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so + * this function is called on each children elements to move the XReal/Yreal only (with a delta) + */ + virtual void onFrameUpdateWindowPos(sint dx, sint dy); + + /// if true, InterfaceGroup child resize won't take this element into account + bool avoidResizeParent() const {return _AvoidResizeParent;} + void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;} + + virtual std::string getClassName() + { + nlassert(0); // forgot to implement serial & to register the class ? + return ""; + } + + protected: + + ///the parent + CInterfaceGroup* _Parent; + + ///the id of the element + std::string _Id; + + std::string _Name; + + ///is the element active? + bool _Active; + + // if 0, don't need updateCoords(), else tell the number of pass needed + uint8 _InvalidCoords; + + // Real display coords + sint32 _XReal, _YReal, _WReal, _HReal; + + // Relative coords + sint32 _X; + sint32 _Y; + sint32 _W; + sint32 _H; + + //sint32 _Snap; + + // position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element + // will be placed on the center (middle middle) of the parent window + THotSpot _PosRef; + THotSpot _ParentPosRef; + NLMISC::CRefPtr _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it + + sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3 + sint32 _SizeDivW, _SizeDivH; + NLMISC::CRefPtr _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it + + // Friend Class + friend class ::CGroupList; + friend class ::CGroupParagraph; + + // True if must modulate the global color with the view + bool _ModulateGlobalColor; + // Index of layer to render it. + sint8 _RenderLayer; + + // Used for CInterfaceGroup ChildResize feature + bool _AvoidResizeParent; + + + virtual void serial(NLMISC::IStream &f); + + void parseSizeRef(const char *sizeRef); + void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH); + + private: + //void snapSize(); + + typedef NLMISC::CSmartPtr TLinkSmartPtr; + typedef std::vector TLinkVect; + TLinkVect *_Links; // links, or NULL if no link + }; + + extern NLMISC::CStringMapper *_UIStringMapper; + /** + * class to compress string usage in the interface + * \author Matthieu 'Trap' Besson + * \author Nevrax France + * \date October 2003 + */ + class CStringShared + { + + public: + CStringShared() + { + _Id = NLMISC::CStringMapper::emptyId(); + } + + const CStringShared& operator=(const std::string &str) + { + _Id = _UIStringMapper->localMap(str); + return *this; + } + + const CStringShared& operator=(const CStringShared &str) + { + _Id = str._Id; + return *this; + } + + const std::string &toString() const + { + return _UIStringMapper->localUnmap(_Id); + } + + operator const std::string &() const + { + return _UIStringMapper->localUnmap(_Id); + } + + bool empty() const + { + return _Id == NLMISC::CStringMapper::emptyId(); + } + + static CStringShared emptyString() + { + return CStringShared(); + } + + NLMISC::TStringId getStringId() const { return _Id; } + + void serial(NLMISC::IStream &f) + { + std::string str; + if (f.isReading()) + { + f.serial(str); + *this = str; + } + else + { + str = this->toString(); + f.serial(str); + } + } + + private: + + NLMISC::TStringId _Id; + }; + + inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); } + inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); } + + +} + using namespace NLGUI; -class CInterfaceLink; -class CInterfaceElement; -class CInterfaceGroup; -class CViewBase; -class CCtrlBase; -class IActionHandler; - -/** - * A visitor to walk a tree of interface elements and apply a teartment on them. - * - * For each vsited element, visitElement() is called - * If the element is a control, then visitCtrl() is called, and then visitElement() - * If the element is a view, then visitView() is called, and then visitElement() - * If the element is a group, then visitGoup() is called, and then visitElement() - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2003 - */ -class CInterfaceElementVisitor -{ -public: - virtual void visit(CInterfaceElement * /* elem */) {} - virtual void visitGroup(CInterfaceGroup * /* group */) {} - virtual void visitView(CViewBase * /* view */) {} - virtual void visitCtrl(CCtrlBase * /* ctrl */) {} -}; - - -/** - * class describing a localisable interface element, i.e. : an element with coordinates - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 - */ -class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable -{ -public: - - - enum EStrech - { - none=0, - width=1, - height=2 - }; - - /// Constructor - CInterfaceElement() - { - _Parent = NULL; - - _XReal = _YReal = _WReal = _HReal = 0; - _X = _Y = _W = _H = 0; - //_Snap = 1; - - _PosRef = Hotspot_BL; - _ParentPosRef = Hotspot_BL; - _ParentPos = NULL; - - _SizeRef = 0; - _SizeDivW = 10; - _SizeDivH = 10; - _ParentSize = NULL; - - _Links = NULL; - _Active= true; - // default to 3 pass - _InvalidCoords= 3; - - _ModulateGlobalColor= true; - _RenderLayer= 0; - - _AvoidResizeParent= false; - } - - // dtor - virtual ~CInterfaceElement(); - - /** Cloning - * Cloning is actually performed using a serial / unserial in a memory stream - * NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only - */ - virtual CInterfaceElement *clone(); - - // help to serialize an action handler - static void serialAH(NLMISC::IStream &f, IActionHandler *&ah); - - - /// Parse the element and initalize it - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - /// Debug info on memory - virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); } - - /// helper: display a parse error with the id of the lement - void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL); - - /// Accessors : GET - const std::string& getId() const { return _Id; } - std::string getShortId() const; - std::string getIdByValue() const { return _Id; } - - CInterfaceGroup* getParent() const { return _Parent; } - - CInterfaceElement* getParentPos() const { return _ParentPos; } - - CInterfaceElement* getParentSize() const { return _ParentSize; } - - /// Get the master group of this element (recurs call. - CInterfaceElement* getMasterGroup() const; - - // get a possible group container - CInterfaceGroup* getParentContainer(); - - bool getActive() const { return _Active; } - - sint32 getX() const { return _X; } - - sint32 getY() const { return _Y; } - - sint32 getW() const { return (_Active?_W:0); } - sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); } - - sint32 getH() const { return (_Active?_H:0); } - sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); } - - /** - * Get the max width used by the window. - * - * The view must return the largest width its content can take if it will be resized at maximum. - * Typical use : for a CTextView multiline, it returns the size of the whole string. - * - * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm. - */ - virtual sint32 getMaxUsedW() const { return INT_MAX; }; - - /** - * Get the min width used by the window. - * - * The view must return the smallest width its content can take if it will be resized at minimum. - * Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word. - * - * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm. - */ - virtual sint32 getMinUsedW() const { return 0; }; - - //bool isSnapped() const { return (_Snap>1); } - - //sint32 getSnapping() const { return _Snap; } - - sint32 getXReal() const { return _XReal; } - - sint32 getYReal() const { return _YReal; } - - sint32 getWReal() const { return (_Active?_WReal:0); } - - sint32 getHReal() const { return (_Active?_HReal:0); } - - THotSpot getPosRef () const { return _PosRef; } - - THotSpot getParentPosRef () const { return _ParentPosRef; } - - sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3 - - void setSizeRef(sint32 value) { _SizeRef = value; } - - /// Accessors : SET - void setId (const std::string &newID) { _Id = newID; } - - inline void setName(const std::string &name) { _Name = name; } - inline const std::string& getName() { return _Name; } - - virtual void setIdRecurse(const std::string &newID); - - void setParent (CInterfaceGroup *pIG) { _Parent = pIG; } - - void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; } - - void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; } - - virtual void setActive (bool state); - - void setX (sint32 x) { _X = x; } - void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); } - - void setY (sint32 y) { _Y = y; } - void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); } - - void setW (sint32 w); - void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); } - - void setH (sint32 h); - void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); } - - void setPosRef (THotSpot hs) { _PosRef = hs; } - - void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; } - - // Get the coordinate of a corner on screen - void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot); - - /** Test if the given coordinates are inside this element - */ - bool isIn(sint x, sint y) const; - - /** Test if the given box intersect the element - */ - bool isIn(sint x, sint y, uint width, uint height) const; - - /** Test if another interface element intersect this one - */ - bool isIn(const CInterfaceElement &other) const; - - /** - * get the window containing the element - * \return NULL if the element is not on the window, otherwise returns a pointer to the window - */ - CInterfaceGroup* getRootWindow(); - - /** get the element Depth, ie the number of parent he has (0 if _Parent==NULL) - * \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual) - */ - uint getParentDepth() const; - - /** - * true if the element and all its parents are active (recurs up to the root window) - */ - bool isActiveThroughParents() const; - - /** - * move the element (add dx and dy to its coords) - * \param dx : value added to _X - * \param dy : value added to _Y - */ - virtual void move (sint32 dx, sint32 dy); - - //void resizeBR (sint32 sizex, sint32 sizey); - //void stopResizeBR(); - //void startResizeBR(); - - // Some tools - - void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val, - const std::string &defVal); - void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val, - const std::string &defVal); - void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val, - const std::string &defVal); - void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val, - const std::string &defVal); - - // Parse tools - static THotSpot convertHotSpot (const char *ptr); // - static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef); - static NLMISC::CRGBA convertColor (const char *ptr); - static bool convertBool (const char *ptr); - static NLMISC::CVector convertVector (const char *ptr); - /** Convert a value that is in the form like width="50" or width="10%" - * if the value is absolute like '50' then 'pixels' is filled, else - * the ratio is remapped to the [0, 1] range and is copied in 'ratio' - */ - static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio); - - // add an interface link to that element (kept in a smart ptr) - void addLink(CInterfaceLink *link); - - // remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr) - void removeLink(CInterfaceLink *link); - - /** Update all links for this instance and its sons. - * Derivers should override this to update their sons. - */ - virtual void updateAllLinks(); - - - /** This allow to force opening an element. By default it just activate the element. - * It allow to have different behaviour on more complex containers - */ - virtual void forceOpen() { setActive(true); } - - virtual void enableBlink(uint /* numBlinks */ = 0) {} - virtual void disableBlink() {} - virtual bool getBlink() const { return false; } - - // Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true - void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;} - bool getModulateGlobalColor() const {return _ModulateGlobalColor;} - - - void dummySet(sint32 value); - void dummySet(const std::string &value); - - // lua methods - int luaUpdateCoords(CLuaState &ls); - int luaInvalidateCoords(CLuaState &ls); - int luaInvalidateContent(CLuaState &ls); - int luaCenter(CLuaState &ls); - int luaSetPosRef(CLuaState &ls); - int luaSetParentPos(CLuaState &ls); - - // set sizeref as a string, like "wh", "wh5" .... - void setSizeRef(const std::string &sizeref); - std::string getSizeRefAsString() const; - - // export some properties - REFLECT_EXPORT_START(CInterfaceElement, CReflectable) - REFLECT_BOOL ("active", getActive, setActive); - REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor); - REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords); - REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords); - REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords); - REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords); - REFLECT_SINT32 ("x_real", getXReal, dummySet); - REFLECT_SINT32 ("y_real", getYReal, dummySet); - REFLECT_SINT32 ("w_real", getWReal, dummySet); - REFLECT_SINT32 ("h_real", getHReal, dummySet); - REFLECT_STRING ("id", getIdByValue, dummySet); - REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef); - REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords); - REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords); - REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent); - REFLECT_LUA_METHOD("center", luaCenter); - REFLECT_LUA_METHOD("setPosRef", luaSetPosRef); - REFLECT_LUA_METHOD("setParentPos", luaSetParentPos); - REFLECT_EXPORT_END - - - /* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated - * Default 3 is needed for: - * 1: update _W/_H and _WReal/_HReal according to Sons - * 2: update XReal/YReal (eg: according to Scroll offset) - */ - void invalidateCoords(uint8 numPass= 2); - uint8 getInvalidCoords() const {return _InvalidCoords;} - - /* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable). - * It invalidates the content of the parent too. - */ - void invalidateContent(); - - /* This call back is called when the content or the content of a child is been invalidated. - */ - virtual void onInvalidateContent() {} - - // called by interfaceManager for master window only - void resetInvalidCoords(); - - /// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord) - virtual void updateCoords(); - /// Called each frame before draw to possibly invalidateCoords(). - virtual void checkCoords(); - - /// Test if this element is son of the given element - bool isSonOf(const CInterfaceElement *other) const; - - /// Called after first frame initialised - virtual void launch () {} - - void setRenderLayer(sint8 rl) {_RenderLayer= rl;} - sint8 getRenderLayer() const { return _RenderLayer; } - - void copyOptionFrom(const CInterfaceElement &other); - - // center the element in middle of screen - void center(); - - // for debug only: draw wired quad to see where groups and hotspots are - enum TRenderWired - { - RenderView, - RenderCtrl, - RenderGroup - }; - // if uiFilter is not empty, draw a quad only if the element id match - virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter); - - void drawHotSpot(THotSpot hs, NLMISC::CRGBA col); - - // Returns 'true' if that element can be downcasted to a view - virtual bool isView() const { return false; } - - // Returns 'true' if that element can be downcasted to a ctrl - virtual bool isCtrl() const { return false; } - - // Returns 'true' if that element can be downcasted to an interface group - virtual bool isGroup() const { return false; } - - - /** This is called before the config loading begins. This is the place to restore default state for config info. - */ - virtual void onLoadConfig() {} - /** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig - * is called. - */ - virtual bool wantSerialConfig() const { return false; } - // Serial config info about that element. This is called only if wantSerialConfig() returns true - virtual void serialConfig(NLMISC::IStream &f); - - // visit the node of the ui tree - virtual void visit(CInterfaceElementVisitor *visitor); - - /** When user is quitting the interface, this is called. Then the interface config is saved - * This is where the element get the opportunity to do some cleanup. - */ - virtual void onQuit() {} - - /// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add. - virtual void onAddToGroup() {} - - /** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so - * this function is called on each children elements to move the XReal/Yreal only (with a delta) - */ - virtual void onFrameUpdateWindowPos(sint dx, sint dy); - - /// if true, InterfaceGroup child resize won't take this element into account - bool avoidResizeParent() const {return _AvoidResizeParent;} - void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;} - - virtual std::string getClassName() - { - nlassert(0); // forgot to implement serial & to register the class ? - return ""; - } - -protected: - - ///the parent - CInterfaceGroup* _Parent; - - ///the id of the element - std::string _Id; - - std::string _Name; - - ///is the element active? - bool _Active; - - // if 0, don't need updateCoords(), else tell the number of pass needed - uint8 _InvalidCoords; - - // Real display coords - sint32 _XReal, _YReal, _WReal, _HReal; - - // Relative coords - sint32 _X; - sint32 _Y; - sint32 _W; - sint32 _H; - - //sint32 _Snap; - - // position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element - // will be placed on the center (middle middle) of the parent window - THotSpot _PosRef; - THotSpot _ParentPosRef; - NLMISC::CRefPtr _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it - - sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3 - sint32 _SizeDivW, _SizeDivH; - NLMISC::CRefPtr _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it - - // Friend Class - friend class CGroupList; - friend class CGroupParagraph; - - // True if must modulate the global color with the view - bool _ModulateGlobalColor; - // Index of layer to render it. - sint8 _RenderLayer; - - // Used for CInterfaceGroup ChildResize feature - bool _AvoidResizeParent; - - - virtual void serial(NLMISC::IStream &f); - - void parseSizeRef(const char *sizeRef); - void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH); - -private: - //void snapSize(); - - typedef NLMISC::CSmartPtr TLinkSmartPtr; - typedef std::vector TLinkVect; - TLinkVect *_Links; // links, or NULL if no link -}; - -extern NLMISC::CStringMapper *_UIStringMapper; -/** - * class to compress string usage in the interface - * \author Matthieu 'Trap' Besson - * \author Nevrax France - * \date October 2003 - */ -class CStringShared -{ - -public: - CStringShared() - { - _Id = NLMISC::CStringMapper::emptyId(); - } - - const CStringShared& operator=(const std::string &str) - { - _Id = _UIStringMapper->localMap(str); - return *this; - } - - const CStringShared& operator=(const CStringShared &str) - { - _Id = str._Id; - return *this; - } - - const std::string &toString() const - { - return _UIStringMapper->localUnmap(_Id); - } - - operator const std::string &() const - { - return _UIStringMapper->localUnmap(_Id); - } - - bool empty() const - { - return _Id == NLMISC::CStringMapper::emptyId(); - } - - static CStringShared emptyString() - { - return CStringShared(); - } - - NLMISC::TStringId getStringId() const { return _Id; } - - void serial(NLMISC::IStream &f) - { - std::string str; - if (f.isReading()) - { - f.serial(str); - *this = str; - } - else - { - str = this->toString(); - f.serial(str); - } - } - -private: - - NLMISC::TStringId _Id; -}; - -inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); } -inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); } - - #endif // NL_INTERFACE_ELEMENT_H /* End of interface_element.h */ diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index 09f248f00..451e38ff3 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -22,382 +22,386 @@ #include "nel/gui/ctrl_base.h" #include "nel/gui/action_handler.h" -// ---------------------------------------------------------------------------- -class CInterfaceGroup : public CCtrlBase +namespace NLGUI { -public: - DECLARE_UI_CLASS(CInterfaceGroup) - /// Constructor - CInterfaceGroup(const TCtorParam ¶m); + class CInterfaceGroup : public CCtrlBase + { + public: + DECLARE_UI_CLASS(CInterfaceGroup) - /// Destructor - virtual ~CInterfaceGroup(); + /// Constructor + CInterfaceGroup(const TCtorParam ¶m); - virtual void setIdRecurse(const std::string &id); + /// Destructor + virtual ~CInterfaceGroup(); - /// Coming from CInterfaceElement - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void setIdRecurse(const std::string &id); - virtual uint32 getMemory (); - - virtual CInterfaceElement* getElement (const std::string &id); - CInterfaceElement* findFromShortId(const std::string &id); + /// Coming from CInterfaceElement + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - /// Dynamic creation - virtual void addView (CViewBase *child , sint eltOrder = -1); - virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1); - virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1); - - CViewBase* getView (const std::string &id); - CCtrlBase* getCtrl (const std::string &id); - CInterfaceGroup* getGroup(const std::string &id) const; - - // Delete know type by ptr (return true if found and removed) - virtual bool delView (CViewBase *child, bool dontDelete = false); - virtual bool delCtrl (CCtrlBase *child, bool dontDelete = false); - virtual bool delGroup (CInterfaceGroup * child, bool dontDelete = false); - - // Delete know type by name (return true if found and removed) - virtual bool delView (const std::string &id, bool dontDelete = false); - virtual bool delCtrl (const std::string &id, bool dontDelete = false); - virtual bool delGroup (const std::string &id, bool dontDelete = false); - - // Delete unknow type by name or ptr. NB: additionaly, if it's a group, unmakeWindow() is called as necessary - bool delElement (const std::string &id, bool noWarning=false); - bool delElement (CInterfaceElement *pIE, bool noWarning=false); + virtual uint32 getMemory (); - uint getNumGroup() const { return (uint)_ChildrenGroups.size(); } - CInterfaceGroup *getGroup(uint index) const; - - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - - /// Coming from CCtrlBase - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - void executeControl (const std::string &sControlName); - - const std::vector & getGroups () { return _ChildrenGroups; } - const std::vector & getControls() { return _Controls; } - const std::vector & getViews() { return _Views; } - - // test is a group is a direct child of this interface group - bool isChildGroup(const CInterfaceGroup *group) const; - - virtual bool isWindowUnder (sint32 x, sint32 y); // Virtual for menu that is not square - CInterfaceGroup *getGroupUnder (sint32 x, sint32 y); - virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group - virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); - virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vIGL); - - void absoluteToRelative (sint32 &x, sint32 &y); - - /// Coming from CViewBase - virtual void draw (); - // Draw with no clip (if clip is done by parent) - virtual void drawNoClip(); - - /// Tool function to draw a single Element that should exist in the group (clipped by the group) - void drawElement (CViewBase *el); - - - /** - * update the elements coords - */ - virtual void checkCoords(); - virtual void updateCoords(); - - /// remove all views - virtual void clearViews(); - - /// remove all controls - virtual void clearControls(); - - /// remove all groups - virtual void clearGroups(); - - void setParentSizeMax(CInterfaceElement *pIE) { _ParentSizeMax = pIE; } - void setMaxW (sint32 maxw) { _MaxW = maxw; } - void setMaxH (sint32 maxh) { _MaxH = maxh; } - void setOfsX (sint32 x) { _OffsetX = x; } - void setOfsY (sint32 y) { _OffsetY = y; } - bool moveSBTrackY (CInterfaceGroup *target, sint32 dy); - bool moveSBTargetY (CInterfaceGroup *target, sint32 dy); - void setResizeFromChildW(bool resize) { _ResizeFromChildW = resize; } - void setResizeFromChildH(bool resize) { _ResizeFromChildH = resize; } - - // Valid only for windows InterfaceGroup. - // escapable - void setEscapable(bool b) { _Escapable= b; } - bool getEscapable() const { return _Escapable; } - void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); } - const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); } - void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; } - const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; } - // enterable - void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); } - const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); } - void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; } - const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; } - uint8 getPriority() const { return _Priority; } - void setPriority(uint8 nprio); - - - sint32 getMaxW () const { return _MaxW; } - sint32 getMaxH () const { return _MaxH; } - sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; } - sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; } - sint32 getOfsX () const { return _OffsetX; } - sint32 getOfsY () const { return _OffsetY; } - bool getResizeFromChildW() const { return _ResizeFromChildW; } - bool getResizeFromChildH() const { return _ResizeFromChildH; } - sint32 getResizeFromChildWMargin() const { return _ResizeFromChildWMargin; } - sint32 getResizeFromChildHMargin() const { return _ResizeFromChildHMargin; } - void setResizeFromChildWMargin(sint32 margin) { _ResizeFromChildWMargin = margin; } - void setResizeFromChildHMargin(sint32 margin) { _ResizeFromChildHMargin = margin; } - bool getOverlappable() const { return _Overlappable; } - - virtual void setActive (bool state); - - // eval dimension of children bbox - void evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const; - - virtual void launch (); - - - // right & left clicks handler - void setLeftClickHandler(const std::string &handler); - void setRightClickHandler(const std::string &handler); - void setLeftClickHandlerParams(const std::string ¶ms) { _AHOnLeftClickParams = params; } - void setRightClickHandlerParams(const std::string ¶ms) { _AHOnRightClickParams = params; } - void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); } - void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; } - void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); } - void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; } - - const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } - const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; } - const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); } - const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; } - const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); } - const std::string &getOnActiveParams() const { return _AHOnActiveParams; } - const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); } - const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; } - - // find a sub view/ctrl/group in this group from its id - int luaFind(CLuaState &ls); - int luaGetEnclosingContainer(CLuaState &ls); - int luaDeleteLUAEnvTable(CLuaState &ls); - int luaAddGroup(CLuaState &ls); - int luaDelGroup(CLuaState &ls); - int luaGetNumGroups(CLuaState &ls); - int luaGetGroup(CLuaState &ls); - - void setMaxSizeRef(const std::string &maxSizeRef); - std::string getMaxSizeRefAsString() const; - - - REFLECT_EXPORT_START(CInterfaceGroup, CCtrlBase) - REFLECT_LUA_METHOD("find", luaFind); - REFLECT_LUA_METHOD("deleteLUAEnvTable", luaDeleteLUAEnvTable); - REFLECT_LUA_METHOD("getEnclosingContainer", luaGetEnclosingContainer); - REFLECT_LUA_METHOD("addGroup", luaAddGroup); - REFLECT_LUA_METHOD("delGroup", luaDelGroup); - REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups); - REFLECT_LUA_METHOD("getGroup", luaGetGroup); - REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler); - REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler); - REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams); - REFLECT_STRING ("right_click_params", getRightClickHandlerParams, setRightClickHandlerParams); - REFLECT_STRING ("on_active", getOnActiveHandler, setOnActiveHandler); - REFLECT_STRING ("on_active_params", getOnActiveParams, setOnActiveParams); - REFLECT_STRING ("on_deactive", getOnDeactiveHandler, setOnDeactiveHandler); - REFLECT_STRING ("on_deactive_params", getOnDeactiveParams, setOnDeactiveParams); - REFLECT_STRING ("on_enter", getAHOnEnter, setAHOnEnter); - REFLECT_STRING ("on_enter_params", getAHOnEnterParams, setAHOnEnterParams); - REFLECT_STRING ("on_escape", getAHOnEscape, setAHOnEscape); - REFLECT_STRING ("on_escape_params", getAHOnEscapeParams, setAHOnEscapeParams); - REFLECT_SINT32 ("ofsx", getOfsX, setOfsX); - REFLECT_SINT32 ("ofsy", getOfsY, setOfsY); - REFLECT_BOOL("child_resize_w", getResizeFromChildW, setResizeFromChildW); - REFLECT_SINT32("child_resize_wmargin", getResizeFromChildWMargin, setResizeFromChildWMargin); - REFLECT_BOOL("child_resize_h", getResizeFromChildH, setResizeFromChildH); - REFLECT_SINT32("child_resize_hmargin", getResizeFromChildHMargin, setResizeFromChildHMargin); - REFLECT_SINT32 ("ofsy", getOfsY, setOfsY); - REFLECT_STRING("max_sizeref", getMaxSizeRefAsString, setMaxSizeRef); - REFLECT_SINT32 ("max_w", getMaxW, setMaxW); - REFLECT_SINT32 ("max_h", getMaxH, setMaxH); - REFLECT_SINT32 ("max_w_real", getMaxWReal, dummySet); - REFLECT_SINT32 ("max_h_real", getMaxHReal, dummySet); - REFLECT_EXPORT_END - - - - // From CCtrlBase - virtual void updateAllLinks(); - - /// return true for some containers. false by default - virtual bool isMovable() const {return false;} - - virtual sint32 getAlpha() const; - virtual void setAlpha (sint32 a); - - /// Eval current clip coords. This is not incremental as with makeNewClip, and thus more slow. This also doesn't change the current clip window. - void getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const; - - // quick way to know if the group is a CGroupContainer - bool isGroupContainer() const { return _IsGroupContainer; } - bool isGroupScrollText() const{ return _IsGroupScrollText; } - bool isGroupInScene() const{ return _IsGroupInScene; } - - CInterfaceGroup* getEnclosingContainer(); - - sint getInsertionOrder(CViewBase *vb) const; - - // for debug only - void dumpGroups(); - void dumpEltsOrder(); - - virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter); - - virtual bool isGroup() const { return true; } - - // clear all edit box in the ui - virtual void clearAllEditBox(); - // restore all backuped positions for containers - virtual void restoreAllContainersBackupPosition(); - - virtual void dumpSize(uint depth = 0) const; - - // From CInterfaceElement - virtual void visit(CInterfaceElementVisitor *visitor); - - /// Visits only this group's sub-groups and then the group itself - virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor ); - - // Check cursor - void setUseCursor(bool use); - bool getUseCursor() const { return _UseCursor; } - - - // From CInterfaceElement - virtual void onFrameUpdateWindowPos(sint dx, sint dy); - // true for CGroupInScene for instance - bool isNeedFrameUpdatePos() const {return _NeedFrameUpdatePos;} - - - /// \name LUA specific - // @{ - // Create a LUA Environement if don't exist, then push it on the LUA stack - void pushLUAEnvTable(); - // Free the LUA Env Table - void deleteLUAEnvTable(bool recurse = false); - // Set the LUA script to execute at checkCoords time (empty to reset) - void setLuaScriptOnDraw(const std::string &script); - // - void executeLuaScriptOnDraw(); - // Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key - void addLuaScriptOnDBChange(const std::string &dbList, const std::string &script); - // Remove the LUA script to execute when a list of DB change - void removeLuaScriptOnDBChange(const std::string &dbList); - // @} - - virtual CInterfaceElement *clone(); - virtual void serial(NLMISC::IStream &f); - - // Return the current Depth, with no ZBias applied. - float getDepthForZSort() const { return _DepthForZSort; } - -protected: - - void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH); - void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH); - - // Compute clip contribution for current window, and a previous clipping rectangle. This doesn't change the clip window in the driver. - void computeCurrentClipContribution(sint32 prevX, sint32 prevY, sint32 prevW, sint32 prevH, - sint32 &newX, sint32 &newY, sint32 &newW, sint32 &newH) const; - - void delEltOrder (CViewBase *pElt); - - // update coords one time - void doUpdateCoords(); - - // notify children controls & groups that 'active' has been called on one of their parent - void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc); + virtual CInterfaceElement* getElement (const std::string &id); + CInterfaceElement* findFromShortId(const std::string &id); -protected: + /// Dynamic creation + virtual void addView (CViewBase *child , sint eltOrder = -1); + virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1); + virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1); - /// children interface elements - std::vector _ChildrenGroups; - std::vector _Controls; - std::vector _Views; + CViewBase* getView (const std::string &id); + CCtrlBase* getCtrl (const std::string &id); + CInterfaceGroup* getGroup(const std::string &id) const; + + // Delete know type by ptr (return true if found and removed) + virtual bool delView (CViewBase *child, bool dontDelete = false); + virtual bool delCtrl (CCtrlBase *child, bool dontDelete = false); + virtual bool delGroup (CInterfaceGroup * child, bool dontDelete = false); + + // Delete know type by name (return true if found and removed) + virtual bool delView (const std::string &id, bool dontDelete = false); + virtual bool delCtrl (const std::string &id, bool dontDelete = false); + virtual bool delGroup (const std::string &id, bool dontDelete = false); + + // Delete unknow type by name or ptr. NB: additionaly, if it's a group, unmakeWindow() is called as necessary + bool delElement (const std::string &id, bool noWarning=false); + bool delElement (CInterfaceElement *pIE, bool noWarning=false); - std::vector _EltOrder; - - /// Scroll properties - NLMISC::CRefPtr _ParentSizeMax; // RefPtr in case of group destroyed in a parent group with posref on it - sint32 _MaxW, _MaxH; - sint32 _MaxWReal, _MaxHReal; - sint32 _OffsetX, _OffsetY; - - uint8 _Priority; - - // Misc prop - bool _Overlappable : 1; - bool _ResizeFromChildW : 1; - bool _ResizeFromChildH : 1; - bool _Escapable : 1; - bool _UseCursor : 1; - bool _IsGroupContainer : 1; // faster than a virual call - bool _IsGroupScrollText : 1; - bool _IsGroupInScene : 1; - bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene - sint32 _ResizeFromChildWMargin; - sint32 _ResizeFromChildHMargin; - sint32 _GroupSizeRef; - - // Projected Depth with no ZBias applied - float _DepthForZSort; - - // handler for activation - IActionHandler *_AHOnActive; - CStringShared _AHOnActiveParams; - IActionHandler *_AHOnDeactive; - CStringShared _AHOnDeactiveParams; - - // right & left clicks - IActionHandler *_AHOnLeftClick; - CStringShared _AHOnLeftClickParams; - IActionHandler *_AHOnRightClick; - CStringShared _AHOnRightClickParams; - - // enter params. - IActionHandler *_AHOnEnter; - CStringShared _AHOnEnterParams; - - // escape AH - IActionHandler *_AHOnEscape; - CStringShared _AHOnEscapeParams; - -private: - - void addToEltOrder(CViewBase *view, sint order); - - /// \name LUA specific - // @{ - // Lua Env Table created. Table is in the LUA_REGISTRYINDEX, with key as this CInterfaceGroup* userdata - bool _LUAEnvTableCreated; - // The LUA script to be executed on Draw (checkCoords) - CStringShared _LUAOnDraw; - // The InterfaceLink created specialy for Lua Script to be executed at some DB change - typedef std::map > TLUAOnDbChange; - TLUAOnDbChange _LUAOnDbChange; - void removeAllLUAOnDbChange(); -protected: - void parseMaxSizeRef(const char *ptr); - // @} -}; + uint getNumGroup() const { return (uint)_ChildrenGroups.size(); } + CInterfaceGroup *getGroup(uint index) const; + + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + /// Coming from CCtrlBase + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + void executeControl (const std::string &sControlName); + + const std::vector & getGroups () { return _ChildrenGroups; } + const std::vector & getControls() { return _Controls; } + const std::vector & getViews() { return _Views; } + + // test is a group is a direct child of this interface group + bool isChildGroup(const CInterfaceGroup *group) const; + + virtual bool isWindowUnder (sint32 x, sint32 y); // Virtual for menu that is not square + CInterfaceGroup *getGroupUnder (sint32 x, sint32 y); + virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group + virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); + virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vIGL); + + void absoluteToRelative (sint32 &x, sint32 &y); + + /// Coming from CViewBase + virtual void draw (); + // Draw with no clip (if clip is done by parent) + virtual void drawNoClip(); + + /// Tool function to draw a single Element that should exist in the group (clipped by the group) + void drawElement (CViewBase *el); + + + /** + * update the elements coords + */ + virtual void checkCoords(); + virtual void updateCoords(); + + /// remove all views + virtual void clearViews(); + + /// remove all controls + virtual void clearControls(); + + /// remove all groups + virtual void clearGroups(); + + void setParentSizeMax(CInterfaceElement *pIE) { _ParentSizeMax = pIE; } + void setMaxW (sint32 maxw) { _MaxW = maxw; } + void setMaxH (sint32 maxh) { _MaxH = maxh; } + void setOfsX (sint32 x) { _OffsetX = x; } + void setOfsY (sint32 y) { _OffsetY = y; } + bool moveSBTrackY (CInterfaceGroup *target, sint32 dy); + bool moveSBTargetY (CInterfaceGroup *target, sint32 dy); + void setResizeFromChildW(bool resize) { _ResizeFromChildW = resize; } + void setResizeFromChildH(bool resize) { _ResizeFromChildH = resize; } + + // Valid only for windows InterfaceGroup. + // escapable + void setEscapable(bool b) { _Escapable= b; } + bool getEscapable() const { return _Escapable; } + void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); } + const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); } + void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; } + const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; } + // enterable + void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); } + const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); } + void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; } + const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; } + uint8 getPriority() const { return _Priority; } + void setPriority(uint8 nprio); + + + sint32 getMaxW () const { return _MaxW; } + sint32 getMaxH () const { return _MaxH; } + sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; } + sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; } + sint32 getOfsX () const { return _OffsetX; } + sint32 getOfsY () const { return _OffsetY; } + bool getResizeFromChildW() const { return _ResizeFromChildW; } + bool getResizeFromChildH() const { return _ResizeFromChildH; } + sint32 getResizeFromChildWMargin() const { return _ResizeFromChildWMargin; } + sint32 getResizeFromChildHMargin() const { return _ResizeFromChildHMargin; } + void setResizeFromChildWMargin(sint32 margin) { _ResizeFromChildWMargin = margin; } + void setResizeFromChildHMargin(sint32 margin) { _ResizeFromChildHMargin = margin; } + bool getOverlappable() const { return _Overlappable; } + + virtual void setActive (bool state); + + // eval dimension of children bbox + void evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const; + + virtual void launch (); + + + // right & left clicks handler + void setLeftClickHandler(const std::string &handler); + void setRightClickHandler(const std::string &handler); + void setLeftClickHandlerParams(const std::string ¶ms) { _AHOnLeftClickParams = params; } + void setRightClickHandlerParams(const std::string ¶ms) { _AHOnRightClickParams = params; } + void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); } + void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; } + void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); } + void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; } + + const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } + const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; } + const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); } + const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; } + const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); } + const std::string &getOnActiveParams() const { return _AHOnActiveParams; } + const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); } + const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; } + + // find a sub view/ctrl/group in this group from its id + int luaFind(CLuaState &ls); + int luaGetEnclosingContainer(CLuaState &ls); + int luaDeleteLUAEnvTable(CLuaState &ls); + int luaAddGroup(CLuaState &ls); + int luaDelGroup(CLuaState &ls); + int luaGetNumGroups(CLuaState &ls); + int luaGetGroup(CLuaState &ls); + + void setMaxSizeRef(const std::string &maxSizeRef); + std::string getMaxSizeRefAsString() const; + + + REFLECT_EXPORT_START(CInterfaceGroup, CCtrlBase) + REFLECT_LUA_METHOD("find", luaFind); + REFLECT_LUA_METHOD("deleteLUAEnvTable", luaDeleteLUAEnvTable); + REFLECT_LUA_METHOD("getEnclosingContainer", luaGetEnclosingContainer); + REFLECT_LUA_METHOD("addGroup", luaAddGroup); + REFLECT_LUA_METHOD("delGroup", luaDelGroup); + REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups); + REFLECT_LUA_METHOD("getGroup", luaGetGroup); + REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler); + REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler); + REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams); + REFLECT_STRING ("right_click_params", getRightClickHandlerParams, setRightClickHandlerParams); + REFLECT_STRING ("on_active", getOnActiveHandler, setOnActiveHandler); + REFLECT_STRING ("on_active_params", getOnActiveParams, setOnActiveParams); + REFLECT_STRING ("on_deactive", getOnDeactiveHandler, setOnDeactiveHandler); + REFLECT_STRING ("on_deactive_params", getOnDeactiveParams, setOnDeactiveParams); + REFLECT_STRING ("on_enter", getAHOnEnter, setAHOnEnter); + REFLECT_STRING ("on_enter_params", getAHOnEnterParams, setAHOnEnterParams); + REFLECT_STRING ("on_escape", getAHOnEscape, setAHOnEscape); + REFLECT_STRING ("on_escape_params", getAHOnEscapeParams, setAHOnEscapeParams); + REFLECT_SINT32 ("ofsx", getOfsX, setOfsX); + REFLECT_SINT32 ("ofsy", getOfsY, setOfsY); + REFLECT_BOOL("child_resize_w", getResizeFromChildW, setResizeFromChildW); + REFLECT_SINT32("child_resize_wmargin", getResizeFromChildWMargin, setResizeFromChildWMargin); + REFLECT_BOOL("child_resize_h", getResizeFromChildH, setResizeFromChildH); + REFLECT_SINT32("child_resize_hmargin", getResizeFromChildHMargin, setResizeFromChildHMargin); + REFLECT_SINT32 ("ofsy", getOfsY, setOfsY); + REFLECT_STRING("max_sizeref", getMaxSizeRefAsString, setMaxSizeRef); + REFLECT_SINT32 ("max_w", getMaxW, setMaxW); + REFLECT_SINT32 ("max_h", getMaxH, setMaxH); + REFLECT_SINT32 ("max_w_real", getMaxWReal, dummySet); + REFLECT_SINT32 ("max_h_real", getMaxHReal, dummySet); + REFLECT_EXPORT_END + + + + // From CCtrlBase + virtual void updateAllLinks(); + + /// return true for some containers. false by default + virtual bool isMovable() const {return false;} + + virtual sint32 getAlpha() const; + virtual void setAlpha (sint32 a); + + /// Eval current clip coords. This is not incremental as with makeNewClip, and thus more slow. This also doesn't change the current clip window. + void getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const; + + // quick way to know if the group is a CGroupContainer + bool isGroupContainer() const { return _IsGroupContainer; } + bool isGroupScrollText() const{ return _IsGroupScrollText; } + bool isGroupInScene() const{ return _IsGroupInScene; } + + CInterfaceGroup* getEnclosingContainer(); + + sint getInsertionOrder(CViewBase *vb) const; + + // for debug only + void dumpGroups(); + void dumpEltsOrder(); + + virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter); + + virtual bool isGroup() const { return true; } + + // clear all edit box in the ui + virtual void clearAllEditBox(); + // restore all backuped positions for containers + virtual void restoreAllContainersBackupPosition(); + + virtual void dumpSize(uint depth = 0) const; + + // From CInterfaceElement + virtual void visit(CInterfaceElementVisitor *visitor); + + /// Visits only this group's sub-groups and then the group itself + virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor ); + + // Check cursor + void setUseCursor(bool use); + bool getUseCursor() const { return _UseCursor; } + + + // From CInterfaceElement + virtual void onFrameUpdateWindowPos(sint dx, sint dy); + // true for CGroupInScene for instance + bool isNeedFrameUpdatePos() const {return _NeedFrameUpdatePos;} + + + /// \name LUA specific + // @{ + // Create a LUA Environement if don't exist, then push it on the LUA stack + void pushLUAEnvTable(); + // Free the LUA Env Table + void deleteLUAEnvTable(bool recurse = false); + // Set the LUA script to execute at checkCoords time (empty to reset) + void setLuaScriptOnDraw(const std::string &script); + // + void executeLuaScriptOnDraw(); + // Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key + void addLuaScriptOnDBChange(const std::string &dbList, const std::string &script); + // Remove the LUA script to execute when a list of DB change + void removeLuaScriptOnDBChange(const std::string &dbList); + // @} + + virtual CInterfaceElement *clone(); + virtual void serial(NLMISC::IStream &f); + + // Return the current Depth, with no ZBias applied. + float getDepthForZSort() const { return _DepthForZSort; } + + protected: + + void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH); + void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH); + + // Compute clip contribution for current window, and a previous clipping rectangle. This doesn't change the clip window in the driver. + void computeCurrentClipContribution(sint32 prevX, sint32 prevY, sint32 prevW, sint32 prevH, + sint32 &newX, sint32 &newY, sint32 &newW, sint32 &newH) const; + + void delEltOrder (CViewBase *pElt); + + // update coords one time + void doUpdateCoords(); + + // notify children controls & groups that 'active' has been called on one of their parent + void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc); + + protected: + + /// children interface elements + std::vector _ChildrenGroups; + std::vector _Controls; + std::vector _Views; + + std::vector _EltOrder; + + /// Scroll properties + NLMISC::CRefPtr _ParentSizeMax; // RefPtr in case of group destroyed in a parent group with posref on it + sint32 _MaxW, _MaxH; + sint32 _MaxWReal, _MaxHReal; + sint32 _OffsetX, _OffsetY; + + uint8 _Priority; + + // Misc prop + bool _Overlappable : 1; + bool _ResizeFromChildW : 1; + bool _ResizeFromChildH : 1; + bool _Escapable : 1; + bool _UseCursor : 1; + bool _IsGroupContainer : 1; // faster than a virual call + bool _IsGroupScrollText : 1; + bool _IsGroupInScene : 1; + bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene + sint32 _ResizeFromChildWMargin; + sint32 _ResizeFromChildHMargin; + sint32 _GroupSizeRef; + + // Projected Depth with no ZBias applied + float _DepthForZSort; + + // handler for activation + IActionHandler *_AHOnActive; + CStringShared _AHOnActiveParams; + IActionHandler *_AHOnDeactive; + CStringShared _AHOnDeactiveParams; + + // right & left clicks + IActionHandler *_AHOnLeftClick; + CStringShared _AHOnLeftClickParams; + IActionHandler *_AHOnRightClick; + CStringShared _AHOnRightClickParams; + + // enter params. + IActionHandler *_AHOnEnter; + CStringShared _AHOnEnterParams; + + // escape AH + IActionHandler *_AHOnEscape; + CStringShared _AHOnEscapeParams; + + private: + + void addToEltOrder(CViewBase *view, sint order); + + /// \name LUA specific + // @{ + // Lua Env Table created. Table is in the LUA_REGISTRYINDEX, with key as this CInterfaceGroup* userdata + bool _LUAEnvTableCreated; + // The LUA script to be executed on Draw (checkCoords) + CStringShared _LUAOnDraw; + // The InterfaceLink created specialy for Lua Script to be executed at some DB change + typedef std::map > TLUAOnDbChange; + TLUAOnDbChange _LUAOnDbChange; + void removeAllLUAOnDbChange(); + protected: + void parseMaxSizeRef(const char *ptr); + // @} + }; + +} #endif // NL_INTERFACE_GROUP_H diff --git a/code/nel/include/nel/gui/interface_link.h b/code/nel/include/nel/gui/interface_link.h index 33561ff0f..96a5558b3 100644 --- a/code/nel/include/nel/gui/interface_link.h +++ b/code/nel/include/nel/gui/interface_link.h @@ -27,165 +27,160 @@ namespace NLGUI class CReflectedProperty; class CInterfaceExprValue; class CInterfaceExprNode; -} + class CInterfaceElement; + class CInterfaceGroup; - -class CInterfaceElement; -class CInterfaceGroup; - - -using namespace NLGUI; - - -/** A link in an interface. - * A link is an object that can read one or several values from the database, that can evaluate an expression - * on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to - * an interface property that has been exported by an interface element (the export system uses reflect.h). - * The first time it is created, it places observers on the database entries that are needed by the expression, so each - * time a database value changes, the link is marked as 'triggered' - * When updateTrigeredLinks() is called, all links are effectively updated. - * - * Example of use : connecting a change in the db tree to the 'active' state of a window - * - * NB : an additionnal action handler can be provided - * NB : The links are owned by the interface element (using a smart pointer) - * NB : Several targets may be used. - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver -{ -public: - #ifdef NL_DEBUG - // for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager - // and was created by calling CInterfaceManager::addLink, contains the name of this link - std::string LinkName; - #endif -public: - struct CTargetInfo - { - CInterfaceElement *Elem; - std::string PropertyName; - /** Affect a value to this target. - * \return true if the affectation could be made - */ - bool affect(const CInterfaceExprValue &value); - }; - - - /// Updates triggered interface links when triggered by the observed branch - class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver + /** A link in an interface. + * A link is an object that can read one or several values from the database, that can evaluate an expression + * on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to + * an interface property that has been exported by an interface element (the export system uses reflect.h). + * The first time it is created, it places observers on the database entries that are needed by the expression, so each + * time a database value changes, the link is marked as 'triggered' + * When updateTrigeredLinks() is called, all links are effectively updated. + * + * Example of use : connecting a change in the db tree to the 'active' state of a window + * + * NB : an additionnal action handler can be provided + * NB : The links are owned by the interface element (using a smart pointer) + * NB : Several targets may be used. + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver { public: - CInterfaceLinkUpdater(); - ~CInterfaceLinkUpdater(); - void onObserverCallFlush(); + #ifdef NL_DEBUG + // for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager + // and was created by calling CInterfaceManager::addLink, contains the name of this link + std::string LinkName; + #endif + public: + struct CTargetInfo + { + CInterfaceElement *Elem; + std::string PropertyName; + /** Affect a value to this target. + * \return true if the affectation could be made + */ + bool affect(const CInterfaceExprValue &value); + }; + + + /// Updates triggered interface links when triggered by the observed branch + class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver + { + public: + CInterfaceLinkUpdater(); + ~CInterfaceLinkUpdater(); + void onObserverCallFlush(); + }; + + public: + CInterfaceLink(); + ~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement + /** Make a link between the given interface element properties and a value that depends on database entries. + * The link is automatically added in the link list of the targets element (it calls CInterfaceElement::addLink), so when all target elements are removed, the link is. + * If there are no target element, the link is permanent (removed at exit) + * NB : The target is not updated during this call. + */ + bool init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); + // force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved. + static void updateAllLinks(); + // force all trigered links to be updated + static void updateTrigeredLinks(); + // remove from the _LinksWithNoTarget list if the link has no target + void uninit(); + + // Force an update of the target of this link + void update(); + /** Remove a target element. It won't be updated anymore by that link + * NB : this don't call removeLink() on the target + */ + void removeTarget(CInterfaceElement *elem); + // Get the number of targets of this link + uint getNumTargets() const { return (uint)_Targets.size(); } + // Get the i-th target + CInterfaceElement *getTarget(uint index) const { return _Targets[index]._InterfaceElement; } + + static void removeAllLinks(); + + static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val); + + static bool isUpdatingAllLinks() { return _UpdateAllLinks; } + + /** From a target name of a link, retrieve the target element and its target target property + * \return true if the target is valid + */ + static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm); + + /** From several target names of a link (seprated by ','), retrieve the target elements and their target properties + * \return true if all targets are valid + */ + static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); + //////////////////////////////////////////////////////////////////////////////////////////////////////// + private: + friend struct CRemoveTargetPred; + // a target property + struct CTarget + { + CInterfaceElement *_InterfaceElement; + const CReflectedProperty *_Property; + }; + private: + typedef std::list TLinkList; + typedef NLMISC::CSmartPtr TLinkSmartPtr; + typedef std::vector TLinkVect; + typedef std::vector TNodeVect; + private: + std::vector _Targets; + TNodeVect _ObservedNodes; + std::string _Expr; + CInterfaceExprNode *_ParseTree; + std::string _ActionHandler; + std::string _AHParams; + std::string _AHCond; + CInterfaceGroup *_AHParent; + static TLinkList _LinkList; + TLinkList::iterator _ListEntry; + bool _On; + static TLinkVect _LinksWithNoTarget; // there should be an owner for links with no targets + static bool _UpdateAllLinks; + ///\ name triggered link mgt + //@{ + // next/previous link that was trigered. NULL means end or start of list + // each ptr is duplicated because with manage 2 lists : one list in which links are added, and one list in which we update links. + // This way one link can trigger another with no prb + CInterfaceLink *_PrevTriggeredLink[2]; + CInterfaceLink *_NextTriggeredLink[2]; + bool _Triggered[2]; + // global lists + static CInterfaceLink *_FirstTriggeredLink[2]; + static CInterfaceLink *_LastTriggeredLink[2]; + // iterators in current list being updated : they're global so that deleting a CInterfaceLink instance prevent them from becoming dangling pointers + static CInterfaceLink *_CurrUpdatedLink; + static CInterfaceLink *_NextUpdatedLink; + // Index of the list in which triggered link must be inserted + static uint _CurrentTriggeredLinkList; + + // + void linkInTriggerList(uint list); + void unlinkFromTriggerList(uint list); + //@} + + private: + /** Inherited from ICDBNode::IPropertyObserver + * This doesn't update the node directly, but mark it as 'triggered' + * The node is really updated during the call to 'updateTrigeredLinks()' + */ + virtual void update(NLMISC::ICDBNode *node); + void createObservers(const TNodeVect &nodes); + void removeObservers(const TNodeVect &nodes); + // debug : check that there are as many targets as reference to a link + void checkNbRefs(); }; -public: - CInterfaceLink(); - ~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement - /** Make a link between the given interface element properties and a value that depends on database entries. - * The link is automatically added in the link list of the targets element (it calls CInterfaceElement::addLink), so when all target elements are removed, the link is. - * If there are no target element, the link is permanent (removed at exit) - * NB : The target is not updated during this call. - */ - bool init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent); - // force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved. - static void updateAllLinks(); - // force all trigered links to be updated - static void updateTrigeredLinks(); - // remove from the _LinksWithNoTarget list if the link has no target - void uninit(); - - // Force an update of the target of this link - void update(); - /** Remove a target element. It won't be updated anymore by that link - * NB : this don't call removeLink() on the target - */ - void removeTarget(CInterfaceElement *elem); - // Get the number of targets of this link - uint getNumTargets() const { return (uint)_Targets.size(); } - // Get the i-th target - CInterfaceElement *getTarget(uint index) const { return _Targets[index]._InterfaceElement; } - - static void removeAllLinks(); - - static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val); - - static bool isUpdatingAllLinks() { return _UpdateAllLinks; } - - /** From a target name of a link, retrieve the target element and its target target property - * \return true if the target is valid - */ - static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm); - - /** From several target names of a link (seprated by ','), retrieve the target elements and their target properties - * \return true if all targets are valid - */ - static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect); -//////////////////////////////////////////////////////////////////////////////////////////////////////// -private: - friend struct CRemoveTargetPred; - // a target property - struct CTarget - { - CInterfaceElement *_InterfaceElement; - const CReflectedProperty *_Property; - }; -private: - typedef std::list TLinkList; - typedef NLMISC::CSmartPtr TLinkSmartPtr; - typedef std::vector TLinkVect; - typedef std::vector TNodeVect; -private: - std::vector _Targets; - TNodeVect _ObservedNodes; - std::string _Expr; - CInterfaceExprNode *_ParseTree; - std::string _ActionHandler; - std::string _AHParams; - std::string _AHCond; - CInterfaceGroup *_AHParent; - static TLinkList _LinkList; - TLinkList::iterator _ListEntry; - bool _On; - static TLinkVect _LinksWithNoTarget; // there should be an owner for links with no targets - static bool _UpdateAllLinks; - ///\ name triggered link mgt - //@{ - // next/previous link that was trigered. NULL means end or start of list - // each ptr is duplicated because with manage 2 lists : one list in which links are added, and one list in which we update links. - // This way one link can trigger another with no prb - CInterfaceLink *_PrevTriggeredLink[2]; - CInterfaceLink *_NextTriggeredLink[2]; - bool _Triggered[2]; - // global lists - static CInterfaceLink *_FirstTriggeredLink[2]; - static CInterfaceLink *_LastTriggeredLink[2]; - // iterators in current list being updated : they're global so that deleting a CInterfaceLink instance prevent them from becoming dangling pointers - static CInterfaceLink *_CurrUpdatedLink; - static CInterfaceLink *_NextUpdatedLink; - // Index of the list in which triggered link must be inserted - static uint _CurrentTriggeredLinkList; - - // - void linkInTriggerList(uint list); - void unlinkFromTriggerList(uint list); - //@} - -private: - /** Inherited from ICDBNode::IPropertyObserver - * This doesn't update the node directly, but mark it as 'triggered' - * The node is really updated during the call to 'updateTrigeredLinks()' - */ - virtual void update(NLMISC::ICDBNode *node); - void createObservers(const TNodeVect &nodes); - void removeObservers(const TNodeVect &nodes); - // debug : check that there are as many targets as reference to a link - void checkNbRefs(); -}; +} #endif diff --git a/code/nel/include/nel/gui/interface_options.h b/code/nel/include/nel/gui/interface_options.h index 990f1ab19..7ca938140 100644 --- a/code/nel/include/nel/gui/interface_options.h +++ b/code/nel/include/nel/gui/interface_options.h @@ -28,70 +28,73 @@ namespace NL3D class UAnimationSet; } - -// *************************************************************************** -class CInterfaceOptionValue +namespace NLGUI { -public: - CInterfaceOptionValue() + + // *************************************************************************** + class CInterfaceOptionValue { - _Color= NLMISC::CRGBA::White; - _Int= 0; - _Float= 0; - _Boolean= false; - } + public: + CInterfaceOptionValue() + { + _Color= NLMISC::CRGBA::White; + _Int= 0; + _Float= 0; + _Boolean= false; + } - const std::string &getValStr () const {return _Str;} - sint32 getValSInt32() const {return _Int;} - float getValFloat () const {return _Float;} - NLMISC::CRGBA getValColor () const {return _Color;} - bool getValBool () const {return _Boolean;} + const std::string &getValStr () const {return _Str;} + sint32 getValSInt32() const {return _Int;} + float getValFloat () const {return _Float;} + NLMISC::CRGBA getValColor () const {return _Color;} + bool getValBool () const {return _Boolean;} - void init(const std::string &str); + void init(const std::string &str); - // returned when InterfaceOptions param not found - static const CInterfaceOptionValue NullValue; + // returned when InterfaceOptions param not found + static const CInterfaceOptionValue NullValue; -private: + private: - std::string _Str; - NLMISC::CRGBA _Color; - sint32 _Int; - float _Float; - bool _Boolean; -}; + std::string _Str; + NLMISC::CRGBA _Color; + sint32 _Int; + float _Float; + bool _Boolean; + }; -// *************************************************************************** -class CInterfaceOptions : public NLMISC::CRefCount -{ + // *************************************************************************** + class CInterfaceOptions : public NLMISC::CRefCount + { -public: + public: - CInterfaceOptions(); - virtual ~CInterfaceOptions(); + CInterfaceOptions(); + virtual ~CInterfaceOptions(); - virtual bool parse (xmlNodePtr cur); + virtual bool parse (xmlNodePtr cur); - // return NullValue if param not found - const CInterfaceOptionValue &getValue(const std::string &sParamName) const; + // return NullValue if param not found + const CInterfaceOptionValue &getValue(const std::string &sParamName) const; - // shortcuts to getValue(paramName).getValXXX() - const std::string &getValStr (const std::string &sParamName) const; - sint32 getValSInt32 (const std::string &sParamName) const; - float getValFloat (const std::string &sParamName) const; - NLMISC::CRGBA getValColor (const std::string &sParamName) const; - bool getValBool (const std::string &sParamName) const; + // shortcuts to getValue(paramName).getValXXX() + const std::string &getValStr (const std::string &sParamName) const; + sint32 getValSInt32 (const std::string &sParamName) const; + float getValFloat (const std::string &sParamName) const; + NLMISC::CRGBA getValColor (const std::string &sParamName) const; + bool getValBool (const std::string &sParamName) const; - // copy basic map only from other CInterfaceOptions (non virtual method) - void copyBasicMap(const CInterfaceOptions &other); + // copy basic map only from other CInterfaceOptions (non virtual method) + void copyBasicMap(const CInterfaceOptions &other); -protected: + protected: - std::map _ParamValue; + std::map _ParamValue; -}; + }; +} #endif // NL_INTERFACE_LAYER_H diff --git a/code/nel/include/nel/gui/view_base.h b/code/nel/include/nel/gui/view_base.h index e8ab73680..db214b772 100644 --- a/code/nel/include/nel/gui/view_base.h +++ b/code/nel/include/nel/gui/view_base.h @@ -23,59 +23,63 @@ #include "nel/misc/factory.h" #include "nel/gui/interface_element.h" -class CViewBase : public CInterfaceElement +namespace NLGUI { -public: - // for factory construction - struct TCtorParam - {}; - - /// Constructor - CViewBase(const TCtorParam &/* param */) : CInterfaceElement() + class CViewBase : public CInterfaceElement { - } + public: - /// Destructor - virtual ~CViewBase(); + // for factory construction + struct TCtorParam + {}; - // Returns 'true' if that element can be downcasted to a view - virtual bool isView() const { return true; } + /// Constructor + CViewBase(const TCtorParam &/* param */) : CInterfaceElement() + { + } - /// Draw the view from XReal, YReal, WReal, HReal (implemented by derived classes) - /// this coordinates are relative to the screen bottom left and begins the bottom left of the view - virtual void draw () = 0; + /// Destructor + virtual ~CViewBase(); - virtual void updateCoords() { CInterfaceElement::updateCoords(); } + // Returns 'true' if that element can be downcasted to a view + virtual bool isView() const { return true; } - /// Debug - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + /// Draw the view from XReal, YReal, WReal, HReal (implemented by derived classes) + /// this coordinates are relative to the screen bottom left and begins the bottom left of the view + virtual void draw () = 0; - /// Reflection - virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this - virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this + virtual void updateCoords() { CInterfaceElement::updateCoords(); } + + /// Debug + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + /// Reflection + virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this + virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this - void copyOptionFrom(const CViewBase &other) - { - CInterfaceElement::copyOptionFrom(other); - } + void copyOptionFrom(const CViewBase &other) + { + CInterfaceElement::copyOptionFrom(other); + } - REFLECT_EXPORT_START(CViewBase, CInterfaceElement) - REFLECT_SINT32 ("alpha", getAlpha, setAlpha); - REFLECT_EXPORT_END + REFLECT_EXPORT_START(CViewBase, CInterfaceElement) + REFLECT_SINT32 ("alpha", getAlpha, setAlpha); + REFLECT_EXPORT_END - virtual void dumpSize(uint depth = 0) const; + virtual void dumpSize(uint depth = 0) const; - // from CInterfaceElement - virtual void visit(CInterfaceElementVisitor *visitor); + // from CInterfaceElement + virtual void visit(CInterfaceElementVisitor *visitor); - // special for mouse over : return true and fill the name of the cursor to display - virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; } + // special for mouse over : return true and fill the name of the cursor to display + virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; } -}; + }; +} #endif // RZ_VIEW_BASE_H diff --git a/code/nel/include/nel/gui/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h index 341ab4259..bcc38fea4 100644 --- a/code/nel/include/nel/gui/view_pointer_base.h +++ b/code/nel/include/nel/gui/view_pointer_base.h @@ -1,55 +1,77 @@ +// Ryzom - MMORPG Framework +// 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 VIEW_POINTER_BASE_H #define VIEW_POINTER_BASE_H #include "nel/gui/view_base.h" -class CViewPointerBase : public CViewBase +namespace NLGUI { -public: - DECLARE_UI_CLASS( CViewPointerBase ) - CViewPointerBase( const TCtorParam ¶m ); - virtual ~CViewPointerBase(); + class CViewPointerBase : public CViewBase + { + public: + DECLARE_UI_CLASS( CViewPointerBase ) - // Set the pointer position. - void setPointerPos (sint32 x, sint32 y); - void setPointerDispPos (sint32 x, sint32 y); + CViewPointerBase( const TCtorParam ¶m ); + virtual ~CViewPointerBase(); - void resetPointerPos (); - void setPointerDown (bool pd); - void setPointerDownString (const std::string &s); + // Set the pointer position. + void setPointerPos (sint32 x, sint32 y); + void setPointerDispPos (sint32 x, sint32 y); - void getPointerPos (sint32 &x, sint32 &y); - void getPointerDispPos (sint32 &x, sint32 &y); + void resetPointerPos (); + void setPointerDown (bool pd); + void setPointerDownString (const std::string &s); - void getPointerOldPos (sint32 &x, sint32 &y); - void getPointerDownPos (sint32 &x, sint32 &y); - bool getPointerDown (); - std::string getPointerDownString (); - bool getPointerDrag (); + void getPointerPos (sint32 &x, sint32 &y); + void getPointerDispPos (sint32 &x, sint32 &y); - /// Is the pointer visible ? - bool show() const {return _PointerVisible;} + void getPointerOldPos (sint32 &x, sint32 &y); + void getPointerDownPos (sint32 &x, sint32 &y); + bool getPointerDown (); + std::string getPointerDownString (); + bool getPointerDrag (); - void draw(){} + /// Is the pointer visible ? + bool show() const {return _PointerVisible;} -protected: - // (x,y) is from the TopLeft corner of the window - sint32 _PointerX; // Current pointer position (raw, before snapping) - sint32 _PointerY; - sint32 _PointerOldX; // Previous frame pointer position - sint32 _PointerOldY; - bool _PointerDown; // Is the pointer down ? - sint32 _PointerDownX; // Pointer down position - sint32 _PointerDownY; - std::string _PointerDownString; // What is under the pointer at the down position - bool _PointerDrag; // Is the pointer down and we have moved ? - bool _PointerVisible; // Is the pointer visible or hidden ? + void draw(){} -private: + protected: + // (x,y) is from the TopLeft corner of the window + sint32 _PointerX; // Current pointer position (raw, before snapping) + sint32 _PointerY; + sint32 _PointerOldX; // Previous frame pointer position + sint32 _PointerOldY; + bool _PointerDown; // Is the pointer down ? + sint32 _PointerDownX; // Pointer down position + sint32 _PointerDownY; + std::string _PointerDownString; // What is under the pointer at the down position + bool _PointerDrag; // Is the pointer down and we have moved ? + bool _PointerVisible; // Is the pointer visible or hidden ? + + private: -}; + }; + +} #endif diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index cf2716eed..9145f66c4 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -23,314 +23,319 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_common.h" -class CInterfaceElement; -class CCtrlBase; -class CViewBase; -class CInterfaceGroup; -class CViewPointerBase; -class CInterfaceOptions; - namespace NLMISC { class CCDBNodeLeaf; } -class IParser +namespace NLGUI { -public: - virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; - virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; - virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; - virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; -}; -/// Manages the GUI widgets -class CWidgetManager{ -public: + class CInterfaceElement; + class CCtrlBase; + class CViewBase; + class CInterfaceGroup; + class CViewPointerBase; + class CInterfaceOptions; - // Master groups encapsulate all windows - struct SMasterGroup + class IParser { - SMasterGroup() - { - Group = NULL; - LastTopWindowPriority = WIN_PRIORITY_NORMAL; - } - - CInterfaceGroup *Group; - std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ]; - - void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL ); - void delWindow( CInterfaceGroup *pIG ); - CInterfaceGroup *getWindowFromId( const std::string &winID ); - bool isWindowPresent( CInterfaceGroup *pIG ); - // Set a window top in its priority queue - void setTopWindow( CInterfaceGroup *pIG ); - void setBackWindow( CInterfaceGroup *pIG ); - void deactiveAllContainers(); - void centerAllContainers(); - void unlockAllContainers(); - - // Sort the world space group - void sortWorldSpaceGroup (); - - uint8 LastTopWindowPriority; + public: + virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; + virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; }; + /// Manages the GUI widgets + class CWidgetManager{ + public: - // Infos about a modal window. - struct SModalWndInfo - { - // Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after) - NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window - NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal; - bool ModalClip; - bool ModalExitClickOut; - bool ModalExitClickL; - bool ModalExitClickR; - bool ModalExitKeyPushed; - std::string ModalHandlerClickOut; - std::string ModalClickOutParams; - - SModalWndInfo() + // Master groups encapsulate all windows + struct SMasterGroup { - ModalWindow = NULL; - CtrlLaunchingModal = NULL; - ModalExitClickOut = false; - ModalExitClickL = false; - ModalExitClickR = false; - ModalExitKeyPushed = false; + SMasterGroup() + { + Group = NULL; + LastTopWindowPriority = WIN_PRIORITY_NORMAL; + } + + CInterfaceGroup *Group; + std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ]; + + void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL ); + void delWindow( CInterfaceGroup *pIG ); + CInterfaceGroup *getWindowFromId( const std::string &winID ); + bool isWindowPresent( CInterfaceGroup *pIG ); + // Set a window top in its priority queue + void setTopWindow( CInterfaceGroup *pIG ); + void setBackWindow( CInterfaceGroup *pIG ); + void deactiveAllContainers(); + void centerAllContainers(); + void unlockAllContainers(); + + // Sort the world space group + void sortWorldSpaceGroup (); + + uint8 LastTopWindowPriority; + }; + + + // Infos about a modal window. + struct SModalWndInfo + { + // Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after) + NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window + NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal; + bool ModalClip; + bool ModalExitClickOut; + bool ModalExitClickL; + bool ModalExitClickR; + bool ModalExitKeyPushed; + std::string ModalHandlerClickOut; + std::string ModalClickOutParams; + + SModalWndInfo() + { + ModalWindow = NULL; + CtrlLaunchingModal = NULL; + ModalExitClickOut = false; + ModalExitClickL = false; + ModalExitClickR = false; + ModalExitKeyPushed = false; + } + }; + + + static CWidgetManager* getInstance(); + static void release(); + + CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName ); + std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; } + SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; } + CInterfaceGroup* getWindowFromId( const std::string &groupId ); + void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); + void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); + void removeAllMasterGroups(); + + void activateMasterGroup (const std::string &sMasterGroupName, bool bActive); + + CInterfaceElement* getElementFromId( const std::string &sEltId ); + CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId ); + + /// Get the window from an element (ui:interface:###) + CInterfaceGroup* getWindow(CInterfaceElement*); + + + /** + * set the top window + * \param win : pointer to the window to be set on top + */ + void setTopWindow (CInterfaceGroup *pWin); + + /** + * set the back window + * \param win : pointer to the window to be set on top + */ + void setBackWindow (CInterfaceGroup *pWin); + + /** get the top window in the first activated masterGroup + */ + CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; + + /** get the back window in the first activated masterGroup + */ + CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; + + /** get the last escapable top window in the first activated masterGroup + */ + CInterfaceGroup* getLastEscapableTopWindow() const; + + void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority); + + /** return the priority of the Last Window setTopWindow()-ed. + */ + uint8 getLastTopWindowPriority() const; + + bool hasModal() const; + + SModalWndInfo& getModal(); + + bool isPreviousModal( CInterfaceGroup *wnd ) const; + + void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); + void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); + // Disable all modals windows + void disableModalWindow (); + + /** Push a modal window that becomes the current modal window + */ + void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); + void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); + void popModalWindow(); + // pop all top modal windows with the given category (a string stored in the modal) + void popModalWindowCategory(const std::string &category); + + CCtrlBase *getCtrlLaunchingModal () + { + if (_ModalStack.empty()) return NULL; + return _ModalStack.back().CtrlLaunchingModal; } + /// get the currently active modal window, or NULL if none + CInterfaceGroup *getModalWindow() const + { + if (_ModalStack.empty()) return NULL; + return _ModalStack.back().ModalWindow; + } + + void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; } + CCtrlBase* getCurContextHelp(){ return curContextHelp; } + + float _DeltaTimeStopingContextHelp; + + CViewPointerBase* getPointer(){ return _Pointer; } + void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; } + + /** + * get the window under a spot + * \param : X coord of the spot + * \param : Y coord of the spot + * \return : pointer to the window + */ + CInterfaceGroup* getWindowUnder (sint32 x, sint32 y); + CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; } + void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; } + CInterfaceGroup* getGroupUnder (sint32 x, sint32 y); + + void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB ); + void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL ); + void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL ); + + const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; } + const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; } + const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; } + + // + void clearViewUnders(){ _ViewsUnderPointer.clear(); } + void clearGroupsUnders() { _GroupsUnderPointer.clear(); } + void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); } + + // Remove all references on a view (called when the ctrl is destroyed) + void removeRefOnView( CViewBase *ctrlBase ); + + // Remove all references on a ctrl (called when the ctrl is destroyed) + void removeRefOnCtrl (CCtrlBase *ctrlBase); + + // Remove all references on a group (called when the group is destroyed) + void removeRefOnGroup (CInterfaceGroup *group); + + void reset(); + + void checkCoords(); + // Relative move of pointer + void movePointer (sint32 dx, sint32 dy); + // Set absolute coordinates of pointer + void movePointerAbs(sint32 px, sint32 py); + + /** + * Capture + */ + CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; } + CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; } + CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; } + CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; } + CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; } + + void setCapturePointerLeft(CCtrlBase *c); + void setCapturePointerRight(CCtrlBase *c); + void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; } + // NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture + // to come back to the last captured window (resetCaptureKeyboard() not) + void setCaptureKeyboard(CCtrlBase *c); + /** Set the default box to use when no keyboard has been previously captured + * The given dialog should be static + */ + void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; } + + void resetCaptureKeyboard(); + + // True if the keyboard is captured + bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;} + + // register a view that wants to be notified at each frame (receive the msg 'clocktick') + void registerClockMsgTarget(CCtrlBase *vb); + void unregisterClockMsgTarget(CCtrlBase *vb); + bool isClockMsgTarget(CCtrlBase *vb) const; + void sendClockTickEvent(); + + void notifyElementCaptured(CCtrlBase *c); + + // Add a group into the windows list of its master goup + void makeWindow( CInterfaceGroup *group ); + + // Remove a group from the windows list of its master group + void unMakeWindow( CInterfaceGroup *group, bool noWarning = false ); + + void setGlobalColor( NLMISC::CRGBA col ); + NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; } + + void setContentAlpha( uint8 alpha ); + uint8 getContentAlpha() const{ return _ContentAlpha; } + + NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; } + void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; } + void resetColorProps(); + + /// Get options by name + CInterfaceOptions* getOptions( const std::string &optName ); + void addOptions( std::string name, CInterfaceOptions *options ); + void removeOptions( std::string name ); + void removeAllOptions(); + + static IParser *parser; + + private: + CWidgetManager(); + ~CWidgetManager(); + + static CWidgetManager *instance; + std::vector< SMasterGroup > _MasterGroups; + std::vector< SModalWndInfo > _ModalStack; + static std::string _CtrlLaunchingModalId; + NLMISC::CRefPtr< CCtrlBase > curContextHelp; + CViewPointerBase *_Pointer; + + // Options description + std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap; + + NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder; + + // Capture + NLMISC::CRefPtr _CaptureKeyboard; + NLMISC::CRefPtr _OldCaptureKeyboard; + NLMISC::CRefPtr _DefaultCaptureKeyboard; + NLMISC::CRefPtr _CapturePointerLeft; + NLMISC::CRefPtr _CapturePointerRight; + + // What is under pointer + std::vector< CViewBase* > _ViewsUnderPointer; + std::vector< CCtrlBase* > _CtrlsUnderPointer; + std::vector< CInterfaceGroup* > _GroupsUnderPointer; + + // view that should be notified from clock msg + std::vector _ClockMsgTargets; + + NLMISC::CRGBA _GlobalColor; + NLMISC::CRGBA _GlobalColorForContent; + uint8 _ContentAlpha; + + NLMISC::CCDBNodeLeaf *_RProp; + NLMISC::CCDBNodeLeaf *_GProp; + NLMISC::CCDBNodeLeaf *_BProp; + NLMISC::CCDBNodeLeaf *_AProp; }; - - static CWidgetManager* getInstance(); - static void release(); - - CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName ); - std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; } - SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; } - CInterfaceGroup* getWindowFromId( const std::string &groupId ); - void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); - void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG ); - void removeAllMasterGroups(); - - void activateMasterGroup (const std::string &sMasterGroupName, bool bActive); - - CInterfaceElement* getElementFromId( const std::string &sEltId ); - CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId ); - - /// Get the window from an element (ui:interface:###) - CInterfaceGroup* getWindow(CInterfaceElement*); - - - /** - * set the top window - * \param win : pointer to the window to be set on top - */ - void setTopWindow (CInterfaceGroup *pWin); - - /** - * set the back window - * \param win : pointer to the window to be set on top - */ - void setBackWindow (CInterfaceGroup *pWin); - - /** get the top window in the first activated masterGroup - */ - CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; - - /** get the back window in the first activated masterGroup - */ - CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const; - - /** get the last escapable top window in the first activated masterGroup - */ - CInterfaceGroup* getLastEscapableTopWindow() const; - - void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority); - - /** return the priority of the Last Window setTopWindow()-ed. - */ - uint8 getLastTopWindowPriority() const; - - bool hasModal() const; - - SModalWndInfo& getModal(); - - bool isPreviousModal( CInterfaceGroup *wnd ) const; - - void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); - void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); - // Disable all modals windows - void disableModalWindow (); - - /** Push a modal window that becomes the current modal window - */ - void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG); - void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName); - void popModalWindow(); - // pop all top modal windows with the given category (a string stored in the modal) - void popModalWindowCategory(const std::string &category); - - CCtrlBase *getCtrlLaunchingModal () - { - if (_ModalStack.empty()) return NULL; - return _ModalStack.back().CtrlLaunchingModal; - } - /// get the currently active modal window, or NULL if none - CInterfaceGroup *getModalWindow() const - { - if (_ModalStack.empty()) return NULL; - return _ModalStack.back().ModalWindow; - } - - void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; } - CCtrlBase* getCurContextHelp(){ return curContextHelp; } - - float _DeltaTimeStopingContextHelp; - - CViewPointerBase* getPointer(){ return _Pointer; } - void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; } - - /** - * get the window under a spot - * \param : X coord of the spot - * \param : Y coord of the spot - * \return : pointer to the window - */ - CInterfaceGroup* getWindowUnder (sint32 x, sint32 y); - CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; } - void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; } - CInterfaceGroup* getGroupUnder (sint32 x, sint32 y); - - void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB ); - void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL ); - void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL ); - - const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; } - const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; } - const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; } - - // - void clearViewUnders(){ _ViewsUnderPointer.clear(); } - void clearGroupsUnders() { _GroupsUnderPointer.clear(); } - void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); } - - // Remove all references on a view (called when the ctrl is destroyed) - void removeRefOnView( CViewBase *ctrlBase ); - - // Remove all references on a ctrl (called when the ctrl is destroyed) - void removeRefOnCtrl (CCtrlBase *ctrlBase); - - // Remove all references on a group (called when the group is destroyed) - void removeRefOnGroup (CInterfaceGroup *group); - - void reset(); - - void checkCoords(); - // Relative move of pointer - void movePointer (sint32 dx, sint32 dy); - // Set absolute coordinates of pointer - void movePointerAbs(sint32 px, sint32 py); - - /** - * Capture - */ - CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; } - CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; } - CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; } - CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; } - CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; } - - void setCapturePointerLeft(CCtrlBase *c); - void setCapturePointerRight(CCtrlBase *c); - void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; } - // NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture - // to come back to the last captured window (resetCaptureKeyboard() not) - void setCaptureKeyboard(CCtrlBase *c); - /** Set the default box to use when no keyboard has been previously captured - * The given dialog should be static - */ - void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; } - - void resetCaptureKeyboard(); - - // True if the keyboard is captured - bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;} - - // register a view that wants to be notified at each frame (receive the msg 'clocktick') - void registerClockMsgTarget(CCtrlBase *vb); - void unregisterClockMsgTarget(CCtrlBase *vb); - bool isClockMsgTarget(CCtrlBase *vb) const; - void sendClockTickEvent(); - - void notifyElementCaptured(CCtrlBase *c); - - // Add a group into the windows list of its master goup - void makeWindow( CInterfaceGroup *group ); - - // Remove a group from the windows list of its master group - void unMakeWindow( CInterfaceGroup *group, bool noWarning = false ); - - void setGlobalColor( NLMISC::CRGBA col ); - NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; } - - void setContentAlpha( uint8 alpha ); - uint8 getContentAlpha() const{ return _ContentAlpha; } - - NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; } - void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; } - void resetColorProps(); - - /// Get options by name - CInterfaceOptions* getOptions( const std::string &optName ); - void addOptions( std::string name, CInterfaceOptions *options ); - void removeOptions( std::string name ); - void removeAllOptions(); - - static IParser *parser; - -private: - CWidgetManager(); - ~CWidgetManager(); - - static CWidgetManager *instance; - std::vector< SMasterGroup > _MasterGroups; - std::vector< SModalWndInfo > _ModalStack; - static std::string _CtrlLaunchingModalId; - NLMISC::CRefPtr< CCtrlBase > curContextHelp; - CViewPointerBase *_Pointer; - - // Options description - std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap; - - NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder; - - // Capture - NLMISC::CRefPtr _CaptureKeyboard; - NLMISC::CRefPtr _OldCaptureKeyboard; - NLMISC::CRefPtr _DefaultCaptureKeyboard; - NLMISC::CRefPtr _CapturePointerLeft; - NLMISC::CRefPtr _CapturePointerRight; - - // What is under pointer - std::vector< CViewBase* > _ViewsUnderPointer; - std::vector< CCtrlBase* > _CtrlsUnderPointer; - std::vector< CInterfaceGroup* > _GroupsUnderPointer; - - // view that should be notified from clock msg - std::vector _ClockMsgTargets; - - NLMISC::CRGBA _GlobalColor; - NLMISC::CRGBA _GlobalColorForContent; - uint8 _ContentAlpha; - - NLMISC::CCDBNodeLeaf *_RProp; - NLMISC::CCDBNodeLeaf *_GProp; - NLMISC::CCDBNodeLeaf *_BProp; - NLMISC::CCDBNodeLeaf *_AProp; -}; +} #endif diff --git a/code/nel/src/gui/action_handler.cpp b/code/nel/src/gui/action_handler.cpp index 110fbb37c..be14aa5c5 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -25,684 +25,689 @@ using namespace std; using namespace NLMISC; -// ------------------------------------------------------------------------------------------------ -CAHManager *CAHManager::_GlobalInstance = NULL; -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -static void skipBlankAtStart (string &start) +namespace NLGUI { - while (!start.empty()) - { - if ((start[0] == ' ' || start[0] == '\t' || start[0] == '\r' || start[0] == '\n')) - start = start.substr(1,start.size()); - else - break; - } -} -// ------------------------------------------------------------------------------------------------ -static void skipBlankAtEnd (string &end) -{ - while (!end.empty()) - { - if ((end[end.size()-1] == ' ' || end[end.size()-1] == '\t' || end[end.size()-1] == '\r' || end[end.size()-1] == '\n')) - end = end.substr(0,end.size()-1); - else - break; - } -} + // ------------------------------------------------------------------------------------------------ + CAHManager *CAHManager::_GlobalInstance = NULL; + // ------------------------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------------------------ -std::string IActionHandler::getParam (const string &Params, const string &ParamName) -{ - string allparam = Params; - skipBlankAtStart (allparam); - string param = toLower (ParamName); - while (allparam.size() > 0) + // ------------------------------------------------------------------------------------------------ + static void skipBlankAtStart (string &start) { - std::string::size_type e = allparam.find('='); - if (e == std::string::npos || e == 0) break; - std::string::size_type p = allparam.find('|'); - string tmp = NLMISC::toLower(allparam.substr(0,e)); - skipBlankAtEnd(tmp); - if (tmp == param) + while (!start.empty()) { + if ((start[0] == ' ' || start[0] == '\t' || start[0] == '\r' || start[0] == '\n')) + start = start.substr(1,start.size()); + else + break; + } + } + + // ------------------------------------------------------------------------------------------------ + static void skipBlankAtEnd (string &end) + { + while (!end.empty()) + { + if ((end[end.size()-1] == ' ' || end[end.size()-1] == '\t' || end[end.size()-1] == '\r' || end[end.size()-1] == '\n')) + end = end.substr(0,end.size()-1); + else + break; + } + } + + // ------------------------------------------------------------------------------------------------ + std::string IActionHandler::getParam (const string &Params, const string &ParamName) + { + string allparam = Params; + skipBlankAtStart (allparam); + string param = toLower (ParamName); + while (allparam.size() > 0) + { + std::string::size_type e = allparam.find('='); + if (e == std::string::npos || e == 0) break; + std::string::size_type p = allparam.find('|'); + string tmp = NLMISC::toLower(allparam.substr(0,e)); + skipBlankAtEnd(tmp); + if (tmp == param) + { + string tmp2 = allparam.substr(e+1,p-e-1); + skipBlankAtStart(tmp2); + skipBlankAtEnd(tmp2); + return tmp2; + } + if (p == std::string::npos || p == 0) break; + allparam = allparam.substr(p+1,allparam.size()); + skipBlankAtStart (allparam); + } + return ""; + } + + // ------------------------------------------------------------------------------------------------ + void IActionHandler::getAllParams (const string &Params, vector< pair > &vAllParams) + { + string allparam = Params; + skipBlankAtStart (allparam); + while (allparam.size() > 0) + { + std::string::size_type e = allparam.find('='); + if (e == std::string::npos || e == 0) break; + std::string::size_type p = allparam.find('|'); + string tmp = NLMISC::toLower(allparam.substr(0,e)); + skipBlankAtEnd(tmp); + string tmp2 = allparam.substr(e+1,p-e-1); skipBlankAtStart(tmp2); skipBlankAtEnd(tmp2); - return tmp2; - } - if (p == std::string::npos || p == 0) break; - allparam = allparam.substr(p+1,allparam.size()); - skipBlankAtStart (allparam); - } - return ""; -} -// ------------------------------------------------------------------------------------------------ -void IActionHandler::getAllParams (const string &Params, vector< pair > &vAllParams) -{ - string allparam = Params; - skipBlankAtStart (allparam); - while (allparam.size() > 0) - { - std::string::size_type e = allparam.find('='); - if (e == std::string::npos || e == 0) break; - std::string::size_type p = allparam.find('|'); - string tmp = NLMISC::toLower(allparam.substr(0,e)); - skipBlankAtEnd(tmp); + vAllParams.push_back(pair(tmp,tmp2)); - string tmp2 = allparam.substr(e+1,p-e-1); - skipBlankAtStart(tmp2); - skipBlankAtEnd(tmp2); - - vAllParams.push_back(pair(tmp,tmp2)); - - if (p == std::string::npos || p == 0) break; - allparam = allparam.substr(p+1,allparam.size()); - skipBlankAtStart (allparam); - } -} - -// ------------------------------------------------------------------------------------------------ -IActionHandler* CAHManager::getAH(const std::string &name, std::string ¶ms) -{ - // Special AH form? - string::size_type i= name.find(':'); - if(i!=string::npos) - { - string ahName= name.substr(0, i); - params= name.substr(i+1); - return getActionHandler(ahName); - } - // standalone form - else - return getActionHandler(name); -} - -// ------------------------------------------------------------------------------------------------ -IActionHandler* CAHManager::getAH(const std::string &name, CStringShared ¶ms) -{ - // Special AH form? - string::size_type i= name.find(':'); - if(i!=string::npos) - { - string ahName= name.substr(0, i); - params= name.substr(i+1); - return getActionHandler(ahName); - } - // standalone form - else - return getActionHandler(name); -} - -// ------------------------------------------------------------------------------------------------ -void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶mRet) -{ - CXMLAutoPtr prop; - - // Read the action handler and any param he defines - bool paramSpecifiedInAH= false; - if(ahId) - { - prop = (char*) xmlGetProp( cur, (xmlChar*)ahId ); - if (prop) - { - string ahVal= (const char*)prop; - if(ahVal.find(':')!= string::npos) - paramSpecifiedInAH= true; - ahRet = getAH(ahVal, paramRet); + if (p == std::string::npos || p == 0) break; + allparam = allparam.substr(p+1,allparam.size()); + skipBlankAtStart (allparam); } } - // Read parameter (if specified) - if(paramId) + // ------------------------------------------------------------------------------------------------ + IActionHandler* CAHManager::getAH(const std::string &name, std::string ¶ms) { - prop = (char*) xmlGetProp( cur, (xmlChar*)paramId ); - /* Precise stuff here (for legacy rules): - If the param is not specified in the ahId, then replace params. - But if it is specified, don't replace it if the prop is empty!! - Because this cause problems with template and parameter replacement. - */ - if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) ) - paramRet = string((const char*)prop); - } -} - -void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared ¶mRet) -{ - CXMLAutoPtr prop; - - // Read the action handler and any param he defines - bool paramSpecifiedInAH= false; - if(ahId) - { - prop = (char*) xmlGetProp( cur, (xmlChar*)ahId ); - if (prop) + // Special AH form? + string::size_type i= name.find(':'); + if(i!=string::npos) { - string ahVal= (const char*)prop; - if(ahVal.find(':')!= string::npos) - paramSpecifiedInAH= true; - ahRet = getAH(ahVal, paramRet); + string ahName= name.substr(0, i); + params= name.substr(i+1); + return getActionHandler(ahName); + } + // standalone form + else + return getActionHandler(name); + } + + // ------------------------------------------------------------------------------------------------ + IActionHandler* CAHManager::getAH(const std::string &name, CStringShared ¶ms) + { + // Special AH form? + string::size_type i= name.find(':'); + if(i!=string::npos) + { + string ahName= name.substr(0, i); + params= name.substr(i+1); + return getActionHandler(ahName); + } + // standalone form + else + return getActionHandler(name); + } + + // ------------------------------------------------------------------------------------------------ + void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶mRet) + { + CXMLAutoPtr prop; + + // Read the action handler and any param he defines + bool paramSpecifiedInAH= false; + if(ahId) + { + prop = (char*) xmlGetProp( cur, (xmlChar*)ahId ); + if (prop) + { + string ahVal= (const char*)prop; + if(ahVal.find(':')!= string::npos) + paramSpecifiedInAH= true; + ahRet = getAH(ahVal, paramRet); + } + } + + // Read parameter (if specified) + if(paramId) + { + prop = (char*) xmlGetProp( cur, (xmlChar*)paramId ); + /* Precise stuff here (for legacy rules): + If the param is not specified in the ahId, then replace params. + But if it is specified, don't replace it if the prop is empty!! + Because this cause problems with template and parameter replacement. + */ + if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) ) + paramRet = string((const char*)prop); } } - // Read parameter (if specified) - if(paramId) + void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared ¶mRet) { - prop = (char*) xmlGetProp( cur, (xmlChar*)paramId ); - /* Precise stuff here (for legacy rules): - If the param is not specified in the ahId, then replace params. - But if it is specified, don't replace it if the prop is empty!! - Because this cause problems with template and parameter replacement. - */ - if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) ) - paramRet = string((const char*)prop); - } -} + CXMLAutoPtr prop; -// ------------------------------------------------------------------------------------------------ -void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams) -{ - if (ahCmdLine.empty()) return; - - // Special AH form ("ah:params") ? - string::size_type i = ahCmdLine.find(':'); - string ahName; - string ahParams; - if(i!=string::npos) - { - ahName= ahCmdLine.substr(0, i); - ahParams= ahCmdLine.substr(i+1); - } - else - { - ahName= ahCmdLine; - } - - // Replace params if defined - if(!ahUserParams.empty()) - ahParams= ahUserParams; - - // Execute the action handler - map::iterator it = FactoryMap.find (ahName); - if (it == FactoryMap.end()) - { - nlwarning ("not found action handler : %s",ahName.c_str()); - return; - } - IActionHandler *pAH = it->second; - pAH->execute (pCaller, ahParams); - - // Quick Help - const string submitQuickHelp = "submit_quick_help"; - it = FactoryMap.find(submitQuickHelp); - if(it == FactoryMap.end()) - { - nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); - return; - } - pAH = it->second; - const std::string event = ahName + ":" + ahParams; - pAH->execute(NULL, event); -} - -// ------------------------------------------------------------------------------------------------ -void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params) -{ - if (pAH == NULL) - { - nlwarning ("no action handler"); - return; - } - pAH->execute (pCaller, Params); - string AHName = CAHManager::getInstance()->getAHName(pAH); - - // Quick Help - const string submitQuickHelp = "submit_quick_help"; - map::iterator it = FactoryMap.find (AHName); - it = FactoryMap.find(submitQuickHelp); - if(it == FactoryMap.end()) - { - nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); - return; - } - pAH = it->second; - const std::string event = AHName + ":" + Params; - pAH->execute(NULL, event); -} - - -// ------------------------------------------------------------------------------------------------ -class CAHSet : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - string dblink = getParam (Params, "dblink"); - string property = getParam (Params, "target_property"); - string propertyToEval = getParam (Params, "target"); - string expr = getParam (Params, "value"); - //nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str()); - CInterfaceExprValue value; - if (CInterfaceExpr::eval(expr, value, NULL)) + // Read the action handler and any param he defines + bool paramSpecifiedInAH= false; + if(ahId) { - if (!dblink.empty()) + prop = (char*) xmlGetProp( cur, (xmlChar*)ahId ); + if (prop) { - // Do not allow Write on SERVER: or LOCAL: - static const std::string dbServer= "SERVER:"; - static const std::string dbLocal= "LOCAL:"; - static const std::string dbLocalR2= "LOCAL:R2"; - if( (0==dblink.compare(0, dbServer.size(), dbServer)) || - (0==dblink.compare(0, dbLocal.size(), dbLocal)) - ) - { - if (0!=dblink.compare(0, dbLocalR2.size(), dbLocalR2)) - { - //nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); - nlstop; - return; - } - } - - string dblinkeval; - CInterfaceExpr::unpackDBentry(dblink.c_str(), NULL, dblinkeval); - if (!value.toInteger()) - { - nlwarning(" expression doesn't evaluate to a numerical value"); - } - CInterfaceProperty ip; - - if (!value.toInteger()) - { - nlwarning(" expression doesn't evaluate to a numerical value"); - } - if (ip.link (dblinkeval.c_str())) - { - ip.setSInt64(value.getInteger()); - } + string ahVal= (const char*)prop; + if(ahVal.find(':')!= string::npos) + paramSpecifiedInAH= true; + ahRet = getAH(ahVal, paramRet); } + } - if (!propertyToEval.empty()) - { - CInterfaceExprValue res; - if (!CInterfaceExpr::eval(propertyToEval, res, NULL)) return; - res.toString(); - property = res.getString(); - } + // Read parameter (if specified) + if(paramId) + { + prop = (char*) xmlGetProp( cur, (xmlChar*)paramId ); + /* Precise stuff here (for legacy rules): + If the param is not specified in the ahId, then replace params. + But if it is specified, don't replace it if the prop is empty!! + Because this cause problems with template and parameter replacement. + */ + if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) ) + paramRet = string((const char*)prop); + } + } + // ------------------------------------------------------------------------------------------------ + void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams) + { + if (ahCmdLine.empty()) return; - if (!property.empty()) - { - std::vector targets; - // find first enclosing group - CCtrlBase *currCtrl = pCaller; - CInterfaceGroup *ig = NULL; - while (currCtrl) - { - ig = dynamic_cast(currCtrl); - if (ig != NULL) break; - currCtrl = currCtrl->getParent(); - } - if (ig == NULL) - { - string elt = property.substr(0,property.rfind(':')); - CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); - ig = dynamic_cast(pIE); - if (ig == NULL && pIE != NULL) - ig = pIE->getParent(); - } - - if (ig != NULL) - { - CInterfaceLink::splitLinkTargets(property, ig, targets); - for(uint k = 0; k < targets.size(); ++k) - { - if (targets[k].Elem) targets[k].affect(value); - } - } - } + // Special AH form ("ah:params") ? + string::size_type i = ahCmdLine.find(':'); + string ahName; + string ahParams; + if(i!=string::npos) + { + ahName= ahCmdLine.substr(0, i); + ahParams= ahCmdLine.substr(i+1); } else { - nlwarning(" Couldn't evaluate expression to affect, expr = %s", expr.c_str()); + ahName= ahCmdLine; } - } -}; -REGISTER_ACTION_HANDLER (CAHSet, "set"); + // Replace params if defined + if(!ahUserParams.empty()) + ahParams= ahUserParams; -// ------------------------------------------------------------------------------------------------ -class CAHCopy : public IActionHandler -{ -public: - virtual void execute (CCtrlBase * /* pCaller */, const string &Params) - { - string dbdst = getParam (Params, "dbdst"); - string dbsrc = getParam (Params, "dbsrc"); - CCDBNodeBranch *pNBdst = NLGUI::CDBManager::getInstance()->getDbBranch(dbdst); - CCDBNodeBranch *pNBsrc = NLGUI::CDBManager::getInstance()->getDbBranch(dbsrc); - - // Branch copy - - if ((pNBdst != NULL) && (pNBsrc != NULL)) + // Execute the action handler + map::iterator it = FactoryMap.find (ahName); + if (it == FactoryMap.end()) { - //nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str()); + nlwarning ("not found action handler : %s",ahName.c_str()); + return; + } + IActionHandler *pAH = it->second; + pAH->execute (pCaller, ahParams); - // Parse all children of the src branch - uint nbLeaves = pNBsrc->countLeaves(); - for (uint i = 0; i < nbLeaves; ++i) + // Quick Help + const string submitQuickHelp = "submit_quick_help"; + it = FactoryMap.find(submitQuickHelp); + if(it == FactoryMap.end()) + { + nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); + return; + } + pAH = it->second; + const std::string event = ahName + ":" + ahParams; + pAH->execute(NULL, event); + } + + // ------------------------------------------------------------------------------------------------ + void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params) + { + if (pAH == NULL) + { + nlwarning ("no action handler"); + return; + } + pAH->execute (pCaller, Params); + string AHName = CAHManager::getInstance()->getAHName(pAH); + + // Quick Help + const string submitQuickHelp = "submit_quick_help"; + map::iterator it = FactoryMap.find (AHName); + it = FactoryMap.find(submitQuickHelp); + if(it == FactoryMap.end()) + { + nlwarning ("not found action handler : %s", submitQuickHelp.c_str()); + return; + } + pAH = it->second; + const std::string event = AHName + ":" + Params; + pAH->execute(NULL, event); + } + + + // ------------------------------------------------------------------------------------------------ + class CAHSet : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + string dblink = getParam (Params, "dblink"); + string property = getParam (Params, "target_property"); + string propertyToEval = getParam (Params, "target"); + string expr = getParam (Params, "value"); + //nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str()); + CInterfaceExprValue value; + if (CInterfaceExpr::eval(expr, value, NULL)) { - uint count = i; - CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count); - // Find its access name - string sTmp = *pNLsrc->getName(); - CCDBNodeBranch *pParent = pNLsrc->getParent(); - while (pParent != pNBsrc) + if (!dblink.empty()) { - sTmp = *pParent->getName() + ":" + sTmp; - pParent = pParent->getParent(); - } - // Find the correspondant node in the dst branch - CCDBNodeLeaf *pNLdst = dynamic_cast(pNBdst->getNode(ICDBNode::CTextId(sTmp))); - if (pNLdst == NULL) - { - nlwarning ("cannot find destination leaf %s",sTmp.c_str()); - } - else - { - pNLdst->setValue64(pNLsrc->getValue64()); + // Do not allow Write on SERVER: or LOCAL: + static const std::string dbServer= "SERVER:"; + static const std::string dbLocal= "LOCAL:"; + static const std::string dbLocalR2= "LOCAL:R2"; + if( (0==dblink.compare(0, dbServer.size(), dbServer)) || + (0==dblink.compare(0, dbLocal.size(), dbLocal)) + ) + { + if (0!=dblink.compare(0, dbLocalR2.size(), dbLocalR2)) + { + //nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database"); + nlstop; + return; + } + } - //sint32 nVal = pNLsrc->getValue64(); - //nlinfo("set value %d for node %s", nVal, sTmp.c_str()); + string dblinkeval; + CInterfaceExpr::unpackDBentry(dblink.c_str(), NULL, dblinkeval); + if (!value.toInteger()) + { + nlwarning(" expression doesn't evaluate to a numerical value"); + } + CInterfaceProperty ip; + + if (!value.toInteger()) + { + nlwarning(" expression doesn't evaluate to a numerical value"); + } + if (ip.link (dblinkeval.c_str())) + { + ip.setSInt64(value.getInteger()); + } + } + + if (!propertyToEval.empty()) + { + CInterfaceExprValue res; + if (!CInterfaceExpr::eval(propertyToEval, res, NULL)) return; + res.toString(); + property = res.getString(); + } + + + if (!property.empty()) + { + std::vector targets; + // find first enclosing group + CCtrlBase *currCtrl = pCaller; + CInterfaceGroup *ig = NULL; + while (currCtrl) + { + ig = dynamic_cast(currCtrl); + if (ig != NULL) break; + currCtrl = currCtrl->getParent(); + } + if (ig == NULL) + { + string elt = property.substr(0,property.rfind(':')); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); + ig = dynamic_cast(pIE); + if (ig == NULL && pIE != NULL) + ig = pIE->getParent(); + } + + if (ig != NULL) + { + CInterfaceLink::splitLinkTargets(property, ig, targets); + for(uint k = 0; k < targets.size(); ++k) + { + if (targets[k].Elem) targets[k].affect(value); + } + } } } - return; + else + { + nlwarning(" Couldn't evaluate expression to affect, expr = %s", expr.c_str()); + } } - - // Not branch copy so leaf copy - - CInterfaceProperty ipsrc; - CInterfaceProperty ipdst; - if (!ipsrc.link (dbsrc.c_str())) - { - nlwarning("cannot find leaf %s",dbsrc.c_str()); - return; - } - if (!ipdst.link (dbdst.c_str())) - { - nlwarning("cannot find leaf %s",dbdst.c_str()); - return; - } - // copy - ipdst.setSInt64 (ipsrc.getSInt64()); - } -}; -REGISTER_ACTION_HANDLER (CAHCopy, "copy"); + }; + REGISTER_ACTION_HANDLER (CAHSet, "set"); -// ------------------------------------------------------------------------------------------------ -class CAHResizeW : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const string &Params) + // ------------------------------------------------------------------------------------------------ + class CAHCopy : public IActionHandler { - string elt = getParam (Params, "elt"); - - sint32 value; - fromString(getParam(Params, "value"), value); - - sint32 limit; - fromString(getParam(Params, "limit"), limit); - - CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), elt); - if (pIE == NULL) return; - - sint32 newW = pIE->getW(); - newW += value; - if (value < 0) + public: + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { - if (newW < limit) - newW = limit; + string dbdst = getParam (Params, "dbdst"); + string dbsrc = getParam (Params, "dbsrc"); + CCDBNodeBranch *pNBdst = NLGUI::CDBManager::getInstance()->getDbBranch(dbdst); + CCDBNodeBranch *pNBsrc = NLGUI::CDBManager::getInstance()->getDbBranch(dbsrc); + + // Branch copy + + if ((pNBdst != NULL) && (pNBsrc != NULL)) + { + //nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str()); + + // Parse all children of the src branch + uint nbLeaves = pNBsrc->countLeaves(); + for (uint i = 0; i < nbLeaves; ++i) + { + uint count = i; + CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count); + // Find its access name + string sTmp = *pNLsrc->getName(); + CCDBNodeBranch *pParent = pNLsrc->getParent(); + while (pParent != pNBsrc) + { + sTmp = *pParent->getName() + ":" + sTmp; + pParent = pParent->getParent(); + } + // Find the correspondant node in the dst branch + CCDBNodeLeaf *pNLdst = dynamic_cast(pNBdst->getNode(ICDBNode::CTextId(sTmp))); + if (pNLdst == NULL) + { + nlwarning ("cannot find destination leaf %s",sTmp.c_str()); + } + else + { + pNLdst->setValue64(pNLsrc->getValue64()); + + //sint32 nVal = pNLsrc->getValue64(); + //nlinfo("set value %d for node %s", nVal, sTmp.c_str()); + } + } + return; + } + + // Not branch copy so leaf copy + + CInterfaceProperty ipsrc; + CInterfaceProperty ipdst; + if (!ipsrc.link (dbsrc.c_str())) + { + nlwarning("cannot find leaf %s",dbsrc.c_str()); + return; + } + if (!ipdst.link (dbdst.c_str())) + { + nlwarning("cannot find leaf %s",dbdst.c_str()); + return; + } + // copy + ipdst.setSInt64 (ipsrc.getSInt64()); } - else - { - if (newW > limit) - newW = limit; - } - pIE->setW (newW); - pIE->invalidateCoords(); - } -}; -REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w"); + }; + REGISTER_ACTION_HANDLER (CAHCopy, "copy"); -//////////////////////////////// -// EDITION OF CONTAINER ALPHA // -//////////////////////////////// -// the container whose alpha is being edited -static CGroupContainerBase *AlphaChooserTarget = NULL; -static bool OldUseGlobalAlpha; -static uint8 OldContentAlpha; -static uint8 OldBgAlpha; -static uint8 OldRolloverAlphaBG; -static uint8 OldRolloverAlphaContent; - -// observer to change the container alpha -class CContainerAlphaObserver : public ICDBNode::IPropertyObserver -{ -public: - bool On; - enum TTargetAlpha { ContentAlpha = 0, BgAlpha, RolloverAlphaContent, RolloverAlphaBG }; - TTargetAlpha Target; - virtual void update(ICDBNode *node) + // ------------------------------------------------------------------------------------------------ + class CAHResizeW : public IActionHandler { - if (!On) return; - if (!AlphaChooserTarget) return; - CCDBNodeLeaf *leaf = safe_cast(node); - switch(Target) + public: + virtual void execute (CCtrlBase *pCaller, const string &Params) { - case ContentAlpha: AlphaChooserTarget->setContentAlpha((uint8) leaf->getValue32()); break; - case BgAlpha: AlphaChooserTarget->setContainerAlpha((uint8) leaf->getValue32()); break; - case RolloverAlphaContent: AlphaChooserTarget->setRolloverAlphaContent((uint8) (255 - (uint8) leaf->getValue32())); break; - case RolloverAlphaBG: AlphaChooserTarget->setRolloverAlphaContainer((uint8) (255 - (uint8) leaf->getValue32())); break; + string elt = getParam (Params, "elt"); + + sint32 value; + fromString(getParam(Params, "value"), value); + + sint32 limit; + fromString(getParam(Params, "limit"), limit); + + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), elt); + if (pIE == NULL) return; + + sint32 newW = pIE->getW(); + newW += value; + if (value < 0) + { + if (newW < limit) + newW = limit; + } + else + { + if (newW > limit) + newW = limit; + } + pIE->setW (newW); + pIE->invalidateCoords(); } - } -}; + }; + REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w"); + //////////////////////////////// + // EDITION OF CONTAINER ALPHA // + //////////////////////////////// + // the container whose alpha is being edited + static CGroupContainerBase *AlphaChooserTarget = NULL; + static bool OldUseGlobalAlpha; + static uint8 OldContentAlpha; + static uint8 OldBgAlpha; + static uint8 OldRolloverAlphaBG; + static uint8 OldRolloverAlphaContent; -// ------------------------------------------------------------------------------------------------ -class CAHChooseUIAlpha : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + // observer to change the container alpha + class CContainerAlphaObserver : public ICDBNode::IPropertyObserver { - CGroupContainerBase *gc = NULL; - CCtrlBase *cb = pCaller; - while (cb) + public: + bool On; + enum TTargetAlpha { ContentAlpha = 0, BgAlpha, RolloverAlphaContent, RolloverAlphaBG }; + TTargetAlpha Target; + virtual void update(ICDBNode *node) { - gc = dynamic_cast(cb); - if (gc) break; - cb = cb->getParent(); + if (!On) return; + if (!AlphaChooserTarget) return; + CCDBNodeLeaf *leaf = safe_cast(node); + switch(Target) + { + case ContentAlpha: AlphaChooserTarget->setContentAlpha((uint8) leaf->getValue32()); break; + case BgAlpha: AlphaChooserTarget->setContainerAlpha((uint8) leaf->getValue32()); break; + case RolloverAlphaContent: AlphaChooserTarget->setRolloverAlphaContent((uint8) (255 - (uint8) leaf->getValue32())); break; + case RolloverAlphaBG: AlphaChooserTarget->setRolloverAlphaContainer((uint8) (255 - (uint8) leaf->getValue32())); break; + } } - if (!gc) return; - AlphaChooserTarget = gc; - if (!_AlphaObserversAdded) - { - _UiVariableBGAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_BG"); - _UiVariableContentAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_CONTENT"); - _UiVariableRolloverAlphaBG = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG"); - _UiVariableRolloverAlphaContent = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT"); - ICDBNode::CTextId textIdBGAlpha, textIdContentAlpha, textIdRolloverAlphaBG, textIdRolloverAlphaContent; - _UiVariableBGAlpha->addObserver(&_BgAlphaObs, textIdBGAlpha); - _UiVariableContentAlpha->addObserver(&_ContentAlphaObs, textIdContentAlpha); - _UiVariableRolloverAlphaBG->addObserver(&_RolloverAlphaBGObs, textIdRolloverAlphaBG); - _UiVariableRolloverAlphaContent->addObserver(&_RolloverAlphaContentObs, textIdRolloverAlphaContent); - _AlphaObserversAdded = true; - } - // disable observers - _ContentAlphaObs.On = false; - _BgAlphaObs.On = false; - _RolloverAlphaBGObs.On = false; - _RolloverAlphaContentObs.On = false; - // set alpha of current chosen container - _UiVariableBGAlpha->setValue32(gc->getContainerAlpha()); - _UiVariableContentAlpha->setValue32(gc->getContentAlpha()); - _UiVariableRolloverAlphaBG->setValue32(255 - gc->getRolloverAlphaContainer()); - _UiVariableRolloverAlphaContent->setValue32(255 - gc->getRolloverAlphaContent()); - // enable observers - _ContentAlphaObs.On = true; - _BgAlphaObs.On = true; - _RolloverAlphaBGObs.On = true; - _RolloverAlphaContentObs.On = true; - // backup current alpha (if the user cancel) - OldContentAlpha = gc->getContentAlpha(); - OldBgAlpha = gc->getContainerAlpha(); - OldRolloverAlphaBG = gc->getRolloverAlphaContainer(); - OldRolloverAlphaContent = gc->getRolloverAlphaContent(); - OldUseGlobalAlpha = gc->isUsingGlobalAlpha(); - // Enable 'use global alpha' button - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1); - // show the modal box - CWidgetManager::getInstance()->enableModalWindow(gc, "ui:interface:define_ui_transparency"); - - } + }; - CAHChooseUIAlpha() + + // ------------------------------------------------------------------------------------------------ + class CAHChooseUIAlpha : public IActionHandler { - _UiVariableContentAlpha = NULL; - _UiVariableBGAlpha = NULL; - _UiVariableRolloverAlphaBG = NULL; - _UiVariableRolloverAlphaContent = NULL; - _AlphaObserversAdded = false; - _BgAlphaObs.Target = CContainerAlphaObserver::BgAlpha; - _ContentAlphaObs.Target = CContainerAlphaObserver::ContentAlpha; - _RolloverAlphaBGObs.Target = CContainerAlphaObserver::RolloverAlphaBG; - _RolloverAlphaContentObs.Target = CContainerAlphaObserver::RolloverAlphaContent; - } -private: - // instance of observer to copy alpha from db to a container - CContainerAlphaObserver _ContentAlphaObs; - CContainerAlphaObserver _BgAlphaObs; - CContainerAlphaObserver _RolloverAlphaContentObs; - CContainerAlphaObserver _RolloverAlphaBGObs; - // flag to know if observer have been added - bool _AlphaObserversAdded; - // db leaf that contains alpha for the current container - CCDBNodeLeaf *_UiVariableContentAlpha; - CCDBNodeLeaf *_UiVariableBGAlpha; - CCDBNodeLeaf *_UiVariableRolloverAlphaContent; - CCDBNodeLeaf *_UiVariableRolloverAlphaBG; -}; -REGISTER_ACTION_HANDLER (CAHChooseUIAlpha, "choose_ui_alpha"); - -// ------------------------------------------------------------------------------------------------ -class CAHCancelChooseUIAlpha : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */) - { - if (AlphaChooserTarget) + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - AlphaChooserTarget->setUseGlobalAlpha(OldUseGlobalAlpha); - AlphaChooserTarget->setContainerAlpha(OldBgAlpha); - AlphaChooserTarget->setContentAlpha(OldContentAlpha); - AlphaChooserTarget->setRolloverAlphaContainer(OldRolloverAlphaBG); - AlphaChooserTarget->setRolloverAlphaContent(OldRolloverAlphaContent); - } - } -}; -REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha, "cancel_choose_ui_alpha"); + CGroupContainerBase *gc = NULL; + CCtrlBase *cb = pCaller; + while (cb) + { + gc = dynamic_cast(cb); + if (gc) break; + cb = cb->getParent(); + } + if (!gc) return; + AlphaChooserTarget = gc; + if (!_AlphaObserversAdded) + { + _UiVariableBGAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_BG"); + _UiVariableContentAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_CONTENT"); + _UiVariableRolloverAlphaBG = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG"); + _UiVariableRolloverAlphaContent = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT"); + ICDBNode::CTextId textIdBGAlpha, textIdContentAlpha, textIdRolloverAlphaBG, textIdRolloverAlphaContent; + _UiVariableBGAlpha->addObserver(&_BgAlphaObs, textIdBGAlpha); + _UiVariableContentAlpha->addObserver(&_ContentAlphaObs, textIdContentAlpha); + _UiVariableRolloverAlphaBG->addObserver(&_RolloverAlphaBGObs, textIdRolloverAlphaBG); + _UiVariableRolloverAlphaContent->addObserver(&_RolloverAlphaContentObs, textIdRolloverAlphaContent); + _AlphaObserversAdded = true; + } + // disable observers + _ContentAlphaObs.On = false; + _BgAlphaObs.On = false; + _RolloverAlphaBGObs.On = false; + _RolloverAlphaContentObs.On = false; + // set alpha of current chosen container + _UiVariableBGAlpha->setValue32(gc->getContainerAlpha()); + _UiVariableContentAlpha->setValue32(gc->getContentAlpha()); + _UiVariableRolloverAlphaBG->setValue32(255 - gc->getRolloverAlphaContainer()); + _UiVariableRolloverAlphaContent->setValue32(255 - gc->getRolloverAlphaContent()); + // enable observers + _ContentAlphaObs.On = true; + _BgAlphaObs.On = true; + _RolloverAlphaBGObs.On = true; + _RolloverAlphaContentObs.On = true; + // backup current alpha (if the user cancel) + OldContentAlpha = gc->getContentAlpha(); + OldBgAlpha = gc->getContainerAlpha(); + OldRolloverAlphaBG = gc->getRolloverAlphaContainer(); + OldRolloverAlphaContent = gc->getRolloverAlphaContent(); + OldUseGlobalAlpha = gc->isUsingGlobalAlpha(); + // Enable 'use global alpha' button + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1); + // show the modal box + CWidgetManager::getInstance()->enableModalWindow(gc, "ui:interface:define_ui_transparency"); -// ------------------------------------------------------------------------------------------------ -class CAHUseGlobalAlphaSettings : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */) - { - if (AlphaChooserTarget) + } + + + CAHChooseUIAlpha() { - AlphaChooserTarget->setUseGlobalAlpha(!AlphaChooserTarget->isUsingGlobalAlpha()); - NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1); + _UiVariableContentAlpha = NULL; + _UiVariableBGAlpha = NULL; + _UiVariableRolloverAlphaBG = NULL; + _UiVariableRolloverAlphaContent = NULL; + _AlphaObserversAdded = false; + _BgAlphaObs.Target = CContainerAlphaObserver::BgAlpha; + _ContentAlphaObs.Target = CContainerAlphaObserver::ContentAlpha; + _RolloverAlphaBGObs.Target = CContainerAlphaObserver::RolloverAlphaBG; + _RolloverAlphaContentObs.Target = CContainerAlphaObserver::RolloverAlphaContent; } - } -}; -REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings, "use_global_alpha_settings"); + private: + // instance of observer to copy alpha from db to a container + CContainerAlphaObserver _ContentAlphaObs; + CContainerAlphaObserver _BgAlphaObs; + CContainerAlphaObserver _RolloverAlphaContentObs; + CContainerAlphaObserver _RolloverAlphaBGObs; + // flag to know if observer have been added + bool _AlphaObserversAdded; + // db leaf that contains alpha for the current container + CCDBNodeLeaf *_UiVariableContentAlpha; + CCDBNodeLeaf *_UiVariableBGAlpha; + CCDBNodeLeaf *_UiVariableRolloverAlphaContent; + CCDBNodeLeaf *_UiVariableRolloverAlphaBG; + }; + REGISTER_ACTION_HANDLER (CAHChooseUIAlpha, "choose_ui_alpha"); - -// ------------------------------------------------------------------------------------------------ -class CAHLockUnlock : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + // ------------------------------------------------------------------------------------------------ + class CAHCancelChooseUIAlpha : public IActionHandler { - CGroupContainerBase *gc = NULL; - CCtrlBase *cb = pCaller; - while (cb) + virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */) { - gc = dynamic_cast< CGroupContainerBase* >(cb); - if (gc) break; - cb = cb->getParent(); + if (AlphaChooserTarget) + { + AlphaChooserTarget->setUseGlobalAlpha(OldUseGlobalAlpha); + AlphaChooserTarget->setContainerAlpha(OldBgAlpha); + AlphaChooserTarget->setContentAlpha(OldContentAlpha); + AlphaChooserTarget->setRolloverAlphaContainer(OldRolloverAlphaBG); + AlphaChooserTarget->setRolloverAlphaContent(OldRolloverAlphaContent); + } } - if (!gc) return; - //gc->setMovable(!gc->isMovable()); - gc->setLocked(!gc->isLocked()); - } -}; -REGISTER_ACTION_HANDLER (CAHLockUnlock, "lock_unlock"); + }; + REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha, "cancel_choose_ui_alpha"); -// ------------------------------------------------------------------------------------------------ -class CAHSetTransparent : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + // ------------------------------------------------------------------------------------------------ + class CAHUseGlobalAlphaSettings : public IActionHandler { - CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params)); - if (pGC != NULL) + virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */) { - pGC->setUseGlobalAlpha(false); - pGC->setContainerAlpha((uint8) 0); - pGC->setContentAlpha((uint8) 255); - pGC->setRolloverAlphaContainer((uint8) 255); - pGC->setRolloverAlphaContent((uint8) 0); + if (AlphaChooserTarget) + { + AlphaChooserTarget->setUseGlobalAlpha(!AlphaChooserTarget->isUsingGlobalAlpha()); + NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1); + } } - } -}; -REGISTER_ACTION_HANDLER (CAHSetTransparent, "set_transparent"); + }; + REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings, "use_global_alpha_settings"); -// ------------------------------------------------------------------------------------------------ -class CAHSetAlpha : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + + // ------------------------------------------------------------------------------------------------ + class CAHLockUnlock : public IActionHandler { - string ui = getParam (Params, "target"); - - uint8 alpha; - fromString(getParam (Params, "alpha"), alpha); - - CGroupContainerBase *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(ui)); - if (pGC != NULL) + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - pGC->setUseGlobalAlpha(false); - pGC->setContainerAlpha((uint8) alpha); - pGC->setContentAlpha((uint8) 255); - pGC->setRolloverAlphaContainer((uint8) 0); - pGC->setRolloverAlphaContent((uint8) 0); + CGroupContainerBase *gc = NULL; + CCtrlBase *cb = pCaller; + while (cb) + { + gc = dynamic_cast< CGroupContainerBase* >(cb); + if (gc) break; + cb = cb->getParent(); + } + if (!gc) return; + //gc->setMovable(!gc->isMovable()); + gc->setLocked(!gc->isLocked()); } - } -}; -REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha"); + }; + REGISTER_ACTION_HANDLER (CAHLockUnlock, "lock_unlock"); -// ------------------------------------------------------------------------------------------------ -class CAHUnlockAllContainer : public IActionHandler -{ - virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + // ------------------------------------------------------------------------------------------------ + class CAHSetTransparent : public IActionHandler { - const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); - for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { -// const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; - CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers(); + CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params)); + if (pGC != NULL) + { + pGC->setUseGlobalAlpha(false); + pGC->setContainerAlpha((uint8) 0); + pGC->setContentAlpha((uint8) 255); + pGC->setRolloverAlphaContainer((uint8) 255); + pGC->setRolloverAlphaContent((uint8) 0); + } } - } -}; -REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container"); + }; + REGISTER_ACTION_HANDLER (CAHSetTransparent, "set_transparent"); + + // ------------------------------------------------------------------------------------------------ + class CAHSetAlpha : public IActionHandler + { + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + { + string ui = getParam (Params, "target"); + + uint8 alpha; + fromString(getParam (Params, "alpha"), alpha); + + CGroupContainerBase *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(ui)); + if (pGC != NULL) + { + pGC->setUseGlobalAlpha(false); + pGC->setContainerAlpha((uint8) alpha); + pGC->setContentAlpha((uint8) 255); + pGC->setRolloverAlphaContainer((uint8) 0); + pGC->setRolloverAlphaContent((uint8) 0); + } + } + }; + REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha"); + + // ------------------------------------------------------------------------------------------------ + class CAHUnlockAllContainer : public IActionHandler + { + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + const vector &rVMG = CWidgetManager::getInstance()->getAllMasterGroup(); + for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++) + { + // const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup]; + CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers(); + } + } + }; + REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container"); + +} \ No newline at end of file diff --git a/code/nel/src/gui/ctrl_base.cpp b/code/nel/src/gui/ctrl_base.cpp index 2577fba21..38871b286 100644 --- a/code/nel/src/gui/ctrl_base.cpp +++ b/code/nel/src/gui/ctrl_base.cpp @@ -24,200 +24,204 @@ using namespace NLMISC; -// *************************************************************************** -CCtrlBase::~CCtrlBase() +namespace NLGUI { - CWidgetManager::getInstance()->removeRefOnCtrl (this); -} -// *************************************************************************** -bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event) -{ - if (event.getType() == NLGUI::CEventDescriptor::system) + // *************************************************************************** + CCtrlBase::~CCtrlBase() { - NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; - if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) + CWidgetManager::getInstance()->removeRefOnCtrl (this); + } + + // *************************************************************************** + bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event) + { + if (event.getType() == NLGUI::CEventDescriptor::system) { - if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive()) + NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) { - // the mouse capture should be lost when the ctrl is hidden - if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) + if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive()) { - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + // the mouse capture should be lost when the ctrl is hidden + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) + { + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + } + if (CWidgetManager::getInstance()->getCapturePointerRight() == this) + { + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + } + // NB : don't call return here because derived class may be interested + // in handling event more speciffically } - if (CWidgetManager::getInstance()->getCapturePointerRight() == this) - { - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - } - // NB : don't call return here because derived class may be interested - // in handling event more speciffically + } + } + return false; + } + + // *************************************************************************** + bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if(!CViewBase::parse(cur, parentGroup)) + return false; + + CXMLAutoPtr prop; + + // get static toolTip + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" ); + if (prop) + { + const char *propPtr = prop; + + _ContextHelp = ucstring(propPtr); + + if (strlen(propPtr) > 2) + { + if ((propPtr[0] == 'u') && (propPtr[1] == 'i')) + _ContextHelp = CI18N::get ((const char *) prop); + } + } + // Force I18N tooltip + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" ); + if ((bool)prop && strlen((const char*)prop)>0) + { + _ContextHelp = CI18N::get ((const char *) prop); + } + + // get dynamic toolTip ActionHandler + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" ); + if (prop) + { + _OnContextHelp= (const char*)prop; + } + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" ); + if (prop) + { + _OnContextHelpParams= (const char*)prop; + } + + // Tooltip parent + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" ); + _ToolTipParent= TTCtrl; + if(prop) + { + if(stricmp((const char*)prop, "win")==0) + _ToolTipParent= TTWindow; + else if(stricmp((const char*)prop, "mouse")==0) + _ToolTipParent= TTMouse; + else if(stricmp((const char*)prop, "special")==0) + _ToolTipParent= TTSpecialWindow; + else + _ToolTipParent= TTCtrl; + } + + // Tooltip special parent + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" ); + _ToolTipSpecialParent= CStringShared(); + if(prop) + { + _ToolTipSpecialParent= std::string((const char*)prop); + } + + // Tooltip posref + THotSpot tmpParentHS, tmpChildHS; + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" ); + convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS); + _ToolTipParentPosRef= tmpParentHS; + _ToolTipPosRef= tmpChildHS; + + // Alternative tooltip posref : this one will be chosen + prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" ); + convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS); + _ToolTipParentPosRefAlt = tmpParentHS; + _ToolTipPosRefAlt = tmpChildHS; + + // ToolTip instant + prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help"); + _ToolTipInstant= true; + if (prop) _ToolTipInstant = convertBool(prop); + + return true; + } + + // *************************************************************************** + void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS) + { + parentHS = Hotspot_TTAuto; + childHS = Hotspot_TTAuto; + if(prop) + { + const char *ptr= (const char*)prop; + if(stricmp(ptr, "auto")==0) + { + parentHS = Hotspot_TTAuto; + childHS = Hotspot_TTAuto; + } + // valid ref? + else if(strlen(ptr)>=5) + { + THotSpot parentPosRef; + THotSpot posRef; + CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef); + parentHS = parentPosRef; + childHS = posRef; } } } - return false; -} -// *************************************************************************** -bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if(!CViewBase::parse(cur, parentGroup)) - return false; - CXMLAutoPtr prop; - - // get static toolTip - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" ); - if (prop) + // *************************************************************************** + bool CCtrlBase::emptyContextHelp() const { - const char *propPtr = prop; - - _ContextHelp = ucstring(propPtr); - - if (strlen(propPtr) > 2) - { - if ((propPtr[0] == 'u') && (propPtr[1] == 'i')) - _ContextHelp = CI18N::get ((const char *) prop); - } - } - // Force I18N tooltip - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" ); - if ((bool)prop && strlen((const char*)prop)>0) - { - _ContextHelp = CI18N::get ((const char *) prop); + ucstring help; + getContextHelp(help); + std::string sTmp = _OnContextHelp; + return help.empty() && sTmp.empty(); } - // get dynamic toolTip ActionHandler - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" ); - if (prop) + // *************************************************************************** + void CCtrlBase::visit(CInterfaceElementVisitor *visitor) { - _OnContextHelp= (const char*)prop; - } - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" ); - if (prop) - { - _OnContextHelpParams= (const char*)prop; + nlassert(visitor); + visitor->visitCtrl(this); + CInterfaceElement::visit(visitor); } - // Tooltip parent - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" ); - _ToolTipParent= TTCtrl; - if(prop) + // *************************************************************************** + void CCtrlBase::serial(NLMISC::IStream &f) { - if(stricmp((const char*)prop, "win")==0) - _ToolTipParent= TTWindow; - else if(stricmp((const char*)prop, "mouse")==0) - _ToolTipParent= TTMouse; - else if(stricmp((const char*)prop, "special")==0) - _ToolTipParent= TTSpecialWindow; - else - _ToolTipParent= TTCtrl; + CViewBase::serial(f); + f.serial(_ContextHelp); + f.serial(_OnContextHelp); + f.serial(_OnContextHelpParams); + f.serial(_ToolTipSpecialParent); + f.serialEnum(_ToolTipParent); + // + + THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef; + THotSpot tmpToolTipPosRef = _ToolTipPosRef; + THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt; + THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt; + + f.serialEnum(tmpToolTipParentPosRef); + f.serialEnum(tmpToolTipPosRef); + f.serialEnum(tmpToolTipParentPosRefAlt); + f.serialEnum(tmpToolTipPosRefAlt); + + _ToolTipParentPosRef = tmpToolTipParentPosRef; + _ToolTipPosRef = tmpToolTipPosRef; + _ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt; + _ToolTipPosRefAlt = tmpToolTipPosRefAlt; + // + nlSerialBitBool(f, _ToolTipInstant); } - // Tooltip special parent - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" ); - _ToolTipSpecialParent= CStringShared(); - if(prop) + // *************************************************************************** + std::string CCtrlBase::getContextHelpWindowName() const { - _ToolTipSpecialParent= std::string((const char*)prop); + return "context_help"; } - // Tooltip posref - THotSpot tmpParentHS, tmpChildHS; - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" ); - convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS); - _ToolTipParentPosRef= tmpParentHS; - _ToolTipPosRef= tmpChildHS; - - // Alternative tooltip posref : this one will be chosen - prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" ); - convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS); - _ToolTipParentPosRefAlt = tmpParentHS; - _ToolTipPosRefAlt = tmpChildHS; - - // ToolTip instant - prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help"); - _ToolTipInstant= true; - if (prop) _ToolTipInstant = convertBool(prop); - - return true; } -// *************************************************************************** -void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS) -{ - parentHS = Hotspot_TTAuto; - childHS = Hotspot_TTAuto; - if(prop) - { - const char *ptr= (const char*)prop; - if(stricmp(ptr, "auto")==0) - { - parentHS = Hotspot_TTAuto; - childHS = Hotspot_TTAuto; - } - // valid ref? - else if(strlen(ptr)>=5) - { - THotSpot parentPosRef; - THotSpot posRef; - CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef); - parentHS = parentPosRef; - childHS = posRef; - } - } -} - - -// *************************************************************************** -bool CCtrlBase::emptyContextHelp() const -{ - ucstring help; - getContextHelp(help); - std::string sTmp = _OnContextHelp; - return help.empty() && sTmp.empty(); -} - -// *************************************************************************** -void CCtrlBase::visit(CInterfaceElementVisitor *visitor) -{ - nlassert(visitor); - visitor->visitCtrl(this); - CInterfaceElement::visit(visitor); -} - -// *************************************************************************** -void CCtrlBase::serial(NLMISC::IStream &f) -{ - CViewBase::serial(f); - f.serial(_ContextHelp); - f.serial(_OnContextHelp); - f.serial(_OnContextHelpParams); - f.serial(_ToolTipSpecialParent); - f.serialEnum(_ToolTipParent); - // - - THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef; - THotSpot tmpToolTipPosRef = _ToolTipPosRef; - THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt; - THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt; - - f.serialEnum(tmpToolTipParentPosRef); - f.serialEnum(tmpToolTipPosRef); - f.serialEnum(tmpToolTipParentPosRefAlt); - f.serialEnum(tmpToolTipPosRefAlt); - - _ToolTipParentPosRef = tmpToolTipParentPosRef; - _ToolTipPosRef = tmpToolTipPosRef; - _ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt; - _ToolTipPosRefAlt = tmpToolTipPosRefAlt; - // - nlSerialBitBool(f, _ToolTipInstant); -} - -// *************************************************************************** -std::string CCtrlBase::getContextHelpWindowName() const -{ - return "context_help"; -} - - diff --git a/code/nel/src/gui/ctrl_draggable.cpp b/code/nel/src/gui/ctrl_draggable.cpp index 0e38d5c8f..b833fa547 100644 --- a/code/nel/src/gui/ctrl_draggable.cpp +++ b/code/nel/src/gui/ctrl_draggable.cpp @@ -1,11 +1,32 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/ctrl_draggable.h" -CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL; - -CCtrlDraggable::CCtrlDraggable(const TCtorParam ¶m) : -CCtrlBase( param ) +namespace NLGUI { - dragged = false; - draggable = false; -} + CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL; + + CCtrlDraggable::CCtrlDraggable(const TCtorParam ¶m) : + CCtrlBase( param ) + { + dragged = false; + draggable = false; + } + +} \ No newline at end of file diff --git a/code/nel/src/gui/ctrl_scroll_base.cpp b/code/nel/src/gui/ctrl_scroll_base.cpp index a3ed058ac..57932af6b 100644 --- a/code/nel/src/gui/ctrl_scroll_base.cpp +++ b/code/nel/src/gui/ctrl_scroll_base.cpp @@ -16,51 +16,57 @@ #include "nel/gui/ctrl_scroll_base.h" -CCtrlScrollBase::CCtrlScrollBase( const TCtorParam ¶m ) : -CCtrlBase( param ) +namespace NLGUI { - _Target = NULL; + + CCtrlScrollBase::CCtrlScrollBase( const TCtorParam ¶m ) : + CCtrlBase( param ) + { + _Target = NULL; + } + + CCtrlScrollBase::~CCtrlScrollBase() + { + } + + void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + + sint32 CCtrlScrollBase::moveTrackX( sint32 dx ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; + } + + sint32 CCtrlScrollBase::moveTrackY( sint32 dy ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; + } + + void CCtrlScrollBase::moveTargetX( sint32 dx ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + + void CCtrlScrollBase::moveTargetY( sint32 dy ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + } -CCtrlScrollBase::~CCtrlScrollBase() -{ -} - -void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); -} - -sint32 CCtrlScrollBase::moveTrackX( sint32 dx ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); - - return 0; -} - -sint32 CCtrlScrollBase::moveTrackY( sint32 dy ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); - - return 0; -} - -void CCtrlScrollBase::moveTargetX( sint32 dx ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); -} - -void CCtrlScrollBase::moveTargetY( sint32 dy ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); -} \ No newline at end of file diff --git a/code/nel/src/gui/group_container_base.cpp b/code/nel/src/gui/group_container_base.cpp index 9946f5e0c..7ef134c8a 100644 --- a/code/nel/src/gui/group_container_base.cpp +++ b/code/nel/src/gui/group_container_base.cpp @@ -17,76 +17,81 @@ #include "nel/gui/group_container_base.h" -CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : -CInterfaceGroup( param ) +namespace NLGUI { - _ContentAlpha = 255; - _ContainerAlpha = 255; - _RolloverAlphaContainer = 0; - _RolloverAlphaContent = 0; - _Locked = false; - _UseGlobalAlpha = true; -} - -CGroupContainerBase::~CGroupContainerBase() -{ -} - -void CGroupContainerBase::removeAllContainers() -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); -} - -void CGroupContainerBase::setLocked( bool locked ) -{ - // Necessary because it's supposed to be an abstract class, - // however reflection requires the class to be instantiated. - nlassert( false ); -} - - -// *************************************************************************** -void CGroupContainerBase::triggerAlphaSettingsChangedAH() -{ - if (_AHOnAlphaSettingsChanged != NULL) - CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); -} - - -// *************************************************************************** -void CGroupContainerBase::setUseGlobalAlpha(bool use) -{ - _UseGlobalAlpha = use; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainerBase::setContainerAlpha(uint8 alpha) -{ - _ContainerAlpha = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainerBase::setContentAlpha(uint8 alpha) -{ - _ContentAlpha = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha) -{ - _RolloverAlphaContent = alpha; - triggerAlphaSettingsChangedAH(); -} - -// *************************************************************************** -void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha) -{ - _RolloverAlphaContainer = alpha; - triggerAlphaSettingsChangedAH(); + + CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : + CInterfaceGroup( param ) + { + _ContentAlpha = 255; + _ContainerAlpha = 255; + _RolloverAlphaContainer = 0; + _RolloverAlphaContent = 0; + _Locked = false; + _UseGlobalAlpha = true; + } + + CGroupContainerBase::~CGroupContainerBase() + { + } + + void CGroupContainerBase::removeAllContainers() + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + + void CGroupContainerBase::setLocked( bool locked ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + + + // *************************************************************************** + void CGroupContainerBase::triggerAlphaSettingsChangedAH() + { + if (_AHOnAlphaSettingsChanged != NULL) + CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams); + } + + + // *************************************************************************** + void CGroupContainerBase::setUseGlobalAlpha(bool use) + { + _UseGlobalAlpha = use; + triggerAlphaSettingsChangedAH(); + } + + // *************************************************************************** + void CGroupContainerBase::setContainerAlpha(uint8 alpha) + { + _ContainerAlpha = alpha; + triggerAlphaSettingsChangedAH(); + } + + // *************************************************************************** + void CGroupContainerBase::setContentAlpha(uint8 alpha) + { + _ContentAlpha = alpha; + triggerAlphaSettingsChangedAH(); + } + + // *************************************************************************** + void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha) + { + _RolloverAlphaContent = alpha; + triggerAlphaSettingsChangedAH(); + } + + // *************************************************************************** + void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha) + { + _RolloverAlphaContainer = alpha; + triggerAlphaSettingsChangedAH(); + } + } diff --git a/code/nel/src/gui/group_editbox_base.cpp b/code/nel/src/gui/group_editbox_base.cpp index 3c67d7d2f..7eafd22aa 100644 --- a/code/nel/src/gui/group_editbox_base.cpp +++ b/code/nel/src/gui/group_editbox_base.cpp @@ -1,14 +1,36 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_editbox_base.h" -CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; - -CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam ¶m ) : -CInterfaceGroup( param ) -{ - _RecoverFocusOnEnter = true; -} - -CGroupEditBoxBase::~CGroupEditBoxBase() +namespace NLGUI { + + CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; + + CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam ¶m ) : + CInterfaceGroup( param ) + { + _RecoverFocusOnEnter = true; + } + + CGroupEditBoxBase::~CGroupEditBoxBase() + { + } + } diff --git a/code/nel/src/gui/group_frame.cpp b/code/nel/src/gui/group_frame.cpp index e8fbfa228..9f8e7ab1d 100644 --- a/code/nel/src/gui/group_frame.cpp +++ b/code/nel/src/gui/group_frame.cpp @@ -24,226 +24,232 @@ using namespace std; using namespace NLMISC; -NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame"); - -// *************************************************************************** -vector CGroupFrame::_DispTypes; - -// *************************************************************************** -CGroupFrame::CGroupFrame(const TCtorParam ¶m) -: CInterfaceGroup(param) +namespace NLGUI { - _DisplayFrame = true; - _Color = CRGBA(255,255,255,255); - _DispType = 0; - _DisplayFrameDefined= false; - _ColorDefined= false; - _DispTypeDefined= false; -} -// *************************************************************************** -bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if(!CInterfaceGroup::parse(cur, parentGroup)) - return false; + NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame"); - // display - CXMLAutoPtr ptr((const char*) xmlGetProp (cur, (xmlChar*)"display")); - _DisplayFrame = true; - _DisplayFrameDefined= false; - if (ptr) + // *************************************************************************** + vector CGroupFrame::_DispTypes; + + // *************************************************************************** + CGroupFrame::CGroupFrame(const TCtorParam ¶m) + : CInterfaceGroup(param) { - _DisplayFrame = convertBool (ptr); - _DisplayFrameDefined= true; + _DisplayFrame = true; + _Color = CRGBA(255,255,255,255); + _DispType = 0; + _DisplayFrameDefined= false; + _ColorDefined= false; + _DispTypeDefined= false; } - // color - ptr = (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _Color = CRGBA(255,255,255,255); - _ColorDefined= false; - if (ptr) + // *************************************************************************** + bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) { - _Color = convertColor (ptr); - _ColorDefined= true; - } + if(!CInterfaceGroup::parse(cur, parentGroup)) + return false; - // Get the borders texture - _DispTypeDefined= false; - CViewRenderer &rVR = *CViewRenderer::getInstance(); + // display + CXMLAutoPtr ptr((const char*) xmlGetProp (cur, (xmlChar*)"display")); + _DisplayFrame = true; + _DisplayFrameDefined= false; + if (ptr) + { + _DisplayFrame = convertBool (ptr); + _DisplayFrameDefined= true; + } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" ); - CInterfaceOptions *pIO = NULL; + // color + ptr = (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _Color = CRGBA(255,255,255,255); + _ColorDefined= false; + if (ptr) + { + _Color = convertColor (ptr); + _ColorDefined= true; + } - if (ptr) - pIO = CWidgetManager::getInstance()->getOptions(ptr); + // Get the borders texture + _DispTypeDefined= false; + CViewRenderer &rVR = *CViewRenderer::getInstance(); - // The first type in display type struct is the default display type - if (_DispTypes.size() == 0) - { - SDisplayType dt; - dt.Name = "default"; - // get texture ids. - dt.BorderIds[TextTL]= rVR.getTextureIdFromName ("w_modal_tl.tga"); - dt.BorderIds[TextTM]= rVR.getTextureIdFromName ("w_modal_t.tga"); - dt.BorderIds[TextTR]= rVR.getTextureIdFromName ("w_modal_tr.tga"); - // middle - dt.BorderIds[TextML]= rVR.getTextureIdFromName ("w_modal_l.tga"); - dt.BorderIds[TextMM]= rVR.getTextureIdFromName ("w_modal_blank.tga"); - dt.BorderIds[TextMR]= rVR.getTextureIdFromName ("w_modal_r.tga"); - // bottom - dt.BorderIds[TextBL]= rVR.getTextureIdFromName ("w_modal_bl.tga"); - dt.BorderIds[TextBM]= rVR.getTextureIdFromName ("w_modal_b.tga"); - dt.BorderIds[TextBR]= rVR.getTextureIdFromName ("w_modal_br.tga"); - // get size - rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder); - rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder); - _DispTypes.push_back(dt); - } + ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" ); + CInterfaceOptions *pIO = NULL; - if (pIO != NULL) - { - _DispTypeDefined= true; + if (ptr) + pIO = CWidgetManager::getInstance()->getOptions(ptr); - // Look if we find the type... - uint32 i; - for (i = 0; i < _DispTypes.size(); ++i) - if (_DispTypes[i].Name == string((const char*)ptr)) - break; - - if (i == _DispTypes.size()) + // The first type in display type struct is the default display type + if (_DispTypes.size() == 0) { SDisplayType dt; - dt.Name = string((const char*)ptr); + dt.Name = "default"; // get texture ids. - dt.BorderIds[TextTL]= rVR.getTextureIdFromName (pIO->getValStr("tx_tl")); - dt.BorderIds[TextTM]= rVR.getTextureIdFromName (pIO->getValStr("tx_t")); - dt.BorderIds[TextTR]= rVR.getTextureIdFromName (pIO->getValStr("tx_tr")); + dt.BorderIds[TextTL]= rVR.getTextureIdFromName ("w_modal_tl.tga"); + dt.BorderIds[TextTM]= rVR.getTextureIdFromName ("w_modal_t.tga"); + dt.BorderIds[TextTR]= rVR.getTextureIdFromName ("w_modal_tr.tga"); // middle - dt.BorderIds[TextML]= rVR.getTextureIdFromName (pIO->getValStr("tx_l")); - dt.BorderIds[TextMM]= rVR.getTextureIdFromName (pIO->getValStr("tx_blank")); - dt.BorderIds[TextMR]= rVR.getTextureIdFromName (pIO->getValStr("tx_r")); + dt.BorderIds[TextML]= rVR.getTextureIdFromName ("w_modal_l.tga"); + dt.BorderIds[TextMM]= rVR.getTextureIdFromName ("w_modal_blank.tga"); + dt.BorderIds[TextMR]= rVR.getTextureIdFromName ("w_modal_r.tga"); // bottom - dt.BorderIds[TextBL]= rVR.getTextureIdFromName (pIO->getValStr("tx_bl")); - dt.BorderIds[TextBM]= rVR.getTextureIdFromName (pIO->getValStr("tx_b")); - dt.BorderIds[TextBR]= rVR.getTextureIdFromName (pIO->getValStr("tx_br")); - - // Tile - dt.TileBorder[TextTM] = (uint8)pIO->getValSInt32("tile_t"); - dt.TileBorder[TextML] = (uint8)pIO->getValSInt32("tile_l"); - dt.TileBorder[TextMM] = (uint8)pIO->getValSInt32("tile_blank"); - dt.TileBorder[TextMR] = (uint8)pIO->getValSInt32("tile_r"); - dt.TileBorder[TextBM] = (uint8)pIO->getValSInt32("tile_b"); - + dt.BorderIds[TextBL]= rVR.getTextureIdFromName ("w_modal_bl.tga"); + dt.BorderIds[TextBM]= rVR.getTextureIdFromName ("w_modal_b.tga"); + dt.BorderIds[TextBR]= rVR.getTextureIdFromName ("w_modal_br.tga"); // get size rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder); rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder); _DispTypes.push_back(dt); } - _DispType = (uint8)i; - } - else - { - _DispType = 0; - } - - return true; -} - - -// *************************************************************************** -void CGroupFrame::draw () -{ - if (_DisplayFrame) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - // get global color - CRGBA col; - if(getModulateGlobalColor()) - col.modulateFromColor( _Color, CWidgetManager::getInstance()->getGlobalColor() ); - else - col= _Color; - - // draw the background - sint xId = 0, yId = 0; - for (yId = 0; yId < 3; yId++) + if (pIO != NULL) { - for (xId = 0; xId < 3; xId++) + _DispTypeDefined= true; + + // Look if we find the type... + uint32 i; + for (i = 0; i < _DispTypes.size(); ++i) + if (_DispTypes[i].Name == string((const char*)ptr)) + break; + + if (i == _DispTypes.size()) { - sint32 x = _XReal; - sint32 y = _YReal; - sint32 w, h; - // top - if (yId == 0) - { - y += _HReal-_DispTypes[_DispType].TopBorder; - h = _DispTypes[_DispType].TopBorder; - } - // Middle - else if (yId == 1) - { - y += _DispTypes[_DispType].BottomBorder; - h = _HReal-_DispTypes[_DispType].TopBorder-_DispTypes[_DispType].BottomBorder; - } - // Bottom - else - { - h = _DispTypes[_DispType].BottomBorder; - } + SDisplayType dt; + dt.Name = string((const char*)ptr); + // get texture ids. + dt.BorderIds[TextTL]= rVR.getTextureIdFromName (pIO->getValStr("tx_tl")); + dt.BorderIds[TextTM]= rVR.getTextureIdFromName (pIO->getValStr("tx_t")); + dt.BorderIds[TextTR]= rVR.getTextureIdFromName (pIO->getValStr("tx_tr")); + // middle + dt.BorderIds[TextML]= rVR.getTextureIdFromName (pIO->getValStr("tx_l")); + dt.BorderIds[TextMM]= rVR.getTextureIdFromName (pIO->getValStr("tx_blank")); + dt.BorderIds[TextMR]= rVR.getTextureIdFromName (pIO->getValStr("tx_r")); + // bottom + dt.BorderIds[TextBL]= rVR.getTextureIdFromName (pIO->getValStr("tx_bl")); + dt.BorderIds[TextBM]= rVR.getTextureIdFromName (pIO->getValStr("tx_b")); + dt.BorderIds[TextBR]= rVR.getTextureIdFromName (pIO->getValStr("tx_br")); - // Left - if (xId == 0) - { - w = _DispTypes[_DispType].LeftBorder; - } - else if (xId == 1) - { - x += _DispTypes[_DispType].LeftBorder; - w = _WReal-_DispTypes[_DispType].LeftBorder-_DispTypes[_DispType].RightBorder; - } - else - { - x += _WReal-_DispTypes[_DispType].RightBorder; - w = _DispTypes[_DispType].RightBorder; - } + // Tile + dt.TileBorder[TextTM] = (uint8)pIO->getValSInt32("tile_t"); + dt.TileBorder[TextML] = (uint8)pIO->getValSInt32("tile_l"); + dt.TileBorder[TextMM] = (uint8)pIO->getValSInt32("tile_blank"); + dt.TileBorder[TextMR] = (uint8)pIO->getValSInt32("tile_r"); + dt.TileBorder[TextBM] = (uint8)pIO->getValSInt32("tile_b"); - // render - uint8 tile = _DispTypes[_DispType].TileBorder[yId*3+xId]; - if (tile == 0) - rVR.drawRotFlipBitmap (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], col); - else - rVR.drawRotFlipBitmapTiled (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], tile-1, col); + // get size + rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder); + rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder); + _DispTypes.push_back(dt); + } + _DispType = (uint8)i; + } + else + { + _DispType = 0; + } + + return true; + } + + + // *************************************************************************** + void CGroupFrame::draw () + { + if (_DisplayFrame) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + // get global color + CRGBA col; + if(getModulateGlobalColor()) + col.modulateFromColor( _Color, CWidgetManager::getInstance()->getGlobalColor() ); + else + col= _Color; + + // draw the background + sint xId = 0, yId = 0; + for (yId = 0; yId < 3; yId++) + { + for (xId = 0; xId < 3; xId++) + { + sint32 x = _XReal; + sint32 y = _YReal; + sint32 w, h; + // top + if (yId == 0) + { + y += _HReal-_DispTypes[_DispType].TopBorder; + h = _DispTypes[_DispType].TopBorder; + } + // Middle + else if (yId == 1) + { + y += _DispTypes[_DispType].BottomBorder; + h = _HReal-_DispTypes[_DispType].TopBorder-_DispTypes[_DispType].BottomBorder; + } + // Bottom + else + { + h = _DispTypes[_DispType].BottomBorder; + } + + // Left + if (xId == 0) + { + w = _DispTypes[_DispType].LeftBorder; + } + else if (xId == 1) + { + x += _DispTypes[_DispType].LeftBorder; + w = _WReal-_DispTypes[_DispType].LeftBorder-_DispTypes[_DispType].RightBorder; + } + else + { + x += _WReal-_DispTypes[_DispType].RightBorder; + w = _DispTypes[_DispType].RightBorder; + } + + // render + uint8 tile = _DispTypes[_DispType].TileBorder[yId*3+xId]; + if (tile == 0) + rVR.drawRotFlipBitmap (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], col); + else + rVR.drawRotFlipBitmapTiled (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], tile-1, col); + + } } } + // draw the components + CInterfaceGroup::draw(); } - // draw the components - CInterfaceGroup::draw(); + + // *************************************************************************** + void CGroupFrame::copyOptionFrom(const CGroupFrame &other) + { + CInterfaceGroup::copyOptionFrom(other); + + // Copy option only if they were not explicitly defined in xml + if(!_DisplayFrameDefined) + _DisplayFrame = other._DisplayFrame; + if(!_ColorDefined) + _Color = other._Color; + if(!_DispTypeDefined) + _DispType = other._DispType; + } + + // *************************************************************************** + void CGroupFrame::setColorAsString(const string & col) + { + _Color = convertColor (col.c_str()); + } + + // *************************************************************************** + string CGroupFrame::getColorAsString() const + { + return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); + } + } -// *************************************************************************** -void CGroupFrame::copyOptionFrom(const CGroupFrame &other) -{ - CInterfaceGroup::copyOptionFrom(other); - - // Copy option only if they were not explicitly defined in xml - if(!_DisplayFrameDefined) - _DisplayFrame = other._DisplayFrame; - if(!_ColorDefined) - _Color = other._Color; - if(!_DispTypeDefined) - _DispType = other._DispType; -} - -// *************************************************************************** -void CGroupFrame::setColorAsString(const string & col) -{ - _Color = convertColor (col.c_str()); -} - -// *************************************************************************** -string CGroupFrame::getColorAsString() const -{ - return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); -} diff --git a/code/nel/src/gui/group_modal.cpp b/code/nel/src/gui/group_modal.cpp index 1b763fad5..22a9956f5 100644 --- a/code/nel/src/gui/group_modal.cpp +++ b/code/nel/src/gui/group_modal.cpp @@ -20,156 +20,159 @@ #include "nel/gui/interface_element.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_renderer.h" +#include "nel/misc/i_xml.h" using namespace std; -#include "nel/misc/i_xml.h" - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal"); - -// *************************************************************************** -CGroupModal::CGroupModal(const TCtorParam ¶m) -: CGroupFrame(param) +namespace NLGUI { - SpawnOnMousePos= true; - ExitClickOut= true; - ExitClickL= false; - ExitClickR= false; - ExitKeyPushed = false; - ForceInsideScreen= false; - SpawnMouseX= SpawnMouseY= 0; - _MouseDeltaX= _MouseDeltaY= 0; - //By default, modal are escapable - _Escapable= true; -} + NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal"); -// *************************************************************************** -bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if(!CGroupFrame::parse(cur, parentGroup)) - return false; - - // read modal option - CXMLAutoPtr prop; - prop = xmlGetProp (cur, (xmlChar*)"mouse_pos"); - if ( prop ) SpawnOnMousePos= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"exit_click_out"); - if ( prop ) ExitClickOut= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"exit_click_l"); - if ( prop ) ExitClickL= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"exit_click_r"); - if ( prop ) ExitClickR= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"exit_click_b"); - if ( prop ) ExitClickR= ExitClickL= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"force_inside_screen"); - if ( prop ) ForceInsideScreen= convertBool(prop); - prop = xmlGetProp (cur, (xmlChar*)"category"); - if ( prop ) Category= (const char *) prop; - prop = xmlGetProp (cur, (xmlChar*)"onclick_out"); - if ( prop ) OnClickOut = (const char *) prop; - prop = xmlGetProp (cur, (xmlChar*)"onclick_out_params"); - if ( prop ) OnClickOutParams = (const char *) prop; - prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out"); - if ( prop ) OnPostClickOut = (const char *) prop; - prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out_params"); - if ( prop ) OnPostClickOutParams = (const char *) prop; - prop = xmlGetProp (cur, (xmlChar*)"exit_key_pushed"); - if ( prop ) ExitKeyPushed= convertBool(prop); - - // Force parent hotspot for spawn on mouse - if(SpawnOnMousePos) - setParentPosRef(Hotspot_BL); - - // bkup x/y as the deltas. - _MouseDeltaX= getX(); - _MouseDeltaY= getY(); - - // Modals are disabled by default - _Active = false; - - return true; -} - -// *************************************************************************** -void CGroupModal::updateCoords () -{ - // if snap to mouse pos. - if(SpawnOnMousePos) + // *************************************************************************** + CGroupModal::CGroupModal(const TCtorParam ¶m) + : CGroupFrame(param) { - // Special for menu for instance: If the size is bigger or equal to the screen, keep 0, because will be clipped just after - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 w,h; - rVR.getScreenSize(w,h); - if(_W>=(sint32)w && _H>=(sint32)h) + SpawnOnMousePos= true; + ExitClickOut= true; + ExitClickL= false; + ExitClickR= false; + ExitKeyPushed = false; + ForceInsideScreen= false; + SpawnMouseX= SpawnMouseY= 0; + _MouseDeltaX= _MouseDeltaY= 0; + //By default, modal are escapable + _Escapable= true; + } + + + // *************************************************************************** + bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if(!CGroupFrame::parse(cur, parentGroup)) + return false; + + // read modal option + CXMLAutoPtr prop; + prop = xmlGetProp (cur, (xmlChar*)"mouse_pos"); + if ( prop ) SpawnOnMousePos= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"exit_click_out"); + if ( prop ) ExitClickOut= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"exit_click_l"); + if ( prop ) ExitClickL= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"exit_click_r"); + if ( prop ) ExitClickR= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"exit_click_b"); + if ( prop ) ExitClickR= ExitClickL= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"force_inside_screen"); + if ( prop ) ForceInsideScreen= convertBool(prop); + prop = xmlGetProp (cur, (xmlChar*)"category"); + if ( prop ) Category= (const char *) prop; + prop = xmlGetProp (cur, (xmlChar*)"onclick_out"); + if ( prop ) OnClickOut = (const char *) prop; + prop = xmlGetProp (cur, (xmlChar*)"onclick_out_params"); + if ( prop ) OnClickOutParams = (const char *) prop; + prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out"); + if ( prop ) OnPostClickOut = (const char *) prop; + prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out_params"); + if ( prop ) OnPostClickOutParams = (const char *) prop; + prop = xmlGetProp (cur, (xmlChar*)"exit_key_pushed"); + if ( prop ) ExitKeyPushed= convertBool(prop); + + // Force parent hotspot for spawn on mouse + if(SpawnOnMousePos) + setParentPosRef(Hotspot_BL); + + // bkup x/y as the deltas. + _MouseDeltaX= getX(); + _MouseDeltaY= getY(); + + // Modals are disabled by default + _Active = false; + + return true; + } + + // *************************************************************************** + void CGroupModal::updateCoords () + { + // if snap to mouse pos. + if(SpawnOnMousePos) { - _X= _Y= 0; + // Special for menu for instance: If the size is bigger or equal to the screen, keep 0, because will be clipped just after + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 w,h; + rVR.getScreenSize(w,h); + if(_W>=(sint32)w && _H>=(sint32)h) + { + _X= _Y= 0; + } + else + { + // change coords + _X= SpawnMouseX+_MouseDeltaX; + _Y= SpawnMouseY+_MouseDeltaY; + } } - else + + // update group + CGroupFrame::updateCoords(); + + // if snap to mouse pos or ForceInsideScreen + if(SpawnOnMousePos || ForceInsideScreen) { - // change coords - _X= SpawnMouseX+_MouseDeltaX; - _Y= SpawnMouseY+_MouseDeltaY; + bool clipped = false; + // repos the group according to real size. clip against screen + if(_XReal<0) + { + _X+= -_XReal; + clipped = true; + } + else + { + if (!SpawnOnMousePos) + _X = _MouseDeltaX; + } + + if(_XReal+_WReal>_Parent->getW()) + { + _X-= _XReal+_WReal-_Parent->getW(); + clipped =true; + } + else + { + if ((!SpawnOnMousePos) && (_XReal>=0)) + _X = _MouseDeltaX; + } + + if(_YReal<0) + { + _Y+= -_YReal; + clipped =true; + } + else + { + if (!SpawnOnMousePos) + _Y = _MouseDeltaY; + } + + if(_YReal+_HReal>_Parent->getH()) + { + _Y-= _YReal+_HReal-_Parent->getH(); + clipped =true; + } + else + { + if ((!SpawnOnMousePos) && (_YReal>=0)) + _Y = _MouseDeltaY; + } + + if (clipped) + { + CGroupFrame::updateCoords(); + } } } - // update group - CGroupFrame::updateCoords(); - - // if snap to mouse pos or ForceInsideScreen - if(SpawnOnMousePos || ForceInsideScreen) - { - bool clipped = false; - // repos the group according to real size. clip against screen - if(_XReal<0) - { - _X+= -_XReal; - clipped = true; - } - else - { - if (!SpawnOnMousePos) - _X = _MouseDeltaX; - } - - if(_XReal+_WReal>_Parent->getW()) - { - _X-= _XReal+_WReal-_Parent->getW(); - clipped =true; - } - else - { - if ((!SpawnOnMousePos) && (_XReal>=0)) - _X = _MouseDeltaX; - } - - if(_YReal<0) - { - _Y+= -_YReal; - clipped =true; - } - else - { - if (!SpawnOnMousePos) - _Y = _MouseDeltaY; - } - - if(_YReal+_HReal>_Parent->getH()) - { - _Y-= _YReal+_HReal-_Parent->getH(); - clipped =true; - } - else - { - if ((!SpawnOnMousePos) && (_YReal>=0)) - _Y = _MouseDeltaY; - } - - if (clipped) - { - CGroupFrame::updateCoords(); - } - } } - diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index a90e2639a..4d969b187 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -29,174 +29,253 @@ using namespace std; using namespace NLMISC; -CStringMapper *_UIStringMapper = NULL; - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement::~CInterfaceElement() +namespace NLGUI { - if (_Links) // remove any link that point to that element + + CStringMapper *_UIStringMapper = NULL; + + // ------------------------------------------------------------------------------------------------ + CInterfaceElement::~CInterfaceElement() { - for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it) + if (_Links) // remove any link that point to that element { - (*it)->removeTarget(this); + for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it) + { + (*it)->removeTarget(this); + } + delete _Links; } - delete _Links; } -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::parseError(CInterfaceGroup * parentGroup, const char *reason) -{ - string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - if (reason) - nlinfo("reason : %s", reason); -} - - -void CInterfaceElement::setIdRecurse(const std::string &newID) -{ - std::string baseId = _Parent ? _Parent->getId() : "ui"; - setId(baseId + ":" + newID); -} - -// ------------------------------------------------------------------------------------------------ -std::string CInterfaceElement::getShortId() const -{ - std::string::size_type last = _Id.find_last_of(':'); - if (last != std::string::npos) + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::parseError(CInterfaceGroup * parentGroup, const char *reason) { - return _Id.substr(last + 1); + string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + if (reason) + nlinfo("reason : %s", reason); } - return _Id; -} -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - // parse the basic properties - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"id" )); - if (ptr) + + void CInterfaceElement::setIdRecurse(const std::string &newID) { - if (parentGroup) + std::string baseId = _Parent ? _Parent->getId() : "ui"; + setId(baseId + ":" + newID); + } + + // ------------------------------------------------------------------------------------------------ + std::string CInterfaceElement::getShortId() const + { + std::string::size_type last = _Id.find_last_of(':'); + if (last != std::string::npos) { - _Id = ( (CInterfaceElement*)parentGroup )->_Id; + return _Id.substr(last + 1); + } + return _Id; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + // parse the basic properties + CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"id" )); + if (ptr) + { + if (parentGroup) + { + _Id = ( (CInterfaceElement*)parentGroup )->_Id; + } + else + { + _Id ="ui"; + } + _Id += ":"+ string((const char*)ptr); } else { - _Id ="ui"; + nlinfo(" error no id in an element"); + return false; } - _Id += ":"+ string((const char*)ptr); - } - else - { - nlinfo(" error no id in an element"); - return false; - } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"active" ); - _Active = true; - if (ptr) - { - _Active = convertBool(ptr); - } - - _Parent = parentGroup; - - // parse location. If these properties are not specified, set them to 0 - ptr = (char*) xmlGetProp( cur, (xmlChar*)"x" ); - _X = 0; - if (ptr) fromString((const char*)ptr, _X); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"y" ); - _Y = 0; - if (ptr) fromString((const char*)ptr, _Y); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"w" ); - _W = 0; - if (parentGroup != NULL) - _W = parentGroup->getW(); - if (ptr) fromString((const char*)ptr, _W); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"h" ); - _H = 0; - if (parentGroup != NULL) - _H = parentGroup->getH(); - if (ptr) fromString((const char*)ptr, _H); - - // snapping -// ptr = (char*) xmlGetProp( cur, (xmlChar*)"snap" ); -// _Snap = 1; -// if (ptr) -// fromString((const char*)ptr, _Snap); -// if (_Snap <= 0) -// { -// parseError(parentGroup, "snap must be > 0" ); -// return false; -// } - - ptr = (char*) xmlGetProp( cur, (xmlChar*) "posref" ); - _ParentPosRef = Hotspot_BL; - _PosRef = Hotspot_BL; - if (ptr) - { - convertHotSpotCouple(ptr.getDatas(), _ParentPosRef, _PosRef); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"posparent" ); - if (ptr) - { - if (strcmp(ptr,"parent")) // is ptr != "parent" + ptr = (char*) xmlGetProp( cur, (xmlChar*)"active" ); + _Active = true; + if (ptr) { - string idparent; - if (parentGroup) - idparent = parentGroup->getId() +":"; + _Active = convertBool(ptr); + } + + _Parent = parentGroup; + + // parse location. If these properties are not specified, set them to 0 + ptr = (char*) xmlGetProp( cur, (xmlChar*)"x" ); + _X = 0; + if (ptr) fromString((const char*)ptr, _X); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"y" ); + _Y = 0; + if (ptr) fromString((const char*)ptr, _Y); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"w" ); + _W = 0; + if (parentGroup != NULL) + _W = parentGroup->getW(); + if (ptr) fromString((const char*)ptr, _W); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"h" ); + _H = 0; + if (parentGroup != NULL) + _H = parentGroup->getH(); + if (ptr) fromString((const char*)ptr, _H); + + // snapping + // ptr = (char*) xmlGetProp( cur, (xmlChar*)"snap" ); + // _Snap = 1; + // if (ptr) + // fromString((const char*)ptr, _Snap); + // if (_Snap <= 0) + // { + // parseError(parentGroup, "snap must be > 0" ); + // return false; + // } + + ptr = (char*) xmlGetProp( cur, (xmlChar*) "posref" ); + _ParentPosRef = Hotspot_BL; + _PosRef = Hotspot_BL; + if (ptr) + { + convertHotSpotCouple(ptr.getDatas(), _ParentPosRef, _PosRef); + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"posparent" ); + if (ptr) + { + if (strcmp(ptr,"parent")) // is ptr != "parent" + { + string idparent; + if (parentGroup) + idparent = parentGroup->getId() +":"; + else + idparent = "ui:"; + CWidgetManager::parser->addParentPositionAssociation(this, idparent + string((const char*)ptr)); + } + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"sizeparent" ); + if (ptr) + { + string idparent = ptr; + idparent = NLMISC::strlwr(idparent); + if (idparent != "parent") + { + if (parentGroup) + idparent = parentGroup->getId() +":" + string((const char*)ptr); + else + idparent = "ui:" + string((const char*)ptr); + } else - idparent = "ui:"; - CWidgetManager::parser->addParentPositionAssociation(this, idparent + string((const char*)ptr)); + { + if (parentGroup) + idparent = parentGroup->getId(); + } + CWidgetManager::parser->addParentSizeAssociation( this, idparent ); } + + ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref"); + _SizeRef = 0; + _SizeDivW = 10; + _SizeDivH = 10; + if (ptr) + { + parseSizeRef(ptr.getDatas()); + sint32 nWhat = 0; + const char *seekPtr = ptr.getDatas(); + while (*seekPtr != 0) + { + if ((*seekPtr=='w')||(*seekPtr=='W')) + { + _SizeRef |= 1; + nWhat = 1; + } + + if ((*seekPtr=='h')||(*seekPtr=='H')) + { + _SizeRef |= 2; + nWhat = 2; + } + + if ((*seekPtr>='1')&&(*seekPtr<='9')) + { + if (nWhat != 0) + { + if (nWhat == 1) + _SizeDivW = *seekPtr-'0'; + if (nWhat == 2) + _SizeDivH = *seekPtr-'0'; + } + } + + ++seekPtr; + } + } + + // snapSize(); + + ptr= (char*) xmlGetProp (cur, (xmlChar*)"global_color"); + if(ptr) + { + _ModulateGlobalColor= convertBool(ptr); + } + + ptr= (char*) xmlGetProp (cur, (xmlChar*)"render_layer"); + if(ptr) fromString((const char*)ptr, _RenderLayer); + + ptr= (char*) xmlGetProp (cur, (xmlChar*)"avoid_resize_parent"); + if(ptr) _AvoidResizeParent= convertBool(ptr); + + return true; } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"sizeparent" ); - if (ptr) + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::setSizeRef(const std::string &sizeref) { - string idparent = ptr; - idparent = NLMISC::strlwr(idparent); - if (idparent != "parent") - { - if (parentGroup) - idparent = parentGroup->getId() +":" + string((const char*)ptr); - else - idparent = "ui:" + string((const char*)ptr); - } - else - { - if (parentGroup) - idparent = parentGroup->getId(); - } - CWidgetManager::parser->addParentSizeAssociation( this, idparent ); + parseSizeRef(sizeref.c_str()); } - ptr = (char*) xmlGetProp (cur, (xmlChar*)"sizeref"); - _SizeRef = 0; - _SizeDivW = 10; - _SizeDivH = 10; - if (ptr) + // ------------------------------------------------------------------------------------------------ + std::string CInterfaceElement::getSizeRefAsString() const { - parseSizeRef(ptr.getDatas()); + return "IMPLEMENT ME!"; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::parseSizeRef(const char *sizeRefStr) + { + parseSizeRef(sizeRefStr, _SizeRef, _SizeDivW, _SizeDivH); + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::parseSizeRef(const char *sizeRefStr, sint32 &sizeRef, sint32 &sizeDivW, sint32 &sizeDivH) + { + nlassert(sizeRefStr); + + sizeRef = 0; + sizeDivW = 10; + sizeDivH = 10; sint32 nWhat = 0; - const char *seekPtr = ptr.getDatas(); + const char *seekPtr = sizeRefStr; while (*seekPtr != 0) { if ((*seekPtr=='w')||(*seekPtr=='W')) { - _SizeRef |= 1; + sizeRef |= 1; nWhat = 1; } if ((*seekPtr=='h')||(*seekPtr=='H')) { - _SizeRef |= 2; + sizeRef |= 2; nWhat = 2; } @@ -205,9 +284,9 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if (nWhat != 0) { if (nWhat == 1) - _SizeDivW = *seekPtr-'0'; + sizeDivW = *seekPtr-'0'; if (nWhat == 2) - _SizeDivH = *seekPtr-'0'; + sizeDivH = *seekPtr-'0'; } } @@ -215,1046 +294,971 @@ bool CInterfaceElement::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) } } -// snapSize(); - - ptr= (char*) xmlGetProp (cur, (xmlChar*)"global_color"); - if(ptr) + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::updateCoords() { - _ModulateGlobalColor= convertBool(ptr); - } + _XReal = _X; + _YReal = _Y; + _WReal = getW(); + _HReal = getH(); - ptr= (char*) xmlGetProp (cur, (xmlChar*)"render_layer"); - if(ptr) fromString((const char*)ptr, _RenderLayer); + CInterfaceElement *el = NULL; - ptr= (char*) xmlGetProp (cur, (xmlChar*)"avoid_resize_parent"); - if(ptr) _AvoidResizeParent= convertBool(ptr); + // Modif Pos - return true; -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::setSizeRef(const std::string &sizeref) -{ - parseSizeRef(sizeref.c_str()); -} - -// ------------------------------------------------------------------------------------------------ -std::string CInterfaceElement::getSizeRefAsString() const -{ - return "IMPLEMENT ME!"; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::parseSizeRef(const char *sizeRefStr) -{ - parseSizeRef(sizeRefStr, _SizeRef, _SizeDivW, _SizeDivH); -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::parseSizeRef(const char *sizeRefStr, sint32 &sizeRef, sint32 &sizeDivW, sint32 &sizeDivH) -{ - nlassert(sizeRefStr); - - sizeRef = 0; - sizeDivW = 10; - sizeDivH = 10; - sint32 nWhat = 0; - const char *seekPtr = sizeRefStr; - while (*seekPtr != 0) - { - if ((*seekPtr=='w')||(*seekPtr=='W')) - { - sizeRef |= 1; - nWhat = 1; - } - - if ((*seekPtr=='h')||(*seekPtr=='H')) - { - sizeRef |= 2; - nWhat = 2; - } - - if ((*seekPtr>='1')&&(*seekPtr<='9')) - { - if (nWhat != 0) - { - if (nWhat == 1) - sizeDivW = *seekPtr-'0'; - if (nWhat == 2) - sizeDivH = *seekPtr-'0'; - } - } - - ++seekPtr; - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::updateCoords() -{ - _XReal = _X; - _YReal = _Y; - _WReal = getW(); - _HReal = getH(); - - CInterfaceElement *el = NULL; - - // Modif Pos - - if (_ParentPos != NULL) - el = _ParentPos; - else - el = _Parent; - - if (el == NULL) - return; - - _XReal += el->_XReal; - _YReal += el->_YReal; - - THotSpot hsParent = _ParentPosRef; - if (hsParent & Hotspot_Mx) - _YReal += el->_HReal/2; - if (hsParent & Hotspot_Tx) - _YReal += el->_HReal; - if (hsParent & Hotspot_xM) - _XReal += el->_WReal/2; - if (hsParent & Hotspot_xR) - _XReal += el->_WReal; - - // Modif Size - - if (_ParentSize != NULL) - { - el = _ParentSize; - } - else - { if (_ParentPos != NULL) el = _ParentPos; else el = _Parent; - } - if (el == NULL) - return; - - if (_SizeRef&1) - _WReal += _SizeDivW * el->_WReal / 10; - - if (_SizeRef&2) - _HReal += _SizeDivH * el->_HReal / 10; - - THotSpot hs = _PosRef; - if (hs & Hotspot_Mx) - _YReal -= _HReal/2; - if (hs & Hotspot_Tx) - _YReal -= _HReal; - if (hs & Hotspot_xM) - _XReal -= _WReal/2; - if (hs & Hotspot_xR) - _XReal -= _WReal; -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::getCorner(sint32 &px, sint32 &py, THotSpot hs) -{ - px = _XReal; - py = _YReal; - if (hs & 1) px += _WReal; - if (hs & 2) px += _WReal >> 1; - if (hs & 8) py += _HReal; - if (hs & 16) py += _HReal >> 1; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::move (sint32 dx, sint32 dy) -{ - _X += dx; - _Y += dy; - invalidateCoords(); -} - - - -// ------------------------------------------------------------------------------------------------ -/*void CInterfaceElement::resizeBR (sint32 sizeW, sint32 sizeH) -{ - uint32 i = i / 0; - THotSpot hs = _PosRef; - - sint32 dw = sizeW - _W; - sint32 dh = sizeH - _H; - - sint32 snap = _Snap; - nlassert(snap > 0); - - if (hs&8) // is top ? - { - sint32 newH = dh + _H; - if (snap > 1) - newH -= newH % snap; - _H = newH; - } - if (hs&32) // is bottom ? - { - sint32 newH = dh + _H; - if (snap > 1) - newH -= newH % snap; - _Y = _H - newH + _Y; - _H = newH; - } - - if (hs&1) // is right ? - { - sint32 newW = dw + _W; - if (snap > 1) - newW -= newW % snap; - _X = newW - _W + _X; - _W = newW; - } - if (hs&4) // is left ? - { - sint32 newW = dw + _W; - if (snap > 1) - newW -= newW % snap; - _W = newW; - } - - // DO NOT TREAT THE MIDDLE HOTSPOT CASE - - invalidateCoords(); -}*/ - - -// ------------------------------------------------------------------------------------------------ -/*void CInterfaceElement::snapSize() -{ - sint32 snap = _Snap; - nlassert(snap > 0); - if (snap > 1) - { - _W = _W - (_W % snap); - _H = _H - (_H % snap); - } -}*/ - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::setW (sint32 w) -{ - _W = w; -// sint32 snap = _Snap; -// nlassert(snap > 0); -// if (snap > 1) -// { -// _W = _W - (_W % snap); -// } -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::setH (sint32 h) -{ - _H = h; -// sint32 snap = _Snap; -// nlassert(snap > 0); -// if (snap > 1) -// { -// _H = _H - (_H % snap); -// } -} - - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceElement::getRootWindow () -{ - if (_Parent == NULL) - return NULL; - if (_Parent->getParent() == NULL) - return dynamic_cast(this); - return _Parent->getRootWindow(); -} - -// ------------------------------------------------------------------------------------------------ -uint CInterfaceElement::getParentDepth() const -{ - uint depth= 0; - CInterfaceGroup *parent= _Parent; - while(parent!=NULL) - { - parent= parent->getParent(); - depth++; - } - return depth; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::isActiveThroughParents() const -{ - if(!getActive()) - return false; - if(_Parent == NULL) - return false; - // is it the root window? - if (_Parent->getParent() == NULL) - // yes and getActive() is true => the element is visible! - return true; - else - return _Parent->isActiveThroughParents(); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const string &prop, const char *val, - const string &defVal) -{ - if (val == NULL) - { - rIP.readSInt64 (defVal.c_str(), _Id+":"+prop); - } - else - { - if ( isdigit(*val) || *val=='-') - { - rIP.readSInt64 (val, _Id+":"+prop); + if (el == NULL) return; - } - sint32 decal = 0; - if (val[0] == ':') - decal = 1; - if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) + _XReal += el->_XReal; + _YReal += el->_YReal; + + THotSpot hsParent = _ParentPosRef; + if (hsParent & Hotspot_Mx) + _YReal += el->_HReal/2; + if (hsParent & Hotspot_Tx) + _YReal += el->_HReal; + if (hsParent & Hotspot_xM) + _XReal += el->_WReal/2; + if (hsParent & Hotspot_xR) + _XReal += el->_WReal; + + // Modif Size + + if (_ParentSize != NULL) { - rIP.readSInt64 (val+decal, _Id+":"+prop); - return; + el = _ParentSize; } else { - string sTmp; - CInterfaceElement *pIEL = this; - - while (pIEL != NULL) - { - sTmp = pIEL->getId()+":"+string(val+decal); - if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) - { - rIP.readSInt64 (sTmp.c_str(), _Id+":"+prop); - return; - } - pIEL = pIEL->getParent(); - } - - rIP.readSInt64 (val+decal, _Id+":"+prop); + if (_ParentPos != NULL) + el = _ParentPos; + else + el = _Parent; } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const string &prop, const char *val, - const string &defVal) -{ - if (val == NULL) - { - rIP.readSInt32 (defVal.c_str(), _Id+":"+prop); - } - else - { - if ( isdigit(*val) || *val=='-') - { - rIP.readSInt32 (val, _Id+":"+prop); + if (el == NULL) return; - } - sint32 decal = 0; - if (val[0] == ':') - decal = 1; - if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) - { - rIP.readSInt32 (val+decal, _Id+":"+prop); - return; - } - else - { - string sTmp; - CInterfaceElement *pIEL = this; + if (_SizeRef&1) + _WReal += _SizeDivW * el->_WReal / 10; - while (pIEL != NULL) - { - sTmp = pIEL->getId()+":"+string(val+decal); - if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) - { - rIP.readSInt32 (sTmp.c_str(), _Id+":"+prop); - return; - } - pIEL = pIEL->getParent(); - } + if (_SizeRef&2) + _HReal += _SizeDivH * el->_HReal / 10; - rIP.readSInt32 (val+decal, _Id+":"+prop); - } + THotSpot hs = _PosRef; + if (hs & Hotspot_Mx) + _YReal -= _HReal/2; + if (hs & Hotspot_Tx) + _YReal -= _HReal; + if (hs & Hotspot_xM) + _XReal -= _WReal/2; + if (hs & Hotspot_xR) + _XReal -= _WReal; } -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string &prop, const char *val, - const string &defVal) -{ - if (val == NULL) + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::getCorner(sint32 &px, sint32 &py, THotSpot hs) { - rIP.readBool (defVal.c_str(), _Id+":"+prop); + px = _XReal; + py = _YReal; + if (hs & 1) px += _WReal; + if (hs & 2) px += _WReal >> 1; + if (hs & 8) py += _HReal; + if (hs & 16) py += _HReal >> 1; } - else + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::move (sint32 dx, sint32 dy) { - sint32 decal = 0; - if (val[0] == ':') - decal = 1; - if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) - { - rIP.readBool (val+decal, _Id+":"+prop); - return; - } - else - { - string sTmp; - CInterfaceElement *pIEL = this; - - while (pIEL != NULL) - { - sTmp = pIEL->getId()+":"+string(val+decal); - if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) - { - rIP.readBool (sTmp.c_str(), _Id+":"+prop); - return; - } - pIEL = pIEL->getParent(); - } - - rIP.readBool (val+decal, _Id+":"+prop); - } - } -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::string &prop,const char *val,const std::string &defVal) -{ - if (val == NULL) - { - rIP.readRGBA (defVal.c_str(), _Id+":"+prop); - } - else - { - if ( isdigit(*val) || *val=='-') - { - rIP.readRGBA (val, _Id+":"+prop); - return; - } - - sint32 decal = 0; - if (val[0] == ':') - decal = 1; - if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) - { - rIP.readRGBA (val+decal, _Id+":"+prop); - return; - } - else - { - string sTmp; - CInterfaceElement *pIEL = this; - - while (pIEL != NULL) - { - sTmp = pIEL->getId()+":"+string(val+decal); - if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) - { - rIP.readRGBA (sTmp.c_str(), _Id+":"+prop); - return; - } - pIEL = pIEL->getParent(); - } - - rIP.readRGBA (val+decal, _Id+":"+prop); - } - } -} - - -// ------------------------------------------------------------------------------------------------ -THotSpot CInterfaceElement::convertHotSpot (const char *ptr) -{ - if ( !strnicmp(ptr,"TL",2) ) - { - return Hotspot_TL; - } - else if ( !strnicmp(ptr,"TM",2) ) - { - return Hotspot_TM; - } - else if ( !strnicmp(ptr,"TR",2) ) - { - return Hotspot_TR; - } - else if ( !strnicmp(ptr,"ML",2) ) - { - return Hotspot_ML; - } - else if ( !strnicmp(ptr,"MM",2) ) - { - return Hotspot_MM; - } - else if ( !strnicmp(ptr,"MR",2) ) - { - return Hotspot_MR; - } - else if ( !strnicmp(ptr,"BL",2) ) - { - return Hotspot_BL; - } - else if ( !strnicmp(ptr,"BM",2) ) - { - return Hotspot_BM; - } - else if ( !strnicmp(ptr,"BR",2) ) - { - return Hotspot_BR; - } - else - return Hotspot_BL; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef) -{ - nlassert(ptr); - - // *** first hotspot - // skip any space or tab - while(*ptr=='\t' || *ptr==' ') - ptr++; - // convert first - parentPosRef = convertHotSpot (ptr); - - // *** second hotspot - // must be at least 2 letter and a space - nlassert(strlen(ptr)>=3); - ptr+=3; - // skip any space or tab - while(*ptr=='\t' || *ptr==' ') - ptr++; - // convert second - posRef = convertHotSpot (ptr); -} - -// ------------------------------------------------------------------------------------------------ -NLMISC::CRGBA CInterfaceElement::convertColor (const char *ptr) -{ - return NLMISC::CRGBA::stringToRGBA(ptr); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::convertBool (const char *ptr) -{ - string str= ptr; - NLMISC::strlwr(str); - return str=="true"?true:false; -} - -// ------------------------------------------------------------------------------------------------ -NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) -{ - float x = 0.0f, y = 0.0f, z = 0.0f; - - sscanf (ptr, "%f %f %f", &x, &y, &z); - - return CVector(x,y,z); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio) -{ - std::string value = ptr; - if (!value.empty()) - { - if (value[value.size() - 1] == '%') - { - value.resize(value.size() - 1); - fromString(value, ratio); - ratio /= 100.f; - clamp(ratio, 0.f, 1.f); - } - else - { - fromString(value, pixels); - } - } -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::addLink(CInterfaceLink *link) -{ - nlassert(link != NULL); - if (!_Links) - { - _Links = new TLinkVect; - } - TLinkSmartPtr linkPtr(link); - TLinkVect::const_iterator it = std::find(_Links->begin(), _Links->end(), linkPtr); - if (it != _Links->end()) - { - // Link already appened : this can be the case when a link has several targets property that belong to the same element, in this case, one single ptr in the vector is enough. - // nlwarning("Link added twice"); - } - else - { - _Links->push_back(linkPtr); - } -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::removeLink(CInterfaceLink *link) -{ - nlassert(link != NULL); - if (!_Links) - { - nlwarning("No link added"); - return; - } - TLinkVect::iterator it = std::find(_Links->begin(), _Links->end(), TLinkSmartPtr(link)); - if (it == _Links->end()) - { - nlwarning("Unknown link"); - return; - } - _Links->erase(it); // kill the smart ptr, maybe deleting the link. - if (_Links->empty()) - { - delete _Links; - _Links = NULL; - } -} - - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CInterfaceElement::getMasterGroup() const -{ - if(getParent()==NULL) - return const_cast(this); - else - return getParent()->getMasterGroup(); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceElement::getParentContainer() -{ - CInterfaceElement *parent = this; - while (parent) - { - CInterfaceGroup *gc = dynamic_cast< CInterfaceGroup* >( parent ); - if( ( gc != NULL ) && gc->isGroupContainer() ) - return gc; - - parent = parent->getParent(); - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::isIn(sint x, sint y) const -{ - return (x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal)); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::isIn(sint x, sint y, uint width, uint height) const -{ - return (x + (sint) width) >= _XReal && - (y + (sint) height) > _YReal && - x < (_XReal + _WReal) && - y <= (_YReal + _HReal); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceElement::isIn(const CInterfaceElement &other) const -{ - return isIn(other._XReal, other._YReal, other._WReal, other._HReal); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceElement::setActive (bool state) -{ - if (_Active != state) - { - _Active = state; + _X += dx; + _Y += dy; invalidateCoords(); } -} -// *************************************************************************** -void CInterfaceElement::invalidateCoords(uint8 numPass) -{ - // Get the "Root Group" ie the 1st son of the master group of us (eg "ui:interface:rootgroup" ) - CInterfaceGroup *parent= getParent(); - // if our parent is NULL, then we are the master group (error!) - if(parent==NULL) - return; - // if our grandfather is NULL, then our father is the Master Group => we are the "Root group" - if(parent->getParent()==NULL) + + // ------------------------------------------------------------------------------------------------ + /*void CInterfaceElement::resizeBR (sint32 sizeW, sint32 sizeH) { - parent= dynamic_cast(this); + uint32 i = i / 0; + THotSpot hs = _PosRef; + + sint32 dw = sizeW - _W; + sint32 dh = sizeH - _H; + + sint32 snap = _Snap; + nlassert(snap > 0); + + if (hs&8) // is top ? + { + sint32 newH = dh + _H; + if (snap > 1) + newH -= newH % snap; + _H = newH; + } + if (hs&32) // is bottom ? + { + sint32 newH = dh + _H; + if (snap > 1) + newH -= newH % snap; + _Y = _H - newH + _Y; + _H = newH; + } + + if (hs&1) // is right ? + { + sint32 newW = dw + _W; + if (snap > 1) + newW -= newW % snap; + _X = newW - _W + _X; + _W = newW; + } + if (hs&4) // is left ? + { + sint32 newW = dw + _W; + if (snap > 1) + newW -= newW % snap; + _W = newW; + } + + // DO NOT TREAT THE MIDDLE HOTSPOT CASE + + invalidateCoords(); + }*/ + + + // ------------------------------------------------------------------------------------------------ + /*void CInterfaceElement::snapSize() + { + sint32 snap = _Snap; + nlassert(snap > 0); + if (snap > 1) + { + _W = _W - (_W % snap); + _H = _H - (_H % snap); + } + }*/ + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::setW (sint32 w) + { + _W = w; + // sint32 snap = _Snap; + // nlassert(snap > 0); + // if (snap > 1) + // { + // _W = _W - (_W % snap); + // } } - else + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::setH (sint32 h) { - // parent is the root group when is grandFather is NULL - while( parent->getParent()->getParent()!=NULL ) + _H = h; + // sint32 snap = _Snap; + // nlassert(snap > 0); + // if (snap > 1) + // { + // _H = _H - (_H % snap); + // } + } + + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CInterfaceElement::getRootWindow () + { + if (_Parent == NULL) + return NULL; + if (_Parent->getParent() == NULL) + return dynamic_cast(this); + return _Parent->getRootWindow(); + } + + // ------------------------------------------------------------------------------------------------ + uint CInterfaceElement::getParentDepth() const + { + uint depth= 0; + CInterfaceGroup *parent= _Parent; + while(parent!=NULL) { parent= parent->getParent(); + depth++; } + return depth; } - // invalidate the "root group" - if(parent) + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::isActiveThroughParents() const { - uint8 &val= static_cast(parent)->_InvalidCoords; - val= max(val, numPass); + if(!getActive()) + return false; + if(_Parent == NULL) + return false; + // is it the root window? + if (_Parent->getParent() == NULL) + // yes and getActive() is true => the element is visible! + return true; + else + return _Parent->isActiveThroughParents(); } -} - -// *************************************************************************** -void CInterfaceElement::checkCoords() -{ -} - -// *************************************************************************** -bool CInterfaceElement::isSonOf(const CInterfaceElement *other) const -{ - const CInterfaceElement *currElem = this; - do + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::relativeSInt64Read (CInterfaceProperty &rIP, const string &prop, const char *val, + const string &defVal) { - if (currElem == other) return true; - currElem = currElem->_Parent; - } - while (currElem); - return false; -} - -// *************************************************************************** -void CInterfaceElement::resetInvalidCoords() -{ - _InvalidCoords= 0; -} - -// *************************************************************************** -void CInterfaceElement::updateAllLinks() -{ - if (_Links) - { - for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it) + if (val == NULL) { - (*it)->update(); + rIP.readSInt64 (defVal.c_str(), _Id+":"+prop); + } + else + { + if ( isdigit(*val) || *val=='-') + { + rIP.readSInt64 (val, _Id+":"+prop); + return; + } + + sint32 decal = 0; + if (val[0] == ':') + decal = 1; + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) + { + rIP.readSInt64 (val+decal, _Id+":"+prop); + return; + } + else + { + string sTmp; + CInterfaceElement *pIEL = this; + + while (pIEL != NULL) + { + sTmp = pIEL->getId()+":"+string(val+decal); + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) + { + rIP.readSInt64 (sTmp.c_str(), _Id+":"+prop); + return; + } + pIEL = pIEL->getParent(); + } + + rIP.readSInt64 (val+decal, _Id+":"+prop); + } } } -} -// *************************************************************************** -void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other) -{ - _Active = other._Active; - _InvalidCoords = other._InvalidCoords; - _XReal = other._XReal; - _YReal = other._YReal; - _WReal = other._WReal; - _HReal = other._HReal; - _X = other._X; - _Y = other._Y; - _XReal = other._XReal; - _YReal = other._YReal; - _PosRef = other._PosRef; - _ParentPosRef = other._ParentPosRef; - _SizeRef = other._SizeRef; - _SizeDivW = other._SizeDivW; - _SizeDivH = other._SizeDivH; - _ModulateGlobalColor = other._ModulateGlobalColor; - _RenderLayer = other._RenderLayer; -} - -// *************************************************************************** -void CInterfaceElement::center() -{ - // center the pc - CViewRenderer &vr = *CViewRenderer::getInstance(); - uint32 sw, sh; - vr.getScreenSize(sw, sh); - setX(sw / 2 - getWReal() / 2); - setY(sh / 2 + getHReal() / 2); -} - -// *************************************************************************** -void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &uiFilter) -{ - CCtrlBase *ctrlBase = dynamic_cast(this); - CInterfaceGroup *groupBase = dynamic_cast(this); - if ( - ((type == RenderView) && (ctrlBase==NULL) && (groupBase==NULL)) || - ((type == RenderCtrl) && (ctrlBase!=NULL) && (groupBase==NULL)) || - ((type == RenderGroup) && (ctrlBase!=NULL) && (groupBase!=NULL))) + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const string &prop, const char *val, + const string &defVal) { - if (!_Active) return; - // if there is an uiFilter, the end of _Id must match it - if (!uiFilter.empty() && (uiFilter.size()>_Id.size() || - _Id.compare(_Id.size()-uiFilter.size(),string::npos,uiFilter)!=0) - ) + if (val == NULL) + { + rIP.readSInt32 (defVal.c_str(), _Id+":"+prop); + } + else + { + if ( isdigit(*val) || *val=='-') + { + rIP.readSInt32 (val, _Id+":"+prop); + return; + } + + sint32 decal = 0; + if (val[0] == ':') + decal = 1; + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) + { + rIP.readSInt32 (val+decal, _Id+":"+prop); + return; + } + else + { + string sTmp; + CInterfaceElement *pIEL = this; + + while (pIEL != NULL) + { + sTmp = pIEL->getId()+":"+string(val+decal); + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) + { + rIP.readSInt32 (sTmp.c_str(), _Id+":"+prop); + return; + } + pIEL = pIEL->getParent(); + } + + rIP.readSInt32 (val+decal, _Id+":"+prop); + } + } + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::relativeBoolRead (CInterfaceProperty &rIP, const string &prop, const char *val, + const string &defVal) + { + if (val == NULL) + { + rIP.readBool (defVal.c_str(), _Id+":"+prop); + } + else + { + sint32 decal = 0; + if (val[0] == ':') + decal = 1; + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) + { + rIP.readBool (val+decal, _Id+":"+prop); + return; + } + else + { + string sTmp; + CInterfaceElement *pIEL = this; + + while (pIEL != NULL) + { + sTmp = pIEL->getId()+":"+string(val+decal); + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) + { + rIP.readBool (sTmp.c_str(), _Id+":"+prop); + return; + } + pIEL = pIEL->getParent(); + } + + rIP.readBool (val+decal, _Id+":"+prop); + } + } + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::relativeRGBARead(CInterfaceProperty &rIP,const std::string &prop,const char *val,const std::string &defVal) + { + if (val == NULL) + { + rIP.readRGBA (defVal.c_str(), _Id+":"+prop); + } + else + { + if ( isdigit(*val) || *val=='-') + { + rIP.readRGBA (val, _Id+":"+prop); + return; + } + + sint32 decal = 0; + if (val[0] == ':') + decal = 1; + if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL) + { + rIP.readRGBA (val+decal, _Id+":"+prop); + return; + } + else + { + string sTmp; + CInterfaceElement *pIEL = this; + + while (pIEL != NULL) + { + sTmp = pIEL->getId()+":"+string(val+decal); + if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL) + { + rIP.readRGBA (sTmp.c_str(), _Id+":"+prop); + return; + } + pIEL = pIEL->getParent(); + } + + rIP.readRGBA (val+decal, _Id+":"+prop); + } + } + } + + + // ------------------------------------------------------------------------------------------------ + THotSpot CInterfaceElement::convertHotSpot (const char *ptr) + { + if ( !strnicmp(ptr,"TL",2) ) + { + return Hotspot_TL; + } + else if ( !strnicmp(ptr,"TM",2) ) + { + return Hotspot_TM; + } + else if ( !strnicmp(ptr,"TR",2) ) + { + return Hotspot_TR; + } + else if ( !strnicmp(ptr,"ML",2) ) + { + return Hotspot_ML; + } + else if ( !strnicmp(ptr,"MM",2) ) + { + return Hotspot_MM; + } + else if ( !strnicmp(ptr,"MR",2) ) + { + return Hotspot_MR; + } + else if ( !strnicmp(ptr,"BL",2) ) + { + return Hotspot_BL; + } + else if ( !strnicmp(ptr,"BM",2) ) + { + return Hotspot_BM; + } + else if ( !strnicmp(ptr,"BR",2) ) + { + return Hotspot_BR; + } + else + return Hotspot_BL; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef) + { + nlassert(ptr); + + // *** first hotspot + // skip any space or tab + while(*ptr=='\t' || *ptr==' ') + ptr++; + // convert first + parentPosRef = convertHotSpot (ptr); + + // *** second hotspot + // must be at least 2 letter and a space + nlassert(strlen(ptr)>=3); + ptr+=3; + // skip any space or tab + while(*ptr=='\t' || *ptr==' ') + ptr++; + // convert second + posRef = convertHotSpot (ptr); + } + + // ------------------------------------------------------------------------------------------------ + NLMISC::CRGBA CInterfaceElement::convertColor (const char *ptr) + { + return NLMISC::CRGBA::stringToRGBA(ptr); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::convertBool (const char *ptr) + { + string str= ptr; + NLMISC::strlwr(str); + return str=="true"?true:false; + } + + // ------------------------------------------------------------------------------------------------ + NLMISC::CVector CInterfaceElement::convertVector (const char *ptr) + { + float x = 0.0f, y = 0.0f, z = 0.0f; + + sscanf (ptr, "%f %f %f", &x, &y, &z); + + return CVector(x,y,z); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio) + { + std::string value = ptr; + if (!value.empty()) + { + if (value[value.size() - 1] == '%') + { + value.resize(value.size() - 1); + fromString(value, ratio); + ratio /= 100.f; + clamp(ratio, 0.f, 1.f); + } + else + { + fromString(value, pixels); + } + } + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::addLink(CInterfaceLink *link) + { + nlassert(link != NULL); + if (!_Links) + { + _Links = new TLinkVect; + } + TLinkSmartPtr linkPtr(link); + TLinkVect::const_iterator it = std::find(_Links->begin(), _Links->end(), linkPtr); + if (it != _Links->end()) + { + // Link already appened : this can be the case when a link has several targets property that belong to the same element, in this case, one single ptr in the vector is enough. + // nlwarning("Link added twice"); + } + else + { + _Links->push_back(linkPtr); + } + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::removeLink(CInterfaceLink *link) + { + nlassert(link != NULL); + if (!_Links) + { + nlwarning("No link added"); return; - CViewRenderer &vr = *CViewRenderer::getInstance(); - vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); - drawHotSpot(_PosRef, CRGBA::Red); - if (_Parent) _Parent->drawHotSpot(_ParentPosRef, CRGBA::Blue); - } -} - -// *************************************************************************** -void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col) -{ - const sint32 radius = 2; - sint32 px, py; - // - if (hs & Hotspot_Bx) - { - py = _YReal + radius; - } - else if (hs & Hotspot_Mx) - { - py = _YReal + _HReal / 2; - } - else - { - py = _YReal + _HReal - radius; - } - // - if (hs & Hotspot_xL) - { - px = _XReal + radius; - } - else if (hs & Hotspot_xM) - { - px = _XReal + _WReal / 2; - } - else - { - px = _XReal + _WReal - radius; - } - CViewRenderer &vr = *CViewRenderer::getInstance(); - vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); - -} - -// *************************************************************************** -void CInterfaceElement::invalidateContent() -{ - CInterfaceElement *elm = this; - while (elm) - { - // Call back - elm->onInvalidateContent(); - - // Get the parent - elm = elm->getParent(); - } -} - -// *************************************************************************** -void CInterfaceElement::visit(CInterfaceElementVisitor *visitor) -{ - nlassert(visitor); - visitor->visit(this); -} - -// *************************************************************************** -void CInterfaceElement::serialConfig(NLMISC::IStream &f) -{ - if (f.isReading()) - { - throw NLMISC::ENewerStream(f); - nlassert(0); - } -} - -// *************************************************************************** -void CInterfaceElement::onFrameUpdateWindowPos(sint dx, sint dy) -{ - _XReal+= dx; - _YReal+= dy; -} - -// *************************************************************************** -void CInterfaceElement::dummySet(sint32 /* value */) -{ - nlwarning("Element can't be written."); -} - -// *************************************************************************** -void CInterfaceElement::dummySet(const std::string &/* value */) -{ - nlwarning("Element can't be written."); -} - -// *************************************************************************** -int CInterfaceElement::luaUpdateCoords(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "updateCoords", 0); - updateCoords(); - return 0; -} - -// *************************************************************************** -int CInterfaceElement::luaInvalidateCoords(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "updateCoords", 0); - invalidateCoords(); - return 0; -} - -// *************************************************************************** -int CInterfaceElement::luaInvalidateContent(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "invalidateContent", 0); - invalidateContent(); - return 0; -} - -// *************************************************************************** -int CInterfaceElement::luaCenter(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "center", 0); - center(); - return 0; -} - -// *************************************************************************** -int CInterfaceElement::luaSetPosRef(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "setPosRef", 1); - CLuaIHM::check(ls, ls.isString(1), "setPosRef() requires a string in param 1"); - - // get hotspot - THotSpot newParentPosRef, newPosRef; - convertHotSpotCouple(ls.toString(1), newParentPosRef, newPosRef); - - // if different from current, set,a nd invalidate coords - if(newParentPosRef!=getParentPosRef() || newPosRef!=getPosRef()) - { - setParentPosRef(newParentPosRef); - setPosRef(newPosRef); - invalidateCoords(); - } - - return 0; -} - -// *************************************************************************** -int CInterfaceElement::luaSetParentPos(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "setParentPos", 1); - CInterfaceElement *ie = CLuaIHM::getUIOnStack(ls, 1); - if(ie) - { - setParentPos(ie); - } - return 0; -} - - - -// *************************************************************************** -CInterfaceElement *CInterfaceElement::clone() -{ - NLMISC::CMemStream dupStream; - nlassert(!dupStream.isReading()); - CInterfaceGroup *oldParent = _Parent; - _Parent = NULL; - CInterfaceElement *oldParentPos = _ParentPos; - CInterfaceElement *oldParentSize = _ParentSize; - if (_ParentPos == oldParent) _ParentPos = NULL; - if (_ParentSize == oldParent) _ParentSize = NULL; - CInterfaceElement *begunThisCloneWarHas = NULL; - try - { - if (dupStream.isReading()) - { - dupStream.invert(); } - CInterfaceElement *self = this; - dupStream.serialPolyPtr(self); - std::vector datas(dupStream.length()); - std::copy(dupStream.buffer(), dupStream.buffer() + dupStream.length(), datas.begin()); - dupStream.resetPtrTable(); - dupStream.invert(); - dupStream.fill(&datas[0], (uint32)datas.size()); - dupStream.serialPolyPtr(begunThisCloneWarHas); + TLinkVect::iterator it = std::find(_Links->begin(), _Links->end(), TLinkSmartPtr(link)); + if (it == _Links->end()) + { + nlwarning("Unknown link"); + return; + } + _Links->erase(it); // kill the smart ptr, maybe deleting the link. + if (_Links->empty()) + { + delete _Links; + _Links = NULL; + } } - catch(const NLMISC::EStream &) - { - // no-op -> caller has to handle the failure because NULL will be returned - } - // - _Parent = oldParent; - _ParentPos = oldParentPos; - _ParentSize = oldParentSize; - // - return begunThisCloneWarHas; -} - -// *************************************************************************** -void CInterfaceElement::serial(NLMISC::IStream &f) -{ - f.serialPolyPtr(_Parent); - f.serial(_Id); - f.serial(_Active); - f.serial(_InvalidCoords); - f.serial(_XReal, _YReal, _WReal, _HReal); - f.serial(_X, _Y, _W, _H); - f.serialEnum(_PosRef); - f.serialEnum(_ParentPosRef); - _ParentPos.serialPolyPtr(f); - f.serial(_SizeRef); - f.serial(_SizeDivW, _SizeDivH); - _ParentSize.serialPolyPtr(f); - f.serial(_ModulateGlobalColor); - f.serial(_RenderLayer); - f.serial(_AvoidResizeParent); - nlassert(_Links == NULL); // not supported -} -// *************************************************************************** -void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah) -{ - std::string ahName; - if (f.isReading()) + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CInterfaceElement::getMasterGroup() const { - f.serial(ahName); - ah = CAHManager::getInstance()->getActionHandler(ahName); + if(getParent()==NULL) + return const_cast(this); + else + return getParent()->getMasterGroup(); } - else + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CInterfaceElement::getParentContainer() { - ahName = CAHManager::getInstance()->getActionHandlerName(ah); - f.serial(ahName); + CInterfaceElement *parent = this; + while (parent) + { + CInterfaceGroup *gc = dynamic_cast< CInterfaceGroup* >( parent ); + if( ( gc != NULL ) && gc->isGroupContainer() ) + return gc; + + parent = parent->getParent(); + } + return NULL; } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::isIn(sint x, sint y) const + { + return (x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal)); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::isIn(sint x, sint y, uint width, uint height) const + { + return (x + (sint) width) >= _XReal && + (y + (sint) height) > _YReal && + x < (_XReal + _WReal) && + y <= (_YReal + _HReal); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceElement::isIn(const CInterfaceElement &other) const + { + return isIn(other._XReal, other._YReal, other._WReal, other._HReal); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceElement::setActive (bool state) + { + if (_Active != state) + { + _Active = state; + invalidateCoords(); + } + } + + + // *************************************************************************** + void CInterfaceElement::invalidateCoords(uint8 numPass) + { + // Get the "Root Group" ie the 1st son of the master group of us (eg "ui:interface:rootgroup" ) + CInterfaceGroup *parent= getParent(); + // if our parent is NULL, then we are the master group (error!) + if(parent==NULL) + return; + // if our grandfather is NULL, then our father is the Master Group => we are the "Root group" + if(parent->getParent()==NULL) + { + parent= dynamic_cast(this); + } + else + { + // parent is the root group when is grandFather is NULL + while( parent->getParent()->getParent()!=NULL ) + { + parent= parent->getParent(); + } + } + + // invalidate the "root group" + if(parent) + { + uint8 &val= static_cast(parent)->_InvalidCoords; + val= max(val, numPass); + } + } + + + // *************************************************************************** + void CInterfaceElement::checkCoords() + { + } + + // *************************************************************************** + bool CInterfaceElement::isSonOf(const CInterfaceElement *other) const + { + const CInterfaceElement *currElem = this; + do + { + if (currElem == other) return true; + currElem = currElem->_Parent; + } + while (currElem); + return false; + } + + // *************************************************************************** + void CInterfaceElement::resetInvalidCoords() + { + _InvalidCoords= 0; + } + + // *************************************************************************** + void CInterfaceElement::updateAllLinks() + { + if (_Links) + { + for(TLinkVect::iterator it = _Links->begin(); it != _Links->end(); ++it) + { + (*it)->update(); + } + } + } + + // *************************************************************************** + void CInterfaceElement::copyOptionFrom(const CInterfaceElement &other) + { + _Active = other._Active; + _InvalidCoords = other._InvalidCoords; + _XReal = other._XReal; + _YReal = other._YReal; + _WReal = other._WReal; + _HReal = other._HReal; + _X = other._X; + _Y = other._Y; + _XReal = other._XReal; + _YReal = other._YReal; + _PosRef = other._PosRef; + _ParentPosRef = other._ParentPosRef; + _SizeRef = other._SizeRef; + _SizeDivW = other._SizeDivW; + _SizeDivH = other._SizeDivH; + _ModulateGlobalColor = other._ModulateGlobalColor; + _RenderLayer = other._RenderLayer; + + } + + // *************************************************************************** + void CInterfaceElement::center() + { + // center the pc + CViewRenderer &vr = *CViewRenderer::getInstance(); + uint32 sw, sh; + vr.getScreenSize(sw, sh); + setX(sw / 2 - getWReal() / 2); + setY(sh / 2 + getHReal() / 2); + } + + // *************************************************************************** + void CInterfaceElement::renderWiredQuads(TRenderWired type, const std::string &uiFilter) + { + CCtrlBase *ctrlBase = dynamic_cast(this); + CInterfaceGroup *groupBase = dynamic_cast(this); + if ( + ((type == RenderView) && (ctrlBase==NULL) && (groupBase==NULL)) || + ((type == RenderCtrl) && (ctrlBase!=NULL) && (groupBase==NULL)) || + ((type == RenderGroup) && (ctrlBase!=NULL) && (groupBase!=NULL))) + { + if (!_Active) return; + // if there is an uiFilter, the end of _Id must match it + if (!uiFilter.empty() && (uiFilter.size()>_Id.size() || + _Id.compare(_Id.size()-uiFilter.size(),string::npos,uiFilter)!=0) + ) + return; + CViewRenderer &vr = *CViewRenderer::getInstance(); + vr.drawWiredQuad(_XReal, _YReal, _WReal, _HReal); + drawHotSpot(_PosRef, CRGBA::Red); + if (_Parent) _Parent->drawHotSpot(_ParentPosRef, CRGBA::Blue); + } + } + + // *************************************************************************** + void CInterfaceElement::drawHotSpot(THotSpot hs, CRGBA col) + { + const sint32 radius = 2; + sint32 px, py; + // + if (hs & Hotspot_Bx) + { + py = _YReal + radius; + } + else if (hs & Hotspot_Mx) + { + py = _YReal + _HReal / 2; + } + else + { + py = _YReal + _HReal - radius; + } + // + if (hs & Hotspot_xL) + { + px = _XReal + radius; + } + else if (hs & Hotspot_xM) + { + px = _XReal + _WReal / 2; + } + else + { + px = _XReal + _WReal - radius; + } + CViewRenderer &vr = *CViewRenderer::getInstance(); + vr.drawFilledQuad(px - radius, py - radius, radius * 2, radius * 2, col); + + } + + // *************************************************************************** + void CInterfaceElement::invalidateContent() + { + CInterfaceElement *elm = this; + while (elm) + { + // Call back + elm->onInvalidateContent(); + + // Get the parent + elm = elm->getParent(); + } + } + + // *************************************************************************** + void CInterfaceElement::visit(CInterfaceElementVisitor *visitor) + { + nlassert(visitor); + visitor->visit(this); + } + + // *************************************************************************** + void CInterfaceElement::serialConfig(NLMISC::IStream &f) + { + if (f.isReading()) + { + throw NLMISC::ENewerStream(f); + nlassert(0); + } + } + + // *************************************************************************** + void CInterfaceElement::onFrameUpdateWindowPos(sint dx, sint dy) + { + _XReal+= dx; + _YReal+= dy; + } + + // *************************************************************************** + void CInterfaceElement::dummySet(sint32 /* value */) + { + nlwarning("Element can't be written."); + } + + // *************************************************************************** + void CInterfaceElement::dummySet(const std::string &/* value */) + { + nlwarning("Element can't be written."); + } + + // *************************************************************************** + int CInterfaceElement::luaUpdateCoords(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "updateCoords", 0); + updateCoords(); + return 0; + } + + // *************************************************************************** + int CInterfaceElement::luaInvalidateCoords(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "updateCoords", 0); + invalidateCoords(); + return 0; + } + + // *************************************************************************** + int CInterfaceElement::luaInvalidateContent(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "invalidateContent", 0); + invalidateContent(); + return 0; + } + + // *************************************************************************** + int CInterfaceElement::luaCenter(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "center", 0); + center(); + return 0; + } + + // *************************************************************************** + int CInterfaceElement::luaSetPosRef(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "setPosRef", 1); + CLuaIHM::check(ls, ls.isString(1), "setPosRef() requires a string in param 1"); + + // get hotspot + THotSpot newParentPosRef, newPosRef; + convertHotSpotCouple(ls.toString(1), newParentPosRef, newPosRef); + + // if different from current, set,a nd invalidate coords + if(newParentPosRef!=getParentPosRef() || newPosRef!=getPosRef()) + { + setParentPosRef(newParentPosRef); + setPosRef(newPosRef); + invalidateCoords(); + } + + return 0; + } + + // *************************************************************************** + int CInterfaceElement::luaSetParentPos(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "setParentPos", 1); + CInterfaceElement *ie = CLuaIHM::getUIOnStack(ls, 1); + if(ie) + { + setParentPos(ie); + } + return 0; + } + + + + // *************************************************************************** + CInterfaceElement *CInterfaceElement::clone() + { + NLMISC::CMemStream dupStream; + nlassert(!dupStream.isReading()); + CInterfaceGroup *oldParent = _Parent; + _Parent = NULL; + CInterfaceElement *oldParentPos = _ParentPos; + CInterfaceElement *oldParentSize = _ParentSize; + if (_ParentPos == oldParent) _ParentPos = NULL; + if (_ParentSize == oldParent) _ParentSize = NULL; + CInterfaceElement *begunThisCloneWarHas = NULL; + try + { + if (dupStream.isReading()) + { + dupStream.invert(); + } + CInterfaceElement *self = this; + dupStream.serialPolyPtr(self); + std::vector datas(dupStream.length()); + std::copy(dupStream.buffer(), dupStream.buffer() + dupStream.length(), datas.begin()); + dupStream.resetPtrTable(); + dupStream.invert(); + dupStream.fill(&datas[0], (uint32)datas.size()); + dupStream.serialPolyPtr(begunThisCloneWarHas); + } + catch(const NLMISC::EStream &) + { + // no-op -> caller has to handle the failure because NULL will be returned + } + // + _Parent = oldParent; + _ParentPos = oldParentPos; + _ParentSize = oldParentSize; + // + return begunThisCloneWarHas; + } + + // *************************************************************************** + void CInterfaceElement::serial(NLMISC::IStream &f) + { + f.serialPolyPtr(_Parent); + f.serial(_Id); + f.serial(_Active); + f.serial(_InvalidCoords); + f.serial(_XReal, _YReal, _WReal, _HReal); + f.serial(_X, _Y, _W, _H); + f.serialEnum(_PosRef); + f.serialEnum(_ParentPosRef); + _ParentPos.serialPolyPtr(f); + f.serial(_SizeRef); + f.serial(_SizeDivW, _SizeDivH); + _ParentSize.serialPolyPtr(f); + f.serial(_ModulateGlobalColor); + f.serial(_RenderLayer); + f.serial(_AvoidResizeParent); + nlassert(_Links == NULL); // not supported + } + + + // *************************************************************************** + void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah) + { + std::string ahName; + if (f.isReading()) + { + f.serial(ahName); + ah = CAHManager::getInstance()->getActionHandler(ahName); + } + else + { + ahName = CAHManager::getInstance()->getActionHandlerName(ah); + f.serial(ahName); + } + } + + } - - diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index 9b1ae75fb..bfa58b535 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -34,1923 +34,1928 @@ using namespace NL3D; // the first), instead of using 'this'. 'this' is already used by // CLuaIHM::pushReflectableOnStack as unique id to CInterfaceElement's ref pointers -REGISTER_UI_CLASS(CInterfaceGroup) - -// ------------------------------------------------------------------------------------------------ -NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroup, std::string, "interface_group"); - -CInterfaceGroup::CInterfaceGroup(const TCtorParam ¶m) : CCtrlBase(param) +namespace NLGUI { - _ParentSizeMax = NULL; - _MaxW = _MaxH = 16384; - _OffsetX = _OffsetY = 0; - _Overlappable= true; - _ResizeFromChildW= false; - _ResizeFromChildH= false; - _ResizeFromChildWMargin= 0; - _ResizeFromChildHMargin= 0; - _MaxWReal = _MaxHReal = 16384; - _GroupSizeRef = 0; - _Escapable= false; - _Priority= WIN_PRIORITY_NORMAL; - _UseCursor = true; - _IsGroupContainer = false; - _IsGroupScrollText = false; - _IsGroupInScene = false; - _AHOnActive = NULL; - _AHOnDeactive = NULL; - _AHOnLeftClick = NULL; - _AHOnRightClick = NULL; - _AHOnEnter = NULL; - _AHOnEscape = NULL; - _NeedFrameUpdatePos= false; - _LUAEnvTableCreated= false; - _DepthForZSort= 0.f; -#ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS - CInterfaceManager::getInstance()->DebugTrackGroupsCreated( this ); -#endif -} + REGISTER_UI_CLASS(CInterfaceGroup) + // ------------------------------------------------------------------------------------------------ + NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroup, std::string, "interface_group"); -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setIdRecurse(const std::string &id) -{ - CCtrlBase::setIdRecurse(id); - for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) + CInterfaceGroup::CInterfaceGroup(const TCtorParam ¶m) : CCtrlBase(param) { - (*it)->setIdRecurse((*it)->getShortId()); + _ParentSizeMax = NULL; + _MaxW = _MaxH = 16384; + _OffsetX = _OffsetY = 0; + _Overlappable= true; + _ResizeFromChildW= false; + _ResizeFromChildH= false; + _ResizeFromChildWMargin= 0; + _ResizeFromChildHMargin= 0; + _MaxWReal = _MaxHReal = 16384; + _GroupSizeRef = 0; + _Escapable= false; + _Priority= WIN_PRIORITY_NORMAL; + _UseCursor = true; + _IsGroupContainer = false; + _IsGroupScrollText = false; + _IsGroupInScene = false; + _AHOnActive = NULL; + _AHOnDeactive = NULL; + _AHOnLeftClick = NULL; + _AHOnRightClick = NULL; + _AHOnEnter = NULL; + _AHOnEscape = NULL; + _NeedFrameUpdatePos= false; + _LUAEnvTableCreated= false; + _DepthForZSort= 0.f; + + #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS + CInterfaceManager::getInstance()->DebugTrackGroupsCreated( this ); + #endif } - for(std::vector::iterator it = _Controls.begin(); it != _Controls.end(); ++it) - { - (*it)->setIdRecurse((*it)->getShortId()); - } - for(std::vector::iterator it = _Views.begin(); it != _Views.end(); ++it) - { - (*it)->setIdRecurse((*it)->getShortId()); - } -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc) -{ - // notify children that the 'active' state of this group has changed - for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setIdRecurse(const std::string &id) { - (*it)->handleEvent(desc); - } - for(std::vector::iterator ctrlIt = _Controls.begin(); ctrlIt != _Controls.end(); ++ctrlIt) - { - (*ctrlIt)->handleEvent(desc); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setActive(bool state) -{ - if(state != getActive()) - { - CCtrlBase::setActive(state); - if (_AHOnActive != NULL && state) + CCtrlBase::setIdRecurse(id); + for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) { - CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); + (*it)->setIdRecurse((*it)->getShortId()); } - if (_AHOnDeactive != NULL && !state) + for(std::vector::iterator it = _Controls.begin(); it != _Controls.end(); ++it) { - CAHManager::getInstance()->runActionHandler (_AHOnDeactive, this, _AHOnDeactiveParams); + (*it)->setIdRecurse((*it)->getShortId()); } - - notifyActiveCalled(NLGUI::CEventDescriptorActiveCalledOnParent(state)); - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup::~CInterfaceGroup() -{ - // delete any LUA group environnement - deleteLUAEnvTable(); - // delete any LUA interface link "ondbchange" - removeAllLUAOnDbChange(); - -// NLMISC::TTime initStart; -// initStart = ryzomGetLocalTime (); - clearGroups(); -// nlinfo ("%d seconds for clearGroups '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); -// initStart = ryzomGetLocalTime (); - clearViews(); -// nlinfo ("%d seconds for clearViews '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); -// initStart = ryzomGetLocalTime (); - clearControls(); -// nlinfo ("%d seconds for clearControls '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); - CWidgetManager::getInstance()->removeRefOnGroup (this); - -#ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS - // AJM DEBUG - CInterfaceManager::getInstance()->DebugTrackGroupsDestroyed( this ); -#endif -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::clearViews() -{ - // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML and LibWWW callback - // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) - while(!_Views.empty()) - { - CViewBase *pVB = _Views.back(); - delEltOrder (pVB); - delete pVB; - // slower than a _Views.clear() out of loop, but we have to keep a clean array. - _Views.pop_back(); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::clearControls() -{ - // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML() and LibWWW callback - // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) - while(!_Controls.empty()) - { - CCtrlBase *pCB = _Controls.back(); - delEltOrder (pCB); - delete pCB; - // slower than a _Controls.clear() out of loop, but we have to keep a clean array. - _Controls.pop_back(); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::clearGroups() -{ - // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML() and LibWWW callback - // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) - while(!_ChildrenGroups.empty()) - { - CInterfaceGroup *pIG = _ChildrenGroups.back(); - delEltOrder (pIG); - delete pIG; - // slower than a _ChildrenGroups.clear() out of loop, but we have to keep a clean array. - _ChildrenGroups.pop_back(); - } -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::moveSBTrackY (CInterfaceGroup *target, sint32 dy) -{ - // Look if there is a vertical scrollbar with this target attached ... - vector::iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase *pCB = *itc; - CCtrlScrollBase *pSB = dynamic_cast(pCB); - if (pSB != NULL) + for(std::vector::iterator it = _Views.begin(); it != _Views.end(); ++it) { - if (pSB->getTarget() == target) + (*it)->setIdRecurse((*it)->getShortId()); + } + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc) + { + // notify children that the 'active' state of this group has changed + for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) + { + (*it)->handleEvent(desc); + } + for(std::vector::iterator ctrlIt = _Controls.begin(); ctrlIt != _Controls.end(); ++ctrlIt) + { + (*ctrlIt)->handleEvent(desc); + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setActive(bool state) + { + if(state != getActive()) + { + CCtrlBase::setActive(state); + if (_AHOnActive != NULL && state) { - pSB->moveTrackY(dy); - return true; + CAHManager::getInstance()->runActionHandler (_AHOnActive, this, _AHOnActiveParams); + } + if (_AHOnDeactive != NULL && !state) + { + CAHManager::getInstance()->runActionHandler (_AHOnDeactive, this, _AHOnDeactiveParams); + } + + notifyActiveCalled(NLGUI::CEventDescriptorActiveCalledOnParent(state)); + } + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup::~CInterfaceGroup() + { + // delete any LUA group environnement + deleteLUAEnvTable(); + // delete any LUA interface link "ondbchange" + removeAllLUAOnDbChange(); + + // NLMISC::TTime initStart; + // initStart = ryzomGetLocalTime (); + clearGroups(); + // nlinfo ("%d seconds for clearGroups '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); + // initStart = ryzomGetLocalTime (); + clearViews(); + // nlinfo ("%d seconds for clearViews '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); + // initStart = ryzomGetLocalTime (); + clearControls(); + // nlinfo ("%d seconds for clearControls '%s'", (uint32)(ryzomGetLocalTime ()-initStart)/1000, _Id.c_str()); + CWidgetManager::getInstance()->removeRefOnGroup (this); + + #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS + // AJM DEBUG + CInterfaceManager::getInstance()->DebugTrackGroupsDestroyed( this ); + #endif + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::clearViews() + { + // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML and LibWWW callback + // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) + while(!_Views.empty()) + { + CViewBase *pVB = _Views.back(); + delEltOrder (pVB); + delete pVB; + // slower than a _Views.clear() out of loop, but we have to keep a clean array. + _Views.pop_back(); + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::clearControls() + { + // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML() and LibWWW callback + // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) + while(!_Controls.empty()) + { + CCtrlBase *pCB = _Controls.back(); + delEltOrder (pCB); + delete pCB; + // slower than a _Controls.clear() out of loop, but we have to keep a clean array. + _Controls.pop_back(); + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::clearGroups() + { + // Yoyo: important to not Leave NULL in the array, because of ~CGroupHTML() and LibWWW callback + // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) + while(!_ChildrenGroups.empty()) + { + CInterfaceGroup *pIG = _ChildrenGroups.back(); + delEltOrder (pIG); + delete pIG; + // slower than a _ChildrenGroups.clear() out of loop, but we have to keep a clean array. + _ChildrenGroups.pop_back(); + } + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::moveSBTrackY (CInterfaceGroup *target, sint32 dy) + { + // Look if there is a vertical scrollbar with this target attached ... + vector::iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase *pCB = *itc; + CCtrlScrollBase *pSB = dynamic_cast(pCB); + if (pSB != NULL) + { + if (pSB->getTarget() == target) + { + pSB->moveTrackY(dy); + return true; + } } } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::moveSBTargetY(CInterfaceGroup *target,sint32 dy) -{ - // Look if there is a vertical scrollbar with this target attached ... - vector::iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase *pCB = *itc; - CCtrlScrollBase *pSB = dynamic_cast(pCB); - if (pSB != NULL) - { - if (pSB->getTarget() == target) - { - pSB->moveTargetY(dy); - return true; - } - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setPriority(uint8 nprio) -{ - if (nprio != _Priority) - { - CWidgetManager::getInstance()->setWindowPriority(this, nprio); - } -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if ( !CCtrlBase::parse(cur,parentGroup) ) - { - nlinfo ("cannot parse InterfaceElementLocalisable part"); return false; } - //determine if the group is a window. If the property is not specified, set it to false. - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"win" )); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"overlappable" ); - if(ptr) + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::moveSBTargetY(CInterfaceGroup *target,sint32 dy) { - _Overlappable= convertBool(ptr); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"escapable" ); - if(ptr) _Escapable= convertBool(ptr); - - // determine if the group must be sized according to his sons. - ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_w" ); - if(ptr) - { - _ResizeFromChildW= convertBool(ptr); - } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_h" ); - if(ptr) - { - _ResizeFromChildH= convertBool(ptr); - } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_wmargin" ); - if(ptr) - { - NLMISC::fromString((const char*)ptr, _ResizeFromChildWMargin); - } - ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_hmargin" ); - if(ptr) - { - NLMISC::fromString((const char*)ptr, _ResizeFromChildHMargin); - } - CAHManager::getInstance()->parseAH(cur, "on_active", "on_active_params", _AHOnActive, _AHOnActiveParams); - CAHManager::getInstance()->parseAH(cur, "on_deactive", "on_deactive_params", _AHOnDeactive, _AHOnDeactiveParams); - - // Read user max size - ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_w" ); - if (ptr) NLMISC::fromString((const char*)ptr, _MaxW); - ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_h" ); - if (ptr) NLMISC::fromString((const char*)ptr, _MaxH); - ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeref" ); - if (ptr) - { - parseMaxSizeRef(ptr); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" ); - if (ptr) - { - string idparent = ptr; - idparent = NLMISC::strlwr(idparent); - if (idparent != "parent") + // Look if there is a vertical scrollbar with this target attached ... + vector::iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { - if (parentGroup) - idparent = parentGroup->getId() +":" + string((const char*)ptr); - else - idparent = "ui:" + string((const char*)ptr); + CCtrlBase *pCB = *itc; + CCtrlScrollBase *pSB = dynamic_cast(pCB); + if (pSB != NULL) + { + if (pSB->getTarget() == target) + { + pSB->moveTargetY(dy); + return true; + } + } } - else + return false; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setPriority(uint8 nprio) + { + if (nprio != _Priority) { - if (parentGroup) - idparent = parentGroup->getId(); + CWidgetManager::getInstance()->setWindowPriority(this, nprio); } - CWidgetManager::parser->addParentSizeMaxAssociation (this, idparent); } - // left & right clicks - CAHManager::getInstance()->parseAH(cur, "group_onclick_r", "group_params_r", _AHOnRightClick, _AHOnRightClickParams); - CAHManager::getInstance()->parseAH(cur, "group_onclick_l", "group_params_l", _AHOnLeftClick, _AHOnLeftClickParams); - - // Each window (modal and groupContainer) can be validated by Enter. if "" => no op. - CAHManager::getInstance()->parseAH(cur, "on_enter", "on_enter_params", _AHOnEnter, _AHOnEnterParams); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"win_priority" ); - if(ptr) NLMISC::fromString((const char*)ptr, _Priority); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"use_cursor" ); - if(ptr) _UseCursor= convertBool(ptr); - - // Each window (modal and groupContainer) can be escaped if "escapable" set - // they can add an action handler before the hide - CAHManager::getInstance()->parseAH(cur, "on_escape", "on_escape_params", _AHOnEscape, _AHOnEscapeParams); - - - // LuaClass script - ptr = xmlGetProp (cur, (xmlChar*)"lua_class"); - if( ptr ) - CWidgetManager::parser->addLuaClassAssociation( this, (const char*)ptr ); - - return true; -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::parseMaxSizeRef(const char *ptr) -{ - parseSizeRef(ptr, _GroupSizeRef, _SizeDivW, _SizeDivH); -} - -// ------------------------------------------------------------------------------------------------ -uint32 CInterfaceGroup::getMemory () -{ - uint32 Mem = sizeof(*this); - /*vector::const_iterator itg; - for (itg = _ChildrenGroups.begin() ; itg != _ChildrenGroups.end(); itg++) + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { - CInterfaceGroup *pIG = *itg; - Mem += pIG->getMemory(); - }*/ - - for (vector::const_iterator itv = _Views.begin() ; itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - Mem += pVB->getMemory(); - } - - for (vector::const_iterator itc = _Controls.begin() ; itc != _Controls.end(); itc++) - { - CCtrlBase* ctrl = *itc; - Mem += ctrl->getMemory(); - } - return Mem; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::addToEltOrder(CViewBase *view, sint order) -{ - if (!view) return; - if (order == -1) - { - _EltOrder.push_back(view); - } - else - { - if (order > (sint) _EltOrder.size()) return; - _EltOrder.insert(_EltOrder.begin() + order, view); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::addView (CViewBase *child, sint eltOrder /*= -1*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return; - } - _Views.push_back(child); - addToEltOrder(child, eltOrder); - - // elt callBack. - child->onAddToGroup(); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::addCtrl (CCtrlBase *child, sint eltOrder /*= -1*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL ctrl"); - return; - } - _Controls.push_back(child); - addToEltOrder(child, eltOrder); - - // elt callBack. - child->onAddToGroup(); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::addGroup (CInterfaceGroup *child, sint eltOrder /*= -1*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL group"); - return; - } - _ChildrenGroups.push_back(child); - addToEltOrder(child, eltOrder); - - // elt callBack. - child->onAddToGroup(); -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaAddGroup (CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::addTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if(group) - { - group->setParent(this); - group->setParentPos(this); - addGroup(group); - } - return 0; -} -// ------------------------------------------------------------------------------------------------ -// id = incomplete path (text:list:a) lid complete one (ui:interface:content:text:list:a) -static bool reverseCheckPath(const string &id, const string &lid) -{ - string idTmp = id, lidTmp = lid; -// bool isFound = true; - while (idTmp.size() > 0) - { - string tokid, toklid; - - string::size_type posid = idTmp.rfind (":"); - if (posid == string::npos) + if ( !CCtrlBase::parse(cur,parentGroup) ) { - posid = 0; - tokid = idTmp; - } - else - { - tokid = idTmp.substr (posid+1); - } - - string::size_type poslid = lidTmp.rfind (":"); - if (poslid == string::npos) - { - poslid = 0; - toklid = lidTmp; - } - else - { - toklid = lidTmp.substr (poslid+1); - } - - if (tokid != toklid) + nlinfo ("cannot parse InterfaceElementLocalisable part"); return false; + } - if (posid > 0) - idTmp = idTmp.substr (0, posid); + //determine if the group is a window. If the property is not specified, set it to false. + CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"win" )); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"overlappable" ); + if(ptr) + { + _Overlappable= convertBool(ptr); + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"escapable" ); + if(ptr) _Escapable= convertBool(ptr); + + // determine if the group must be sized according to his sons. + ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_w" ); + if(ptr) + { + _ResizeFromChildW= convertBool(ptr); + } + ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_h" ); + if(ptr) + { + _ResizeFromChildH= convertBool(ptr); + } + ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_wmargin" ); + if(ptr) + { + NLMISC::fromString((const char*)ptr, _ResizeFromChildWMargin); + } + ptr = (char*) xmlGetProp( cur, (xmlChar*)"child_resize_hmargin" ); + if(ptr) + { + NLMISC::fromString((const char*)ptr, _ResizeFromChildHMargin); + } + CAHManager::getInstance()->parseAH(cur, "on_active", "on_active_params", _AHOnActive, _AHOnActiveParams); + CAHManager::getInstance()->parseAH(cur, "on_deactive", "on_deactive_params", _AHOnDeactive, _AHOnDeactiveParams); + + // Read user max size + ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_w" ); + if (ptr) NLMISC::fromString((const char*)ptr, _MaxW); + ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_h" ); + if (ptr) NLMISC::fromString((const char*)ptr, _MaxH); + ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeref" ); + if (ptr) + { + parseMaxSizeRef(ptr); + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"max_sizeparent" ); + if (ptr) + { + string idparent = ptr; + idparent = NLMISC::strlwr(idparent); + if (idparent != "parent") + { + if (parentGroup) + idparent = parentGroup->getId() +":" + string((const char*)ptr); + else + idparent = "ui:" + string((const char*)ptr); + } + else + { + if (parentGroup) + idparent = parentGroup->getId(); + } + CWidgetManager::parser->addParentSizeMaxAssociation (this, idparent); + } + + // left & right clicks + CAHManager::getInstance()->parseAH(cur, "group_onclick_r", "group_params_r", _AHOnRightClick, _AHOnRightClickParams); + CAHManager::getInstance()->parseAH(cur, "group_onclick_l", "group_params_l", _AHOnLeftClick, _AHOnLeftClickParams); + + // Each window (modal and groupContainer) can be validated by Enter. if "" => no op. + CAHManager::getInstance()->parseAH(cur, "on_enter", "on_enter_params", _AHOnEnter, _AHOnEnterParams); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"win_priority" ); + if(ptr) NLMISC::fromString((const char*)ptr, _Priority); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"use_cursor" ); + if(ptr) _UseCursor= convertBool(ptr); + + // Each window (modal and groupContainer) can be escaped if "escapable" set + // they can add an action handler before the hide + CAHManager::getInstance()->parseAH(cur, "on_escape", "on_escape_params", _AHOnEscape, _AHOnEscapeParams); + + + // LuaClass script + ptr = xmlGetProp (cur, (xmlChar*)"lua_class"); + if( ptr ) + CWidgetManager::parser->addLuaClassAssociation( this, (const char*)ptr ); + + return true; + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::parseMaxSizeRef(const char *ptr) + { + parseSizeRef(ptr, _GroupSizeRef, _SizeDivW, _SizeDivH); + } + + // ------------------------------------------------------------------------------------------------ + uint32 CInterfaceGroup::getMemory () + { + uint32 Mem = sizeof(*this); + /*vector::const_iterator itg; + for (itg = _ChildrenGroups.begin() ; itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pIG = *itg; + Mem += pIG->getMemory(); + }*/ + + for (vector::const_iterator itv = _Views.begin() ; itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + Mem += pVB->getMemory(); + } + + for (vector::const_iterator itc = _Controls.begin() ; itc != _Controls.end(); itc++) + { + CCtrlBase* ctrl = *itc; + Mem += ctrl->getMemory(); + } + return Mem; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addToEltOrder(CViewBase *view, sint order) + { + if (!view) return; + if (order == -1) + { + _EltOrder.push_back(view); + } else - idTmp = ""; - - if (poslid > 0) - lidTmp = lidTmp.substr (0, poslid); - else - lidTmp = ""; - } - return true; -} - -// ------------------------------------------------------------------------------------------------ -CViewBase* CInterfaceGroup::getView (const std::string &id) -{ - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); ++itv) - { - CViewBase *pVB = (*itv); - if (reverseCheckPath(id, pVB->getId())) - return *itv; - } - // search in sons - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) - { - CViewBase* view = (*itg)->getView(id); - if (view) - return view; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -CCtrlBase* CInterfaceGroup::getCtrl (const std::string &id) -{ - vector::const_iterator itv; - for (itv = _Controls.begin(); itv != _Controls.end(); ++itv) - { - CCtrlBase *pCB = (*itv); - if (reverseCheckPath(id, pCB->getId())) - return *itv; - } - // search in sons - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) - { - CCtrlBase*pCtrl = (*itg)->getCtrl (id); - if (pCtrl) - return pCtrl; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup*CInterfaceGroup::getGroup (const std::string &id) const -{ - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end();itg++) - { - CInterfaceGroup *pIG = (*itg); - if (reverseCheckPath(id, pIG->getId())) - return *itg; - } - // search in sons - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) - { - CInterfaceGroup *pCtrl = (*itg)->getGroup (id); - if (pCtrl) - return pCtrl; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delView (CViewBase *child, bool dontDelete /* = false*/) -{ - for (sint32 i = 0; i < (sint32)_Views.size(); ++i) - { - if (_Views[i] == child) { - if (!dontDelete) delete _Views[i]; - _Views.erase(_Views.begin()+i); - delEltOrder (child); - return true; + if (order > (sint) _EltOrder.size()) return; + _EltOrder.insert(_EltOrder.begin() + order, view); } } - return false; -} -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delCtrl (CCtrlBase *child, bool dontDelete /* = false*/) -{ - for (sint32 i = 0; i < (sint32)_Controls.size(); ++i) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addView (CViewBase *child, sint eltOrder /*= -1*/) { - if (_Controls[i] == child) + if (!child) { - if (!dontDelete) delete _Controls[i]; - _Controls.erase(_Controls.begin()+i); - delEltOrder (child); - return true; - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delGroup (CInterfaceGroup *child, bool dontDelete /* = false*/) -{ - for (sint32 i = 0; i < (sint32)_ChildrenGroups.size(); ++i) - { - if (_ChildrenGroups[i] == child) - { - if (!dontDelete) delete _ChildrenGroups[i]; - _ChildrenGroups.erase(_ChildrenGroups.begin()+i); - delEltOrder (child); - return true; - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaDelGroup (CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::delTab", 1); - CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if(group) - { - delGroup(group); - } - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaGetNumGroups(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getNumGroups", 0); - ls.push((double) _ChildrenGroups.size()); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaGetGroup(CLuaState &ls) -{ - const char *funcName = "CInterfaceGroup::getGroup"; - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getGroup", 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - uint index = (uint) ls.toNumber(1); - if (index >= _ChildrenGroups.size()) - { - CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size()); - } - CLuaIHM::pushUIOnStack(ls, _ChildrenGroups[index]); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::delEltOrder (CViewBase *pElt) -{ - for (sint32 i = 0; i < (sint32)_EltOrder.size(); ++i) - { - if (_EltOrder[i] == pElt) - { - _EltOrder.erase (_EltOrder.begin()+i); + nlwarning(" : tried to add a NULL view"); return; } + _Views.push_back(child); + addToEltOrder(child, eltOrder); + + // elt callBack. + child->onAddToGroup(); } -} -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delView (const std::string &id, bool dontDelete /* = false*/) -{ - return delView(getView(id), dontDelete); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delCtrl (const std::string &id, bool dontDelete /* = false*/) -{ - return delCtrl(getCtrl(id), dontDelete); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delGroup (const std::string &id, bool dontDelete /* = false*/) -{ - return delGroup(getGroup(id), dontDelete); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::isChildGroup(const CInterfaceGroup *group) const -{ - return std::find(_ChildrenGroups.begin(), _ChildrenGroups.end(), group) != _ChildrenGroups.end(); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active) - return false; - - if (event.getType() == NLGUI::CEventDescriptor::system) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addCtrl (CCtrlBase *child, sint eltOrder /*= -1*/) { - NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; - if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) + if (!child) { - // notify all childrens - notifyActiveCalled((NLGUI::CEventDescriptorActiveCalledOnParent &) eds); + nlwarning(" : tried to add a NULL ctrl"); + return; + } + _Controls.push_back(child); + addToEltOrder(child, eltOrder); + + // elt callBack. + child->onAddToGroup(); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addGroup (CInterfaceGroup *child, sint eltOrder /*= -1*/) + { + if (!child) + { + nlwarning(" : tried to add a NULL group"); + return; + } + _ChildrenGroups.push_back(child); + addToEltOrder(child, eltOrder); + + // elt callBack. + child->onAddToGroup(); + } + + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaAddGroup (CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::addTab", 1); + CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if(group) + { + group->setParent(this); + group->setParentPos(this); + addGroup(group); + } + return 0; + } + // ------------------------------------------------------------------------------------------------ + // id = incomplete path (text:list:a) lid complete one (ui:interface:content:text:list:a) + static bool reverseCheckPath(const string &id, const string &lid) + { + string idTmp = id, lidTmp = lid; + // bool isFound = true; + while (idTmp.size() > 0) + { + string tokid, toklid; + + string::size_type posid = idTmp.rfind (":"); + if (posid == string::npos) + { + posid = 0; + tokid = idTmp; + } + else + { + tokid = idTmp.substr (posid+1); + } + + string::size_type poslid = lidTmp.rfind (":"); + if (poslid == string::npos) + { + poslid = 0; + toklid = lidTmp; + } + else + { + toklid = lidTmp.substr (poslid+1); + } + + if (tokid != toklid) + return false; + + if (posid > 0) + idTmp = idTmp.substr (0, posid); + else + idTmp = ""; + + if (poslid > 0) + lidTmp = lidTmp.substr (0, poslid); + else + lidTmp = ""; + } + return true; + } + + // ------------------------------------------------------------------------------------------------ + CViewBase* CInterfaceGroup::getView (const std::string &id) + { + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); ++itv) + { + CViewBase *pVB = (*itv); + if (reverseCheckPath(id, pVB->getId())) + return *itv; + } + // search in sons + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) + { + CViewBase* view = (*itg)->getView(id); + if (view) + return view; + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + CCtrlBase* CInterfaceGroup::getCtrl (const std::string &id) + { + vector::const_iterator itv; + for (itv = _Controls.begin(); itv != _Controls.end(); ++itv) + { + CCtrlBase *pCB = (*itv); + if (reverseCheckPath(id, pCB->getId())) + return *itv; + } + // search in sons + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) + { + CCtrlBase*pCtrl = (*itg)->getCtrl (id); + if (pCtrl) + return pCtrl; + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup*CInterfaceGroup::getGroup (const std::string &id) const + { + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end();itg++) + { + CInterfaceGroup *pIG = (*itg); + if (reverseCheckPath(id, pIG->getId())) + return *itg; + } + // search in sons + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); ++itg) + { + CInterfaceGroup *pCtrl = (*itg)->getGroup (id); + if (pCtrl) + return pCtrl; + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delView (CViewBase *child, bool dontDelete /* = false*/) + { + for (sint32 i = 0; i < (sint32)_Views.size(); ++i) + { + if (_Views[i] == child) + { + if (!dontDelete) delete _Views[i]; + _Views.erase(_Views.begin()+i); + delEltOrder (child); + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delCtrl (CCtrlBase *child, bool dontDelete /* = false*/) + { + for (sint32 i = 0; i < (sint32)_Controls.size(); ++i) + { + if (_Controls[i] == child) + { + if (!dontDelete) delete _Controls[i]; + _Controls.erase(_Controls.begin()+i); + delEltOrder (child); + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delGroup (CInterfaceGroup *child, bool dontDelete /* = false*/) + { + for (sint32 i = 0; i < (sint32)_ChildrenGroups.size(); ++i) + { + if (_ChildrenGroups[i] == child) + { + if (!dontDelete) delete _ChildrenGroups[i]; + _ChildrenGroups.erase(_ChildrenGroups.begin()+i); + delEltOrder (child); + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaDelGroup (CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::delTab", 1); + CInterfaceGroup * group = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if(group) + { + delGroup(group); + } + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaGetNumGroups(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getNumGroups", 0); + ls.push((double) _ChildrenGroups.size()); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaGetGroup(CLuaState &ls) + { + const char *funcName = "CInterfaceGroup::getGroup"; + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getGroup", 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + uint index = (uint) ls.toNumber(1); + if (index >= _ChildrenGroups.size()) + { + CLuaIHM::fails(ls, "getGroup : try to index group %s, but there are only %d son groups", ls.toString(1), (int) _ChildrenGroups.size()); + } + CLuaIHM::pushUIOnStack(ls, _ChildrenGroups[index]); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::delEltOrder (CViewBase *pElt) + { + for (sint32 i = 0; i < (sint32)_EltOrder.size(); ++i) + { + if (_EltOrder[i] == pElt) + { + _EltOrder.erase (_EltOrder.begin()+i); + return; + } } } - if (event.getType() == NLGUI::CEventDescriptor::mouse) + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delView (const std::string &id, bool dontDelete /* = false*/) { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + return delView(getView(id), dontDelete); + } - if (!isIn(eventDesc.getX(), eventDesc.getY())) + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delCtrl (const std::string &id, bool dontDelete /* = false*/) + { + return delCtrl(getCtrl(id), dontDelete); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delGroup (const std::string &id, bool dontDelete /* = false*/) + { + return delGroup(getGroup(id), dontDelete); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::isChildGroup(const CInterfaceGroup *group) const + { + return std::find(_ChildrenGroups.begin(), _ChildrenGroups.end(), group) != _ChildrenGroups.end(); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active) return false; - bool taken = false; + if (event.getType() == NLGUI::CEventDescriptor::system) + { + NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) + { + // notify all childrens + notifyActiveCalled((NLGUI::CEventDescriptorActiveCalledOnParent &) eds); + } + } + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + + if (!isIn(eventDesc.getX(), eventDesc.getY())) + return false; + + bool taken = false; + + // For each control in the group... + vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase *pCB = *itc; + if (pCB->getActive()) + taken = taken || pCB->handleEvent(eventDesc); + } + if (taken) + return true; + + // For each child group + for (sint i = (sint)_ChildrenGroups.size()-1; i >= 0; --i) + { + CInterfaceGroup *pIG = _ChildrenGroups[i]; + if (pIG->getActive()) + if (pIG->handleEvent(eventDesc)) + return true; + } + + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + if (_AHOnLeftClick != NULL) + { + CAHManager::getInstance()->runActionHandler(_AHOnLeftClick, this, _AHOnLeftClickParams); + return true; + } + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + { + if (_AHOnRightClick != NULL) + { + CAHManager::getInstance()->runActionHandler(_AHOnRightClick, this, _AHOnRightClickParams); + return true; + } + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + // handle the Mouse Wheel only if interesting + if (_H>_MaxH) + { + CInterfaceGroup *currParent = _Parent; + while (currParent) + { + if (currParent->moveSBTrackY (this, eventDesc.getWheel()*12)) + return true; + currParent = currParent->getParent(); + } + } + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::executeControl (const std::string &/* sControlName */) + { + // bool taken = false; + // CCtrlBase *pIC = getCtrl (sControlName); + // if (pIC != NULL) + // pIC->callback(taken); + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::draw () + { + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); + + // Display sons only if not total clipped + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if( !rVR.isClipWindowEmpty() ) + { + // Draw all decorative elements + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pVB = *ite; + if (pVB->getActive()) + pVB->draw(); + } + } + + restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::drawNoClip() + { + // Display sons only if not total clipped + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if( !rVR.isClipWindowEmpty() ) + { + // Draw all decorative elements + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pVB = *ite; + if (pVB->getActive()) + pVB->draw(); + } + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter) + { + if (!_Active) return; + CInterfaceElement::renderWiredQuads(type, uiFilter); + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); + for(std::vector::iterator it = _EltOrder.begin(); it != _EltOrder.end(); ++it) + { + if (*it) (*it)->renderWiredQuads(type, uiFilter); + } + restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::drawElement (CViewBase *el) + { + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); + + if(el) + el->draw(); + + restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::checkCoords() + { + //update all children elements + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pIE = *ite; + if(pIE->getActive()) + pIE->checkCoords(); + } + executeLuaScriptOnDraw(); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::executeLuaScriptOnDraw() + { + // If some LUA script attached to me, execute it + if(!_LUAOnDraw.empty()) + CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); + + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::doUpdateCoords() + { + _MaxWReal = _MaxW; + _MaxHReal = _MaxH; + + CInterfaceElement *el = NULL; + + if (_ParentSizeMax != NULL) + { + el = _ParentSizeMax; + } + else + { + if (_ParentSize != NULL) + { + el = _ParentSize; + } + else + { + if (_ParentPos != NULL) + el = _ParentPos; + else + el = _Parent; + } + } + + if (el != NULL) + { + if (_GroupSizeRef&1) + _MaxWReal += _SizeDivW * el->getWReal() / 10; + + if (_GroupSizeRef&2) + _MaxHReal += _SizeDivH * el->getHReal() / 10; + } + + CViewBase::updateCoords(); + _XReal += _OffsetX; + _YReal += _OffsetY; + + //update all children elements + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pIE = *ite; + pIE->updateCoords(); + } + + _XReal -= _OffsetX; + _YReal -= _OffsetY; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::updateCoords() + { + // update basis and sons one time. + doUpdateCoords(); + + // if the group must resize from children + if(_ResizeFromChildH || _ResizeFromChildW) + { + // compute BBox of all childrens + sint width, height; + evalChildrenBBox(_ResizeFromChildW, _ResizeFromChildH, width, height); + // set forced size. + if(_ResizeFromChildW) + { + _W= _ResizeFromChildWMargin + width; + } + if(_ResizeFromChildH) + { + _H= _ResizeFromChildHMargin + height; + } + } + + CInterfaceElement::updateCoords(); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const + { + sint yMin=INT_MAX, yMax=INT_MIN; + sint xMin=INT_MAX, xMax=INT_MIN; + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pIE = *ite; + if (pIE->getActive()) + { + const CInterfaceElement *el = pIE->getParentPos() ? pIE->getParentPos() : pIE->getParent(); + if (el == this) + { + // to compute the bbox, don't use direct sons that have a sizeref on the resizing coordinate + if ((resizeFromChildW && (pIE->getSizeRef() & 1)) + || (resizeFromChildH && (pIE->getSizeRef() & 2)) + ) + { + continue; + } + } + // avoid also some interface elements + if(pIE->avoidResizeParent()) + continue; + // get the real coords bounds. + sint32 x0,y0,x1,y1; + // If it is a group, minimize with MaxHReal / MaxWReal + const CInterfaceGroup *sonGroup= dynamic_cast(pIE); + // \todo yoyo: do not know why but don't work if this==scroll_text + if(sonGroup && !isGroupScrollText()) + { + sint32 oldSciX= -16384; + sint32 oldSciY= -16384; + sint32 oldSciW= 32768; + sint32 oldSciH= 32768; + sint32 w, h; + sonGroup->computeCurrentClipContribution(oldSciX, oldSciY, oldSciW, oldSciH, x0, y0, w, h); + x1= x0 + w; + y1= y0 + h; + } + else + { + x0= pIE->getXReal(); + y0= pIE->getYReal(); + x1= x0 + pIE->getWReal(); + y1= y0 + pIE->getHReal(); + } + // enlarge + if(x0xMax) + xMax= x1; + if(y1>yMax) + yMax= y1; + } + } + width = xMax - xMin; + height = yMax - yMin; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CInterfaceGroup::getElement (const std::string &id) + { + if (_Id == id) + return this; + + if (id.compare(0, _Id.size(), _Id) != 0) + return NULL; + + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + #if !FINAL_VERSION // For SpeedUp in final version + nlassert(pVB); // The element must not be NULL + #endif + if (pVB->getId() == id) + return pVB; + } + + vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase* ctrl = *itc; + #if !FINAL_VERSION // For SpeedUp in final version + nlassert(ctrl); // The element must not be NULL + #endif + if (ctrl->getId() == id) + return ctrl; + } + + vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pIG = *itg; + #if !FINAL_VERSION // For SpeedUp in final version + nlassert(pIG); // The element must not be NULL + #endif + CInterfaceElement *pIEL = pIG->getElement(id); + if (pIEL != NULL) + return pIEL; + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delElement (const std::string &id, bool noWarning) + { + if (id.substr(0, _Id.size()) != _Id) + return false; + + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + if (pVB->getId() == id) + { + delView (pVB, false); + return true; + } + } + + vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase* ctrl = *itc; + if (ctrl->getId() == id) + { + delCtrl (ctrl, false); + return true; + } + } + + vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pIG = *itg; + if (pIG->getId() == id) + { + // If this is a root window + if (pIG->getRootWindow () == pIG) + CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); + delGroup (pIG, false); + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::delElement (CInterfaceElement *pIE, bool noWarning) + { + // delete correct type of element + if(pIE->isGroup()) + { + CInterfaceGroup *pIG= static_cast(pIE); + // unmake window if it is + if (pIG->getRootWindow () == pIG) + CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); + return delGroup(pIG); + } + else if(pIE->isCtrl()) + { + return delCtrl(static_cast(pIE)); + } + + nlassert(pIE->isView()); + return delView(static_cast(pIE)); + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::isWindowUnder (sint32 x, sint32 y) + { + return ((x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal + _HReal))); + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CInterfaceGroup::getGroupUnder (sint32 x, sint32 y) + { + // Begins by the children + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pChild = *itg; + CInterfaceGroup *pChildUnder = pChild->getGroupUnder (x-_XReal, y-_YReal); + if (pChildUnder != NULL) + { + if ( (x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal))) + return pChildUnder; + } + } + + // If not found in childs then try in the parent one + if ( (x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal))) + return this; + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB) + { + if (!((x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal)))) + return false; + // test against current clip + computeCurrentClipContribution(clipX, clipY, clipW, clipH, + clipX, clipY, clipW, clipH); + + if (!((x > clipX) && + (x < (clipX + clipW))&& + (y > clipY) && + (y < (clipY + clipH)))) + return false; + + + + // same as draw order: start with parent + std::vector::const_iterator itc; + for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) + { + if (!(*itc)->isCtrl() && !(*itc)->isGroup()) // must be a view + { + CViewBase *pVB = *itc; + if (pVB != NULL) + if (pVB->getActive()) + if ( ((x) > pVB->getXReal()) && + ((x) < (pVB->getXReal() + pVB->getWReal()))&& + ((y) > pVB->getYReal()) && + ((y) < (pVB->getYReal() + pVB->getHReal()))) + { + vVB.push_back (pVB); + } + } + } + + // same as draw order: continue with children + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pChild = *itg; + if (pChild->getActive()) + { + // bool bUnder = + pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB); + // if (bUnder && (vICL.size() > 0)) + // return true; + } + } + return true; + } + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL) + { + if (!((x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal)))) + return false; + // test against current clip + computeCurrentClipContribution(clipX, clipY, clipW, clipH, + clipX, clipY, clipW, clipH); + + if (!((x >= clipX) && + (x < (clipX + clipW))&& + (y > clipY) && + (y <= (clipY + clipH)))) + return false; + + + + // same as draw order: start with parent + std::vector::const_iterator itc; + for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) + { + if ((*itc)->isCtrl() && !(*itc)->isGroup()) // must be a ctrl but not a group (parsed later) + { + CCtrlBase *pICL = (CCtrlBase *) *itc; + if (pICL != NULL) + if (pICL->getActive()) + if ( ((x) >= pICL->getXReal()) && + ((x) < (pICL->getXReal() + pICL->getWReal()))&& + ((y) > pICL->getYReal()) && + ((y) <= (pICL->getYReal() + pICL->getHReal()))) + { + vICL.push_back (pICL->getSubCtrl(x,y)); + } + } + } + + // same as draw order: continue with children + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pChild = *itg; + if (pChild->getActive()) + { + // bool bUnder = + pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL); + // if (bUnder && (vICL.size() > 0)) + // return true; + } + } + return true; + } + + + // ------------------------------------------------------------------------------------------------ + bool CInterfaceGroup::getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vIGL) + { + if (!((x >= _XReal) && + (x < (_XReal + _WReal))&& + (y > _YReal) && + (y <= (_YReal+ _HReal)))) + return false; + // test against current clip + computeCurrentClipContribution(clipX, clipY, clipW, clipH, + clipX, clipY, clipW, clipH); + + if (!((x >= clipX) && + (x < (clipX + clipW))&& + (y > clipY) && + (y <= (clipY + clipH)))) + return false; + + + + // same as draw order: start with parent + std::vector::const_iterator itc; + for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) + { + if ((*itc)->isGroup()) // must be a group + { + CInterfaceGroup *pIGL = (CInterfaceGroup *) *itc; + if (pIGL != NULL) + if (pIGL->getActive()) + if ( ((x) >= pIGL->getXReal()) && + ((x) < (pIGL->getXReal() + pIGL->getWReal()))&& + ((y) > pIGL->getYReal()) && + ((y) <= (pIGL->getYReal() + pIGL->getHReal()))) + { + vIGL.push_back (pIGL); + } + } + } + + // same as draw order: continue with children + std::vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pChild = *itg; + if (pChild->getActive()) + { + // bool bUnder = + pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL); + // if (bUnder && (vICL.size() > 0)) + // return true; + } + } + return true; + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::absoluteToRelative (sint32 &x, sint32 &y) + { + CInterfaceGroup *curGrp = _Parent; + while (curGrp != NULL) + { + x = x - curGrp->_XReal; + y = y - curGrp->_YReal; + curGrp = curGrp->_Parent; + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::computeCurrentClipContribution(sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH, + sint32 &newSciXDest, sint32 &newSciYDest, sint32 &newSciWDest, sint32 &newSciHDest) const + { + sint32 newSciX = _XReal; + sint32 newSciY = _YReal; + sint32 newSciW = _WReal; + sint32 newSciH = _HReal; + // If there is width size limiter + if (_MaxWReal < _WReal) + { + if ((_PosRef == Hotspot_TR) || (_PosRef == Hotspot_MR) || (_PosRef == Hotspot_BR)) + newSciX = _XReal + _WReal - _MaxWReal; + newSciW = _MaxWReal; + } + // If there is height size limiter + if (_MaxHReal < _HReal) + { + if ((_PosRef == Hotspot_TL) || (_PosRef == Hotspot_TM) || (_PosRef == Hotspot_TR)) + newSciY = _YReal + _HReal - _MaxHReal; + newSciH = _MaxHReal; + } + // Clip Left + if (newSciX < oldSciX) + { + newSciW = newSciW - (oldSciX - newSciX); + newSciX = oldSciX; + } + // Clip Right + if ((newSciX+newSciW) > (oldSciX+oldSciW)) + { + newSciW = newSciW - ((newSciX+newSciW)-(oldSciX+oldSciW)); + } + // Clip Bottom + if (newSciY < oldSciY) + { + newSciH = newSciH - (oldSciY - newSciY); + newSciY = oldSciY; + } + // Clip Top + if ((newSciY+newSciH) > (oldSciY+oldSciH)) + { + newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); + } + + newSciXDest = newSciX; + newSciYDest = newSciY; + newSciWDest = newSciW; + newSciHDest = newSciH; + + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::makeNewClip (sint32 &oldSciX, sint32 &oldSciY, sint32 &oldSciW, sint32 &oldSciH) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); + + sint32 newSciX, newSciY, newSciW, newSciH; + computeCurrentClipContribution(oldSciX, oldSciY, oldSciW, oldSciH, newSciX, newSciY, newSciW, newSciH); + rVR.setClipWindow (newSciX, newSciY, newSciW, newSciH); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 sw, sh; + rVR.getScreenSize(sw, sh); + sint32 sciX = 0, sciY = 0, sciW = sw, sciH =sh; + const CInterfaceGroup *currGroup = this; + do + { + currGroup->computeCurrentClipContribution(sciX, sciY, sciW, sciH, sciX, sciY, sciW, sciH); + currGroup = currGroup->_Parent; + } while(currGroup); + x = sciX; + y = sciY; + w = sciW; + h = sciH; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.setClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); + } + + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::launch () + { + // launch all elements + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pIE = *ite; + pIE->launch(); + } + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup *CInterfaceGroup::getGroup(uint index) const + { + if (index > _ChildrenGroups.size()) + { + nlwarning(" bad index;"); + return NULL; + } + return _ChildrenGroups[index]; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::updateAllLinks() + { + CCtrlBase::updateAllLinks(); + { + for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) + { + (*it)->updateAllLinks(); + } + } + { + for(std::vector::iterator it = _Controls.begin(); it != _Controls.end(); ++it) + { + (*it)->updateAllLinks(); + } + } + { + for(std::vector::iterator it = _Views.begin(); it != _Views.end(); ++it) + { + (*it)->updateAllLinks(); + } + } + } + + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceGroup::getAlpha() const + { + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + sint32 a = pVB->getAlpha(); + if (a != -1) + return a; + } - // For each control in the group... vector::const_iterator itc; for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { CCtrlBase *pCB = *itc; - if (pCB->getActive()) - taken = taken || pCB->handleEvent(eventDesc); - } - if (taken) - return true; - - // For each child group - for (sint i = (sint)_ChildrenGroups.size()-1; i >= 0; --i) - { - CInterfaceGroup *pIG = _ChildrenGroups[i]; - if (pIG->getActive()) - if (pIG->handleEvent(eventDesc)) - return true; + sint32 a = pCB->getAlpha(); + if (a != -1) + return a; } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) { - if (_AHOnLeftClick != NULL) + CInterfaceGroup *pIG = *itg; + sint32 a = pIG->getAlpha(); + if (a != -1) + return a; + } + return -1; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setAlpha (sint32 a) + { + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + pVB->setAlpha(a); + } + + vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase *pCB = *itc; + pCB->setAlpha(a); + } + + vector::const_iterator itg; + for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + { + CInterfaceGroup *pIG = *itg; + pIG->setAlpha(a); + } + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setLeftClickHandler(const std::string &handler) + { + _AHOnLeftClick = CAHManager::getInstance()->getAH(handler, _AHOnLeftClickParams); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setRightClickHandler(const std::string &handler) + { + _AHOnRightClick = CAHManager::getInstance()->getAH(handler, _AHOnRightClickParams); + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CInterfaceGroup::getEnclosingContainer() + { + CInterfaceGroup *ig = this; + do + { + if( ig->isGroupContainer() ) + return ig; + ig = ig->getParent(); + } + while( ig != NULL ); + + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::dumpGroups() + { + nlinfo("Num groups = %d", (int) _ChildrenGroups.size()); + for(uint k = 0; k < _ChildrenGroups.size(); ++k) + { + std::string typeName = "???"; + if (_ChildrenGroups[k]) { - CAHManager::getInstance()->runActionHandler(_AHOnLeftClick, this, _AHOnLeftClickParams); - return true; + const type_info &ti = typeid(*_ChildrenGroups[k]); + typeName = ti.name(); } + nlinfo("Group %d, name = %s, type=%s", k, _ChildrenGroups[k] ? _ChildrenGroups[k]->getId().c_str() : "???", typeName.c_str()); } + } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::dumpEltsOrder() + { + nlinfo("Num elements = %d", (int) _EltOrder.size()); + for(uint k = 0; k < _EltOrder.size(); ++k) { - if (_AHOnRightClick != NULL) + std::string typeName = "???"; + if (_ChildrenGroups[k]) { - CAHManager::getInstance()->runActionHandler(_AHOnRightClick, this, _AHOnRightClickParams); - return true; + const type_info &ti = typeid(*_EltOrder[k]); + typeName = ti.name(); } - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - // handle the Mouse Wheel only if interesting - if (_H>_MaxH) + CInterfaceElement *el = _EltOrder[k]; + if (el) { - CInterfaceGroup *currParent = _Parent; - while (currParent) - { - if (currParent->moveSBTrackY (this, eventDesc.getWheel()*12)) - return true; - currParent = currParent->getParent(); - } - } - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::executeControl (const std::string &/* sControlName */) -{ -// bool taken = false; -// CCtrlBase *pIC = getCtrl (sControlName); -// if (pIC != NULL) -// pIC->callback(taken); -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::draw () -{ - sint32 oldSciX, oldSciY, oldSciW, oldSciH; - makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); - - // Display sons only if not total clipped - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if( !rVR.isClipWindowEmpty() ) - { - // Draw all decorative elements - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pVB = *ite; - if (pVB->getActive()) - pVB->draw(); - } - } - - restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::drawNoClip() -{ - // Display sons only if not total clipped - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if( !rVR.isClipWindowEmpty() ) - { - // Draw all decorative elements - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pVB = *ite; - if (pVB->getActive()) - pVB->draw(); - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter) -{ - if (!_Active) return; - CInterfaceElement::renderWiredQuads(type, uiFilter); - sint32 oldSciX, oldSciY, oldSciW, oldSciH; - makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); - for(std::vector::iterator it = _EltOrder.begin(); it != _EltOrder.end(); ++it) - { - if (*it) (*it)->renderWiredQuads(type, uiFilter); - } - restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::drawElement (CViewBase *el) -{ - sint32 oldSciX, oldSciY, oldSciW, oldSciH; - makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); - - if(el) - el->draw(); - - restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::checkCoords() -{ - //update all children elements - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pIE = *ite; - if(pIE->getActive()) - pIE->checkCoords(); - } - executeLuaScriptOnDraw(); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::executeLuaScriptOnDraw() -{ - // If some LUA script attached to me, execute it - if(!_LUAOnDraw.empty()) - CAHManager::getInstance()->runActionHandler("lua", this, _LUAOnDraw); - -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::doUpdateCoords() -{ - _MaxWReal = _MaxW; - _MaxHReal = _MaxH; - - CInterfaceElement *el = NULL; - - if (_ParentSizeMax != NULL) - { - el = _ParentSizeMax; - } - else - { - if (_ParentSize != NULL) - { - el = _ParentSize; - } - else - { - if (_ParentPos != NULL) - el = _ParentPos; - else - el = _Parent; - } - } - - if (el != NULL) - { - if (_GroupSizeRef&1) - _MaxWReal += _SizeDivW * el->getWReal() / 10; - - if (_GroupSizeRef&2) - _MaxHReal += _SizeDivH * el->getHReal() / 10; - } - - CViewBase::updateCoords(); - _XReal += _OffsetX; - _YReal += _OffsetY; - - //update all children elements - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pIE = *ite; - pIE->updateCoords(); - } - - _XReal -= _OffsetX; - _YReal -= _OffsetY; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::updateCoords() -{ - // update basis and sons one time. - doUpdateCoords(); - - // if the group must resize from children - if(_ResizeFromChildH || _ResizeFromChildW) - { - // compute BBox of all childrens - sint width, height; - evalChildrenBBox(_ResizeFromChildW, _ResizeFromChildH, width, height); - // set forced size. - if(_ResizeFromChildW) - { - _W= _ResizeFromChildWMargin + width; - } - if(_ResizeFromChildH) - { - _H= _ResizeFromChildHMargin + height; - } - } - - CInterfaceElement::updateCoords(); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const -{ - sint yMin=INT_MAX, yMax=INT_MIN; - sint xMin=INT_MAX, xMax=INT_MIN; - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pIE = *ite; - if (pIE->getActive()) - { - const CInterfaceElement *el = pIE->getParentPos() ? pIE->getParentPos() : pIE->getParent(); - if (el == this) - { - // to compute the bbox, don't use direct sons that have a sizeref on the resizing coordinate - if ((resizeFromChildW && (pIE->getSizeRef() & 1)) - || (resizeFromChildH && (pIE->getSizeRef() & 2)) - ) - { - continue; - } - } - // avoid also some interface elements - if(pIE->avoidResizeParent()) - continue; - // get the real coords bounds. - sint32 x0,y0,x1,y1; - // If it is a group, minimize with MaxHReal / MaxWReal - const CInterfaceGroup *sonGroup= dynamic_cast(pIE); - // \todo yoyo: do not know why but don't work if this==scroll_text - if(sonGroup && !isGroupScrollText()) - { - sint32 oldSciX= -16384; - sint32 oldSciY= -16384; - sint32 oldSciW= 32768; - sint32 oldSciH= 32768; - sint32 w, h; - sonGroup->computeCurrentClipContribution(oldSciX, oldSciY, oldSciW, oldSciH, x0, y0, w, h); - x1= x0 + w; - y1= y0 + h; + nlinfo("Element %d, name = %s, type=%s, x=%d, y=%d, parent_name=%s parentposname=%s xreal=%d, yreal=%d, wreal=%d, hreal=%d", + k, el->getId().c_str(), typeName.c_str(), el->getX(), el->getY(), el->getParent() ? el->getParent()->getId().c_str() : "no parent", + el->getParentPos() ? el->getParentPos()->getId().c_str() : "parent", + (int) el->getXReal(), + (int) el->getYReal(), + (int) el->getWReal(), + (int) el->getHReal() + ); } else { - x0= pIE->getXReal(); - y0= pIE->getYReal(); - x1= x0 + pIE->getWReal(); - y1= y0 + pIE->getHReal(); - } - // enlarge - if(x0xMax) - xMax= x1; - if(y1>yMax) - yMax= y1; - } - } - width = xMax - xMin; - height = yMax - yMin; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CInterfaceGroup::getElement (const std::string &id) -{ - if (_Id == id) - return this; - - if (id.compare(0, _Id.size(), _Id) != 0) - return NULL; - - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; -#if !FINAL_VERSION // For SpeedUp in final version - nlassert(pVB); // The element must not be NULL -#endif - if (pVB->getId() == id) - return pVB; - } - - vector::const_iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase* ctrl = *itc; -#if !FINAL_VERSION // For SpeedUp in final version - nlassert(ctrl); // The element must not be NULL -#endif - if (ctrl->getId() == id) - return ctrl; - } - - vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pIG = *itg; -#if !FINAL_VERSION // For SpeedUp in final version - nlassert(pIG); // The element must not be NULL -#endif - CInterfaceElement *pIEL = pIG->getElement(id); - if (pIEL != NULL) - return pIEL; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delElement (const std::string &id, bool noWarning) -{ - if (id.substr(0, _Id.size()) != _Id) - return false; - - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - if (pVB->getId() == id) - { - delView (pVB, false); - return true; - } - } - - vector::const_iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase* ctrl = *itc; - if (ctrl->getId() == id) - { - delCtrl (ctrl, false); - return true; - } - } - - vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pIG = *itg; - if (pIG->getId() == id) - { - // If this is a root window - if (pIG->getRootWindow () == pIG) - CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); - delGroup (pIG, false); - return true; - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::delElement (CInterfaceElement *pIE, bool noWarning) -{ - // delete correct type of element - if(pIE->isGroup()) - { - CInterfaceGroup *pIG= static_cast(pIE); - // unmake window if it is - if (pIG->getRootWindow () == pIG) - CWidgetManager::getInstance()->unMakeWindow(pIG, noWarning); - return delGroup(pIG); - } - else if(pIE->isCtrl()) - { - return delCtrl(static_cast(pIE)); - } - - nlassert(pIE->isView()); - return delView(static_cast(pIE)); -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::isWindowUnder (sint32 x, sint32 y) -{ - return ((x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal + _HReal))); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceGroup::getGroupUnder (sint32 x, sint32 y) -{ - // Begins by the children - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pChild = *itg; - CInterfaceGroup *pChildUnder = pChild->getGroupUnder (x-_XReal, y-_YReal); - if (pChildUnder != NULL) - { - if ( (x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal))) - return pChildUnder; - } - } - - // If not found in childs then try in the parent one - if ( (x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal))) - return this; - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB) -{ - if (!((x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal)))) - return false; - // test against current clip - computeCurrentClipContribution(clipX, clipY, clipW, clipH, - clipX, clipY, clipW, clipH); - - if (!((x > clipX) && - (x < (clipX + clipW))&& - (y > clipY) && - (y < (clipY + clipH)))) - return false; - - - - // same as draw order: start with parent - std::vector::const_iterator itc; - for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) - { - if (!(*itc)->isCtrl() && !(*itc)->isGroup()) // must be a view - { - CViewBase *pVB = *itc; - if (pVB != NULL) - if (pVB->getActive()) - if ( ((x) > pVB->getXReal()) && - ((x) < (pVB->getXReal() + pVB->getWReal()))&& - ((y) > pVB->getYReal()) && - ((y) < (pVB->getYReal() + pVB->getHReal()))) - { - vVB.push_back (pVB); + nlinfo("Element %d = NULL", (int) k); } } } - // same as draw order: continue with children - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + // ------------------------------------------------------------------------------------------------ + sint CInterfaceGroup::getInsertionOrder(CViewBase *vb) const { - CInterfaceGroup *pChild = *itg; - if (pChild->getActive()) + for(uint k = 0; k < _EltOrder.size(); ++k) { -// bool bUnder = - pChild->getViewsUnder (x, y, clipX, clipY, clipW, clipH, vVB); -// if (bUnder && (vICL.size() > 0)) -// return true; + if (_EltOrder[k] == vb) return (sint) k; } + return -1; } - return true; -} -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL) -{ - if (!((x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal)))) - return false; - // test against current clip - computeCurrentClipContribution(clipX, clipY, clipW, clipH, - clipX, clipY, clipW, clipH); - - if (!((x >= clipX) && - (x < (clipX + clipW))&& - (y > clipY) && - (y <= (clipY + clipH)))) - return false; - - - - // same as draw order: start with parent - std::vector::const_iterator itc; - for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceGroup::getMaxUsedW() const { - if ((*itc)->isCtrl() && !(*itc)->isGroup()) // must be a ctrl but not a group (parsed later) + sint maxWidth = 0; + for (uint k = 0; k < _EltOrder.size(); ++k) { - CCtrlBase *pICL = (CCtrlBase *) *itc; - if (pICL != NULL) - if (pICL->getActive()) - if ( ((x) >= pICL->getXReal()) && - ((x) < (pICL->getXReal() + pICL->getWReal()))&& - ((y) > pICL->getYReal()) && - ((y) <= (pICL->getYReal() + pICL->getHReal()))) - { - vICL.push_back (pICL->getSubCtrl(x,y)); - } + // Get the child width + sint32 width = _EltOrder[k]->getMaxUsedW()+_EltOrder[k]->getXReal() - getXReal(); + if (width > maxWidth) + maxWidth = width; + } + return maxWidth; + } + + // ------------------------------------------------------------------------------------------------ + sint32 CInterfaceGroup::getMinUsedW() const + { + sint32 minWidth = 0; + for (uint k = 0; k < _EltOrder.size(); ++k) + { + // Get the child width + sint32 width = _EltOrder[k]->getMinUsedW()+_EltOrder[k]->getXReal() - getXReal(); + if (width > minWidth) + minWidth = width; + } + return minWidth; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::clearAllEditBox() + { + for(uint k = 0; k < _ChildrenGroups.size(); ++k) + { + if (_ChildrenGroups[k]) _ChildrenGroups[k]->clearAllEditBox(); } } - // same as draw order: continue with children - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::restoreAllContainersBackupPosition() { - CInterfaceGroup *pChild = *itg; - if (pChild->getActive()) + for(uint k = 0; k < _ChildrenGroups.size(); ++k) { -// bool bUnder = - pChild->getCtrlsUnder (x, y, clipX, clipY, clipW, clipH, vICL); -// if (bUnder && (vICL.size() > 0)) -// return true; - } - } - return true; -} - - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceGroup::getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vIGL) -{ - if (!((x >= _XReal) && - (x < (_XReal + _WReal))&& - (y > _YReal) && - (y <= (_YReal+ _HReal)))) - return false; - // test against current clip - computeCurrentClipContribution(clipX, clipY, clipW, clipH, - clipX, clipY, clipW, clipH); - - if (!((x >= clipX) && - (x < (clipX + clipW))&& - (y > clipY) && - (y <= (clipY + clipH)))) - return false; - - - - // same as draw order: start with parent - std::vector::const_iterator itc; - for (itc = _EltOrder.begin(); itc != _EltOrder.end(); itc++) - { - if ((*itc)->isGroup()) // must be a group - { - CInterfaceGroup *pIGL = (CInterfaceGroup *) *itc; - if (pIGL != NULL) - if (pIGL->getActive()) - if ( ((x) >= pIGL->getXReal()) && - ((x) < (pIGL->getXReal() + pIGL->getWReal()))&& - ((y) > pIGL->getYReal()) && - ((y) <= (pIGL->getYReal() + pIGL->getHReal()))) - { - vIGL.push_back (pIGL); - } + if (_ChildrenGroups[k]) _ChildrenGroups[k]->restoreAllContainersBackupPosition(); } } - // same as draw order: continue with children - std::vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::dumpSize(uint depth /*=0*/) const { - CInterfaceGroup *pChild = *itg; - if (pChild->getActive()) + CViewBase::dumpSize(depth); + for(uint k = 0; k < _ChildrenGroups.size(); ++k) { -// bool bUnder = - pChild->getGroupsUnder (x, y, clipX, clipY, clipW, clipH, vIGL); -// if (bUnder && (vICL.size() > 0)) -// return true; + _ChildrenGroups[k]->dumpSize(depth + 1); + } + for(uint k = 0; k < _Controls.size(); ++k) + { + _Controls[k]->dumpSize(depth + 1); + } + for(uint k = 0; k < _Views.size(); ++k) + { + _Views[k]->dumpSize(depth + 1); } } - return true; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::absoluteToRelative (sint32 &x, sint32 &y) -{ - CInterfaceGroup *curGrp = _Parent; - while (curGrp != NULL) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::visit(CInterfaceElementVisitor *visitor) { - x = x - curGrp->_XReal; - y = y - curGrp->_YReal; - curGrp = curGrp->_Parent; - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::computeCurrentClipContribution(sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH, - sint32 &newSciXDest, sint32 &newSciYDest, sint32 &newSciWDest, sint32 &newSciHDest) const -{ - sint32 newSciX = _XReal; - sint32 newSciY = _YReal; - sint32 newSciW = _WReal; - sint32 newSciH = _HReal; - // If there is width size limiter - if (_MaxWReal < _WReal) - { - if ((_PosRef == Hotspot_TR) || (_PosRef == Hotspot_MR) || (_PosRef == Hotspot_BR)) - newSciX = _XReal + _WReal - _MaxWReal; - newSciW = _MaxWReal; - } - // If there is height size limiter - if (_MaxHReal < _HReal) - { - if ((_PosRef == Hotspot_TL) || (_PosRef == Hotspot_TM) || (_PosRef == Hotspot_TR)) - newSciY = _YReal + _HReal - _MaxHReal; - newSciH = _MaxHReal; - } - // Clip Left - if (newSciX < oldSciX) - { - newSciW = newSciW - (oldSciX - newSciX); - newSciX = oldSciX; - } - // Clip Right - if ((newSciX+newSciW) > (oldSciX+oldSciW)) - { - newSciW = newSciW - ((newSciX+newSciW)-(oldSciX+oldSciW)); - } - // Clip Bottom - if (newSciY < oldSciY) - { - newSciH = newSciH - (oldSciY - newSciY); - newSciY = oldSciY; - } - // Clip Top - if ((newSciY+newSciH) > (oldSciY+oldSciH)) - { - newSciH = newSciH - ((newSciY+newSciH)-(oldSciY+oldSciH)); - } - - newSciXDest = newSciX; - newSciYDest = newSciY; - newSciWDest = newSciW; - newSciHDest = newSciH; - -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::makeNewClip (sint32 &oldSciX, sint32 &oldSciY, sint32 &oldSciW, sint32 &oldSciH) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); - - sint32 newSciX, newSciY, newSciW, newSciH; - computeCurrentClipContribution(oldSciX, oldSciY, oldSciW, oldSciH, newSciX, newSciY, newSciW, newSciH); - rVR.setClipWindow (newSciX, newSciY, newSciW, newSciH); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 sw, sh; - rVR.getScreenSize(sw, sh); - sint32 sciX = 0, sciY = 0, sciW = sw, sciH =sh; - const CInterfaceGroup *currGroup = this; - do - { - currGroup->computeCurrentClipContribution(sciX, sciY, sciW, sciH, sciX, sciY, sciW, sciH); - currGroup = currGroup->_Parent; - } while(currGroup); - x = sciX; - y = sciY; - w = sciW; - h = sciH; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.setClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); -} - - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::launch () -{ - // launch all elements - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pIE = *ite; - pIE->launch(); - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup *CInterfaceGroup::getGroup(uint index) const -{ - if (index > _ChildrenGroups.size()) - { - nlwarning(" bad index;"); - return NULL; - } - return _ChildrenGroups[index]; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::updateAllLinks() -{ - CCtrlBase::updateAllLinks(); - { - for(std::vector::iterator it = _ChildrenGroups.begin(); it != _ChildrenGroups.end(); ++it) + nlassert(visitor); + for(uint k = 0; k < _ChildrenGroups.size(); ++k) { - (*it)->updateAllLinks(); + _ChildrenGroups[k]->visit(visitor); + } + for(uint k = 0; k < _Controls.size(); ++k) + { + _Controls[k]->visit(visitor); + } + for(uint k = 0; k < _Views.size(); ++k) + { + _Views[k]->visit(visitor); + } + visitor->visitGroup(this); + CInterfaceElement::visit(visitor); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::visitGroupAndChildren( CInterfaceElementVisitor *visitor ) + { + nlassert( visitor != 0 ); + for( uint i = 0; i < _ChildrenGroups.size(); i++ ) + { + _ChildrenGroups[ i ]->visitGroupAndChildren( visitor ); + } + + visitor->visitGroup( this ); + } + + + // ------------------------------------------------------------------------------------------------ + + void CInterfaceGroup::setUseCursor(bool use) + { + _UseCursor=use; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy) + { + // Move me. + _XReal+= dx; + _YReal+= dy; + + // Move all my sons. + vector::const_iterator ite; + for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) + { + CViewBase *pIE = *ite; + pIE->onFrameUpdateWindowPos(dx, dy); } } - { - for(std::vector::iterator it = _Controls.begin(); it != _Controls.end(); ++it) - { - (*it)->updateAllLinks(); - } - } - { - for(std::vector::iterator it = _Views.begin(); it != _Views.end(); ++it) - { - (*it)->updateAllLinks(); - } - } -} -// ------------------------------------------------------------------------------------------------ -sint32 CInterfaceGroup::getAlpha() const -{ - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - sint32 a = pVB->getAlpha(); - if (a != -1) - return a; - } - - vector::const_iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase *pCB = *itc; - sint32 a = pCB->getAlpha(); - if (a != -1) - return a; - } - - vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pIG = *itg; - sint32 a = pIG->getAlpha(); - if (a != -1) - return a; - } - return -1; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setAlpha (sint32 a) -{ - vector::const_iterator itv; - for (itv = _Views.begin(); itv != _Views.end(); itv++) - { - CViewBase *pVB = *itv; - pVB->setAlpha(a); - } - - vector::const_iterator itc; - for (itc = _Controls.begin(); itc != _Controls.end(); itc++) - { - CCtrlBase *pCB = *itc; - pCB->setAlpha(a); - } - - vector::const_iterator itg; - for (itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - { - CInterfaceGroup *pIG = *itg; - pIG->setAlpha(a); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setLeftClickHandler(const std::string &handler) -{ - _AHOnLeftClick = CAHManager::getInstance()->getAH(handler, _AHOnLeftClickParams); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setRightClickHandler(const std::string &handler) -{ - _AHOnRightClick = CAHManager::getInstance()->getAH(handler, _AHOnRightClickParams); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CInterfaceGroup::getEnclosingContainer() -{ - CInterfaceGroup *ig = this; - do - { - if( ig->isGroupContainer() ) - return ig; - ig = ig->getParent(); - } - while( ig != NULL ); - - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::dumpGroups() -{ - nlinfo("Num groups = %d", (int) _ChildrenGroups.size()); - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - std::string typeName = "???"; - if (_ChildrenGroups[k]) - { - const type_info &ti = typeid(*_ChildrenGroups[k]); - typeName = ti.name(); - } - nlinfo("Group %d, name = %s, type=%s", k, _ChildrenGroups[k] ? _ChildrenGroups[k]->getId().c_str() : "???", typeName.c_str()); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::dumpEltsOrder() -{ - nlinfo("Num elements = %d", (int) _EltOrder.size()); - for(uint k = 0; k < _EltOrder.size(); ++k) - { - std::string typeName = "???"; - if (_ChildrenGroups[k]) - { - const type_info &ti = typeid(*_EltOrder[k]); - typeName = ti.name(); - } - CInterfaceElement *el = _EltOrder[k]; - if (el) - { - nlinfo("Element %d, name = %s, type=%s, x=%d, y=%d, parent_name=%s parentposname=%s xreal=%d, yreal=%d, wreal=%d, hreal=%d", - k, el->getId().c_str(), typeName.c_str(), el->getX(), el->getY(), el->getParent() ? el->getParent()->getId().c_str() : "no parent", - el->getParentPos() ? el->getParentPos()->getId().c_str() : "parent", - (int) el->getXReal(), - (int) el->getYReal(), - (int) el->getWReal(), - (int) el->getHReal() - ); - } - else - { - nlinfo("Element %d = NULL", (int) k); - } - } -} - -// ------------------------------------------------------------------------------------------------ -sint CInterfaceGroup::getInsertionOrder(CViewBase *vb) const -{ - for(uint k = 0; k < _EltOrder.size(); ++k) - { - if (_EltOrder[k] == vb) return (sint) k; - } - return -1; -} - -// ------------------------------------------------------------------------------------------------ -sint32 CInterfaceGroup::getMaxUsedW() const -{ - sint maxWidth = 0; - for (uint k = 0; k < _EltOrder.size(); ++k) - { - // Get the child width - sint32 width = _EltOrder[k]->getMaxUsedW()+_EltOrder[k]->getXReal() - getXReal(); - if (width > maxWidth) - maxWidth = width; - } - return maxWidth; -} - -// ------------------------------------------------------------------------------------------------ -sint32 CInterfaceGroup::getMinUsedW() const -{ - sint32 minWidth = 0; - for (uint k = 0; k < _EltOrder.size(); ++k) - { - // Get the child width - sint32 width = _EltOrder[k]->getMinUsedW()+_EltOrder[k]->getXReal() - getXReal(); - if (width > minWidth) - minWidth = width; - } - return minWidth; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::clearAllEditBox() -{ - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - if (_ChildrenGroups[k]) _ChildrenGroups[k]->clearAllEditBox(); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::restoreAllContainersBackupPosition() -{ - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - if (_ChildrenGroups[k]) _ChildrenGroups[k]->restoreAllContainersBackupPosition(); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::dumpSize(uint depth /*=0*/) const -{ - CViewBase::dumpSize(depth); - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - _ChildrenGroups[k]->dumpSize(depth + 1); - } - for(uint k = 0; k < _Controls.size(); ++k) - { - _Controls[k]->dumpSize(depth + 1); - } - for(uint k = 0; k < _Views.size(); ++k) - { - _Views[k]->dumpSize(depth + 1); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::visit(CInterfaceElementVisitor *visitor) -{ - nlassert(visitor); - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - _ChildrenGroups[k]->visit(visitor); - } - for(uint k = 0; k < _Controls.size(); ++k) - { - _Controls[k]->visit(visitor); - } - for(uint k = 0; k < _Views.size(); ++k) - { - _Views[k]->visit(visitor); - } - visitor->visitGroup(this); - CInterfaceElement::visit(visitor); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::visitGroupAndChildren( CInterfaceElementVisitor *visitor ) -{ - nlassert( visitor != 0 ); - for( uint i = 0; i < _ChildrenGroups.size(); i++ ) - { - _ChildrenGroups[ i ]->visitGroupAndChildren( visitor ); - } - - visitor->visitGroup( this ); -} - - -// ------------------------------------------------------------------------------------------------ - -void CInterfaceGroup::setUseCursor(bool use) -{ - _UseCursor=use; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::onFrameUpdateWindowPos(sint dx, sint dy) -{ - // Move me. - _XReal+= dx; - _YReal+= dy; - - // Move all my sons. - vector::const_iterator ite; - for (ite = _EltOrder.begin() ; ite != _EltOrder.end(); ite++) - { - CViewBase *pIE = *ite; - pIE->onFrameUpdateWindowPos(dx, dy); - } -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::pushLUAEnvTable() -{ - CLuaState *lua= CLuaManager::getInstance().getLuaState(); - nlassert(lua); - - if(!_LUAEnvTableCreated) - { - CLuaStackChecker lsc(lua); - - // Create a table and assign it in the REGISTRY."__ui_envtable" table, with a userdata ptr - lua->push(IHM_LUA_ENVTABLE); - lua->getTable(LUA_REGISTRYINDEX); // Stack: __ui_envtable - lua->pushLightUserData(IG_UNIQUE_ID(this)); - lua->newTable(); - lua->setTable(-3); // Stack: __ui_envtable (with .this={}) - lua->pop(); - - // Created! - _LUAEnvTableCreated= true; - } - - // Get the table from registry, and push it on stack - CLuaStackChecker lsc(lua, 1); - lua->push(IHM_LUA_ENVTABLE); - lua->getTable(LUA_REGISTRYINDEX); // __ui_envtable - lua->pushLightUserData(IG_UNIQUE_ID(this)); - lua->getTable(-2); // __ui_envtable envtable - lua->remove(-2); // envtable - nlassert(lua->isTable()); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::deleteLUAEnvTable(bool recurse) -{ - if(_LUAEnvTableCreated) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::pushLUAEnvTable() { CLuaState *lua= CLuaManager::getInstance().getLuaState(); nlassert(lua); - // replace simply the table with Nil, letting LUA Garbage collector do the realease stuff - CLuaStackChecker lsc(lua); + if(!_LUAEnvTableCreated) + { + CLuaStackChecker lsc(lua); + + // Create a table and assign it in the REGISTRY."__ui_envtable" table, with a userdata ptr + lua->push(IHM_LUA_ENVTABLE); + lua->getTable(LUA_REGISTRYINDEX); // Stack: __ui_envtable + lua->pushLightUserData(IG_UNIQUE_ID(this)); + lua->newTable(); + lua->setTable(-3); // Stack: __ui_envtable (with .this={}) + lua->pop(); + + // Created! + _LUAEnvTableCreated= true; + } + + // Get the table from registry, and push it on stack + CLuaStackChecker lsc(lua, 1); lua->push(IHM_LUA_ENVTABLE); lua->getTable(LUA_REGISTRYINDEX); // __ui_envtable - lua->pushLightUserData(IG_UNIQUE_ID(this)); // NB nico : use some pointer *inside* that object as a unique id (any field but - // the first), instead of using 'this'. 'this' is already used by - // CLuaIHM::pushReflectableOnStack - lua->pushNil(); - lua->setTable(-3); // __ui_envtable - lua->pop(); - - _LUAEnvTableCreated= false; + lua->pushLightUserData(IG_UNIQUE_ID(this)); + lua->getTable(-2); // __ui_envtable envtable + lua->remove(-2); // envtable + nlassert(lua->isTable()); } - if (recurse) + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::deleteLUAEnvTable(bool recurse) { - for(uint k = 0; k < _ChildrenGroups.size(); ++k) + if(_LUAEnvTableCreated) { - _ChildrenGroups[k]->deleteLUAEnvTable(true); + CLuaState *lua= CLuaManager::getInstance().getLuaState(); + nlassert(lua); + + // replace simply the table with Nil, letting LUA Garbage collector do the realease stuff + CLuaStackChecker lsc(lua); + lua->push(IHM_LUA_ENVTABLE); + lua->getTable(LUA_REGISTRYINDEX); // __ui_envtable + lua->pushLightUserData(IG_UNIQUE_ID(this)); // NB nico : use some pointer *inside* that object as a unique id (any field but + // the first), instead of using 'this'. 'this' is already used by + // CLuaIHM::pushReflectableOnStack + lua->pushNil(); + lua->setTable(-3); // __ui_envtable + lua->pop(); + + _LUAEnvTableCreated= false; + } + if (recurse) + { + for(uint k = 0; k < _ChildrenGroups.size(); ++k) + { + _ChildrenGroups[k]->deleteLUAEnvTable(true); + } } } -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setLuaScriptOnDraw(const std::string &script) -{ - _LUAOnDraw= script; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::addLuaScriptOnDBChange(const std::string &dbList, const std::string &script) -{ - // remove any existing - removeLuaScriptOnDBChange(dbList); - - // create and attach the link - NLMISC::CSmartPtr newLink= new CInterfaceLink; - _LUAOnDbChange[dbList]= newLink; - // Init and attach to list of untargeted links - std::vector noTargets; - newLink->init(noTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::removeLuaScriptOnDBChange(const std::string &dbList) -{ - TLUAOnDbChange::iterator it= _LUAOnDbChange.find(dbList); - if(it!=_LUAOnDbChange.end()) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setLuaScriptOnDraw(const std::string &script) { - nlassert(it->second!=NULL); - // Remove from link of untargeted Links - it->second->uninit(); - // erase from map (thus the ptr should be deleted) - _LUAOnDbChange.erase(it); + _LUAOnDraw= script; } -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::removeAllLUAOnDbChange() -{ - TLUAOnDbChange::iterator it= _LUAOnDbChange.begin(); - for(;it!=_LUAOnDbChange.end();) + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::addLuaScriptOnDBChange(const std::string &dbList, const std::string &script) { - // since deleted, must not do it++, but it= begin() - removeLuaScriptOnDBChange(it->first); - it= _LUAOnDbChange.begin(); - } -} + // remove any existing + removeLuaScriptOnDBChange(dbList); -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaFind(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::find", 1); - CLuaIHM::checkArgType(ls, "CInterfaceGroup::find", 1, LUA_TSTRING); - std::string id = ls.toString(1); - CInterfaceElement* element = findFromShortId(id); - if (!element) + // create and attach the link + NLMISC::CSmartPtr newLink= new CInterfaceLink; + _LUAOnDbChange[dbList]= newLink; + // Init and attach to list of untargeted links + std::vector noTargets; + newLink->init(noTargets, NLMISC::toString("depends(%s)", dbList.c_str()), "lua", script, "", this); + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::removeLuaScriptOnDBChange(const std::string &dbList) { - ls.pushNil(); + TLUAOnDbChange::iterator it= _LUAOnDbChange.find(dbList); + if(it!=_LUAOnDbChange.end()) + { + nlassert(it->second!=NULL); + // Remove from link of untargeted Links + it->second->uninit(); + // erase from map (thus the ptr should be deleted) + _LUAOnDbChange.erase(it); + } } - else + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::removeAllLUAOnDbChange() { - CLuaIHM::pushUIOnStack(ls, element); + TLUAOnDbChange::iterator it= _LUAOnDbChange.begin(); + for(;it!=_LUAOnDbChange.end();) + { + // since deleted, must not do it++, but it= begin() + removeLuaScriptOnDBChange(it->first); + it= _LUAOnDbChange.begin(); + } } - return 1; -} -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CInterfaceGroup::findFromShortId(const std::string &id) -{ - CInterfaceElement* element = NULL; - element = getView(id); - if (!element) element = getCtrl(id); - if (!element) element = getGroup(id); - return element; -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaGetEnclosingContainer(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getEnclosingContainer", 0); - CLuaIHM::pushUIOnStack(ls, getEnclosingContainer()); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CInterfaceGroup::luaDeleteLUAEnvTable(CLuaState &ls) -{ - const char *funcName = "deleteLUAenvTable"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TBOOLEAN); // is delete recursive - deleteLUAEnvTable(ls.toBoolean(1)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::serial(NLMISC::IStream &f) -{ - CCtrlBase::serial(f); - f.serialContPolyPtr(_ChildrenGroups); - f.serialContPolyPtr(_Controls); - f.serialContPolyPtr(_Views); - f.serialContPolyPtr(_EltOrder); - f.serial(_MaxW, _MaxH); - f.serial(_MaxWReal, _MaxHReal); - f.serial(_OffsetX, _OffsetY); - f.serial(_Priority); - - nlSerialBitBool(f, _Overlappable); - nlSerialBitBool(f, _ResizeFromChildW); - nlSerialBitBool(f, _ResizeFromChildH); - nlSerialBitBool(f, _Escapable); - nlSerialBitBool(f, _UseCursor); - nlSerialBitBool(f, _IsGroupContainer); - nlSerialBitBool(f, _NeedFrameUpdatePos); - - f.serial(_ResizeFromChildWMargin); - f.serial(_ResizeFromChildHMargin); - f.serial(_GroupSizeRef); - - serialAH(f, _AHOnActive); - f.serial(_AHOnActiveParams); - serialAH(f, _AHOnDeactive); - f.serial(_AHOnDeactiveParams); - - // right & left clicks - serialAH(f, _AHOnLeftClick); - f.serial(_AHOnLeftClickParams); - serialAH(f, _AHOnRightClick); - f.serial(_AHOnRightClickParams); - - // enter params. - serialAH(f, _AHOnEnter); - f.serial(_AHOnEnterParams); - - // escape AH - serialAH(f, _AHOnEscape); - f.serial(_AHOnEscapeParams); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement *CInterfaceGroup::clone() -{ - CInterfaceElement *oldParentSizeMax = _ParentSizeMax; - if (_ParentSizeMax == _Parent) + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaFind(CLuaState &ls) { - _ParentSizeMax = NULL; + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::find", 1); + CLuaIHM::checkArgType(ls, "CInterfaceGroup::find", 1, LUA_TSTRING); + std::string id = ls.toString(1); + CInterfaceElement* element = findFromShortId(id); + if (!element) + { + ls.pushNil(); + } + else + { + CLuaIHM::pushUIOnStack(ls, element); + } + return 1; } - CInterfaceElement *ret = CCtrlBase::clone(); - _ParentSizeMax = oldParentSizeMax; - return ret; -} -// ------------------------------------------------------------------------------------------------ -void CInterfaceGroup::setMaxSizeRef(const std::string &maxSizeRef) -{ - parseMaxSizeRef(maxSizeRef.c_str()); -} + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CInterfaceGroup::findFromShortId(const std::string &id) + { + CInterfaceElement* element = NULL; + element = getView(id); + if (!element) element = getCtrl(id); + if (!element) element = getGroup(id); + return element; + } -// ------------------------------------------------------------------------------------------------ -std::string CInterfaceGroup::getMaxSizeRefAsString() const -{ - return "IMPLEMENT ME!"; -} + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaGetEnclosingContainer(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CInterfaceGroup::getEnclosingContainer", 0); + CLuaIHM::pushUIOnStack(ls, getEnclosingContainer()); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CInterfaceGroup::luaDeleteLUAEnvTable(CLuaState &ls) + { + const char *funcName = "deleteLUAenvTable"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TBOOLEAN); // is delete recursive + deleteLUAEnvTable(ls.toBoolean(1)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::serial(NLMISC::IStream &f) + { + CCtrlBase::serial(f); + f.serialContPolyPtr(_ChildrenGroups); + f.serialContPolyPtr(_Controls); + f.serialContPolyPtr(_Views); + f.serialContPolyPtr(_EltOrder); + f.serial(_MaxW, _MaxH); + f.serial(_MaxWReal, _MaxHReal); + f.serial(_OffsetX, _OffsetY); + f.serial(_Priority); + + nlSerialBitBool(f, _Overlappable); + nlSerialBitBool(f, _ResizeFromChildW); + nlSerialBitBool(f, _ResizeFromChildH); + nlSerialBitBool(f, _Escapable); + nlSerialBitBool(f, _UseCursor); + nlSerialBitBool(f, _IsGroupContainer); + nlSerialBitBool(f, _NeedFrameUpdatePos); + + f.serial(_ResizeFromChildWMargin); + f.serial(_ResizeFromChildHMargin); + f.serial(_GroupSizeRef); + + serialAH(f, _AHOnActive); + f.serial(_AHOnActiveParams); + serialAH(f, _AHOnDeactive); + f.serial(_AHOnDeactiveParams); + + // right & left clicks + serialAH(f, _AHOnLeftClick); + f.serial(_AHOnLeftClickParams); + serialAH(f, _AHOnRightClick); + f.serial(_AHOnRightClickParams); + + // enter params. + serialAH(f, _AHOnEnter); + f.serial(_AHOnEnterParams); + + // escape AH + serialAH(f, _AHOnEscape); + f.serial(_AHOnEscapeParams); + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceElement *CInterfaceGroup::clone() + { + CInterfaceElement *oldParentSizeMax = _ParentSizeMax; + if (_ParentSizeMax == _Parent) + { + _ParentSizeMax = NULL; + } + CInterfaceElement *ret = CCtrlBase::clone(); + _ParentSizeMax = oldParentSizeMax; + return ret; + } + + // ------------------------------------------------------------------------------------------------ + void CInterfaceGroup::setMaxSizeRef(const std::string &maxSizeRef) + { + parseMaxSizeRef(maxSizeRef.c_str()); + } + + // ------------------------------------------------------------------------------------------------ + std::string CInterfaceGroup::getMaxSizeRefAsString() const + { + return "IMPLEMENT ME!"; + } + +} \ No newline at end of file diff --git a/code/nel/src/gui/interface_link.cpp b/code/nel/src/gui/interface_link.cpp index 68e9a194c..0dffc3d4d 100644 --- a/code/nel/src/gui/interface_link.cpp +++ b/code/nel/src/gui/interface_link.cpp @@ -29,619 +29,626 @@ using namespace std; using namespace NLMISC; -///////////// -// GLOBALS // -///////////// - -CInterfaceLink::TLinkList CInterfaceLink::_LinkList; -CInterfaceLink::TLinkVect CInterfaceLink::_LinksWithNoTarget; -// -CInterfaceLink *CInterfaceLink::_FirstTriggeredLink[2] = { NULL, NULL }; -CInterfaceLink *CInterfaceLink::_LastTriggeredLink[2] = { NULL, NULL }; -CInterfaceLink *CInterfaceLink::_CurrUpdatedLink = NULL; -CInterfaceLink *CInterfaceLink::_NextUpdatedLink = NULL; -uint CInterfaceLink::_CurrentTriggeredLinkList = 0; - -bool CInterfaceLink::_UpdateAllLinks = false; - - -/////////////// -// FUNCTIONS // -/////////////// - -/** Tool fct : affect a value to a reflected property of an interface element. - */ -static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem, const CReflectedProperty &property) +namespace NLGUI { - CInterfaceExprValue valueToAffect = value; - switch(property.Type) + ///////////// + // GLOBALS // + ///////////// + + CInterfaceLink::TLinkList CInterfaceLink::_LinkList; + CInterfaceLink::TLinkVect CInterfaceLink::_LinksWithNoTarget; + // + CInterfaceLink *CInterfaceLink::_FirstTriggeredLink[2] = { NULL, NULL }; + CInterfaceLink *CInterfaceLink::_LastTriggeredLink[2] = { NULL, NULL }; + CInterfaceLink *CInterfaceLink::_CurrUpdatedLink = NULL; + CInterfaceLink *CInterfaceLink::_NextUpdatedLink = NULL; + uint CInterfaceLink::_CurrentTriggeredLinkList = 0; + + bool CInterfaceLink::_UpdateAllLinks = false; + + + /////////////// + // FUNCTIONS // + /////////////// + + /** Tool fct : affect a value to a reflected property of an interface element. + */ + static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem, const CReflectedProperty &property) { - case CReflectedProperty::Boolean: - if (valueToAffect.toBool()) - { - (destElem.*(property.SetMethod.SetBool))(valueToAffect.getBool()); - } - else - { - return false; - } - break; - case CReflectedProperty::SInt32: - if (valueToAffect.toInteger()) - { - (destElem.*(property.SetMethod.SetSInt32))((sint32) valueToAffect.getInteger()); - } - else - { - - return false; - } - break; - case CReflectedProperty::Float: - if (valueToAffect.toDouble()) - { - (destElem.*(property.SetMethod.SetFloat))((float) valueToAffect.getDouble()); - } - else - { - - return false; - } - break; - case CReflectedProperty::String: - if (valueToAffect.toString()) - { - (destElem.*(property.SetMethod.SetString))(valueToAffect.getString()); - } - else - { - - return false; - } - break; - case CReflectedProperty::UCString: - if (valueToAffect.toString()) - { - (destElem.*(property.SetMethod.SetUCString))(valueToAffect.getUCString()); - } - else - { - - return false; - } - break; - case CReflectedProperty::RGBA: - if (valueToAffect.toRGBA()) - { - (destElem.*(property.SetMethod.SetRGBA))(valueToAffect.getRGBA()); - } - else - { - - return false; - } - break; - default: - break; - } - - return true; -} - -CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() -{ - NLGUI::CDBManager::getInstance()->addFlushObserver( this ); -} - -CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() -{ -} - -void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush() -{ - CInterfaceLink::updateTrigeredLinks(); -} - -///////////// -// MEMBERS // -///////////// - -//=========================================================== -CInterfaceLink::CInterfaceLink() : _On(true) -{ - // add an entry in the links list - _LinkList.push_front(this); - _ListEntry = _LinkList.begin(); - _PrevTriggeredLink[0] = _PrevTriggeredLink[1] = NULL; - _NextTriggeredLink[0] = _NextTriggeredLink[1] = NULL; - _Triggered[0] = _Triggered[1] = false; - _ParseTree = NULL; -} - -//=========================================================== -CInterfaceLink::~CInterfaceLink() -{ - if (this == _CurrUpdatedLink) - { - _CurrUpdatedLink = NULL; - } - if (this == _NextUpdatedLink) - { - _NextUpdatedLink = _NextUpdatedLink->_NextTriggeredLink[1 - _CurrentTriggeredLinkList]; - } - // unlink observer from both update lists - unlinkFromTriggerList(0); - unlinkFromTriggerList(1); - - removeObservers(_ObservedNodes); - // removes from the link list - _LinkList.erase(_ListEntry); - - delete _ParseTree; -} - -//=========================================================== -bool CInterfaceLink::init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) -{ - CInterfaceExprValue result; - // Build the parse tree - nlassert(!_ParseTree); - _ParseTree = CInterfaceExpr::buildExprTree(expr); - if (!_ParseTree) - { - // wrong expression : release the link - nlwarning("CInterfaceLink::init : can't parse expression %s", expr.c_str()); - _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); - return false; - } - // Examine the expression, to see which database nodes it depends on - _ParseTree->getDepends(_ObservedNodes); - // must keep observerd node sorted (for std::set_xx ops) - std::sort(_ObservedNodes.begin(), _ObservedNodes.end()); - if (!targets.empty()) - { - // retrieve properties from the element - _Targets.resize(targets.size()); - for (uint k = 0; k < targets.size(); ++k) + CInterfaceExprValue valueToAffect = value; + switch(property.Type) { - CInterfaceElement *elem = targets[k].Elem; - if (!elem) + case CReflectedProperty::Boolean: + if (valueToAffect.toBool()) + { + (destElem.*(property.SetMethod.SetBool))(valueToAffect.getBool()); + } + else + { + + return false; + } + break; + case CReflectedProperty::SInt32: + if (valueToAffect.toInteger()) + { + (destElem.*(property.SetMethod.SetSInt32))((sint32) valueToAffect.getInteger()); + } + else + { + + return false; + } + break; + case CReflectedProperty::Float: + if (valueToAffect.toDouble()) + { + (destElem.*(property.SetMethod.SetFloat))((float) valueToAffect.getDouble()); + } + else + { + + return false; + } + break; + case CReflectedProperty::String: + if (valueToAffect.toString()) + { + (destElem.*(property.SetMethod.SetString))(valueToAffect.getString()); + } + else + { + + return false; + } + break; + case CReflectedProperty::UCString: + if (valueToAffect.toString()) + { + (destElem.*(property.SetMethod.SetUCString))(valueToAffect.getUCString()); + } + else + { + + return false; + } + break; + case CReflectedProperty::RGBA: + if (valueToAffect.toRGBA()) + { + (destElem.*(property.SetMethod.SetRGBA))(valueToAffect.getRGBA()); + } + else + { + + return false; + } + break; + default: + break; + } + + return true; + } + + CInterfaceLink::CInterfaceLinkUpdater::CInterfaceLinkUpdater() + { + NLGUI::CDBManager::getInstance()->addFlushObserver( this ); + } + + CInterfaceLink::CInterfaceLinkUpdater::~CInterfaceLinkUpdater() + { + } + + void CInterfaceLink::CInterfaceLinkUpdater::onObserverCallFlush() + { + CInterfaceLink::updateTrigeredLinks(); + } + + ///////////// + // MEMBERS // + ///////////// + + //=========================================================== + CInterfaceLink::CInterfaceLink() : _On(true) + { + // add an entry in the links list + _LinkList.push_front(this); + _ListEntry = _LinkList.begin(); + _PrevTriggeredLink[0] = _PrevTriggeredLink[1] = NULL; + _NextTriggeredLink[0] = _NextTriggeredLink[1] = NULL; + _Triggered[0] = _Triggered[1] = false; + _ParseTree = NULL; + } + + //=========================================================== + CInterfaceLink::~CInterfaceLink() + { + if (this == _CurrUpdatedLink) + { + _CurrUpdatedLink = NULL; + } + if (this == _NextUpdatedLink) + { + _NextUpdatedLink = _NextUpdatedLink->_NextTriggeredLink[1 - _CurrentTriggeredLinkList]; + } + // unlink observer from both update lists + unlinkFromTriggerList(0); + unlinkFromTriggerList(1); + + removeObservers(_ObservedNodes); + // removes from the link list + _LinkList.erase(_ListEntry); + + delete _ParseTree; + } + + //=========================================================== + bool CInterfaceLink::init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parentGroup) + { + CInterfaceExprValue result; + // Build the parse tree + nlassert(!_ParseTree); + _ParseTree = CInterfaceExpr::buildExprTree(expr); + if (!_ParseTree) + { + // wrong expression : release the link + nlwarning("CInterfaceLink::init : can't parse expression %s", expr.c_str()); + _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); + return false; + } + // Examine the expression, to see which database nodes it depends on + _ParseTree->getDepends(_ObservedNodes); + // must keep observerd node sorted (for std::set_xx ops) + std::sort(_ObservedNodes.begin(), _ObservedNodes.end()); + if (!targets.empty()) + { + // retrieve properties from the element + _Targets.resize(targets.size()); + for (uint k = 0; k < targets.size(); ++k) { - nlwarning(" : Element %d is NULL", k); - _Targets[k]._InterfaceElement = NULL; - continue; + CInterfaceElement *elem = targets[k].Elem; + if (!elem) + { + nlwarning(" : Element %d is NULL", k); + _Targets[k]._InterfaceElement = NULL; + continue; + } + _Targets[k]._Property = elem->getReflectedProperty(targets[k].PropertyName); + if (!_Targets[k]._Property) + { + nlwarning(" : Can't retrieve property %s for element %d.", targets[k].PropertyName.c_str(), k); + _Targets[k]._InterfaceElement = NULL; + continue; + } + _Targets[k]._InterfaceElement = elem; + elem->addLink(this); } - _Targets[k]._Property = elem->getReflectedProperty(targets[k].PropertyName); - if (!_Targets[k]._Property) + } + else + { + // There are no target for this link, so, put in a dedicated list to ensure that the link will be destroyed at exit + _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); + } + + // create observers + createObservers(_ObservedNodes); + _Expr = expr; + // + _ActionHandler = actionHandler; + _AHParams = ahParams; + _AHCond = ahCond; + _AHParent = parentGroup; + return true; + } + + //=========================================================== + void CInterfaceLink::uninit() + { + for (uint32 i = 0; i < _LinksWithNoTarget.size(); i++) + { + CInterfaceLink *pLink = _LinksWithNoTarget[i]; + if (pLink == this) { - nlwarning(" : Can't retrieve property %s for element %d.", targets[k].PropertyName.c_str(), k); - _Targets[k]._InterfaceElement = NULL; - continue; + _LinksWithNoTarget.erase(_LinksWithNoTarget.begin()+i); + return; } - _Targets[k]._InterfaceElement = elem; - elem->addLink(this); } } - else + + //=========================================================== + void CInterfaceLink::update(ICDBNode * /* node */) { - // There are no target for this link, so, put in a dedicated list to ensure that the link will be destroyed at exit - _LinksWithNoTarget.push_back(TLinkSmartPtr(this)); + // mark link as triggered + linkInTriggerList(_CurrentTriggeredLinkList); } - // create observers - createObservers(_ObservedNodes); - _Expr = expr; - // - _ActionHandler = actionHandler; - _AHParams = ahParams; - _AHCond = ahCond; - _AHParent = parentGroup; - return true; -} - -//=========================================================== -void CInterfaceLink::uninit() -{ - for (uint32 i = 0; i < _LinksWithNoTarget.size(); i++) + //=========================================================== + void CInterfaceLink::createObservers(const TNodeVect &nodes) { - CInterfaceLink *pLink = _LinksWithNoTarget[i]; - if (pLink == this) + for(std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { - _LinksWithNoTarget.erase(_LinksWithNoTarget.begin()+i); + if ((*it)->isLeaf()) + { + ICDBNode::CTextId textId; + (*it)->addObserver(this, textId); + } + else + { + CCDBNodeBranch *br = static_cast(*it); + NLGUI::CDBManager::getInstance()->addBranchObserver( br, this ); + } + } + } + + //=========================================================== + void CInterfaceLink::removeObservers(const TNodeVect &nodes) + { + for(std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) + { + if ((*it)->isLeaf()) + { + ICDBNode::CTextId textId; + (*it)->removeObserver(this, textId); + } + else + { + CCDBNodeBranch *br = static_cast(*it); + NLGUI::CDBManager::getInstance()->removeBranchObserver( br, this ); + } + } + } + + //=========================================================== + void CInterfaceLink::updateAllLinks() + { + nlassert(!_UpdateAllLinks); + _UpdateAllLinks = true; + for(TLinkList::iterator it = _LinkList.begin(); it != _LinkList.end(); ++it) + { + CInterfaceLink *pLink = *it; + pLink->update(); + } + _UpdateAllLinks = false; + } + + //=========================================================== + void CInterfaceLink::update() + { + //_On = false; // prvent recursive calls + if (!_ParseTree) return; + static TNodeVect observedNodes; // should not be too big, so ok to keep it static. + static TNodeVect tmpNodes; + observedNodes.clear(); + CInterfaceExprValue result; + _ParseTree->evalWithDepends(result, observedNodes); + // std::set_xxx require ordered container + std::sort(observedNodes.begin(), observedNodes.end()); + // we assume that _ObservedNode are also sorted + // compute new observers + tmpNodes.clear(); + std::set_difference(observedNodes.begin(), observedNodes.end(), _ObservedNodes.begin(), _ObservedNodes.end(), std::back_inserter(tmpNodes)); + // add these observers + createObservers(tmpNodes); + // compute lost observers + tmpNodes.clear(); + std::set_difference(_ObservedNodes.begin(), _ObservedNodes.end(), observedNodes.begin(), observedNodes.end(), std::back_inserter(tmpNodes)); + // remove these observers + removeObservers(tmpNodes); + // subsitute new (sorted) list to current + _ObservedNodes.swap(observedNodes); + // + for (uint k = 0; k < _Targets.size(); ++k) + { + CInterfaceElement *elem = _Targets[k]._InterfaceElement; + const CReflectedProperty *prop = _Targets[k]._Property; + if (elem && prop) + { + if (!affect(result, *elem, *prop)) + { + nlwarning("CInterfaceLink::update: Result conversion failed"); + } + } + } + // if there's an action handler, execute it + if (!_ActionHandler.empty()) + { + // If there is a condition, test it. + bool launch= true; + if(!_AHCond.empty()) + { + launch= false; + CInterfaceExprValue result; + if(CInterfaceExpr::eval(_AHCond, result)) + launch= result.getBool(); + } + if(launch) + { + CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); + // do not add any code after this line because this can be deleted !!!! + } + } + + //_On = true; // prevent recursive calls + } + + // predicate to remove an element from a list + struct CRemoveTargetPred + { + CInterfaceElement *Target; + bool operator()(const CInterfaceLink::CTarget &target) const { return target._InterfaceElement == Target; } + }; + + //=========================================================== + void CInterfaceLink::removeTarget(CInterfaceElement *elem) + { + CRemoveTargetPred pred; + pred.Target = elem; + _Targets.erase(std::remove_if(_Targets.begin(), _Targets.end(), pred), _Targets.end()); + } + + //=========================================================== + bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value) + { + + if (!Elem) + { + nlwarning(" : Target element is NULL"); + + return false; + } + const CReflectedProperty *property = Elem->getReflectedProperty(PropertyName); + if (!property) + { + nlwarning(" : Can't retrieve property %s for element %s.", PropertyName.c_str(), Elem->getId().c_str()); + + return false; + } + // try to affect the property + if (!NLGUI::affect(value, *Elem, *property)) + { + nlwarning(" Couldn't convert the value to affect to %s", Elem->getId().c_str()); + + return false; + } + + return true; + } + + //=========================================================== + void CInterfaceLink::removeAllLinks() + { + _LinksWithNoTarget.clear(); + TLinkList::iterator curr = _LinkList.begin(); + TLinkList::iterator nextIt; + uint k; + while(curr != _LinkList.end()) + { + nextIt = curr; + ++ nextIt; + CInterfaceLink &link = **curr; + link.checkNbRefs(); + NLMISC::CSmartPtr linkPtr = *curr; // must keep a smart ptr because of the test in the loop + for (k = 0; k < link._Targets.size(); ++k) + { + if (link._Targets[k]._InterfaceElement) + { + nlinfo("InterfaceElement %s was not remove.", link._Targets[k]._InterfaceElement->getId().c_str()); + link._Targets[k]._InterfaceElement->removeLink(&link); + } + } + linkPtr = NULL; // effectively destroy link + curr = nextIt; + } + nlassert(_LinkList.empty()); + } + + // *************************************************************************** + bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm) + { + // the last token of the target gives the name of the property + std::string::size_type lastPos = target.find_last_of(':'); + if (lastPos == (target.length() - 1)) + { + // todo hulud interface syntax error + nlwarning("The target should at least contains a path and a property as follow 'path:property'"); + return false; + } + std::string elmPath; + std::string elmProp; + CInterfaceElement *elm = NULL; + if (parentGroup) + { + if (lastPos == std::string::npos) + { + elmProp = target; + elm = parentGroup; + elmPath = "current"; + } + else + { + elmProp = target.substr(lastPos + 1); + elmPath = parentGroup->getId() + ":" + target.substr(0, lastPos); + elm = parentGroup->getElement(elmPath); + } + } + if (!elm) + { + // try the absolute adress of the element + elmPath = target.substr(0, lastPos); + elm = CWidgetManager::getInstance()->getElementFromId(elmPath); + elmProp = target.substr(lastPos + 1); + } + + if (!elm) + { + // todo hulud interface syntax error + nlwarning(" can't find target link %s", elmPath.c_str()); + return false; + } + targetElm = elm; + propertyName = elmProp; + return true; + } + + + // *************************************************************************** + bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect) + { + std::vector targetNames; + NLMISC::splitString(targets, ",", targetNames); + targetsVect.clear(); + targetsVect.reserve(targetNames.size()); + bool everythingOk = true; + for (uint k = 0; k < targetNames.size(); ++k) + { + CInterfaceLink::CTargetInfo ti; + std::string::size_type startPos = targetNames[k].find_first_not_of(" "); + if(startPos == std::string::npos) + { + // todo hulud interface syntax error + nlwarning(" empty target encountered"); + continue; + } + std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); + + if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) + { + // todo hulud interface syntax error + nlwarning(" Can't get link target"); + everythingOk = false; + continue; + } + targetsVect.push_back(ti); + } + return everythingOk; + } + + + //=========================================================== + void CInterfaceLink::checkNbRefs() + { + uint numValidPtr = 0; + for(uint k = 0; k < _Targets.size(); ++k) + { + if (_Targets[k]._InterfaceElement != NULL) ++numValidPtr; + } + nlassert(numValidPtr == (uint) crefs); + } + + + //=========================================================== + void CInterfaceLink::setTargetProperty (const std::string &Target, const CInterfaceExprValue &val) + { + // Eval target ! + string elt = Target.substr(0,Target.rfind(':')); + CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); + CInterfaceGroup *pIG = dynamic_cast(pIE); + if (pIG == NULL) + pIG = pIE->getParent(); + + if (pIG != NULL) + { + std::vector vTargets; + splitLinkTargets(Target, pIG, vTargets); + if ((vTargets.size() > 0) && (vTargets[0].Elem)) + { + vTargets[0].affect(val); + } + } + } + + //----------------------------------------------- + void CInterfaceLink::linkInTriggerList(uint list) + { + nlassert(list < 2); + if (_Triggered[list]) return; // already inserted in list + _Triggered[list] = true; + nlassert(!_PrevTriggeredLink[list]); + nlassert(!_NextTriggeredLink[list]); + if (!_FirstTriggeredLink[list]) + { + _FirstTriggeredLink[list] = _LastTriggeredLink[list] = this; + } + else + { + nlassert(!_LastTriggeredLink[list]->_NextTriggeredLink[list]); + _LastTriggeredLink[list]->_NextTriggeredLink[list] = this; + _PrevTriggeredLink[list] = _LastTriggeredLink[list]; + _LastTriggeredLink[list] = this; + } + } + + //----------------------------------------------- + void CInterfaceLink::unlinkFromTriggerList(uint list) + { + nlassert(list < 2); + if (!_Triggered[list]) + { + // not linked in this list + nlassert(_PrevTriggeredLink[list] == NULL); + nlassert(_NextTriggeredLink[list] == NULL); return; } - } -} - -//=========================================================== -void CInterfaceLink::update(ICDBNode * /* node */) -{ - // mark link as triggered - linkInTriggerList(_CurrentTriggeredLinkList); -} - -//=========================================================== -void CInterfaceLink::createObservers(const TNodeVect &nodes) -{ - for(std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) - { - if ((*it)->isLeaf()) + if (_PrevTriggeredLink[list]) { - ICDBNode::CTextId textId; - (*it)->addObserver(this, textId); + _PrevTriggeredLink[list]->_NextTriggeredLink[list] = _NextTriggeredLink[list]; } else { - CCDBNodeBranch *br = static_cast(*it); - NLGUI::CDBManager::getInstance()->addBranchObserver( br, this ); + // this was the first node + _FirstTriggeredLink[list] = _NextTriggeredLink[list]; } - } -} - -//=========================================================== -void CInterfaceLink::removeObservers(const TNodeVect &nodes) -{ - for(std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) - { - if ((*it)->isLeaf()) + if (_NextTriggeredLink[list]) { - ICDBNode::CTextId textId; - (*it)->removeObserver(this, textId); + _NextTriggeredLink[list]->_PrevTriggeredLink[list] = _PrevTriggeredLink[list]; } else { - CCDBNodeBranch *br = static_cast(*it); - NLGUI::CDBManager::getInstance()->removeBranchObserver( br, this ); - } - } -} - -//=========================================================== -void CInterfaceLink::updateAllLinks() -{ - nlassert(!_UpdateAllLinks); - _UpdateAllLinks = true; - for(TLinkList::iterator it = _LinkList.begin(); it != _LinkList.end(); ++it) - { - CInterfaceLink *pLink = *it; - pLink->update(); - } - _UpdateAllLinks = false; -} - -//=========================================================== -void CInterfaceLink::update() -{ - //_On = false; // prvent recursive calls - if (!_ParseTree) return; - static TNodeVect observedNodes; // should not be too big, so ok to keep it static. - static TNodeVect tmpNodes; - observedNodes.clear(); - CInterfaceExprValue result; - _ParseTree->evalWithDepends(result, observedNodes); - // std::set_xxx require ordered container - std::sort(observedNodes.begin(), observedNodes.end()); - // we assume that _ObservedNode are also sorted - // compute new observers - tmpNodes.clear(); - std::set_difference(observedNodes.begin(), observedNodes.end(), _ObservedNodes.begin(), _ObservedNodes.end(), std::back_inserter(tmpNodes)); - // add these observers - createObservers(tmpNodes); - // compute lost observers - tmpNodes.clear(); - std::set_difference(_ObservedNodes.begin(), _ObservedNodes.end(), observedNodes.begin(), observedNodes.end(), std::back_inserter(tmpNodes)); - // remove these observers - removeObservers(tmpNodes); - // subsitute new (sorted) list to current - _ObservedNodes.swap(observedNodes); - // - for (uint k = 0; k < _Targets.size(); ++k) - { - CInterfaceElement *elem = _Targets[k]._InterfaceElement; - const CReflectedProperty *prop = _Targets[k]._Property; - if (elem && prop) - { - if (!affect(result, *elem, *prop)) - { - nlwarning("CInterfaceLink::update: Result conversion failed"); - } - } - } - // if there's an action handler, execute it - if (!_ActionHandler.empty()) - { - // If there is a condition, test it. - bool launch= true; - if(!_AHCond.empty()) - { - launch= false; - CInterfaceExprValue result; - if(CInterfaceExpr::eval(_AHCond, result)) - launch= result.getBool(); - } - if(launch) - { - CAHManager::getInstance()->runActionHandler(_ActionHandler, _AHParent, _AHParams); - // do not add any code after this line because this can be deleted !!!! + // this was the last node + _LastTriggeredLink[list] = _PrevTriggeredLink[list]; } + _PrevTriggeredLink[list] = NULL; + _NextTriggeredLink[list] = NULL; + _Triggered[list] = false; } - //_On = true; // prevent recursive calls -} -// predicate to remove an element from a list -struct CRemoveTargetPred -{ - CInterfaceElement *Target; - bool operator()(const CInterfaceLink::CTarget &target) const { return target._InterfaceElement == Target; } -}; -//=========================================================== -void CInterfaceLink::removeTarget(CInterfaceElement *elem) -{ - CRemoveTargetPred pred; - pred.Target = elem; - _Targets.erase(std::remove_if(_Targets.begin(), _Targets.end(), pred), _Targets.end()); -} -//=========================================================== -bool CInterfaceLink::CTargetInfo::affect(const CInterfaceExprValue &value) -{ - if (!Elem) + //----------------------------------------------- + void CInterfaceLink::updateTrigeredLinks() { - nlwarning(" : Target element is NULL"); - - return false; - } - const CReflectedProperty *property = Elem->getReflectedProperty(PropertyName); - if (!property) - { - nlwarning(" : Can't retrieve property %s for element %s.", PropertyName.c_str(), Elem->getId().c_str()); - - return false; - } - // try to affect the property - if (!::affect(value, *Elem, *property)) - { - nlwarning(" Couldn't convert the value to affect to %s", Elem->getId().c_str()); - - return false; - } - - return true; -} - -//=========================================================== -void CInterfaceLink::removeAllLinks() -{ - _LinksWithNoTarget.clear(); - TLinkList::iterator curr = _LinkList.begin(); - TLinkList::iterator nextIt; - uint k; - while(curr != _LinkList.end()) - { - nextIt = curr; - ++ nextIt; - CInterfaceLink &link = **curr; - link.checkNbRefs(); - NLMISC::CSmartPtr linkPtr = *curr; // must keep a smart ptr because of the test in the loop - for (k = 0; k < link._Targets.size(); ++k) - { - if (link._Targets[k]._InterfaceElement) - { - nlinfo("InterfaceElement %s was not remove.", link._Targets[k]._InterfaceElement->getId().c_str()); - link._Targets[k]._InterfaceElement->removeLink(&link); - } - } - linkPtr = NULL; // effectively destroy link - curr = nextIt; - } - nlassert(_LinkList.empty()); -} - -// *************************************************************************** -bool CInterfaceLink::splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm) -{ - // the last token of the target gives the name of the property - std::string::size_type lastPos = target.find_last_of(':'); - if (lastPos == (target.length() - 1)) - { - // todo hulud interface syntax error - nlwarning("The target should at least contains a path and a property as follow 'path:property'"); - return false; - } - std::string elmPath; - std::string elmProp; - CInterfaceElement *elm = NULL; - if (parentGroup) - { - if (lastPos == std::string::npos) - { - elmProp = target; - elm = parentGroup; - elmPath = "current"; - } - else - { - elmProp = target.substr(lastPos + 1); - elmPath = parentGroup->getId() + ":" + target.substr(0, lastPos); - elm = parentGroup->getElement(elmPath); - } - } - if (!elm) - { - // try the absolute adress of the element - elmPath = target.substr(0, lastPos); - elm = CWidgetManager::getInstance()->getElementFromId(elmPath); - elmProp = target.substr(lastPos + 1); - } - - if (!elm) - { - // todo hulud interface syntax error - nlwarning(" can't find target link %s", elmPath.c_str()); - return false; - } - targetElm = elm; - propertyName = elmProp; - return true; -} - - -// *************************************************************************** -bool CInterfaceLink::splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup,std::vector &targetsVect) -{ - std::vector targetNames; - NLMISC::splitString(targets, ",", targetNames); - targetsVect.clear(); - targetsVect.reserve(targetNames.size()); - bool everythingOk = true; - for (uint k = 0; k < targetNames.size(); ++k) - { - CInterfaceLink::CTargetInfo ti; - std::string::size_type startPos = targetNames[k].find_first_not_of(" "); - if(startPos == std::string::npos) - { - // todo hulud interface syntax error - nlwarning(" empty target encountered"); - continue; - } - std::string::size_type lastPos = targetNames[k].find_last_not_of(" "); - - if (!splitLinkTarget(targetNames[k].substr(startPos, lastPos - startPos+1), parentGroup, ti.PropertyName, ti.Elem)) - { - // todo hulud interface syntax error - nlwarning(" Can't get link target"); - everythingOk = false; - continue; - } - targetsVect.push_back(ti); - } - return everythingOk; -} - - -//=========================================================== -void CInterfaceLink::checkNbRefs() -{ - uint numValidPtr = 0; - for(uint k = 0; k < _Targets.size(); ++k) - { - if (_Targets[k]._InterfaceElement != NULL) ++numValidPtr; - } - nlassert(numValidPtr == (uint) crefs); -} - - -//=========================================================== -void CInterfaceLink::setTargetProperty (const std::string &Target, const CInterfaceExprValue &val) -{ - // Eval target ! - string elt = Target.substr(0,Target.rfind(':')); - CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt); - CInterfaceGroup *pIG = dynamic_cast(pIE); - if (pIG == NULL) - pIG = pIE->getParent(); - - if (pIG != NULL) - { - std::vector vTargets; - splitLinkTargets(Target, pIG, vTargets); - if ((vTargets.size() > 0) && (vTargets[0].Elem)) - { - vTargets[0].affect(val); - } - } -} - -//----------------------------------------------- -void CInterfaceLink::linkInTriggerList(uint list) -{ - nlassert(list < 2); - if (_Triggered[list]) return; // already inserted in list - _Triggered[list] = true; - nlassert(!_PrevTriggeredLink[list]); - nlassert(!_NextTriggeredLink[list]); - if (!_FirstTriggeredLink[list]) - { - _FirstTriggeredLink[list] = _LastTriggeredLink[list] = this; - } - else - { - nlassert(!_LastTriggeredLink[list]->_NextTriggeredLink[list]); - _LastTriggeredLink[list]->_NextTriggeredLink[list] = this; - _PrevTriggeredLink[list] = _LastTriggeredLink[list]; - _LastTriggeredLink[list] = this; - } -} - -//----------------------------------------------- -void CInterfaceLink::unlinkFromTriggerList(uint list) -{ - nlassert(list < 2); - if (!_Triggered[list]) - { - // not linked in this list - nlassert(_PrevTriggeredLink[list] == NULL); - nlassert(_NextTriggeredLink[list] == NULL); - return; - } - if (_PrevTriggeredLink[list]) - { - _PrevTriggeredLink[list]->_NextTriggeredLink[list] = _NextTriggeredLink[list]; - } - else - { - // this was the first node - _FirstTriggeredLink[list] = _NextTriggeredLink[list]; - } - if (_NextTriggeredLink[list]) - { - _NextTriggeredLink[list]->_PrevTriggeredLink[list] = _PrevTriggeredLink[list]; - } - else - { - // this was the last node - _LastTriggeredLink[list] = _PrevTriggeredLink[list]; - } - _PrevTriggeredLink[list] = NULL; - _NextTriggeredLink[list] = NULL; - _Triggered[list] = false; -} - - - - - -//----------------------------------------------- -void CInterfaceLink::updateTrigeredLinks() -{ - static bool called = false; - nlassert(!called); - called = true; - _CurrUpdatedLink = _FirstTriggeredLink[_CurrentTriggeredLinkList]; - while (_CurrUpdatedLink) - { - // modified node should now store them in other list when they're modified - _CurrentTriggeredLinkList = 1 - _CurrentTriggeredLinkList; - // switch list so that modified node are stored in the other list + static bool called = false; + nlassert(!called); + called = true; + _CurrUpdatedLink = _FirstTriggeredLink[_CurrentTriggeredLinkList]; while (_CurrUpdatedLink) { - _NextUpdatedLink = _CurrUpdatedLink->_NextTriggeredLink[1 - _CurrentTriggeredLinkList]; - _CurrUpdatedLink->update(); - if (_CurrUpdatedLink) // this may be modified by the call (if current observer is removed) + // modified node should now store them in other list when they're modified + _CurrentTriggeredLinkList = 1 - _CurrentTriggeredLinkList; + // switch list so that modified node are stored in the other list + while (_CurrUpdatedLink) { - _CurrUpdatedLink->unlinkFromTriggerList(1 - _CurrentTriggeredLinkList); + _NextUpdatedLink = _CurrUpdatedLink->_NextTriggeredLink[1 - _CurrentTriggeredLinkList]; + _CurrUpdatedLink->update(); + if (_CurrUpdatedLink) // this may be modified by the call (if current observer is removed) + { + _CurrUpdatedLink->unlinkFromTriggerList(1 - _CurrentTriggeredLinkList); + } + _CurrUpdatedLink = _NextUpdatedLink; } - _CurrUpdatedLink = _NextUpdatedLink; + nlassert(_FirstTriggeredLink[1 - _CurrentTriggeredLinkList] == NULL); + nlassert(_LastTriggeredLink[1 - _CurrentTriggeredLinkList] == NULL); + // examine other list to see if nodes have been registered + _CurrUpdatedLink = _FirstTriggeredLink[_CurrentTriggeredLinkList]; } - nlassert(_FirstTriggeredLink[1 - _CurrentTriggeredLinkList] == NULL); - nlassert(_LastTriggeredLink[1 - _CurrentTriggeredLinkList] == NULL); - // examine other list to see if nodes have been registered - _CurrUpdatedLink = _FirstTriggeredLink[_CurrentTriggeredLinkList]; + called = false; } - called = false; + + } + diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 2c9bd97d8..1a01bce6e 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -23,103 +23,106 @@ using namespace std; using namespace NLMISC; -// *************************************************************************** -const CInterfaceOptionValue CInterfaceOptionValue::NullValue; - -// *************************************************************************** -void CInterfaceOptionValue::init(const std::string &str) +namespace NLGUI { - _Str= str; - fromString(str, _Int); - fromString(str, _Float); - _Color= CInterfaceElement::convertColor (str.c_str()); - _Boolean= CInterfaceElement::convertBool(str.c_str()); -} + const CInterfaceOptionValue CInterfaceOptionValue::NullValue; -// ---------------------------------------------------------------------------- -// CInterfaceOptions -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -CInterfaceOptions::CInterfaceOptions() -{ -} - -// ---------------------------------------------------------------------------- -CInterfaceOptions::~CInterfaceOptions() -{ -} - -// ---------------------------------------------------------------------------- -bool CInterfaceOptions::parse (xmlNodePtr cur) -{ - cur = cur->children; - bool ok = true; - while (cur) + // *************************************************************************** + void CInterfaceOptionValue::init(const std::string &str) { - if ( !stricmp((char*)cur->name,"param") ) - { - CXMLAutoPtr ptr, val; - ptr = xmlGetProp (cur, (xmlChar*)"name"); - val = xmlGetProp (cur, (xmlChar*)"value"); - if (!ptr || !val) - { - nlinfo("param with no name or no value"); - ok = false; - } - else - { - string name = NLMISC::toLower(string((const char*)ptr)); - string value = (string((const char*)val)); - _ParamValue[name].init(value); - } - } - cur = cur->next; + _Str= str; + fromString(str, _Int); + fromString(str, _Float); + _Color= CInterfaceElement::convertColor (str.c_str()); + _Boolean= CInterfaceElement::convertBool(str.c_str()); } - return ok; -} -// *************************************************************************** -void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other) -{ - _ParamValue= other._ParamValue; -} -// *************************************************************************** -const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const -{ - string sLwrParamName = strlwr (sParamName); - std::map::const_iterator it = _ParamValue.find (sLwrParamName); - if (it != _ParamValue.end()) - return it->second; - else - return CInterfaceOptionValue::NullValue; -} + // ---------------------------------------------------------------------------- + // CInterfaceOptions + // ---------------------------------------------------------------------------- -// *************************************************************************** -const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const -{ - return getValue(sParamName).getValStr(); -} -// *************************************************************************** -sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const -{ - return getValue(sParamName).getValSInt32(); -} -// *************************************************************************** -float CInterfaceOptions::getValFloat(const std::string &sParamName) const -{ - return getValue(sParamName).getValFloat(); -} -// *************************************************************************** -NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const -{ - return getValue(sParamName).getValColor(); -} -// *************************************************************************** -bool CInterfaceOptions::getValBool(const std::string &sParamName) const -{ - return getValue(sParamName).getValBool(); -} + // ---------------------------------------------------------------------------- + CInterfaceOptions::CInterfaceOptions() + { + } + // ---------------------------------------------------------------------------- + CInterfaceOptions::~CInterfaceOptions() + { + } + + // ---------------------------------------------------------------------------- + bool CInterfaceOptions::parse (xmlNodePtr cur) + { + cur = cur->children; + bool ok = true; + while (cur) + { + if ( !stricmp((char*)cur->name,"param") ) + { + CXMLAutoPtr ptr, val; + ptr = xmlGetProp (cur, (xmlChar*)"name"); + val = xmlGetProp (cur, (xmlChar*)"value"); + if (!ptr || !val) + { + nlinfo("param with no name or no value"); + ok = false; + } + else + { + string name = NLMISC::toLower(string((const char*)ptr)); + string value = (string((const char*)val)); + _ParamValue[name].init(value); + } + } + cur = cur->next; + } + return ok; + } + + // *************************************************************************** + void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other) + { + _ParamValue= other._ParamValue; + } + + // *************************************************************************** + const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const + { + string sLwrParamName = strlwr (sParamName); + std::map::const_iterator it = _ParamValue.find (sLwrParamName); + if (it != _ParamValue.end()) + return it->second; + else + return CInterfaceOptionValue::NullValue; + } + + // *************************************************************************** + const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const + { + return getValue(sParamName).getValStr(); + } + // *************************************************************************** + sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const + { + return getValue(sParamName).getValSInt32(); + } + // *************************************************************************** + float CInterfaceOptions::getValFloat(const std::string &sParamName) const + { + return getValue(sParamName).getValFloat(); + } + // *************************************************************************** + NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const + { + return getValue(sParamName).getValColor(); + } + // *************************************************************************** + bool CInterfaceOptions::getValBool(const std::string &sParamName) const + { + return getValue(sParamName).getValBool(); + } + +} diff --git a/code/nel/src/gui/view_base.cpp b/code/nel/src/gui/view_base.cpp index 56761c571..9636ed9c1 100644 --- a/code/nel/src/gui/view_base.cpp +++ b/code/nel/src/gui/view_base.cpp @@ -18,27 +18,32 @@ #include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" -CViewBase::~CViewBase() +namespace NLGUI { - CWidgetManager::getInstance()->removeRefOnView (this); -} - -// *************************************************************************** -void CViewBase::dumpSize(uint depth /*=0*/) const -{ - std::string result; - result.resize(depth * 4, ' '); - std::string::size_type pos = _Id.find_last_of(':'); - std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos); - result += NLMISC::toString("id=%s, w=%d, h=%d, x=%d, y=%d, wreal=%d, hreal=%d, xreal=%d, yreal=%d", shortID.c_str(), (int) _W, (int) _H, (int) _X, (int) _Y, (int) _WReal, (int) _HReal, (int) _XReal, (int) _YReal); - nlinfo(result.c_str()); -} - -// *************************************************************************** -void CViewBase::visit(CInterfaceElementVisitor *visitor) -{ - nlassert(visitor); - visitor->visitView(this); - CInterfaceElement::visit(visitor); + + CViewBase::~CViewBase() + { + CWidgetManager::getInstance()->removeRefOnView (this); + } + + // *************************************************************************** + void CViewBase::dumpSize(uint depth /*=0*/) const + { + std::string result; + result.resize(depth * 4, ' '); + std::string::size_type pos = _Id.find_last_of(':'); + std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos); + result += NLMISC::toString("id=%s, w=%d, h=%d, x=%d, y=%d, wreal=%d, hreal=%d, xreal=%d, yreal=%d", shortID.c_str(), (int) _W, (int) _H, (int) _X, (int) _Y, (int) _WReal, (int) _HReal, (int) _XReal, (int) _YReal); + nlinfo(result.c_str()); + } + + // *************************************************************************** + void CViewBase::visit(CInterfaceElementVisitor *visitor) + { + nlassert(visitor); + visitor->visitView(this); + CInterfaceElement::visit(visitor); + } + } diff --git a/code/nel/src/gui/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp index b89febad9..976263eb1 100644 --- a/code/nel/src/gui/view_pointer_base.cpp +++ b/code/nel/src/gui/view_pointer_base.cpp @@ -1,122 +1,142 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_pointer_base.h" -CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) : -CViewBase( param ) +namespace NLGUI { - _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; - _PointerDown = false; - _PointerVisible = true; -} -CViewPointerBase::~CViewPointerBase() -{ -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::setPointerPos (sint32 x, sint32 y) -{ - if (_PointerDown) + CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) : + CViewBase( param ) { - if (!_PointerDrag) + _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; + _PointerDown = false; + _PointerVisible = true; + } + + CViewPointerBase::~CViewPointerBase() + { + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerPos (sint32 x, sint32 y) + { + if (_PointerDown) { - if (((_PointerX - _PointerDownX) != 0) || - ((_PointerY - _PointerDownY) != 0)) + if (!_PointerDrag) { - _PointerDrag = true; + if (((_PointerX - _PointerDownX) != 0) || + ((_PointerY - _PointerDownY) != 0)) + { + _PointerDrag = true; + } } } + + _PointerOldX = getX(); + _PointerOldY = getY(); + + _PointerX = x; + _PointerY = y; } - _PointerOldX = getX(); - _PointerOldY = getY(); - - _PointerX = x; - _PointerY = y; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y) -{ - setX (x); - setY (y); - updateCoords (); -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::resetPointerPos () -{ - _PointerOldX = _PointerX; - _PointerOldY = _PointerY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::setPointerDown (bool pd) -{ - _PointerDown = pd; - - if (_PointerDown == true) + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y) { - _PointerDownX = _PointerX; - _PointerDownY = _PointerY; + setX (x); + setY (y); + updateCoords (); + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::resetPointerPos () + { + _PointerOldX = _PointerX; + _PointerOldY = _PointerY; + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerDown (bool pd) + { + _PointerDown = pd; + + if (_PointerDown == true) + { + _PointerDownX = _PointerX; + _PointerDownY = _PointerY; + } + + if (_PointerDown == false) + _PointerDrag = false; + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::setPointerDownString (const std::string &s) + { + _PointerDownString = s; + } + + // +++ GET +++ + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y) + { + x = _PointerX; + y = _PointerY; + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y) + { + x = getX(); + y = getY(); + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y) + { + x = _PointerOldX; + y = _PointerOldY; + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) + { + x = _PointerDownX; + y = _PointerDownY; + } + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointerBase::getPointerDown () + { + return _PointerDown; + } + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointerBase::getPointerDrag () + { + return _PointerDrag; + } + + // -------------------------------------------------------------------------------------------------------------------- + std::string CViewPointerBase::getPointerDownString () + { + return _PointerDownString; } - if (_PointerDown == false) - _PointerDrag = false; } -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::setPointerDownString (const std::string &s) -{ - _PointerDownString = s; -} - -// +++ GET +++ - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y) -{ - x = _PointerX; - y = _PointerY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y) -{ - x = getX(); - y = getY(); -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y) -{ - x = _PointerOldX; - y = _PointerOldY; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y) -{ - x = _PointerDownX; - y = _PointerDownY; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointerBase::getPointerDown () -{ - return _PointerDown; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointerBase::getPointerDrag () -{ - return _PointerDrag; -} - -// -------------------------------------------------------------------------------------------------------------------- -std::string CViewPointerBase::getPointerDownString () -{ - return _PointerDownString; -} - - - diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index aaf0813ef..14064ec40 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -25,1377 +25,1382 @@ #include "nel/gui/group_editbox_base.h" #include "nel/gui/interface_options.h" - -CWidgetManager* CWidgetManager::instance = NULL; -std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; -IParser* CWidgetManager::parser = NULL; - -// ---------------------------------------------------------------------------- -// SMasterGroup -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio) +namespace NLGUI { - nlassert(nPrioisGroupInScene() ); + CWidgetManager* CWidgetManager::instance = NULL; + std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; + IParser* CWidgetManager::parser = NULL; - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + // ---------------------------------------------------------------------------- + // SMasterGroup + // ---------------------------------------------------------------------------- + + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::addWindow(CInterfaceGroup *pIG, uint8 nPrio) { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - // If the element already exists in the list return ! - if (*it == pIG) - return; - it++; - } - } - PrioritizedWindows[nPrio].push_back(pIG); -} + nlassert(nPrio::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) + // Priority WIN_PRIORITY_WORLD_SPACE is only for CGroupInScene ! + // Add this group in another priority list + nlassert ((nPrio!=WIN_PRIORITY_MAX) || pIG->isGroupInScene() ); + + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { - if ((*it) == pIG) + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) { - PrioritizedWindows[i].erase(it); - return; + // If the element already exists in the list return ! + if (*it == pIG) + return; + it++; } - it++; } + PrioritizedWindows[nPrio].push_back(pIG); } -} -// ---------------------------------------------------------------------------- -CInterfaceGroup* CWidgetManager::SMasterGroup::getWindowFromId(const std::string &winID) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::delWindow(CInterfaceGroup *pIG) { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { - if ((*it)->getId() == winID) - return *it; - it++; - } - } - return NULL; -} - -// ---------------------------------------------------------------------------- -bool CWidgetManager::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if ((*it) == pIG) - return true; - it++; - } - } - return false; -} - -// Set a window top in its priority queue -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::setTopWindow(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - if (*it == pIG) + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) { - PrioritizedWindows[i].erase(it); - PrioritizedWindows[i].push_back(pIG); - LastTopWindowPriority= i; - return; + if ((*it) == pIG) + { + PrioritizedWindows[i].erase(it); + return; + } + it++; } - it++; } } - // todo hulud interface syntax error - nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); -} -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::setBackWindow(CInterfaceGroup *pIG) -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + // ---------------------------------------------------------------------------- + CInterfaceGroup* CWidgetManager::SMasterGroup::getWindowFromId(const std::string &winID) { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { - if (*it == pIG) + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) { - PrioritizedWindows[i].erase(it); - PrioritizedWindows[i].push_front(pIG); - return; + if ((*it)->getId() == winID) + return *it; + it++; } - it++; } + return NULL; } - // todo hulud interface syntax error - nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); -} -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::deactiveAllContainers() -{ - std::vector gcs; - - // Make first a list of all window (Warning: all group container are not window!) - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + // ---------------------------------------------------------------------------- + bool CWidgetManager::SMasterGroup::isWindowPresent(CInterfaceGroup *pIG) { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { - CGroupContainerBase *pGC = dynamic_cast(*it); - if (pGC != NULL) - gcs.push_back(pGC); - it++; - } - } - - // Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows, - // and hence invalidate its. - for (uint32 i = 0; i < gcs.size(); ++i) - { - gcs[i]->setActive(false); - } -} - -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::centerAllContainers() -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) - { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) - { - CGroupContainerBase *pGC = dynamic_cast(*it); - if ((pGC != NULL) && (pGC->getParent() != NULL)) + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) { - sint32 wParent = pGC->getParent()->getW(false); - sint32 w = pGC->getW(false); - pGC->setXAndInvalidateCoords((wParent - w) / 2); - sint32 hParent = pGC->getParent()->getH(false); - sint32 h = pGC->getH(false); - pGC->setYAndInvalidateCoords(h+(hParent - h) / 2); + if ((*it) == pIG) + return true; + it++; } - - it++; } + return false; } -} -// ---------------------------------------------------------------------------- -void CWidgetManager::SMasterGroup::unlockAllContainers() -{ - for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + // Set a window top in its priority queue + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::setTopWindow(CInterfaceGroup *pIG) { - std::list::iterator it = PrioritizedWindows[i].begin(); - while (it != PrioritizedWindows[i].end()) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) { - CGroupContainerBase *pGC = dynamic_cast(*it); - if (pGC != NULL) - pGC->setLocked(false); + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if (*it == pIG) + { + PrioritizedWindows[i].erase(it); + PrioritizedWindows[i].push_back(pIG); + LastTopWindowPriority= i; + return; + } + it++; + } + } + // todo hulud interface syntax error + nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::setBackWindow(CInterfaceGroup *pIG) + { + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + if (*it == pIG) + { + PrioritizedWindows[i].erase(it); + PrioritizedWindows[i].push_front(pIG); + return; + } + it++; + } + } + // todo hulud interface syntax error + nlwarning("window %s do not exist in a priority list", pIG->getId().c_str()); + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::deactiveAllContainers() + { + std::vector gcs; + + // Make first a list of all window (Warning: all group container are not window!) + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainerBase *pGC = dynamic_cast(*it); + if (pGC != NULL) + gcs.push_back(pGC); + it++; + } + } + + // Then hide them. Must do this in 2 times, because setActive(false) change PrioritizedWindows, + // and hence invalidate its. + for (uint32 i = 0; i < gcs.size(); ++i) + { + gcs[i]->setActive(false); + } + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::centerAllContainers() + { + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainerBase *pGC = dynamic_cast(*it); + if ((pGC != NULL) && (pGC->getParent() != NULL)) + { + sint32 wParent = pGC->getParent()->getW(false); + sint32 w = pGC->getW(false); + pGC->setXAndInvalidateCoords((wParent - w) / 2); + sint32 hParent = pGC->getParent()->getH(false); + sint32 h = pGC->getH(false); + pGC->setYAndInvalidateCoords(h+(hParent - h) / 2); + } + + it++; + } + } + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::SMasterGroup::unlockAllContainers() + { + for (uint8 i = 0; i < WIN_PRIORITY_MAX; ++i) + { + std::list::iterator it = PrioritizedWindows[i].begin(); + while (it != PrioritizedWindows[i].end()) + { + CGroupContainerBase *pGC = dynamic_cast(*it); + if (pGC != NULL) + pGC->setLocked(false); + + it++; + } + } + } + + class CElementToSort + { + public: + CInterfaceGroup *pIG; + float Distance; + bool operator< (const CElementToSort& other) const + { + // We want first farest views + return Distance > other.Distance; + } + }; + + void CWidgetManager::SMasterGroup::sortWorldSpaceGroup () + { + static std::vector sortTable; + sortTable.clear (); + + // Fill the sort table + std::list::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); + while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) + { + sortTable.push_back (CElementToSort ()); + CElementToSort &elm = sortTable.back(); + elm.pIG = *it; + elm.Distance = (*it)->getDepthForZSort(); it++; } - } -} -class CElementToSort -{ -public: - CInterfaceGroup *pIG; - float Distance; - bool operator< (const CElementToSort& other) const - { - // We want first farest views - return Distance > other.Distance; - } -}; + // Sort the table + std::sort (sortTable.begin(), sortTable.end()); -void CWidgetManager::SMasterGroup::sortWorldSpaceGroup () -{ - static std::vector sortTable; - sortTable.clear (); + // Fill the final table + uint i = 0; + it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); + while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) + { + *it = sortTable[i].pIG; - // Fill the sort table - std::list::iterator it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); - while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) - { - sortTable.push_back (CElementToSort ()); - CElementToSort &elm = sortTable.back(); - elm.pIG = *it; - elm.Distance = (*it)->getDepthForZSort(); - - it++; + it++; + i++; + } } - // Sort the table - std::sort (sortTable.begin(), sortTable.end()); - // Fill the final table - uint i = 0; - it = PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].begin(); - while (it != PrioritizedWindows[WIN_PRIORITY_WORLD_SPACE].end()) + CWidgetManager* CWidgetManager::getInstance() { - *it = sortTable[i].pIG; + if( instance == NULL ) + instance = new CWidgetManager; - it++; - i++; + return instance; } -} - -CWidgetManager* CWidgetManager::getInstance() -{ - if( instance == NULL ) - instance = new CWidgetManager; - - return instance; -} - -void CWidgetManager::release() -{ - delete instance; - instance = NULL; -} - -// ---------------------------------------------------------------------------- -CInterfaceGroup* CWidgetManager::getMasterGroupFromId (const std::string &MasterGroupName) -{ - for (uint32 i = 0; i < _MasterGroups.size(); ++i) + void CWidgetManager::release() { - if (_MasterGroups[i].Group->getId() == MasterGroupName) - return _MasterGroups[i].Group; + delete instance; + instance = NULL; } - return NULL; -} -// ---------------------------------------------------------------------------- -CInterfaceGroup* CWidgetManager::getWindowFromId (const std::string & groupId) -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // ---------------------------------------------------------------------------- + CInterfaceGroup* CWidgetManager::getMasterGroupFromId (const std::string &MasterGroupName) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - CInterfaceGroup *pIG = rMG.getWindowFromId(groupId); + for (uint32 i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group->getId() == MasterGroupName) + return _MasterGroups[i].Group; + } + return NULL; + } + + // ---------------------------------------------------------------------------- + CInterfaceGroup* CWidgetManager::getWindowFromId (const std::string & groupId) + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CInterfaceGroup *pIG = rMG.getWindowFromId(groupId); + if (pIG != NULL) + return pIG; + } + return NULL; + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG) + { + // Warning this function is not smart : its a o(n) ! + if (pIG == NULL) return; + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getId() == sMasterGroupName) + { + rMG.addWindow(pIG, pIG->getPriority()); + } + } + } + + // ---------------------------------------------------------------------------- + void CWidgetManager::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG) + { + // Warning this function is not smart : its a o(n) ! + if (pIG == NULL) return; + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getId() == sMasterGroupName) + { + rMG.delWindow(pIG); + } + } + } + + void unlinkAllContainers (CInterfaceGroup *pIG) + { + const std::vector &rG = pIG->getGroups(); + for(uint i = 0; i < rG.size(); ++i) + unlinkAllContainers (rG[i]); + + CGroupContainerBase *pGC = dynamic_cast(pIG); + if (pGC != NULL) + pGC->removeAllContainers(); + } + + // *************************************************************************** + void CWidgetManager::removeAllMasterGroups() + { + uint i; + + for (i = 0; i < _MasterGroups.size(); ++i) + unlinkAllContainers (_MasterGroups[i].Group); + + // Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback + // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) + while(!_MasterGroups.empty()) + { + delete _MasterGroups.back().Group; + _MasterGroups.pop_back(); + } + + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::activateMasterGroup (const std::string &sMasterGroupName, bool bActive) + { + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getMasterGroupFromId (sMasterGroupName); if (pIG != NULL) - return pIG; - } - return NULL; -} - -// ---------------------------------------------------------------------------- -void CWidgetManager::addWindowToMasterGroup (const std::string &sMasterGroupName, CInterfaceGroup *pIG) -{ - // Warning this function is not smart : its a o(n) ! - if (pIG == NULL) return; - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) - { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getId() == sMasterGroupName) { - rMG.addWindow(pIG, pIG->getPriority()); + pIG->setActive(bActive); + pIG->invalidateCoords(); } } -} -// ---------------------------------------------------------------------------- -void CWidgetManager::removeWindowFromMasterGroup(const std::string &sMasterGroupName,CInterfaceGroup *pIG) -{ - // Warning this function is not smart : its a o(n) ! - if (pIG == NULL) return; - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); ++nMasterGroup) + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CWidgetManager::getWindow(CInterfaceElement *pIE) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getId() == sMasterGroupName) + CInterfaceGroup *pIG = pIE->getParent(); + if (pIG == NULL) return NULL; + if (pIG->getParent() == NULL) return NULL; + while (pIG->getParent()->getParent() != NULL) { - rMG.delWindow(pIG); + pIG = pIG->getParent(); } - } -} - -void unlinkAllContainers (CInterfaceGroup *pIG) -{ - const std::vector &rG = pIG->getGroups(); - for(uint i = 0; i < rG.size(); ++i) - unlinkAllContainers (rG[i]); - - CGroupContainerBase *pGC = dynamic_cast(pIG); - if (pGC != NULL) - pGC->removeAllContainers(); -} - -// *************************************************************************** -void CWidgetManager::removeAllMasterGroups() -{ - uint i; - - for (i = 0; i < _MasterGroups.size(); ++i) - unlinkAllContainers (_MasterGroups[i].Group); - - // Yoyo: important to not Leave NULL in the array, because of CGroupHTML and LibWWW callback - // that may call CInterfaceManager::getElementFromId() (and this method hates having NULL in the arrays ^^) - while(!_MasterGroups.empty()) - { - delete _MasterGroups.back().Group; - _MasterGroups.pop_back(); + return pIG; } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::activateMasterGroup (const std::string &sMasterGroupName, bool bActive) -{ - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getMasterGroupFromId (sMasterGroupName); - if (pIG != NULL) + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sEltId) { - pIG->setActive(bActive); - pIG->invalidateCoords(); - } -} + // System special + if(sEltId == _CtrlLaunchingModalId) + return getCtrlLaunchingModal(); -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CWidgetManager::getWindow(CInterfaceElement *pIE) -{ - CInterfaceGroup *pIG = pIE->getParent(); - if (pIG == NULL) return NULL; - if (pIG->getParent() == NULL) return NULL; - while (pIG->getParent()->getParent() != NULL) - { - pIG = pIG->getParent(); - } - return pIG; -} - - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sEltId) -{ - // System special - if(sEltId == _CtrlLaunchingModalId) - return getCtrlLaunchingModal(); - - // Search for all elements - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - CInterfaceElement *pIEL = rMG.Group->getElement (sEltId); - if (pIEL != NULL) - return pIEL; - } - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sStart, const std::string &sEltId) -{ - CInterfaceElement *pIEL = getElementFromId (sEltId); - if (pIEL == NULL) - { - std::string sZeStart = sStart, sTmp; - if (sZeStart[sZeStart.size()-1] == ':') - sZeStart = sZeStart.substr(0, sZeStart.size()-1); - - while (sZeStart != "") + // Search for all elements + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - if (sEltId[0] == ':') - sTmp = sZeStart + sEltId; - else - sTmp = sZeStart + ":" + sEltId; - pIEL = getElementFromId (sTmp); + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + CInterfaceElement *pIEL = rMG.Group->getElement (sEltId); if (pIEL != NULL) return pIEL; - std::string::size_type nextPos = sZeStart.rfind(':'); - if (nextPos == std::string::npos) break; - sZeStart = sZeStart.substr(0, nextPos); } + return NULL; } - return pIEL; -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::setTopWindow (CInterfaceGroup* win) -{ - //find the window in the window list - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CWidgetManager::getElementFromId (const std::string &sStart, const std::string &sEltId) { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - rMG.setTopWindow(win); - } -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::setBackWindow(CInterfaceGroup* win) -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - rMG.setBackWindow(win); - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CWidgetManager::getTopWindow (uint8 nPriority) const -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) + CInterfaceElement *pIEL = getElementFromId (sEltId); + if (pIEL == NULL) { - // return the first. - if(rMG.PrioritizedWindows[nPriority].empty()) - return NULL; - else - return rMG.PrioritizedWindows[nPriority].back(); - } - } - return NULL; -} + std::string sZeStart = sStart, sTmp; + if (sZeStart[sZeStart.size()-1] == ':') + sZeStart = sZeStart.substr(0, sZeStart.size()-1); - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CWidgetManager::getBackWindow (uint8 nPriority) const -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - // return the first. - if(rMG.PrioritizedWindows[nPriority].empty()) - return NULL; - else - return rMG.PrioritizedWindows[nPriority].front(); - } - } - return NULL; -} - -// *************************************************************************** -CInterfaceGroup* CWidgetManager::getLastEscapableTopWindow() const -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + while (sZeStart != "") { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator it; - it= rList.rbegin(); - for(;it!=rList.rend();it++) + if (sEltId[0] == ':') + sTmp = sZeStart + sEltId; + else + sTmp = sZeStart + ":" + sEltId; + pIEL = getElementFromId (sTmp); + if (pIEL != NULL) + return pIEL; + std::string::size_type nextPos = sZeStart.rfind(':'); + if (nextPos == std::string::npos) break; + sZeStart = sZeStart.substr(0, nextPos); + } + } + return pIEL; + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::setTopWindow (CInterfaceGroup* win) + { + //find the window in the window list + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + rMG.setTopWindow(win); + } + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::setBackWindow(CInterfaceGroup* win) + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + rMG.setBackWindow(win); + } + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CWidgetManager::getTopWindow (uint8 nPriority) const + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + // return the first. + if(rMG.PrioritizedWindows[nPriority].empty()) + return NULL; + else + return rMG.PrioritizedWindows[nPriority].back(); + } + } + return NULL; + } + + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CWidgetManager::getBackWindow (uint8 nPriority) const + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + // return the first. + if(rMG.PrioritizedWindows[nPriority].empty()) + return NULL; + else + return rMG.PrioritizedWindows[nPriority].front(); + } + } + return NULL; + } + + // *************************************************************************** + CInterfaceGroup* CWidgetManager::getLastEscapableTopWindow() const + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) { - if((*it)->getActive() && (*it)->getEscapable()) - return *it; + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator it; + it= rList.rbegin(); + for(;it!=rList.rend();it++) + { + if((*it)->getActive() && (*it)->getEscapable()) + return *it; + } + } + } + } + return NULL; + } + + // *************************************************************************** + void CWidgetManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority) + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + if (rMG.isWindowPresent(pWin)) + { + rMG.delWindow(pWin); + rMG.addWindow(pWin, nNewPriority); } } } } - return NULL; -} -// *************************************************************************** -void CWidgetManager::setWindowPriority (CInterfaceGroup *pWin, uint8 nNewPriority) -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // *************************************************************************** + uint8 CWidgetManager::getLastTopWindowPriority() const { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - if (rMG.isWindowPresent(pWin)) + const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) { - rMG.delWindow(pWin); - rMG.addWindow(pWin, nNewPriority); + return rMG.LastTopWindowPriority; } } + return 0; } -} -// *************************************************************************** -uint8 CWidgetManager::getLastTopWindowPriority() const -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + bool CWidgetManager::hasModal() const { - const CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - return rMG.LastTopWindowPriority; - } - } - return 0; -} - -bool CWidgetManager::hasModal() const -{ - if( !_ModalStack.empty() ) - return true; - else - return false; -} - -CWidgetManager::SModalWndInfo& CWidgetManager::getModal() -{ - return _ModalStack.back(); -} - -bool CWidgetManager::isPreviousModal( CInterfaceGroup *wnd ) const -{ - std::vector< SModalWndInfo >::size_type s = _ModalStack.size(); - for( std::vector< SModalWndInfo >::size_type i = 0; i < s; i++ ) - if( _ModalStack[ i ].ModalWindow == wnd ) + if( !_ModalStack.empty() ) return true; - - return false; -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) -{ - // disable any modal before. release keyboard - disableModalWindow(); - pushModalWindow(ctrlLaunchingModal, pIG); -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::enableModalWindow (CCtrlBase *CtrlLaunchingModal, const std::string &groupName) -{ - CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); - if(group) - { - // enable the modal - enableModalWindow(CtrlLaunchingModal, group); + else + return false; } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::disableModalWindow () -{ - while (!_ModalStack.empty()) + CWidgetManager::SModalWndInfo& CWidgetManager::getModal() { - SModalWndInfo winInfo = _ModalStack.back(); - _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash - // disable old modal window - if(winInfo.ModalWindow) + return _ModalStack.back(); + } + + bool CWidgetManager::isPreviousModal( CInterfaceGroup *wnd ) const + { + std::vector< SModalWndInfo >::size_type s = _ModalStack.size(); + for( std::vector< SModalWndInfo >::size_type i = 0; i < s; i++ ) + if( _ModalStack[ i ].ModalWindow == wnd ) + return true; + + return false; + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) + { + // disable any modal before. release keyboard + disableModalWindow(); + pushModalWindow(ctrlLaunchingModal, pIG); + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::enableModalWindow (CCtrlBase *CtrlLaunchingModal, const std::string &groupName) + { + CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); + if(group) { - setBackWindow(winInfo.ModalWindow); - winInfo.ModalWindow->setActive(false); + // enable the modal + enableModalWindow(CtrlLaunchingModal, group); } } - // disable any context help - setCurContextHelp( NULL ); - CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) -{ - // enable the wanted modal - if(pIG) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::disableModalWindow () { - SModalWndInfo mwi; - mwi.ModalWindow = pIG; - mwi.CtrlLaunchingModal = ctrlLaunchingModal; - // setup special group - CGroupModal *groupModal= dynamic_cast(pIG); - if(groupModal) + while (!_ModalStack.empty()) { - mwi.ModalExitClickOut = groupModal->ExitClickOut; - mwi.ModalExitClickL = groupModal->ExitClickL; - mwi.ModalExitClickR = groupModal->ExitClickR; - mwi.ModalHandlerClickOut = groupModal->OnClickOut; - mwi.ModalClickOutParams = groupModal->OnClickOutParams; - mwi.ModalExitKeyPushed = groupModal->ExitKeyPushed; - // update coords of the modal - if(groupModal->SpawnOnMousePos) + SModalWndInfo winInfo = _ModalStack.back(); + _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash + // disable old modal window + if(winInfo.ModalWindow) { - groupModal->SpawnMouseX = _Pointer->getX(); - groupModal->SpawnMouseY = _Pointer->getY(); + setBackWindow(winInfo.ModalWindow); + winInfo.ModalWindow->setActive(false); } } - else - { - // default for group not modal. Backward compatibility - mwi.ModalExitClickOut = false; - mwi.ModalExitClickL = false; - mwi.ModalExitClickR = false; - mwi.ModalExitKeyPushed = false; - } - _ModalStack.push_back(mwi); - - // update coords and activate the modal - mwi.ModalWindow->invalidateCoords(); - mwi.ModalWindow->setActive(true); - setTopWindow(mwi.ModalWindow); + // disable any context help + setCurContextHelp( NULL ); + CWidgetManager::getInstance()->_DeltaTimeStopingContextHelp = 0; } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, const std::string &groupName) -{ - CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); - if(group) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG) { - // enable the modal - enableModalWindow(ctrlLaunchingModal, group); - } -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::popModalWindow() -{ - if (!_ModalStack.empty()) - { - SModalWndInfo winInfo = _ModalStack.back(); - _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash - if(winInfo.ModalWindow) + // enable the wanted modal + if(pIG) { - setBackWindow(winInfo.ModalWindow); - winInfo.ModalWindow->setActive(false); + SModalWndInfo mwi; + mwi.ModalWindow = pIG; + mwi.CtrlLaunchingModal = ctrlLaunchingModal; + // setup special group + CGroupModal *groupModal= dynamic_cast(pIG); + if(groupModal) + { + mwi.ModalExitClickOut = groupModal->ExitClickOut; + mwi.ModalExitClickL = groupModal->ExitClickL; + mwi.ModalExitClickR = groupModal->ExitClickR; + mwi.ModalHandlerClickOut = groupModal->OnClickOut; + mwi.ModalClickOutParams = groupModal->OnClickOutParams; + mwi.ModalExitKeyPushed = groupModal->ExitKeyPushed; + // update coords of the modal + if(groupModal->SpawnOnMousePos) + { + groupModal->SpawnMouseX = _Pointer->getX(); + groupModal->SpawnMouseY = _Pointer->getY(); + } + } + else + { + // default for group not modal. Backward compatibility + mwi.ModalExitClickOut = false; + mwi.ModalExitClickL = false; + mwi.ModalExitClickR = false; + mwi.ModalExitKeyPushed = false; + } + + _ModalStack.push_back(mwi); + + // update coords and activate the modal + mwi.ModalWindow->invalidateCoords(); + mwi.ModalWindow->setActive(true); + setTopWindow(mwi.ModalWindow); } + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::pushModalWindow(CCtrlBase *ctrlLaunchingModal, const std::string &groupName) + { + CInterfaceGroup *group= dynamic_cast( getElementFromId(groupName) ); + if(group) + { + // enable the modal + enableModalWindow(ctrlLaunchingModal, group); + } + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::popModalWindow() + { if (!_ModalStack.empty()) { - if(_ModalStack.back().ModalWindow) + SModalWndInfo winInfo = _ModalStack.back(); + _ModalStack.pop_back(); // must pop back as early as possible because 'setActive' may trigger another 'popModalWindow', leading to a crash + if(winInfo.ModalWindow) { - _ModalStack.back().ModalWindow->setActive(true); - setTopWindow(_ModalStack.back().ModalWindow); + setBackWindow(winInfo.ModalWindow); + winInfo.ModalWindow->setActive(false); } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::popModalWindowCategory(const std::string &category) -{ - for(;;) - { - if (_ModalStack.empty()) break; - if (!_ModalStack.back().ModalWindow) break; - CGroupModal *gm = dynamic_cast((CInterfaceGroup*)(_ModalStack.back().ModalWindow)); - if (gm && gm->Category == category) - { - _ModalStack.back().ModalWindow->setActive(false); - _ModalStack.pop_back(); - } - else - { - break; - } - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CWidgetManager::getWindowUnder (sint32 x, sint32 y) -{ - H_AUTO (RZ_Interface_Window_Under ) - - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + if (!_ModalStack.empty()) { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) + if(_ModalStack.back().ModalWindow) { - CInterfaceGroup *pIG = *itw; - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->isWindowUnder (x, y)) - return pIG; - } + _ModalStack.back().ModalWindow->setActive(true); + setTopWindow(_ModalStack.back().ModalWindow); } } } } - return NULL; -} -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup* CWidgetManager::getGroupUnder (sint32 x, sint32 y) -{ - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::popModalWindowCategory(const std::string &category) { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) + for(;;) { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + if (_ModalStack.empty()) break; + if (!_ModalStack.back().ModalWindow) break; + CGroupModal *gm = dynamic_cast((CInterfaceGroup*)(_ModalStack.back().ModalWindow)); + if (gm && gm->Category == category) { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - if (pIG->getActive() && pIG->getUseCursor()) - { - CInterfaceGroup *pIGunder = pIG->getGroupUnder (x ,y); - if (pIGunder != NULL) - return pIGunder; - } - } + _ModalStack.back().ModalWindow->setActive(false); + _ModalStack.pop_back(); + } + else + { + break; } } } - return NULL; -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::getViewsUnder (sint32 x, sint32 y, std::vector &vVB) -{ - vVB.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CWidgetManager::getWindowUnder (sint32 x, sint32 y) { - SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) + H_AUTO (RZ_Interface_Window_Under ) + + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (pIG->getActive() && pIG->getUseCursor()) + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) { - if (pIG->getViewsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vVB)) - return ; - } - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::getCtrlsUnder (sint32 x, sint32 y, std::vector &vICL) -{ - vICL.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) - { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || CWidgetManager::getInstance()->getModal().ModalExitClickOut) - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->getCtrlsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vICL)) - return; - } - } - } - } - } -} - - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::getGroupsUnder (sint32 x, sint32 y, std::vector &vIGL) -{ - vIGL.clear (); - - // No Op if screen minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - uint32 sw, sh; - CViewRenderer::getInstance()->getScreenSize(sw, sh); - for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) - { - CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; - if (rMG.Group->getActive()) - { - for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) - { - const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; - std::list::const_reverse_iterator itw; - for (itw = rList.rbegin(); itw != rList.rend(); itw++) - { - CInterfaceGroup *pIG = *itw; - - // Accecpt if not modal clip - if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || - CWidgetManager::getInstance()->getModal().ModalExitClickOut) - if (pIG->getActive() && pIG->getUseCursor()) - { - if (pIG->isIn(x, y)) + CInterfaceGroup *pIG = *itw; + if (pIG->getActive() && pIG->getUseCursor()) { - vIGL.push_back(pIG); - pIG->getGroupsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vIGL); - return; + if (pIG->isWindowUnder (x, y)) + return pIG; + } + } + } + } + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup* CWidgetManager::getGroupUnder (sint32 x, sint32 y) + { + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + if (pIG->getActive() && pIG->getUseCursor()) + { + CInterfaceGroup *pIGunder = pIG->getGroupUnder (x ,y); + if (pIGunder != NULL) + return pIGunder; + } + } + } + } + } + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::getViewsUnder (sint32 x, sint32 y, std::vector &vVB) + { + vVB.clear (); + + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0; nPriority--) + { + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) + { + CInterfaceGroup *pIG = *itw; + + // Accecpt if not modal clip + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->getViewsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vVB)) + return ; } } } } } } -} - -// *************************************************************************** -void CWidgetManager::removeRefOnView( CViewBase *viewBase ) -{ - uint i; - for (i=0; i<_ViewsUnderPointer.size(); i++) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::getCtrlsUnder (sint32 x, sint32 y, std::vector &vICL) { - if (_ViewsUnderPointer[i] == viewBase) - { - _ViewsUnderPointer.erase (_ViewsUnderPointer.begin()+i); - i--; - } - } -} + vICL.clear (); -// *************************************************************************** -void CWidgetManager::removeRefOnCtrl(CCtrlBase *ctrlBase) -{ - if ( getCurContextHelp() == ctrlBase) - setCurContextHelp( NULL ); - if (getCapturePointerLeft() == ctrlBase) - setCapturePointerLeft(NULL); - if (getCapturePointerRight() == ctrlBase) - setCapturePointerRight (NULL); - if (getCaptureKeyboard() == ctrlBase) - setCaptureKeyboard(NULL); - if (getOldCaptureKeyboard() == ctrlBase) - setOldCaptureKeyboard(NULL); - if (getDefaultCaptureKeyboard() == ctrlBase) - setDefaultCaptureKeyboard(NULL); - uint i; - for (i=0; i<_CtrlsUnderPointer.size(); i++) - { - if (_CtrlsUnderPointer[i] == ctrlBase) - { - _CtrlsUnderPointer.erase (_CtrlsUnderPointer.begin()+i); - i--; - } - } + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; - // Unregister from ClockMsgTargets - unregisterClockMsgTarget(ctrlBase); -} - - -// *************************************************************************** -void CWidgetManager::removeRefOnGroup (CInterfaceGroup *group) -{ - uint i; - for (i=0; i<_GroupsUnderPointer.size(); i++) - { - if (_GroupsUnderPointer[i] == group) - { - _GroupsUnderPointer.erase (_GroupsUnderPointer.begin()+i); - i--; - } - } -} - - -void CWidgetManager::reset() -{ - setCurContextHelp( NULL ); - - _ViewsUnderPointer.clear(); - _CtrlsUnderPointer.clear(); - _GroupsUnderPointer.clear(); - - _CaptureKeyboard = NULL; - _OldCaptureKeyboard = NULL; - setCapturePointerLeft(NULL); - setCapturePointerRight(NULL); - - resetColorProps(); -} - - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::checkCoords() -{ - H_AUTO ( RZ_Interface_validateCoords ) - - uint32 nMasterGroup; - - { - H_AUTO ( RZ_Interface_checkCoords ) - - // checkCoords all the windows - for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { - for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) { - std::list &rList = rMG.PrioritizedWindows[nPriority]; - std::list::const_iterator itw; - for (itw = rList.begin(); itw!= rList.end();) + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) { CInterfaceGroup *pIG = *itw; - itw++; // since checkCoords invalidate the iterator, be sure we move to the next one before - if (pIG->getActive()) - pIG->checkCoords (); + + // Accecpt if not modal clip + if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || CWidgetManager::getInstance()->getModal().ModalExitClickOut) + if (pIG->getActive() && pIG->getUseCursor()) + { + if (pIG->getCtrlsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vICL)) + return; + } } } } } } - bool bRecomputeCtrlUnderPtr = false; - { - H_AUTO ( RZ_Interface_updateCoords ) - // updateCoords all the needed windows - for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::getGroupsUnder (sint32 x, sint32 y, std::vector &vIGL) + { + vIGL.clear (); + + // No Op if screen minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + uint32 sw, sh; + CViewRenderer::getInstance()->getScreenSize(sw, sh); + for (uint32 nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) { CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; if (rMG.Group->getActive()) { - for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + for (uint8 nPriority = WIN_PRIORITY_MAX; nPriority > 0 ; nPriority--) { - std::list &rList = rMG.PrioritizedWindows[nPriority]; - std::list::const_iterator itw; - for (itw = rList.begin(); itw!= rList.end(); itw++) + const std::list &rList = rMG.PrioritizedWindows[nPriority-1]; + std::list::const_reverse_iterator itw; + for (itw = rList.rbegin(); itw != rList.rend(); itw++) { CInterfaceGroup *pIG = *itw; - bool updateCoordCalled= false; - // updateCoords the window only if the master group is his parent and if need it - // do it until updateCoords() no more invalidate coordinates!! - while (pIG->getParent()==rMG.Group && (pIG->getInvalidCoords()>0)) + + // Accecpt if not modal clip + if (!CWidgetManager::getInstance()->hasModal() || CWidgetManager::getInstance()->getModal().ModalWindow == pIG || + CWidgetManager::getInstance()->getModal().ModalExitClickOut) + if (pIG->getActive() && pIG->getUseCursor()) { - bRecomputeCtrlUnderPtr = true; - // Update as many pass wanted (3 time for complex resizing, 1 for scroll for example) - uint numPass= pIG->getInvalidCoords(); - // reset before updateCoords - pIG->resetInvalidCoords(); - for(uint i=0;iisIn(x, y)) { - pIG->updateCoords (); + vIGL.push_back(pIG); + pIG->getGroupsUnder (x, y, 0, 0, (sint32) sw, (sint32) sh, vIGL); + return; } - updateCoordCalled= true; } - // If the group need to update pos each frame (eg: CGroupInScene), - // and updateCoords not called - if(pIG->getParent()==rMG.Group && !updateCoordCalled && pIG->isNeedFrameUpdatePos()) + } + } + } + } + } + + + // *************************************************************************** + void CWidgetManager::removeRefOnView( CViewBase *viewBase ) + { + uint i; + for (i=0; i<_ViewsUnderPointer.size(); i++) + { + if (_ViewsUnderPointer[i] == viewBase) + { + _ViewsUnderPointer.erase (_ViewsUnderPointer.begin()+i); + i--; + } + } + } + + // *************************************************************************** + void CWidgetManager::removeRefOnCtrl(CCtrlBase *ctrlBase) + { + if ( getCurContextHelp() == ctrlBase) + setCurContextHelp( NULL ); + if (getCapturePointerLeft() == ctrlBase) + setCapturePointerLeft(NULL); + if (getCapturePointerRight() == ctrlBase) + setCapturePointerRight (NULL); + if (getCaptureKeyboard() == ctrlBase) + setCaptureKeyboard(NULL); + if (getOldCaptureKeyboard() == ctrlBase) + setOldCaptureKeyboard(NULL); + if (getDefaultCaptureKeyboard() == ctrlBase) + setDefaultCaptureKeyboard(NULL); + uint i; + for (i=0; i<_CtrlsUnderPointer.size(); i++) + { + if (_CtrlsUnderPointer[i] == ctrlBase) + { + _CtrlsUnderPointer.erase (_CtrlsUnderPointer.begin()+i); + i--; + } + } + + // Unregister from ClockMsgTargets + unregisterClockMsgTarget(ctrlBase); + } + + + // *************************************************************************** + void CWidgetManager::removeRefOnGroup (CInterfaceGroup *group) + { + uint i; + for (i=0; i<_GroupsUnderPointer.size(); i++) + { + if (_GroupsUnderPointer[i] == group) + { + _GroupsUnderPointer.erase (_GroupsUnderPointer.begin()+i); + i--; + } + } + } + + + void CWidgetManager::reset() + { + setCurContextHelp( NULL ); + + _ViewsUnderPointer.clear(); + _CtrlsUnderPointer.clear(); + _GroupsUnderPointer.clear(); + + _CaptureKeyboard = NULL; + _OldCaptureKeyboard = NULL; + setCapturePointerLeft(NULL); + setCapturePointerRight(NULL); + + resetColorProps(); + } + + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::checkCoords() + { + H_AUTO ( RZ_Interface_validateCoords ) + + uint32 nMasterGroup; + + { + H_AUTO ( RZ_Interface_checkCoords ) + + // checkCoords all the windows + for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + { + std::list &rList = rMG.PrioritizedWindows[nPriority]; + std::list::const_iterator itw; + for (itw = rList.begin(); itw!= rList.end();) { - // This Group will compute the delta to apply. - pIG->onFrameUpdateWindowPos(0,0); + CInterfaceGroup *pIG = *itw; + itw++; // since checkCoords invalidate the iterator, be sure we move to the next one before + if (pIG->getActive()) + pIG->checkCoords (); } } } } } - if ( CWidgetManager::getInstance()->getPointer() != NULL) - CWidgetManager::getInstance()->getPointer()->updateCoords(); - } - - - - if (bRecomputeCtrlUnderPtr) - { - H_AUTO ( RZ_Interface_RecomputeCtrlUnderPtr ) - if ( CWidgetManager::getInstance()->getPointer() != NULL ) + bool bRecomputeCtrlUnderPtr = false; { - sint32 mx = _Pointer->getX(); - sint32 my = _Pointer->getY(); - getViewsUnder (mx, my, _ViewsUnderPointer); - getCtrlsUnder (mx, my, _CtrlsUnderPointer); - getGroupsUnder (mx, my, _GroupsUnderPointer); - CInterfaceGroup *ptr = getWindowUnder (mx, my); - _WindowUnder = ptr; - } - } -} + H_AUTO ( RZ_Interface_updateCoords ) -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::movePointer (sint32 dx, sint32 dy) -{ - if (!_Pointer) - return; + // updateCoords all the needed windows + for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) + { + CWidgetManager::SMasterGroup &rMG = _MasterGroups[nMasterGroup]; + if (rMG.Group->getActive()) + { + for (uint8 nPriority = 0; nPriority < WIN_PRIORITY_MAX; nPriority++) + { + std::list &rList = rMG.PrioritizedWindows[nPriority]; + std::list::const_iterator itw; + for (itw = rList.begin(); itw!= rList.end(); itw++) + { + CInterfaceGroup *pIG = *itw; + bool updateCoordCalled= false; + // updateCoords the window only if the master group is his parent and if need it + // do it until updateCoords() no more invalidate coordinates!! + while (pIG->getParent()==rMG.Group && (pIG->getInvalidCoords()>0)) + { + bRecomputeCtrlUnderPtr = true; + // Update as many pass wanted (3 time for complex resizing, 1 for scroll for example) + uint numPass= pIG->getInvalidCoords(); + // reset before updateCoords + pIG->resetInvalidCoords(); + for(uint i=0;iupdateCoords (); + } + updateCoordCalled= true; + } + // If the group need to update pos each frame (eg: CGroupInScene), + // and updateCoords not called + if(pIG->getParent()==rMG.Group && !updateCoordCalled && pIG->isNeedFrameUpdatePos()) + { + // This Group will compute the delta to apply. + pIG->onFrameUpdateWindowPos(0,0); + } + } + } + } + } - uint32 nScrW, nScrH; - sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; - - CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); - _Pointer->getPointerPos (oldpx, oldpy); - - olddisppx = oldpx; - olddisppy = oldpy; - - newpx = oldpx + dx; - newpy = oldpy + dy; - - if (newpx < 0) newpx = 0; - if (newpy < 0) newpy = 0; - if (newpx > (sint32)nScrW) newpx = nScrW; - if (newpy > (sint32)nScrH) newpy = nScrH; - dx = newpx - oldpx; - dy = newpy - oldpy; - - disppx = newpx; - disppy = newpy; - - _Pointer->setPointerPos (newpx, newpy); - _Pointer->setPointerDispPos (disppx, disppy); - - // must get back coordinates because of snapping - sint32 mx = _Pointer->getX(); - sint32 my = _Pointer->getY(); - getViewsUnder (mx, my, _ViewsUnderPointer); - getCtrlsUnder (mx, my, _CtrlsUnderPointer); - getGroupsUnder (mx, my, _GroupsUnderPointer); -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::movePointerAbs(sint32 px, sint32 py) -{ - if(!CWidgetManager::getInstance()->getPointer()) - return; - - uint32 nScrW, nScrH; - CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); - NLMISC::clamp(px, 0, (sint32) nScrW); - NLMISC::clamp(py, 0, (sint32) nScrH); - // - _Pointer->setPointerPos (px, py); - _Pointer->setPointerDispPos (px, py); - // - getViewsUnder (px, py, _ViewsUnderPointer); - getCtrlsUnder (px, py, _CtrlsUnderPointer); - getGroupsUnder (px, py, _GroupsUnderPointer); -} - -// *************************************************************************** -void CWidgetManager::setCapturePointerLeft(CCtrlBase *c) -{ - // additionally, abort any dragging - if( CCtrlDraggable::getDraggedSheet() != NULL ) - CCtrlDraggable::getDraggedSheet()->abortDragging(); - - _CapturePointerLeft = c; - notifyElementCaptured(c); -} - -// *************************************************************************** -void CWidgetManager::setCapturePointerRight(CCtrlBase *c) -{ - _CapturePointerRight = c; - notifyElementCaptured(c); -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) -{ - CGroupEditBoxBase *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); - CGroupEditBoxBase *newEb= dynamic_cast(c); - - if (_CaptureKeyboard && _CaptureKeyboard != c) - { - _CaptureKeyboard->onKeyboardCaptureLost(); - } - // If the old capturedKeyboard is an editBox and allow recoverFocusOnEnter - if ( oldEb && oldEb->getRecoverFocusOnEnter() ) - { - _OldCaptureKeyboard = _CaptureKeyboard; - } - if ( newEb ) - { - CGroupEditBoxBase::disableSelection(); - - if (!newEb->getAHOnFocus().empty()) - { - CAHManager::getInstance()->runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); + if ( CWidgetManager::getInstance()->getPointer() != NULL) + CWidgetManager::getInstance()->getPointer()->updateCoords(); } - } - _CaptureKeyboard = c; - notifyElementCaptured(c); -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::resetCaptureKeyboard() -{ - CCtrlBase *captureKeyboard = _CaptureKeyboard; - _OldCaptureKeyboard = NULL; - _CaptureKeyboard = NULL; - if (captureKeyboard) - { - captureKeyboard->onKeyboardCaptureLost(); - } -} -// *************************************************************************** -void CWidgetManager::registerClockMsgTarget(CCtrlBase *vb) -{ - if (!vb) return; - if (isClockMsgTarget(vb)) - { - nlwarning(" Element %s is already registered", vb->getId().c_str()); - return; - } - _ClockMsgTargets.push_back(vb); -} - -// *************************************************************************** -void CWidgetManager::unregisterClockMsgTarget(CCtrlBase *vb) -{ - if (!vb) return; - std::vector::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); - if (it != _ClockMsgTargets.end()) - { - _ClockMsgTargets.erase(it); - } -} - -// *************************************************************************** -bool CWidgetManager::isClockMsgTarget(CCtrlBase *vb) const -{ - std::vector::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); - return it != _ClockMsgTargets.end(); -} - -void CWidgetManager::sendClockTickEvent() -{ - NLGUI::CEventDescriptorSystem clockTick; - clockTick.setEventTypeExtended(NLGUI::CEventDescriptorSystem::clocktick); - - if (_CapturePointerLeft) - { - _CapturePointerLeft->handleEvent(clockTick); - } - if (_CapturePointerRight) - { - _CapturePointerRight->handleEvent(clockTick); - } - - // and send clock tick msg to ctrl that are registered - std::vector clockMsgTarget = _ClockMsgTargets; - for(std::vector::iterator it = clockMsgTarget.begin(); it != clockMsgTarget.end(); ++it) - { - (*it)->handleEvent(clockTick); - } -} - -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::notifyElementCaptured(CCtrlBase *c) -{ - std::set seen; - CCtrlBase *curr = c; - while (curr) - { - seen.insert(curr); - curr->elementCaptured(c); - curr = curr->getParent(); - } - // also warn the ctrl under the pointer - for (uint i = 0; i < (uint) _CtrlsUnderPointer.size(); ++i) - { - if (!seen.count(_CtrlsUnderPointer[i])) + if (bRecomputeCtrlUnderPtr) { - _CtrlsUnderPointer[i]->elementCaptured(c); + H_AUTO ( RZ_Interface_RecomputeCtrlUnderPtr ) + if ( CWidgetManager::getInstance()->getPointer() != NULL ) + { + sint32 mx = _Pointer->getX(); + sint32 my = _Pointer->getY(); + getViewsUnder (mx, my, _ViewsUnderPointer); + getCtrlsUnder (mx, my, _CtrlsUnderPointer); + getGroupsUnder (mx, my, _GroupsUnderPointer); + CInterfaceGroup *ptr = getWindowUnder (mx, my); + _WindowUnder = ptr; + } } } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::makeWindow(CInterfaceGroup *group) -{ - if(!group) - return; - - uint32 i = 0; - for (i = 0; i < _MasterGroups.size(); ++i) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::movePointer (sint32 dx, sint32 dy) { - if (_MasterGroups[i].Group == group->getParent()) - break; + if (!_Pointer) + return; + + uint32 nScrW, nScrH; + sint32 oldpx, oldpy, newpx, newpy, disppx, disppy, olddisppx, olddisppy; + + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); + _Pointer->getPointerPos (oldpx, oldpy); + + olddisppx = oldpx; + olddisppy = oldpy; + + newpx = oldpx + dx; + newpy = oldpy + dy; + + if (newpx < 0) newpx = 0; + if (newpy < 0) newpy = 0; + if (newpx > (sint32)nScrW) newpx = nScrW; + if (newpy > (sint32)nScrH) newpy = nScrH; + dx = newpx - oldpx; + dy = newpy - oldpy; + + disppx = newpx; + disppy = newpy; + + _Pointer->setPointerPos (newpx, newpy); + _Pointer->setPointerDispPos (disppx, disppy); + + // must get back coordinates because of snapping + sint32 mx = _Pointer->getX(); + sint32 my = _Pointer->getY(); + getViewsUnder (mx, my, _ViewsUnderPointer); + getCtrlsUnder (mx, my, _CtrlsUnderPointer); + getGroupsUnder (mx, my, _GroupsUnderPointer); } - if (i == _MasterGroups.size()) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::movePointerAbs(sint32 px, sint32 py) { - std::string stmp = std::string("not found master group for window: ")+group->getId(); - nlwarning (stmp.c_str()); - return; + if(!CWidgetManager::getInstance()->getPointer()) + return; + + uint32 nScrW, nScrH; + CViewRenderer::getInstance()->getScreenSize (nScrW, nScrH); + NLMISC::clamp(px, 0, (sint32) nScrW); + NLMISC::clamp(py, 0, (sint32) nScrH); + // + _Pointer->setPointerPos (px, py); + _Pointer->setPointerDispPos (px, py); + // + getViewsUnder (px, py, _ViewsUnderPointer); + getCtrlsUnder (px, py, _CtrlsUnderPointer); + getGroupsUnder (px, py, _GroupsUnderPointer); } - else + + // *************************************************************************** + void CWidgetManager::setCapturePointerLeft(CCtrlBase *c) { - // check if group hasn't been inserted twice. - if (_MasterGroups[i].isWindowPresent(group)) + // additionally, abort any dragging + if( CCtrlDraggable::getDraggedSheet() != NULL ) + CCtrlDraggable::getDraggedSheet()->abortDragging(); + + _CapturePointerLeft = c; + notifyElementCaptured(c); + } + + // *************************************************************************** + void CWidgetManager::setCapturePointerRight(CCtrlBase *c) + { + _CapturePointerRight = c; + notifyElementCaptured(c); + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) + { + CGroupEditBoxBase *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); + CGroupEditBoxBase *newEb= dynamic_cast(c); + + if (_CaptureKeyboard && _CaptureKeyboard != c) { - nlwarning("Window inserted twice"); + _CaptureKeyboard->onKeyboardCaptureLost(); } - else + // If the old capturedKeyboard is an editBox and allow recoverFocusOnEnter + if ( oldEb && oldEb->getRecoverFocusOnEnter() ) { - _MasterGroups[i].addWindow(group,group->getPriority()); + _OldCaptureKeyboard = _CaptureKeyboard; + } + if ( newEb ) + { + CGroupEditBoxBase::disableSelection(); + + if (!newEb->getAHOnFocus().empty()) + { + CAHManager::getInstance()->runActionHandler(newEb->getAHOnFocus(), newEb, newEb->getAHOnFocusParams()); + } + + } + _CaptureKeyboard = c; + notifyElementCaptured(c); + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::resetCaptureKeyboard() + { + CCtrlBase *captureKeyboard = _CaptureKeyboard; + _OldCaptureKeyboard = NULL; + _CaptureKeyboard = NULL; + if (captureKeyboard) + { + captureKeyboard->onKeyboardCaptureLost(); } } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) -{ - if (!group) - return; - - uint32 i = 0; - for (i = 0; i < _MasterGroups.size(); ++i) + // *************************************************************************** + void CWidgetManager::registerClockMsgTarget(CCtrlBase *vb) { - if (_MasterGroups[i].Group == group->getParent()) - break; + if (!vb) return; + if (isClockMsgTarget(vb)) + { + nlwarning(" Element %s is already registered", vb->getId().c_str()); + return; + } + _ClockMsgTargets.push_back(vb); } - if (i == _MasterGroups.size()) + // *************************************************************************** + void CWidgetManager::unregisterClockMsgTarget(CCtrlBase *vb) { - if (!noWarning) + if (!vb) return; + std::vector::iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); + if (it != _ClockMsgTargets.end()) + { + _ClockMsgTargets.erase(it); + } + } + + // *************************************************************************** + bool CWidgetManager::isClockMsgTarget(CCtrlBase *vb) const + { + std::vector::const_iterator it = std::find(_ClockMsgTargets.begin(), _ClockMsgTargets.end(), vb); + return it != _ClockMsgTargets.end(); + } + + void CWidgetManager::sendClockTickEvent() + { + NLGUI::CEventDescriptorSystem clockTick; + clockTick.setEventTypeExtended(NLGUI::CEventDescriptorSystem::clocktick); + + if (_CapturePointerLeft) + { + _CapturePointerLeft->handleEvent(clockTick); + } + if (_CapturePointerRight) + { + _CapturePointerRight->handleEvent(clockTick); + } + + // and send clock tick msg to ctrl that are registered + std::vector clockMsgTarget = _ClockMsgTargets; + for(std::vector::iterator it = clockMsgTarget.begin(); it != clockMsgTarget.end(); ++it) + { + (*it)->handleEvent(clockTick); + } + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::notifyElementCaptured(CCtrlBase *c) + { + std::set seen; + CCtrlBase *curr = c; + while (curr) + { + seen.insert(curr); + curr->elementCaptured(c); + curr = curr->getParent(); + } + // also warn the ctrl under the pointer + for (uint i = 0; i < (uint) _CtrlsUnderPointer.size(); ++i) + { + if (!seen.count(_CtrlsUnderPointer[i])) + { + _CtrlsUnderPointer[i]->elementCaptured(c); + } + } + } + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::makeWindow(CInterfaceGroup *group) + { + if(!group) + return; + + uint32 i = 0; + for (i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group == group->getParent()) + break; + } + + if (i == _MasterGroups.size()) { std::string stmp = std::string("not found master group for window: ")+group->getId(); nlwarning (stmp.c_str()); - } - return; - } - else - { - // check if group hasn't been inserted twice. - if (!_MasterGroups[i].isWindowPresent(group)) - { - if (!noWarning) - nlwarning("Window not inserted in master group"); + return; } else { - _MasterGroups[i].delWindow(group); + // check if group hasn't been inserted twice. + if (_MasterGroups[i].isWindowPresent(group)) + { + nlwarning("Window inserted twice"); + } + else + { + _MasterGroups[i].addWindow(group,group->getPriority()); + } } } -} -// ------------------------------------------------------------------------------------------------ -void CWidgetManager::setGlobalColor (NLMISC::CRGBA col) -{ - if (!_RProp) + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::unMakeWindow(CInterfaceGroup *group, bool noWarning) { - _RProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); - _GProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); - _BProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); - _AProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); - } - _RProp ->setValue32 (col.R); - _GProp ->setValue32 (col.G); - _BProp ->setValue32 (col.B); - _AProp ->setValue32 (col.A); + if (!group) + return; - _GlobalColor = col; + uint32 i = 0; + for (i = 0; i < _MasterGroups.size(); ++i) + { + if (_MasterGroups[i].Group == group->getParent()) + break; + } - // set the global color for content (the same with modulated alpha) - _GlobalColorForContent = _GlobalColor; - _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColorForContent.A * (uint16) _ContentAlpha) >> 8); -} - -// *************************************************************************** -void CWidgetManager::setContentAlpha(uint8 alpha) -{ - _ContentAlpha = alpha; - // update alpha of global color - _GlobalColorForContent.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8);*/ -} - -void CWidgetManager::resetColorProps() -{ - _RProp = NULL; - _GProp = NULL; - _BProp = NULL; - _AProp = NULL; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceOptions* CWidgetManager::getOptions( const std::string &name ) -{ - std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > >::iterator it = _OptionsMap.find( name ); - if( it == _OptionsMap.end() ) - return NULL; - else - return it->second; -} - -void CWidgetManager::addOptions( std::string name, CInterfaceOptions *options ) -{ - _OptionsMap.insert( std::map< std::string, CInterfaceOptions* >::value_type( name, options ) ); -} - -void CWidgetManager::removeOptions( std::string name ) -{ - _OptionsMap.erase( name ); -} - -void CWidgetManager::removeAllOptions() -{ - _OptionsMap.clear(); -} - -CWidgetManager::CWidgetManager() -{ - _Pointer = NULL; - curContextHelp = NULL; - - resetColorProps(); - - _GlobalColor = NLMISC::CRGBA(255,255,255,255); - _GlobalColorForContent = _GlobalColor; - _ContentAlpha = 255; -} - -CWidgetManager::~CWidgetManager() -{ - for (uint32 i = 0; i < _MasterGroups.size(); ++i) - { - delete _MasterGroups[i].Group; + if (i == _MasterGroups.size()) + { + if (!noWarning) + { + std::string stmp = std::string("not found master group for window: ")+group->getId(); + nlwarning (stmp.c_str()); + } + return; + } + else + { + // check if group hasn't been inserted twice. + if (!_MasterGroups[i].isWindowPresent(group)) + { + if (!noWarning) + nlwarning("Window not inserted in master group"); + } + else + { + _MasterGroups[i].delWindow(group); + } + } } - _Pointer = NULL; - curContextHelp = NULL; -} \ No newline at end of file + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::setGlobalColor (NLMISC::CRGBA col) + { + if (!_RProp) + { + _RProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:R"); + _GProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:G"); + _BProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:B"); + _AProp = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:COLOR:A"); + } + _RProp ->setValue32 (col.R); + _GProp ->setValue32 (col.G); + _BProp ->setValue32 (col.B); + _AProp ->setValue32 (col.A); + + _GlobalColor = col; + + // set the global color for content (the same with modulated alpha) + _GlobalColorForContent = _GlobalColor; + _GlobalColorForContent.A = (uint8) (( (uint16) _GlobalColorForContent.A * (uint16) _ContentAlpha) >> 8); + } + + // *************************************************************************** + void CWidgetManager::setContentAlpha(uint8 alpha) + { + _ContentAlpha = alpha; + // update alpha of global color + _GlobalColorForContent.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContentAlpha) >> 8);*/ + } + + void CWidgetManager::resetColorProps() + { + _RProp = NULL; + _GProp = NULL; + _BProp = NULL; + _AProp = NULL; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceOptions* CWidgetManager::getOptions( const std::string &name ) + { + std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > >::iterator it = _OptionsMap.find( name ); + if( it == _OptionsMap.end() ) + return NULL; + else + return it->second; + } + + void CWidgetManager::addOptions( std::string name, CInterfaceOptions *options ) + { + _OptionsMap.insert( std::map< std::string, CInterfaceOptions* >::value_type( name, options ) ); + } + + void CWidgetManager::removeOptions( std::string name ) + { + _OptionsMap.erase( name ); + } + + void CWidgetManager::removeAllOptions() + { + _OptionsMap.clear(); + } + + CWidgetManager::CWidgetManager() + { + _Pointer = NULL; + curContextHelp = NULL; + + resetColorProps(); + + _GlobalColor = NLMISC::CRGBA(255,255,255,255); + _GlobalColorForContent = _GlobalColor; + _ContentAlpha = 255; + } + + CWidgetManager::~CWidgetManager() + { + for (uint32 i = 0; i < _MasterGroups.size(); ++i) + { + delete _MasterGroups[i].Group; + } + + _Pointer = NULL; + curContextHelp = NULL; + } + +} + diff --git a/code/ryzom/client/src/camera_recorder.cpp b/code/ryzom/client/src/camera_recorder.cpp index 68c0ddf4e..174fe84ed 100644 --- a/code/ryzom/client/src/camera_recorder.cpp +++ b/code/ryzom/client/src/camera_recorder.cpp @@ -29,6 +29,7 @@ using namespace NLMISC; using namespace NL3D; +using namespace NLGUI; // TODO nico : that stuff was coded in a hurry, but could be good to add it to NL3D with a better packaging later... diff --git a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp index 8f74e3076..95f63af0c 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp @@ -33,6 +33,8 @@ using namespace NL3D; #include "../user_entity.h" #include "../connection.h" +using namespace NLGUI; + //////////// // GLOBAL // //////////// diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.h b/code/ryzom/client/src/interface_v3/action_handler_misc.h index d0fabdcfc..5d6ff7910 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.h +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.h @@ -23,7 +23,10 @@ #include "nel/gui/action_handler.h" #include "interface_manager.h" -class CInterfaceGroup; +namespace NLGUI +{ + class CInterfaceGroup; +} // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.h b/code/ryzom/client/src/interface_v3/bot_chat_manager.h index e3dd73d79..3ecadca8c 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.h @@ -22,7 +22,11 @@ class CBotChatPage; class CPrerequisitInfos; -class CInterfaceGroup; + +namespace NLGUI +{ + class CInterfaceGroup; +} class IMissionPrereqInfosWaiter { diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.h b/code/ryzom/client/src/interface_v3/chat_text_manager.h index 1c9d6d0cf..1e6f2ad0e 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.h +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.h @@ -21,7 +21,11 @@ #include "nel/misc/rgba.h" -class CViewBase; +namespace NLGUI +{ + class CViewBase; +} + class ucstring; namespace NLMISC{ class CCDBNodeLeaf; @@ -46,7 +50,7 @@ public: * \param col the color of the text * \param justified Should be true for justified text (stretch spaces of line to fill the full width) */ - CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false); + NLGUI::CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false); // Singleton access static CChatTextManager &getInstance(); diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index 5daf24c36..8e5da91c2 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -24,10 +24,15 @@ #include "game_share/chat_group.h" + +namespace NLGUI +{ + class CCtrlBase; +} + class CChatWindow; class CGroupContainer; class CGroupEditBox; -class CCtrlBase; class CViewText; /** Interface to react to a chat box entry @@ -240,7 +245,7 @@ public: // Remove a chat window by its pointer void removeChatWindow(CChatWindow *cw); /// from a ctrl of a chat box that triggered a menu, or an event, retrieve the associated chat box - CChatWindow *getChatWindowFromCaller(CCtrlBase *caller); + CChatWindow *getChatWindowFromCaller(NLGUI::CCtrlBase *caller); // Singleton pattern applied to the chat window manager static CChatWindowManager &getInstance(); // try to rename a window diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h index deb96a691..3d1ea5ca7 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h +++ b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h @@ -22,7 +22,11 @@ class CDBCtrlSheet; -class IActionHandler; + +namespace NLGUI +{ + class IActionHandler; +} /** Infos about a selection group */ diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 7feafadbe..b473c29e3 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -107,10 +107,6 @@ #include "../npc_icon.h" #include "nel/gui/lua_helper.h" -namespace NLGUI -{ - extern void luaDebuggerMainLoop(); -} using namespace NLGUI; #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" @@ -128,9 +124,14 @@ using namespace NLGUI; using namespace NLMISC; +namespace NLGUI +{ + extern void luaDebuggerMainLoop(); + extern NLMISC::CStringMapper *_UIStringMapper; +} + extern CClientChatManager ChatMngr; extern CContinentManager ContinentMngr; -extern CStringMapper *_UIStringMapper; extern bool IsInRingSession; extern CEventsListener EventsListener; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 93b72c97e..4413c5bec 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -69,8 +69,12 @@ extern bool g_hidden; // #define AJM_DEBUG_TRACK_INTERFACE_GROUPS +namespace NLGUI +{ + class CInterfaceOptions; +} + class CGroupContainer; -class CInterfaceOptions; class CInterfaceAnim; class CGroupMenu; diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h index 2d830c1fb..14a623e28 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h @@ -20,6 +20,8 @@ #include "nel/gui/interface_options.h" +using namespace NLGUI; + // *************************************************************************** class COptionsLayer : public CInterfaceOptions { diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index b94ffaa70..0e74c503b 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -29,17 +29,20 @@ #include "nel/gui/widget_manager.h" using namespace NLGUI; -// *************************************************************************** -class CInterfaceElement; -class CInterfaceGroup; +namespace NLGUI +{ + class CInterfaceElement; + class CInterfaceGroup; + class CInterfaceOptions; + class CInterfaceLink; + class CCtrlBase; +} + class CGroupContainer; class CGroupList; -class CInterfaceOptions; class CInterfaceAnim; class CViewPointer; -class CInterfaceLink; class CBrickJob; -class CCtrlBase; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index 8b0e42771..817c927ae 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -21,7 +21,16 @@ #include "nel/misc/resource_ptr.h" -class CInterfaceElement *getInterfaceResource(const std::string &key); +namespace NLGUI +{ + class CInterfaceElement; + class CCtrlBase; + class CInterfaceGroup; +} + +using namespace NLGUI; + +CInterfaceElement *getInterfaceResource(const std::string &key); /** Interface element ptr * This pointer uses the NLMISC::CResourcePtr @@ -47,13 +56,12 @@ public: }; // Some pointers -typedef CInterfacePtr::TInterfacePtr CInterfaceElementPtr; -typedef CInterfacePtr::TInterfacePtr CInterfaceGroupPtr; +typedef CInterfacePtr::TInterfacePtr CInterfaceElementPtr; +typedef CInterfacePtr::TInterfacePtr CInterfaceGroupPtr; typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; typedef CInterfacePtr::TInterfacePtr CViewTextPtr; typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; -typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; -typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; +typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; typedef CInterfacePtr::TInterfacePtr CGroupContainerPtr; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index ebaa84225..274d07a56 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -24,7 +24,11 @@ #include "nel/gui/view_pointer_base.h" class CGroupContainer; -class CCtrlBase; + +namespace NLGUI +{ + class CCtrlBase; +} /** * class describing the pointer diff --git a/code/ryzom/client/src/r2/displayer_base.h b/code/ryzom/client/src/r2/displayer_base.h index 4d60a9f59..20ebdf87a 100644 --- a/code/ryzom/client/src/r2/displayer_base.h +++ b/code/ryzom/client/src/r2/displayer_base.h @@ -38,7 +38,7 @@ class CObjectTable; * - one for the ui (displaying instance in the object tree for example) * - one for the property sheet of the instance */ -class CDisplayerBase : public NLMISC::IClassable, public CReflectableRefPtrTarget +class CDisplayerBase : public NLMISC::IClassable, public NLGUI::CReflectableRefPtrTarget { public: typedef NLMISC::CSmartPtr TSmartPtr; From 7b745058a8783a4f84c90df5291a66b61256d702 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 9 Jun 2012 22:18:29 +0200 Subject: [PATCH 060/339] CHANGED: #1471 Moved back some more static methods from CLuaIHMRyzom to CLuaIHM, as CLuaIHM can now handle these too. --- code/nel/include/nel/gui/lua_ihm.h | 25 + code/nel/src/gui/lua_ihm.cpp | 640 +++++++++++++++++- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 629 ----------------- .../client/src/interface_v3/lua_ihm_ryzom.h | 25 - 4 files changed, 663 insertions(+), 656 deletions(-) diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h index c19460b87..96cce4a2a 100644 --- a/code/nel/include/nel/gui/lua_ihm.h +++ b/code/nel/include/nel/gui/lua_ihm.h @@ -159,6 +159,31 @@ namespace NLGUI ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static int luaMethodCall(lua_State *ls); + + static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none + static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none + static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none + static int setCaptureKeyboard(CLuaState &ls); + static int resetCaptureKeyboard(CLuaState &ls); + static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error) + static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none + static int getWindowSize(CLuaState &ls); + static int setTopWindow(CLuaState &ls); // set the top window + static int getTextureSize(CLuaState &ls); + static int disableModalWindow(CLuaState &ls); + static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none + static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none + static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none) + static bool fileExists(const std::string &fileName); + static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct + static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString + static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString + static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false + static int isUCString(CLuaState &ls); + static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ... + static int concatString(CLuaState &ls); // speedup concatenation of several strings + static int tableToString(CLuaState &ls); // concat element of a table to build a string + static int getPathContent(CLuaState &ls); }; } diff --git a/code/nel/src/gui/lua_ihm.cpp b/code/nel/src/gui/lua_ihm.cpp index 1194b48ec..5c3a8f5df 100644 --- a/code/nel/src/gui/lua_ihm.cpp +++ b/code/nel/src/gui/lua_ihm.cpp @@ -71,10 +71,15 @@ #include "nel/misc/time_nl.h" #include "nel/misc/path.h" #include "nel/misc/sstring.h" +#include "nel/misc/command.h" #include "nel/gui/lua_object.h" #include "nel/misc/polygon.h" #include "nel/gui/lua_manager.h" - +#include "nel/gui/widget_manager.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/interface_expr.h" +#include "nel/misc/debug.h" // *************************************************************************** /* @@ -757,6 +762,614 @@ namespace NLGUI return numResults; } + + + // *************************************************************************** + int CLuaIHM::setOnDraw(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_setOnDraw) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "script". + // return: none + CLuaIHM::checkArgCount(ls, "setOnDraw", 2); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string script; + ls.toString(2, script); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("setOnDraw(): '%s' is not a group", pIE->getId().c_str()); + // Set the script to be executed at each draw + group->setLuaScriptOnDraw(script); + + return 0; + } + + // *************************************************************************** + int CLuaIHM::addOnDbChange(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_addOnDbChange) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "dblist", "script". + // return: none + CLuaIHM::checkArgCount(ls, "addOnDbChange", 3); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); + CLuaIHM::check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string dbList, script; + ls.toString(2, dbList); + ls.toString(3, script); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("addOnDbChange(): '%s' is not a group", pIE->getId().c_str()); + // Set the script to be executed when the given DB change + group->addLuaScriptOnDBChange(dbList, script); + + return 0; + } + + + // *************************************************************************** + int CLuaIHM::removeOnDbChange(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_removeOnDbChange) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceGroup*, "dbList" + // return: none + CLuaIHM::checkArgCount(ls, "removeOnDbChange", 2); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); + CLuaIHM::check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string dbList; + ls.toString(2, dbList); + + // must be a group + CInterfaceGroup *group= dynamic_cast(pIE); + if(!group) + throw ELuaIHMException("removeOnDbChange(): '%s' is not a group", pIE->getId().c_str()); + // Remove the script to be executed when the given DB change + group->removeLuaScriptOnDBChange(dbList); + + return 0; + } + + + + // *************************************************************************** + int CLuaIHM::setCaptureKeyboard(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) + const char *funcName = "setCaptureKeyboard"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); + CCtrlBase *ctrl = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); + if (!ctrl) + { + CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); + } + CWidgetManager::getInstance()->setCaptureKeyboard(ctrl); + return 0; + } + + // *************************************************************************** + int CLuaIHM::resetCaptureKeyboard(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_resetCaptureKeyboard) + const char *funcName = "resetCaptureKeyboard"; + CLuaIHM::checkArgCount(ls, funcName, 0); + CWidgetManager::getInstance()->resetCaptureKeyboard(); + return 0; + } + + // *************************************************************************** + int CLuaIHM::getUIId(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_getUIId) + CLuaStackChecker lsc(&ls, 1); + + // params: CInterfaceElement* + // return: "ui:interface:...". (empty if error) + CLuaIHM::checkArgCount(ls, "getUIId", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + + // convert to id + if(pIE) + ls.push(pIE->getId()); + else + ls.push(""); + + return 1; + } + + + + // *************************************************************************** + int CLuaIHM::runAH(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_runAH) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement *, "ah", "params". + // return: none + CLuaIHM::checkArgCount(ls, "runAH", 3); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); + CLuaIHM::check(ls, ls.isString(2), "runAH() requires a string in param 2"); + CLuaIHM::check(ls, ls.isString(3), "runAH() requires a string in param 3"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + std::string ah, params; + ls.toString(2, ah); + ls.toString(3, params); + + // run AH + // The element must be ctrl (or NULL) + CCtrlBase *ctrl= NULL; + if(pIE) + { + ctrl= dynamic_cast(pIE); + if(!ctrl) + throw ELuaIHMException("runAH(): '%s' is not a ctrl", pIE->getId().c_str()); + } + CAHManager::getInstance()->runActionHandler(ah, ctrl, params); + + return 0; + } + + // *************************************************************************** + int CLuaIHM::getWindowSize(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_getWindowSize) + CLuaIHM::checkArgCount(ls, "getWindowSize", 0); + uint32 w, h; + CViewRenderer::getInstance()->getScreenSize(w, h); + ls.push((double) w); + ls.push((double) h); + return 2; + } + + // *************************************************************************** + int CLuaIHM::setTopWindow(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_setTopWindow) + const char *funcName = "setTopWindow"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CInterfaceGroup *wnd = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); + if (!wnd) + { + CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); + } + CWidgetManager::getInstance()->setTopWindow(wnd); + return 0; + } + + int CLuaIHM::getTextureSize(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_getTextureSize) + const char *funcName = "getTextureSize"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string textureName = ls.toString(1); + + CBitmap bitmap; + CIFile fs(CPath::lookup(textureName).c_str()); + bitmap.load(fs); + + ls.push((double) bitmap.getWidth()); + ls.push((double) bitmap.getHeight()); + + return 2; + } + + + + // *************************************************************************** + int CLuaIHM::disableModalWindow(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_disableModalWindow) + CLuaIHM::checkArgCount(ls, "disableModalWindow", 0); + CWidgetManager::getInstance()->disableModalWindow(); + return 0; + } + + // *************************************************************************** + int CLuaIHM::deleteUI(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_deleteUI) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement * + // return: none + CLuaIHM::checkArgCount(ls, "deleteUI", 1); + CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); + + // retrieve args + CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); + if(!pIE) + return 0; + + // has a parent? + CInterfaceGroup *parent= pIE->getParent(); + if(parent) + { + // correctly remove from parent + parent->delElement(pIE); + } + else + { + // just delete + delete pIE; + } + + return 0; + } + + // *************************************************************************** + int CLuaIHM::deleteReflectable(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_deleteReflectable) + CLuaStackChecker lsc(&ls, 0); + + // params: CInterfaceElement * + // return: none + CLuaIHM::checkArgCount(ls, "deleteReflectable", 1); + CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "deleteReflectable() requires a reflectable C++ object in param 1"); + + // retrieve args + CReflectableRefPtrTarget *pRPT= CLuaIHM::getReflectableOnStack(ls, 1); + if(!pRPT) + return 0; + + + CInterfaceElement *pIE = dynamic_cast(pRPT); + + if (pIE) + { + // has a parent? + CInterfaceGroup *parent= pIE->getParent(); + if(parent) + { + // correctly remove from parent + parent->delElement(pIE); + } + } + + // just delete + delete pIE; + + return 0; + } + + + int CLuaIHM::getCurrentWindowUnder(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_getCurrentWindowUnder) + CLuaStackChecker lsc(&ls, 1); + CInterfaceElement *pIE= CWidgetManager::getInstance()->getCurrentWindowUnder(); + if(!pIE) + { + ls.pushNil(); + nlerror("getCurrentWindowUnder(): No UICaller found. return Nil"); + } + else + { + CLuaIHM::pushUIOnStack(ls, pIE); + } + return 1; + } + + // *************************************************************************** + bool CLuaIHM::fileExists(const std::string &fileName) + { + //H_AUTO(Lua_CLuaIHM_fileExists) + return CPath::exists(fileName); + } + + // *************************************************************************** + int CLuaIHM::runExprAndPushResult(CLuaState &ls, const std::string &expr) + { + //H_AUTO(Lua_CLuaIHM_runExprAndPushResult) + // Execute expression + CInterfaceExprValue value; + if (CInterfaceExpr::eval(expr, value, NULL)) + { + switch(value.getType()) + { + case CInterfaceExprValue::Boolean: + ls.push(value.getBool()); + break; + case CInterfaceExprValue::Integer: + ls.push((double)value.getInteger()); + break; + case CInterfaceExprValue::Double: + ls.push(value.getDouble()); + break; + case CInterfaceExprValue::String: + { + ucstring ucstr= value.getUCString(); + // Yoyo: dynamically decide whether must return a string or a ucstring + bool mustUseUCString= false; + for (uint i = 0; i < ucstr.size (); i++) + { + if (ucstr[i] > 255) + { + mustUseUCString= true; + break; + } + } + // push a ucstring? + if(mustUseUCString) + { + #if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), ucstr); + #else + luabind::object obj(ls.getStatePointer(), ucstr); + obj.pushvalue(); + #endif + } + else + { + ls.push(ucstr.toString()); + } + break; + } + case CInterfaceExprValue::RGBA: + { + CRGBA color = value.getRGBA(); + #if LUABIND_VERSION > 600 + luabind::detail::push(ls.getStatePointer(), color); + #else + luabind::object obj(ls.getStatePointer(), color); + obj.pushvalue(); + #endif + break; + } + break; + case CInterfaceExprValue::UserType: // Yoyo: don't care UserType... + default: + ls.pushNil(); + break; + } + } + else + ls.pushNil(); + + return 1; + } + + // *************************************************************************** + int CLuaIHM::runExpr(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_runExpr) + CLuaStackChecker lsc(&ls, 1); + + // params: "expr". + // return: any of: nil, bool, string, number, RGBA, UCString + CLuaIHM::checkArgCount(ls, "runExpr", 1); + CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); + + // retrieve args + std::string expr; + ls.toString(1, expr); + + // run expression and push result + return runExprAndPushResult(ls, expr); + } + + // *************************************************************************** + int CLuaIHM::runFct(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_runFct) + CLuaStackChecker lsc(&ls, 1); + + // params: "expr", param1, param2... + // return: any of: nil, bool, string, number, RGBA, UCString + CLuaIHM::checkArgMin(ls, "runFct", 1); + CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); + + // retrieve fct + std::string expr; + ls.toString(1, expr); + expr+= "("; + + // retrieve params + uint top= ls.getTop(); + for(uint i=2;i<=top;i++) + { + if(i>2) + expr+= ", "; + + // If it is a number + if(ls.type(i)==LUA_TNUMBER) + { + std::string paramValue; + ls.toString(i, paramValue); // nb: transformed to a string in the stack + expr+= paramValue; + } + // else suppose a string + else + { + // must enclose with "'" + std::string paramValue; + ls.toString(i, paramValue); + expr+= std::string("'") + paramValue + std::string("'") ; + } + } + + // end fct call + expr+= ")"; + + + // run expression and push result + return runExprAndPushResult(ls, expr); + } + + // *************************************************************************** + int CLuaIHM::runCommand(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_runCommand) + CLuaStackChecker lsc(&ls, 1); + if (ls.empty()) + { + nlwarning("'runCommand' : Command name expected"); + ls.push(false); + return 1; + } + const char *commandName = ls.toString(1); + if (!commandName) + { + nlwarning("'runCommand' : Bad command name"); + ls.push(false); + return 1; + } + if (!NLMISC::ICommand::LocalCommands || !NLMISC::ICommand::LocalCommands->count(ls.toString(1))) + { + nlwarning("'runCommand' : Command %s not found", ls.toString(1)); + ls.push(false); + return 1; + } + std::string rawCommandString = ls.toString(1); + NLMISC::ICommand *command = (*NLMISC::ICommand::LocalCommands)[ls.toString(1)]; + nlassert(command); + std::vector args(ls.getTop() - 1); + for(uint k = 2; k <= (uint) ls.getTop(); ++k) + { + if (ls.toString(k)) + { + args[k - 2] = ls.toString(k); + rawCommandString += " " + std::string(ls.toString(k)); + } + } + + ls.push(command->execute(rawCommandString, args, NLMISC::ErrorLog(), false, true)); + return 1; + } + + // *************************************************************************** + int CLuaIHM::isUCString(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_isUCString) + const char *funcName = "isUCString"; + CLuaIHM::checkArgCount(ls, funcName, 1); + ls.push(CLuaIHM::isUCStringOnStack(ls, 1)); + return 1; + } + + // *************************************************************************** + int CLuaIHM::concatUCString(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_concatUCString) + const char *funcName = "concatUCString"; + ucstring result; + for (uint k = 1; k <= (uint) ls.getTop(); ++k) + { + //nlwarning("arg %d = %s", k, ls.getTypename(ls.type(k))); + ucstring part; + if (ls.isString(k)) + { + part.fromUtf8(ls.toString(k)); + } + else + { + CLuaIHM::checkArgTypeUCString(ls, funcName, k); + nlverify(CLuaIHM::getUCStringOnStack(ls, k, part)); + } + result += part; + } + CLuaIHM::push(ls, result); + return 1; + } + + // *************************************************************************** + int CLuaIHM::concatString(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_concatUCString) + const char *funcName = "concatString"; + std::string result; + uint stackSize = ls.getTop(); + for (uint k = 1; k <= stackSize; ++k) + { + CLuaIHM::checkArgType(ls, funcName, k, LUA_TSTRING); + result += ls.toString(k); + } + ls.push(result); + return 1; + } + + // *************************************************************************** + int CLuaIHM::tableToString(CLuaState &ls) + { + const char *funcName = "tableToString"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TTABLE); + uint length = 0; + // compute size + ls.pushNil(); + while (ls.next(-2)) + { + ls.toString(-1); + length += (uint)ls.strlen(-1); + ls.pop(2); + } + std::string result; + result.resize(length); + char *dest = &result[0]; + // concatenate + ls.pushNil(); + while (ls.next(-2)) + { + uint length = (uint)ls.strlen(-1); + if (length) + { + memcpy(dest, ls.toString(-1), length); + } + dest += length; + ls.pop(2); + } + ls.push(result); + return 1; + } + + + int CLuaIHM::getPathContent(CLuaState &ls) + { + //H_AUTO(Lua_CLuaIHM_getPathContent) + const char *funcName = "getPathContent"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::vector files; + NLMISC::CPath::getPathContent(ls.toString(1), false, false, true, files); + ls.newTable(); + for(uint k = 0; k < files.size(); ++k) + { + ls.push((double) k); + ls.push(files[k]); + ls.setTable(-3); + } + return 1; + } + + + + // *************************************************************************** void CLuaIHM::luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property) { @@ -972,6 +1585,28 @@ namespace NLGUI // *** Register Functions + ls.registerFunc("setOnDraw", setOnDraw); + ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); + ls.registerFunc("resetCaptureKeyboard", resetCaptureKeyboard); + ls.registerFunc("setTopWindow", setTopWindow); + ls.registerFunc("addOnDbChange", addOnDbChange); + ls.registerFunc("removeOnDbChange", removeOnDbChange); + ls.registerFunc("getUIId", getUIId); + ls.registerFunc("runAH", runAH); + ls.registerFunc("deleteUI", deleteUI); + ls.registerFunc("deleteReflectable", deleteReflectable); + ls.registerFunc("getWindowSize", getWindowSize); + ls.registerFunc("getTextureSize", getTextureSize); + ls.registerFunc("disableModalWindow", disableModalWindow); + ls.registerFunc("isUCString", isUCString); + ls.registerFunc("concatUCString", concatUCString); + ls.registerFunc("concatString", concatString); + ls.registerFunc("tableToString", tableToString); + ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder); + ls.registerFunc("runExpr", runExpr); + ls.registerFunc("runFct", runFct); + ls.registerFunc("runCommand", runCommand); + ls.registerFunc("getPathContent", getPathContent); // Through LUABind API lua_State *L= ls.getStatePointer(); @@ -990,7 +1625,8 @@ namespace NLGUI #endif luabind::def("fileLookup", CMiscFunctions::fileLookup), - luabind::def("shellExecute", CMiscFunctions::shellExecute) + luabind::def("shellExecute", CMiscFunctions::shellExecute), + LUABIND_FUNC(fileExists) ]; // inside i18n table diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 505bc1fd2..e1e73deed 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -362,55 +362,33 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) globals.setNil("__cfmt"); // remove temp metatable ls.registerFunc( "getUI", getUI ); - ls.registerFunc("setOnDraw", setOnDraw); - ls.registerFunc("setCaptureKeyboard", setCaptureKeyboard); - ls.registerFunc("resetCaptureKeyboard", resetCaptureKeyboard); ls.registerFunc("validMessageBox", validMessageBox); - ls.registerFunc("setTopWindow", setTopWindow); - ls.registerFunc("concatUCString", concatUCString); - ls.registerFunc("concatString", concatString); - ls.registerFunc("tableToString", tableToString); - ls.registerFunc("addOnDbChange", addOnDbChange); - ls.registerFunc("removeOnDbChange", removeOnDbChange); ls.registerFunc("getUICaller", getUICaller); - ls.registerFunc("getCurrentWindowUnder", getCurrentWindowUnder); ls.registerFunc("getUI", getUI); ls.registerFunc("getIndexInDB", getIndexInDB); - ls.registerFunc("getUIId", getUIId); ls.registerFunc("createGroupInstance", createGroupInstance); ls.registerFunc("createRootGroupInstance", createRootGroupInstance); ls.registerFunc("createUIElement", createUIElement); ls.registerFunc("launchContextMenuInGame", launchContextMenuInGame); ls.registerFunc("parseInterfaceFromString", parseInterfaceFromString); ls.registerFunc("updateAllLocalisedElements", updateAllLocalisedElements); - ls.registerFunc("runAH", runAH); - ls.registerFunc("runExpr", runExpr); - ls.registerFunc("runFct", runFct); - ls.registerFunc("runCommand", runCommand); ls.registerFunc("formatUI", formatUI); ls.registerFunc("formatDB", formatDB); - ls.registerFunc("deleteUI", deleteUI); - ls.registerFunc("deleteReflectable", deleteReflectable); ls.registerFunc("dumpUI", dumpUI); ls.registerFunc("setKeyboardContext", setKeyboardContext); ls.registerFunc("breakPoint", breakPoint); - ls.registerFunc("getWindowSize", getWindowSize); ls.registerFunc("setTextFormatTaged", setTextFormatTaged); ls.registerFunc("initEmotesMenu", initEmotesMenu); - ls.registerFunc("isUCString", isUCString); ls.registerFunc("hideAllWindows", hideAllWindows); ls.registerFunc("hideAllNonSavableWindows", hideAllNonSavableWindows); ls.registerFunc("getDesktopIndex", getDesktopIndex); ls.registerFunc("setLuaBreakPoint", setLuaBreakPoint); ls.registerFunc("getMainPageURL", getMainPageURL); ls.registerFunc("getCharSlot", getCharSlot); - ls.registerFunc("getPathContent", getPathContent); ls.registerFunc("getServerSeason", getServerSeason); ls.registerFunc("computeCurrSeason", computeCurrSeason); ls.registerFunc("getAutoSeason", getAutoSeason); - ls.registerFunc("getTextureSize", getTextureSize); ls.registerFunc("enableModalWindow", enableModalWindow); - ls.registerFunc("disableModalWindow", disableModalWindow); ls.registerFunc("getPlayerPos", getPlayerPos); ls.registerFunc("getPlayerFront", getPlayerFront); ls.registerFunc("getPlayerDirection", getPlayerDirection); @@ -497,7 +475,6 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls ) LUABIND_FUNC(getFirstTribeFameIndex), LUABIND_FUNC(getNbTribeFameIndex), LUABIND_FUNC(getClientCfg), - LUABIND_FUNC(fileExists), LUABIND_FUNC(sendMsgToServer), LUABIND_FUNC(sendMsgToServerPvpTag), LUABIND_FUNC(isGuildQuitAvailable), @@ -611,260 +588,6 @@ int CLuaIHMRyzom::getUI(CLuaState &ls) return 1; } -// *************************************************************************** -int CLuaIHMRyzom::setCaptureKeyboard(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setCaptureKeyboard) - const char *funcName = "setCaptureKeyboard"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); - CCtrlBase *ctrl = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); - if (!ctrl) - { - CLuaIHM::fails(ls, "%s waits a ui control as arg 1", funcName); - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - CWidgetManager::getInstance()->setCaptureKeyboard(ctrl); - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::resetCaptureKeyboard(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_resetCaptureKeyboard) - const char *funcName = "resetCaptureKeyboard"; - CLuaIHM::checkArgCount(ls, funcName, 0); - CInterfaceManager *im = CInterfaceManager::getInstance(); - CWidgetManager::getInstance()->resetCaptureKeyboard(); - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::setOnDraw(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setOnDraw) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "script". - // return: none - CLuaIHM::checkArgCount(ls, "setOnDraw", 2); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setOnDraw() requires a UI object in param 1"); - CLuaIHM::check(ls, ls.isString(2), "setOnDraw() requires a string in param 2"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - std::string script; - ls.toString(2, script); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("setOnDraw(): '%s' is not a group", pIE->getId().c_str()); - // Set the script to be executed at each draw - group->setLuaScriptOnDraw(script); - - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::addOnDbChange(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_addOnDbChange) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "dblist", "script". - // return: none - CLuaIHM::checkArgCount(ls, "addOnDbChange", 3); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "addOnDbChange() requires a UI object in param 1"); - CLuaIHM::check(ls, ls.isString(2), "addOnDbChange() requires a string in param 2"); - CLuaIHM::check(ls, ls.isString(3), "addOnDbChange() requires a string in param 3"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - std::string dbList, script; - ls.toString(2, dbList); - ls.toString(3, script); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("addOnDbChange(): '%s' is not a group", pIE->getId().c_str()); - // Set the script to be executed when the given DB change - group->addLuaScriptOnDBChange(dbList, script); - - return 0; -} - - -// *************************************************************************** -int CLuaIHMRyzom::removeOnDbChange(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_removeOnDbChange) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceGroup*, "dbList" - // return: none - CLuaIHM::checkArgCount(ls, "removeOnDbChange", 2); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "removeOnDbChange() requires a UI object in param 1"); - CLuaIHM::check(ls, ls.isString(2), "removeOnDbChange() requires a string in param 2"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - std::string dbList; - ls.toString(2, dbList); - - // must be a group - CInterfaceGroup *group= dynamic_cast(pIE); - if(!group) - throw ELuaIHMException("removeOnDbChange(): '%s' is not a group", pIE->getId().c_str()); - // Remove the script to be executed when the given DB change - group->removeLuaScriptOnDBChange(dbList); - - return 0; -} - - -// *************************************************************************** -int CLuaIHMRyzom::runAH(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runAH) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement *, "ah", "params". - // return: none - CLuaIHM::checkArgCount(ls, "runAH", 3); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1) || ls.isNil(1), "runAH() requires a UI object in param 1 (or Nil)"); - CLuaIHM::check(ls, ls.isString(2), "runAH() requires a string in param 2"); - CLuaIHM::check(ls, ls.isString(3), "runAH() requires a string in param 3"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - std::string ah, params; - ls.toString(2, ah); - ls.toString(3, params); - - // run AH - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - // The element must be ctrl (or NULL) - CCtrlBase *ctrl= NULL; - if(pIE) - { - ctrl= dynamic_cast(pIE); - if(!ctrl) - throw ELuaIHMException("runAH(): '%s' is not a ctrl", pIE->getId().c_str()); - } - CAHManager::getInstance()->runActionHandler(ah, ctrl, params); - - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::runExpr(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runExpr) - CLuaStackChecker lsc(&ls, 1); - - // params: "expr". - // return: any of: nil, bool, string, number, RGBA, UCString - CLuaIHM::checkArgCount(ls, "runExpr", 1); - CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); - - // retrieve args - std::string expr; - ls.toString(1, expr); - - // run expression and push result - return runExprAndPushResult(ls, expr); -} - -// *************************************************************************** -int CLuaIHMRyzom::runFct(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runFct) - CLuaStackChecker lsc(&ls, 1); - - // params: "expr", param1, param2... - // return: any of: nil, bool, string, number, RGBA, UCString - CLuaIHM::checkArgMin(ls, "runFct", 1); - CLuaIHM::check(ls, ls.isString(1), "runExpr() requires a string in param 1"); - - // retrieve fct - std::string expr; - ls.toString(1, expr); - expr+= "("; - - // retrieve params - uint top= ls.getTop(); - for(uint i=2;i<=top;i++) - { - if(i>2) - expr+= ", "; - - // If it is a number - if(ls.type(i)==LUA_TNUMBER) - { - std::string paramValue; - ls.toString(i, paramValue); // nb: transformed to a string in the stack - expr+= paramValue; - } - // else suppose a string - else - { - // must enclose with "'" - std::string paramValue; - ls.toString(i, paramValue); - expr+= std::string("'") + paramValue + std::string("'") ; - } - } - - // end fct call - expr+= ")"; - - - // run expression and push result - return runExprAndPushResult(ls, expr); -} - -// *************************************************************************** -int CLuaIHMRyzom::runCommand(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_runCommand) - CLuaStackChecker lsc(&ls, 1); - if (ls.empty()) - { - nlwarning("'runCommand' : Command name expected"); - ls.push(false); - return 1; - } - const char *commandName = ls.toString(1); - if (!commandName) - { - nlwarning("'runCommand' : Bad command name"); - ls.push(false); - return 1; - } - if (!NLMISC::ICommand::LocalCommands || !NLMISC::ICommand::LocalCommands->count(ls.toString(1))) - { - nlwarning("'runCommand' : Command %s not found", ls.toString(1)); - ls.push(false); - return 1; - } - std::string rawCommandString = ls.toString(1); - NLMISC::ICommand *command = (*NLMISC::ICommand::LocalCommands)[ls.toString(1)]; - nlassert(command); - std::vector args(ls.getTop() - 1); - for(uint k = 2; k <= (uint) ls.getTop(); ++k) - { - if (ls.toString(k)) - { - args[k - 2] = ls.toString(k); - rawCommandString += " " + std::string(ls.toString(k)); - } - } - - ls.push(command->execute(rawCommandString, args, g_log, false, true)); - return 1; -} // *************************************************************************** int CLuaIHMRyzom::formatUI(CLuaState &ls) @@ -939,74 +662,6 @@ int CLuaIHMRyzom::formatDB(CLuaState &ls) return 1; } -// *************************************************************************** -int CLuaIHMRyzom::deleteUI(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_deleteUI) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement * - // return: none - CLuaIHM::checkArgCount(ls, "deleteUI", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "deleteUI() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - if(!pIE) - return 0; - - // has a parent? - CInterfaceGroup *parent= pIE->getParent(); - if(parent) - { - // correctly remove from parent - parent->delElement(pIE); - } - else - { - // just delete - delete pIE; - } - - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::deleteReflectable(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_deleteReflectable) - CLuaStackChecker lsc(&ls, 0); - - // params: CInterfaceElement * - // return: none - CLuaIHM::checkArgCount(ls, "deleteReflectable", 1); - CLuaIHM::check(ls, CLuaIHM::isReflectableOnStack(ls, 1), "deleteReflectable() requires a reflectable C++ object in param 1"); - - // retrieve args - CReflectableRefPtrTarget *pRPT= CLuaIHM::getReflectableOnStack(ls, 1); - if(!pRPT) - return 0; - - - CInterfaceElement *pIE = dynamic_cast(pRPT); - - if (pIE) - { - // has a parent? - CInterfaceGroup *parent= pIE->getParent(); - if(parent) - { - // correctly remove from parent - parent->delElement(pIE); - } - } - - // just delete - delete pIE; - - return 0; -} - // *************************************************************************** int CLuaIHMRyzom::dumpUI(CLuaState &ls) { @@ -1066,97 +721,6 @@ int CLuaIHMRyzom::validMessageBox(CLuaState &ls) return 0; } -// *************************************************************************** -int CLuaIHMRyzom::setTopWindow(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_setTopWindow) - const char *funcName = "setTopWindow"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CInterfaceGroup *wnd = dynamic_cast( CLuaIHM::getUIOnStack(ls, 1)); - if (!wnd) - { - CLuaIHM::fails(ls, "%s : interface group expected as arg 1", funcName); - } - CInterfaceManager *im = CInterfaceManager::getInstance(); - CWidgetManager::getInstance()->setTopWindow(wnd); - return 0; -} - -// *************************************************************************** -int CLuaIHMRyzom::concatUCString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_concatUCString) - const char *funcName = "concatUCString"; - ucstring result; - for (uint k = 1; k <= (uint) ls.getTop(); ++k) - { - //nlwarning("arg %d = %s", k, ls.getTypename(ls.type(k))); - ucstring part; - if (ls.isString(k)) - { - part.fromUtf8(ls.toString(k)); - } - else - { - CLuaIHM::checkArgTypeUCString(ls, funcName, k); - nlverify(CLuaIHM::getUCStringOnStack(ls, k, part)); - } - result += part; - } - CLuaIHM::push(ls, result); - return 1; -} - -// *************************************************************************** -int CLuaIHMRyzom::concatString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_concatUCString) - const char *funcName = "concatString"; - std::string result; - uint stackSize = ls.getTop(); - for (uint k = 1; k <= stackSize; ++k) - { - CLuaIHM::checkArgType(ls, funcName, k, LUA_TSTRING); - result += ls.toString(k); - } - ls.push(result); - return 1; -} - -// *************************************************************************** -int CLuaIHMRyzom::tableToString(CLuaState &ls) -{ - const char *funcName = "tableToString"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TTABLE); - uint length = 0; - // compute size - ls.pushNil(); - while (ls.next(-2)) - { - ls.toString(-1); - length += (uint)ls.strlen(-1); - ls.pop(2); - } - std::string result; - result.resize(length); - char *dest = &result[0]; - // concatenate - ls.pushNil(); - while (ls.next(-2)) - { - uint length = (uint)ls.strlen(-1); - if (length) - { - memcpy(dest, ls.toString(-1), length); - } - dest += length; - ls.pop(2); - } - ls.push(result); - return 1; -} - // *************************************************************************** int CLuaIHMRyzom::breakPoint(CLuaState &ls) { @@ -1174,21 +738,6 @@ int CLuaIHMRyzom::breakPoint(CLuaState &ls) } - -// *************************************************************************** -int CLuaIHMRyzom::getWindowSize(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getWindowSize) - CLuaIHM::checkArgCount(ls, "getWindowSize", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - uint32 w, h; - CViewRenderer::getInstance()->getScreenSize(w, h); - ls.push((double) w); - ls.push((double) h); - return 2; -} - - // *************************************************************************** int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls) { @@ -1412,16 +961,6 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls) return 1; } -// *************************************************************************** -int CLuaIHMRyzom::isUCString(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_isUCString) - const char *funcName = "isUCString"; - CLuaIHM::checkArgCount(ls, funcName, 1); - ls.push(CLuaIHM::isUCStringOnStack(ls, 1)); - return 1; -} - // *************************************************************************** int CLuaIHMRyzom::hideAllWindows(CLuaState &/* ls */) { @@ -1486,25 +1025,6 @@ int CLuaIHMRyzom::getCharSlot(CLuaState &ls) return 1; } - -int CLuaIHMRyzom::getPathContent(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getPathContent) - const char *funcName = "getPathContent"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::vector files; - NLMISC::CPath::getPathContent(ls.toString(1), false, false, true, files); - ls.newTable(); - for(uint k = 0; k < files.size(); ++k) - { - ls.push((double) k); - ls.push(files[k]); - ls.setTable(-3); - } - return 1; -} - int CLuaIHMRyzom::getServerSeason(CLuaState &ls) { //H_AUTO(Lua_CLuaIHM_getServerSeason) @@ -1533,27 +1053,6 @@ int CLuaIHMRyzom::getAutoSeason(CLuaState &ls) return 1; } - - -int CLuaIHMRyzom::getTextureSize(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getTextureSize) - const char *funcName = "getTextureSize"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::string textureName = ls.toString(1); - - CBitmap bitmap; - CIFile fs(CPath::lookup(textureName).c_str()); - bitmap.load(fs); - - ls.push((double) bitmap.getWidth()); - ls.push((double) bitmap.getHeight()); - - return 2; -} - - int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) { //H_AUTO(Lua_CLuaIHM_enableModalWindow) @@ -1592,16 +1091,6 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls) return 0; } -// *************************************************************************** -int CLuaIHMRyzom::disableModalWindow(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_disableModalWindow) - CLuaIHM::checkArgCount(ls, "disableModalWindow", 0); - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CWidgetManager::getInstance()->disableModalWindow(); - return 0; -} - // *************************************************************************** int CLuaIHMRyzom::getPlayerPos(CLuaState &ls) { @@ -1988,47 +1477,6 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls) return 1; } -int CLuaIHMRyzom::getCurrentWindowUnder(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getCurrentWindowUnder) - CLuaStackChecker lsc(&ls, 1); - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceElement *pIE= CWidgetManager::getInstance()->getCurrentWindowUnder(); - if(!pIE) - { - ls.pushNil(); - debugInfo(toString("getCurrentWindowUnder(): No UICaller found. return Nil")); - } - else - { - CLuaIHM::pushUIOnStack(ls, pIE); - } - return 1; -} - -// *************************************************************************** -int CLuaIHMRyzom::getUIId(CLuaState &ls) -{ - //H_AUTO(Lua_CLuaIHM_getUIId) - CLuaStackChecker lsc(&ls, 1); - - // params: CInterfaceElement* - // return: "ui:interface:...". (empty if error) - CLuaIHM::checkArgCount(ls, "getUIId", 1); - CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getUIId() requires a UI object in param 1"); - - // retrieve args - CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1); - - // convert to id - if(pIE) - ls.push(pIE->getId()); - else - ls.push(""); - - return 1; -} - // *************************************************************************** int CLuaIHMRyzom::getIndexInDB(CLuaState &ls) { @@ -3009,13 +2457,6 @@ string CLuaIHMRyzom::getClientCfg(const string &varName) return ClientCfg.readString(varName); } -// *************************************************************************** -bool CLuaIHMRyzom::fileExists(const string &fileName) -{ - //H_AUTO(Lua_CLuaIHM_fileExists) - return CPath::exists(fileName); -} - // *************************************************************************** void CLuaIHMRyzom::sendMsgToServer(const std::string &sMsg) { @@ -3438,74 +2879,4 @@ std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint lin return ""; } -// *************************************************************************** -int CLuaIHMRyzom::runExprAndPushResult(CLuaState &ls, const std::string &expr) -{ - //H_AUTO(Lua_CLuaIHM_runExprAndPushResult) - // Execute expression - CInterfaceExprValue value; - if (CInterfaceExpr::eval(expr, value, NULL)) - { - switch(value.getType()) - { - case CInterfaceExprValue::Boolean: - ls.push(value.getBool()); - break; - case CInterfaceExprValue::Integer: - ls.push((double)value.getInteger()); - break; - case CInterfaceExprValue::Double: - ls.push(value.getDouble()); - break; - case CInterfaceExprValue::String: - { - ucstring ucstr= value.getUCString(); - // Yoyo: dynamically decide whether must return a string or a ucstring - bool mustUseUCString= false; - for (uint i = 0; i < ucstr.size (); i++) - { - if (ucstr[i] > 255) - { - mustUseUCString= true; - break; - } - } - // push a ucstring? - if(mustUseUCString) - { -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), ucstr); -#else - luabind::object obj(ls.getStatePointer(), ucstr); - obj.pushvalue(); -#endif - } - else - { - ls.push(ucstr.toString()); - } - break; - } - case CInterfaceExprValue::RGBA: - { - CRGBA color = value.getRGBA(); -#if LUABIND_VERSION > 600 - luabind::detail::push(ls.getStatePointer(), color); -#else - luabind::object obj(ls.getStatePointer(), color); - obj.pushvalue(); -#endif - break; - } - break; - case CInterfaceExprValue::UserType: // Yoyo: don't care UserType... - default: - ls.pushNil(); - break; - } - } - else - ls.pushNil(); - return 1; -} diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index 3d7c32860..ffe0125a4 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -23,13 +23,7 @@ private: static int getUI(CLuaState &ls); // params: "ui:interface:...". return: CInterfaceElement* (nil if error), an additionnal boolean parameter // LUA exported Functions with standard lua (because use ui object, use variable param number, or return dynamic-typed object) - static int setCaptureKeyboard(CLuaState &ls); - static int resetCaptureKeyboard(CLuaState &ls); - static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none - static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none - static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none static int getUICaller(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if error) - static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none) // can specify verbose display when the element is note found (default is true) static int createGroupInstance(CLuaState &ls); // params : param 1 = template name, // param 2 = id of parent where the instance will be inserted @@ -49,27 +43,16 @@ private: // param 3 = table with all strings and urls // {"main text"="http:///", "text option 1"="http:///", "text option 2"="http:///") etc... static int getIndexInDB(CLuaState &ls); // params: CDBCtrlSheet*.... return: index, or 0 if error - static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error) - static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none - static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString - static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString - static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false static int formatUI(CLuaState &ls); // params: "expr", param1, param2.... return: string with # and % parsed static int formatDB(CLuaState &ls); // params: param1, param2.... return: string with @ and , added static int launchContextMenuInGame(CLuaState &ls); // params : menu name static int parseInterfaceFromString(CLuaState &ls); // params : intreface script static int updateAllLocalisedElements(CLuaState &ls); static int breakPoint(CLuaState &ls); - static int getWindowSize(CLuaState &ls); static int i18n(CLuaState &ls); // retrieve an unicode string from CI18N static int setTextFormatTaged(CLuaState &ls); // set a text that may contains Tag Format infos static int validMessageBox(CLuaState &ls); // ok/cancel type message box (can't get it to work through luabind) - static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ... - static int concatString(CLuaState &ls); // speedup concatenation of several strings - static int tableToString(CLuaState &ls); // concat element of a table to build a string - static int setTopWindow(CLuaState &ls); // set the top window static int initEmotesMenu(CLuaState &ls); - static int isUCString(CLuaState &ls); static int hideAllWindows(CLuaState &ls); static int hideAllNonSavableWindows(CLuaState &ls); static int getDesktopIndex(CLuaState &ls); @@ -81,7 +64,6 @@ private: static int getWeatherValue(CLuaState &ls); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored static int disableContextHelpForControl(CLuaState &ls); // params: CCtrlBase*. return: none static int disableContextHelp(CLuaState &ls); - static int getPathContent(CLuaState &ls); static int getServerSeason(CLuaState &ls); // get the last season sent by the server // 0->auto, computed locally from the current day (or not received from server yet) // 1->server force spring @@ -92,9 +74,7 @@ private: static int getAutoSeason(CLuaState &ls); // compute automatic season that would be at this time (1->spring, etc .) - static int getTextureSize(CLuaState &ls); static int enableModalWindow(CLuaState &ls); - static int disableModalWindow(CLuaState &ls); static int getPlayerPos(CLuaState &ls); static int getPlayerFront(CLuaState &ls); static int getPlayerDirection(CLuaState &ls); @@ -120,8 +100,6 @@ private: static int getSlotDataSetId(CLuaState &ls); // LUA functions exported for Dev only (debug) - static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none - static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none static int dumpUI(CLuaState &ls); // params: CInterfaceElement*.... return: none static int setKeyboardContext(CLuaState &ls); @@ -206,7 +184,6 @@ private: static sint32 getFirstTribeFameIndex(); // fame index of the 1st tribe static sint32 getNbTribeFameIndex(); // number of tribe fame index (which are contiguous) static std::string getClientCfg(const std::string &varName); - static bool fileExists(const std::string &fileName); static void sendMsgToServer(const std::string &msgName); static void sendMsgToServerPvpTag(bool pvpTag); static bool isGuildQuitAvailable(); @@ -260,8 +237,6 @@ public: // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else // a, empty tag is returned static std::string createGotoFileButtonTag(const char *fileName, uint line); - - static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct }; #endif From c57c909ed7f8b7c15f1751195b6ca4a34df1c3c3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 15 Jun 2012 22:40:08 +0200 Subject: [PATCH 061/339] CHANGED: #1471 CCtrlBaseButton is now part of the NELGUI Library. --- code/nel/include/nel/gui/action_handler.h | 3 ++ .../include/nel/gui}/ctrl_base_button.h | 0 code/nel/include/nel/gui/widget_manager.h | 11 +++- code/nel/src/gui/action_handler.cpp | 8 ++- .../src/gui}/ctrl_base_button.cpp | 25 ++++----- code/nel/src/gui/widget_manager.cpp | 45 ++++++++++++++++ code/ryzom/client/src/commands.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/action_handler_move.cpp | 2 +- .../interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../client/src/interface_v3/ctrl_button.h | 2 +- .../src/interface_v3/ctrl_text_button.h | 2 +- .../src/interface_v3/group_container.cpp | 4 +- .../client/src/interface_v3/group_tab.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../interface_v3/input_handler_manager.cpp | 4 +- .../src/interface_v3/interface_manager.cpp | 53 +------------------ .../src/interface_v3/interface_manager.h | 13 ----- .../client/src/interface_v3/view_pointer.cpp | 8 +-- .../ryzom/client/src/motion/modes/ai_mode.cpp | 8 +-- .../ryzom/client/src/motion/user_controls.cpp | 14 ++--- code/ryzom/client/src/r2/tool.cpp | 6 +-- .../client/src/r2/tool_create_entity.cpp | 2 +- 24 files changed, 107 insertions(+), 115 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_base_button.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_base_button.cpp (92%) diff --git a/code/nel/include/nel/gui/action_handler.h b/code/nel/include/nel/gui/action_handler.h index d7bda1bda..830139777 100644 --- a/code/nel/include/nel/gui/action_handler.h +++ b/code/nel/include/nel/gui/action_handler.h @@ -108,6 +108,9 @@ namespace NLGUI void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") ); void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + // Submit a generic event + void submitEvent( const std::string &evt ); + private: CAHManager(){} static CAHManager *_GlobalInstance; diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.h b/code/nel/include/nel/gui/ctrl_base_button.h similarity index 100% rename from code/ryzom/client/src/interface_v3/ctrl_base_button.h rename to code/nel/include/nel/gui/ctrl_base_button.h diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 9145f66c4..a5a7b45b8 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -291,7 +291,14 @@ namespace NLGUI void addOptions( std::string name, CInterfaceOptions *options ); void removeOptions( std::string name ); void removeAllOptions(); - + + // Enable mouse Events to interface. if false, release Captures. + void enableMouseHandling( bool handle ); + bool isMouseHandlingEnabled() const{ return _MouseHandlingEnabled; } + + // Get the User DblClick Delay (according to save...), in milisecond + uint getUserDblClickDelay(); + static IParser *parser; private: @@ -333,6 +340,8 @@ namespace NLGUI NLMISC::CCDBNodeLeaf *_GProp; NLMISC::CCDBNodeLeaf *_BProp; NLMISC::CCDBNodeLeaf *_AProp; + + bool _MouseHandlingEnabled; }; } diff --git a/code/nel/src/gui/action_handler.cpp b/code/nel/src/gui/action_handler.cpp index be14aa5c5..b25dbb0c5 100644 --- a/code/nel/src/gui/action_handler.cpp +++ b/code/nel/src/gui/action_handler.cpp @@ -275,8 +275,14 @@ namespace NLGUI const std::string event = AHName + ":" + Params; pAH->execute(NULL, event); } + + void CAHManager::submitEvent( const std::string &evt ) + { + // Submit the event to the quick help system + runActionHandler( "submit_quick_help", NULL, evt ); + } - + // ------------------------------------------------------------------------------------------------ class CAHSet : public IActionHandler { diff --git a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp similarity index 92% rename from code/ryzom/client/src/interface_v3/ctrl_base_button.cpp rename to code/nel/src/gui/ctrl_base_button.cpp index 8babc835a..39e6f0d14 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -15,15 +15,12 @@ // along with this program. If not, see . - -#include "stdpch.h" - -#include "ctrl_base_button.h" -#include "interface_manager.h" +#include "nel/gui/ctrl_base_button.h" #include "nel/misc/xml_auto_ptr.h" -#include "../time_client.h" - +#include "nel/gui/interface_group.h" #include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/db_manager.h" using namespace std; @@ -205,9 +202,10 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) if (!_Active || _Frozen) return false; + sint64 T1 = NLMISC::CTime::getLocalTime(); + if (event.getType() == NLGUI::CEventDescriptor::mouse) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) @@ -227,7 +225,7 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { if (_AHOnLeftDblClick) { - if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < pIM->getUserDblClickDelay()) + if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay()) { CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams); _LeftDblClickHandled = true; @@ -308,7 +306,6 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { _LastLeftClickButton = NULL; bool handled= false; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCapturePointerRight() != this) return false; @@ -338,11 +335,9 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) { if (_AHOnClockTick != NULL) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams); } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { if (!_LeftLongClickHandled) @@ -445,8 +440,7 @@ void CCtrlBaseButton::unselect() // *************************************************************************** void CCtrlBaseButton::updateOver(bool &lastOver) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - if (!pIM->isMouseHandlingEnabled()) + if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) { _Over = false; return; @@ -500,10 +494,9 @@ void CCtrlBaseButton::runLeftClickAction() { if(_AHOnLeftClick != NULL) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); //nlinfo("clicked on %s", _Id.c_str()); - pIM->submitEvent ("button_click:"+getId());//TEMP + CAHManager::getInstance()->submitEvent( "button_click:" + getId() ); CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); //pIM->submitEvent ("button_click:"+getId()); } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 14064ec40..76b0afcc7 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -25,6 +25,12 @@ #include "nel/gui/group_editbox_base.h" #include "nel/gui/interface_options.h" +namespace +{ + const uint DOUBLE_CLICK_MIN = 50; + const uint DOUBLE_CLICK_MAX = 750; +} + namespace NLGUI { @@ -1378,6 +1384,43 @@ namespace NLGUI { _OptionsMap.clear(); } + + + // *************************************************************************** + void CWidgetManager::enableMouseHandling( bool handle ) + { + _MouseHandlingEnabled = handle; + if(!handle) + { + if(!getPointer()) + return; + + // If Left captured, reset + if( getCapturePointerLeft() ) + setCapturePointerLeft( NULL ); + + // Same for Right + if( getCapturePointerRight() ) + setCapturePointerRight( NULL ); + + // Avoid any problem with modals + disableModalWindow(); + } + } + + // *************************************************************************** + uint CWidgetManager::getUserDblClickDelay() + { + uint nVal = 50; + NLMISC::CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED"); + if( pNL != NULL ) + nVal = pNL->getValue32(); + + uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f); + return dbclickDelay; + } + + CWidgetManager::CWidgetManager() { @@ -1389,6 +1432,8 @@ namespace NLGUI _GlobalColor = NLMISC::CRGBA(255,255,255,255); _GlobalColorForContent = _GlobalColor; _ContentAlpha = 255; + + _MouseHandlingEnabled = true; } CWidgetManager::~CWidgetManager() diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 8e7fbf52f..e3e43b55e 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -88,7 +88,7 @@ #include "actions_client.h" #include "attack_list.h" #include "interface_v3/player_trade.h" -#include "interface_v3/ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" #include "weather.h" #include "forage_source_cl.h" #include "connection.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 0066dd948..c9d37f5fb 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -40,7 +40,7 @@ #include "macrocmd_manager.h" #include "inventory_manager.h" -#include "ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" #include "../connection.h" #include "view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_move.cpp b/code/ryzom/client/src/interface_v3/action_handler_move.cpp index 782617ac3..5efe2c18e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -32,7 +32,7 @@ using namespace NLMISC; #include "../entities.h" #include "interface_manager.h" #include "action_handler_tools.h" -#include "ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" //////////// // GLOBAL // diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index d702689dd..a4cefa3bb 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -1152,7 +1152,7 @@ public: // **** Cyclic Cast? (dblclick) bool cyclic; // Manage "DblHit" - uint dbclickDelay = pIM->getUserDblClickDelay(); + uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); // if success to "dblclick" if(LastIndex==(sint)memoryIndex && T1<=LastHitTime+dbclickDelay ) cyclic= true; diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index d7fc952ed..92d4f4897 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -24,7 +24,7 @@ #include "inventory_manager.h" #include "nel/gui/action_handler.h" #include "../client_cfg.h" -#include "ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" #include "group_container.h" #include "../string_manager_client.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.h b/code/ryzom/client/src/interface_v3/ctrl_button.h index 8ff9686af..64b8ecab0 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_button.h @@ -19,7 +19,7 @@ #ifndef RZ_CTRL_BUTTON_H #define RZ_CTRL_BUTTON_H -#include "ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" #include "nel/gui/view_renderer.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h index 965f3c42d..34a93520e 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.h @@ -19,7 +19,7 @@ #ifndef NL_CTRL_TEXT_BUTTON_H #define NL_CTRL_TEXT_BUTTON_H -#include "ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index ce5499c11..907d08553 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -919,7 +919,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { if (_WaitToOpenClose) { - uint dbclickDelay = pIM->getUserDblClickDelay(); + uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); if ((T1 - _WaitToOpenCloseDate) > dbclickDelay) { CGroupContainer *gc = dynamic_cast(_Parent); @@ -3203,7 +3203,7 @@ void CGroupContainer::setActive (bool state) else CWidgetManager::getInstance()->setBackWindow(this); } - pIM->submitEvent((state?"show:":"hide:")+getId()); + CAHManager::getInstance()->submitEvent((state?"show:":"hide:")+getId()); CInterfaceGroup::setActive(state); } diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index f5b05c5ed..e9fe48a2e 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -798,7 +798,7 @@ bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) if (_Blinking) { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - uint dbclickDelay = pIM->getUserDblClickDelay(); + uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); if ((T1 - _BlinkDate) > dbclickDelay) { if (_BlinkState) diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 1d6282ffd..c739be7dd 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -566,7 +566,7 @@ void CGroupTree::draw() // change the over bool bDisplayOver = true; - if (!pIM->isMouseHandlingEnabled()) + if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) { bDisplayOver = false; } diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index 6074f98e5..da2fddea9 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -258,7 +258,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) } } // **** Event Mouse - else if(CWidgetManager::getInstance()->getPointer() && _Focus /* && pIM->isMouseHandlingEnabled() */ && + else if(CWidgetManager::getInstance()->getPointer() && _Focus /* && CWidgetManager::getInstance()->isMouseHandlingEnabled() */ && ( event == EventMouseMoveId || event == EventMouseDownId || event == EventMouseUpId || @@ -282,7 +282,7 @@ void CInputHandlerManager::operator ()(const NLMISC::CEvent &event) // button down ? static volatile bool doTest = false; - if (!doTest || (doTest && pIM->isMouseHandlingEnabled())) + if (!doTest || (doTest && CWidgetManager::getInstance()->isMouseHandlingEnabled())) { if (event==EventMouseDownId) { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b473c29e3..067c946ea 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -182,10 +182,6 @@ CChatDisplayer * ChatDisplayer = NULL; void initActions(); void uninitActions(); -// ------------------------------------------------------------------------------------------------ -static const uint DOUBLE_CLICK_MIN = 50; -static const uint DOUBLE_CLICK_MAX = 750; - ///\todo nico: remove this dummy displayer NLMISC::CLog g_log; @@ -278,7 +274,6 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _GlobalRolloverFactorContent = 255; _GlobalRolloverFactorContainer = 255; _MouseOverWindow= false; - _MouseHandlingEnabled= true; _ConfigLoaded = false; _LogState = false; _KeysLoaded = false; @@ -2610,7 +2605,7 @@ bool CInterfaceManager::handleEvent (const NLGUI::CEventDescriptor& event) eventDesc.setX( _Pointer->getX() ); eventDesc.setY( _Pointer->getY() ); - if( _MouseHandlingEnabled ) + if( CWidgetManager::getInstance()->isMouseHandlingEnabled() ) { // First thing to do : Capture handling if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) @@ -3493,32 +3488,6 @@ void CInterfaceManager::disableContextHelpForControl(CCtrlBase *pCtrl) disableContextHelp(); } -// *************************************************************************** -void CInterfaceManager::enableMouseHandling(bool handle) -{ - _MouseHandlingEnabled= handle; - if(!handle) - { - if(!CWidgetManager::getInstance()->getPointer()) - return; - - // If Left captured, reset - if( CWidgetManager::getInstance()->getCapturePointerLeft() ) - { - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - } - - // Same for Right - if( CWidgetManager::getInstance()->getCapturePointerRight() ) - { - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - } - - // Avoid any problem with modals - CWidgetManager::getInstance()->disableModalWindow(); - } -} - // *************************************************************************** void CInterfaceManager::displayDebugInfo(const ucstring &str, TSystemInfoMode mode /*=InfoMsg*/) @@ -4039,26 +4008,6 @@ void CInterfaceManager::restoreAllContainersBackupPosition() } } - -// *************************************************************************** - -uint CInterfaceManager::getUserDblClickDelay() -{ - uint nVal = 50; - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:DOUBLE_CLICK_SPEED"); - if (pNL != NULL) - nVal = pNL->getValue32(); - uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f); - return dbclickDelay; -} - -// *************************************************************************** -void CInterfaceManager::submitEvent (const std::string &event) -{ - // Submit the event to the quick help system - CAHManager::getInstance()->runActionHandler("submit_quick_help", NULL, event); -} - // *************************************************************************** void CInterfaceManager::visit(CInterfaceElementVisitor *visitor) { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 4413c5bec..2171ecb4c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -387,10 +387,6 @@ public: bool isMouseOverWindow() const {return _MouseOverWindow;} - // Enable mouse Events to interface. if false, release Captures. - void enableMouseHandling(bool handle); - bool isMouseHandlingEnabled() const { return _MouseHandlingEnabled; } - // Modes void setMode(uint8 newMode); uint8 getMode() const { return _CurrentMode; } @@ -414,12 +410,6 @@ public: void displayUICtrlBBoxs(const std::string &uiFilter); void displayUIGroupBBoxs(const std::string &uiFilter); - // Get the User DblClick Delay (according to save...), in milisecond - uint getUserDblClickDelay(); - - // Submit a generic event - void submitEvent (const std::string &event); - // visit all elements of the interface manager void visit(CInterfaceElementVisitor *visitor); @@ -743,9 +733,6 @@ private: // System Options CInterfaceOptionValue _SystemOptions[NumSystemOptions]; - bool _MouseHandlingEnabled; - - // Modes CInterfaceConfig::CDesktopImage _Modes[MAX_NUM_MODES]; uint8 _CurrentMode; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index ebfdafe1b..ed0cdae23 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -199,7 +199,7 @@ void CViewPointer::draw () _LastHightLight = NULL; } - if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled()) + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && CWidgetManager::getInstance()->isMouseHandlingEnabled()) { CCtrlMover *pCM = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft()); if ((pCM != NULL) && (pCM->canMove() == true)) @@ -308,7 +308,7 @@ void CViewPointer::draw () } // Draw the cursor type that are under the pointer - if (pIM->isMouseHandlingEnabled()) + if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) { // Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo. // Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group) @@ -363,7 +363,7 @@ void CViewPointer::draw () } } - if (pIM->isMouseHandlingEnabled()) + if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) { if (rICL.empty()) { @@ -381,7 +381,7 @@ void CViewPointer::draw () } } - if (_StringMode && pIM->isMouseHandlingEnabled()) + if (_StringMode && CWidgetManager::getInstance()->isMouseHandlingEnabled()) { CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor; if (stringCursor) diff --git a/code/ryzom/client/src/motion/modes/ai_mode.cpp b/code/ryzom/client/src/motion/modes/ai_mode.cpp index 1f5caafab..4c9db3511 100644 --- a/code/ryzom/client/src/motion/modes/ai_mode.cpp +++ b/code/ryzom/client/src/motion/modes/ai_mode.cpp @@ -99,7 +99,7 @@ void CUserControls::aiMode() } if( EventsListener.isMouseButtonReleased (leftButton) ) { - if(T1 <= _LeftClickEnd+IM->getUserDblClickDelay()) + if(T1 <= _LeftClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay()) { dblClickLeft = true; } @@ -114,7 +114,7 @@ void CUserControls::aiMode() } if( EventsListener.isMouseButtonReleased (rightButton) ) { - if(T1 <= _RightClickEnd+IM->getUserDblClickDelay()) + if(T1 <= _RightClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay()) { dblClickRight = true; } @@ -141,13 +141,13 @@ void CUserControls::aiMode() } // Give back the mouse handling to the interface. - IM->enableMouseHandling(true); + CWidgetManager::getInstance()->enableMouseHandling(true); } else if (EventsListener.isMouseButtonDown (rightButton)) { if((T1-_RightClickStart) > _TimeLongClick) { - IM->enableMouseHandling(false); + CWidgetManager::getInstance()->enableMouseHandling(false); EventsListener.enableMouseSmoothing(true); // Get the cursor instance and hide. CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); diff --git a/code/ryzom/client/src/motion/user_controls.cpp b/code/ryzom/client/src/motion/user_controls.cpp index 6c7d5027a..cfa5c3254 100644 --- a/code/ryzom/client/src/motion/user_controls.cpp +++ b/code/ryzom/client/src/motion/user_controls.cpp @@ -505,7 +505,7 @@ void CUserControls::freeLook(bool fullMode) // FREE LOOK : Hide the cursor // disable interface mouse handling. - IM->enableMouseHandling(false); + CWidgetManager::getInstance()->enableMouseHandling(false); // Get the cursor instance CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) @@ -588,7 +588,7 @@ void CUserControls::cameraLook(bool fullMode) // CAMERA LOOK : Hide the cursor // disable interface mouse handling. - IM->enableMouseHandling(false); + CWidgetManager::getInstance()->enableMouseHandling(false); // Get the cursor instance CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); if(cursor) @@ -747,7 +747,7 @@ void CUserControls::commonMove() } if( EventsListener.isMouseButtonReleased (leftButton) ) { - if(T1 <= _LeftClickEnd+IM->getUserDblClickDelay()) + if(T1 <= _LeftClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay()) { dblClickLeft = true; } @@ -762,7 +762,7 @@ void CUserControls::commonMove() } if( EventsListener.isMouseButtonReleased (rightButton) ) { - if(T1 <= _RightClickEnd+IM->getUserDblClickDelay()) + if(T1 <= _RightClickEnd + CWidgetManager::getInstance()->getUserDblClickDelay()) { dblClickRight = true; } @@ -814,7 +814,7 @@ void CUserControls::commonMove() // Give back the mouse handling to the interface. - IM->enableMouseHandling(true); + CWidgetManager::getInstance()->enableMouseHandling(true); EventsListener.enableMouseSmoothing(false); } @@ -831,7 +831,7 @@ void CUserControls::commonMove() } // Give back the mouse handling to the interface. - IM->enableMouseHandling(true); + CWidgetManager::getInstance()->enableMouseHandling(true); EventsListener.enableMouseSmoothing(false); } @@ -1313,7 +1313,7 @@ void CUserControls::stopFreeLook() // Cursor mode SetMouseCursor (); // Give back the mouse handling to the interface. - CInterfaceManager::getInstance()->enableMouseHandling(true); + CWidgetManager::getInstance()->enableMouseHandling(true); } diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp index 9b80311f5..e5adc4913 100644 --- a/code/ryzom/client/src/r2/tool.cpp +++ b/code/ryzom/client/src/r2/tool.cpp @@ -93,7 +93,7 @@ bool CTool::checkDoubleClick() { //H_AUTO(R2_CTool_checkDoubleClick) if (_DoubleClickStartTime == -1) return false; - if (T0 - _DoubleClickStartTime >= getUI().getUserDblClickDelay()) return false; + if (T0 - _DoubleClickStartTime >= CWidgetManager::getInstance()->getUserDblClickDelay()) return false; sint32 mx, my; getMousePos(mx, my); const sint32 moveThrehsold = 2; @@ -725,7 +725,7 @@ void CTool::captureMouse() else { UserControls.captureMouse(); - getUI().enableMouseHandling(false); + CWidgetManager::getInstance()->enableMouseHandling(false); } getUI().setContextHelpActive(false); _MouseCaptured = true; @@ -737,7 +737,7 @@ void CTool::releaseMouse() //H_AUTO(R2_CTool_releaseMouse) CWidgetManager::getInstance()->setCapturePointerLeft(NULL); UserControls.releaseMouse(); - getUI().enableMouseHandling(true); + CWidgetManager::getInstance()->enableMouseHandling(true); getUI().setContextHelpActive(true); _MouseCaptured = false; } diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp index 8819dc24c..97e20a871 100644 --- a/code/ryzom/client/src/r2/tool_create_entity.cpp +++ b/code/ryzom/client/src/r2/tool_create_entity.cpp @@ -36,7 +36,7 @@ #include "verbose_clock.h" #include "entity_sorter.h" // -#include "../interface_v3/ctrl_base_button.h" +#include "nel/gui/ctrl_base_button.h" // #include "game_share/player_visual_properties.h" #include "game_share/visual_slot_manager.h" From 8226c2b897dc868f2905a5c4c6d416a73e267cec Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 15 Jun 2012 23:30:27 +0200 Subject: [PATCH 062/339] CHANGED: #1471 CCtrlBaseButton is now part of the NLGUI namespace. --- code/nel/include/nel/gui/ctrl_base_button.h | 443 ++++----- code/nel/src/gui/ctrl_base_button.cpp | 843 +++++++++--------- .../src/interface_v3/dbgroup_build_phrase.h | 7 +- .../src/interface_v3/dbgroup_combo_box.h | 6 +- .../src/interface_v3/dbgroup_list_sheet.h | 5 +- .../src/interface_v3/dbgroup_select_number.h | 6 +- .../src/interface_v3/group_scrolltext.h | 6 +- .../src/interface_v3/interface_pointer.h | 3 +- code/ryzom/client/src/libwww.h | 6 +- 9 files changed, 678 insertions(+), 647 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_base_button.h b/code/nel/include/nel/gui/ctrl_base_button.h index 3f202dcf7..dab368293 100644 --- a/code/nel/include/nel/gui/ctrl_base_button.h +++ b/code/nel/include/nel/gui/ctrl_base_button.h @@ -22,232 +22,235 @@ #include "nel/gui/ctrl_base.h" #include "nel/gui/action_handler.h" - -// *************************************************************************** -/** - * Base Class For Buttons. - * \author Lionel Berenguier - * \author Nevrax France - * \date 2003 - */ -class CCtrlBaseButton : public CCtrlBase +namespace NLGUI { -public: - enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount }; - - /// Constructor - CCtrlBaseButton(const TCtorParam ¶m); - - virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual bool handleEvent (const NLGUI::CEventDescriptor& event); - - /// \name Misc - // @{ - void setType (EType t) { _Type = t; } - EType getType() { return _Type; } - - void setClickWhenPushed(bool click) { _ClickWhenPushed = click; } - bool getClickWhenPushed() const { return _ClickWhenPushed; } - - void setPushed (bool state); - bool getPushed () const { return _Pushed; } - - void setFrozen (bool state); - bool getFrozen () const { return _Frozen; } - - // Set half tone mode for the display of frozen buttons. Default is true. - void setFrozenHalfTone(bool enabled); - bool getFrozenHalfTone() const { return _FrozenHalfTone; } - - // if the radio is a radio button, then all radio button are unselected - void unselect(); - // @} - - - /// \name Colors - // @{ - void setColor(NLMISC::CRGBA col) { _ColorNormal = col; } - void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; } - void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; } - - NLMISC::CRGBA getColor() const { return _ColorNormal; } - NLMISC::CRGBA getColorPushed() const { return _ColorPushed; } - NLMISC::CRGBA getColorOver() const { return _ColorOver; } - - // Override because mustupdate 3 states - void setModulateGlobalColorAll(bool state); - void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;} - void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;} - void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;} - - virtual sint32 getAlpha() const { return _ColorNormal.A; } - virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; } - - std::string getColorAsString() const - { return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " + - NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); } - std::string getColorOverAsString() const - { return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + - NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); } - std::string getColorPushedAsString() const - { return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " + - NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); } - - void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); } - void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); } - void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); } - // @} - - ///\name radio button specific - //@{ - /** Initialize radio button reference - * Advanced: - * NB: must call initRBRef() for radio button if button is created without parse(). - * NB: setParent() must be called before (else assert) + // *************************************************************************** + /** + * Base Class For Buttons. + * \author Lionel Berenguier + * \author Nevrax France + * \date 2003 */ - void initRBRef(); - //@} - void initRBRefFromRadioButton(CCtrlBaseButton * pBut); - - - /// \name Handlers - // @{ - // Event part - void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } - void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; } - void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } - void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } - void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; } - void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; } - void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } - - // get Event part - std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } - IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } - IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } - IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } - std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); } - const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } - const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } - const std::string &getParamsOnClockTick () const { return _AHClockTickParams; } - - // run action on left click - void runLeftClickAction(); - - // Context menu accessor/ One for each button - void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; } - void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; } - void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; } - std::string getListMenuLeft () { return _ListMenuLeft.toString(); } - std::string getListMenuRight () { return _ListMenuRight.toString(); } - // @} - - - - int luaRunLeftClickAction(CLuaState &ls); - REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase) - REFLECT_BOOL("pushed", getPushed, setPushed); - REFLECT_STRING("col_normal", getColorAsString, setColorAsString); - REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString); - REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString); - REFLECT_RGBA("col_normal_rgba", getColor, setColor); - REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver); - REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed); - REFLECT_BOOL("frozen", getFrozen, setFrozen); - REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone); - REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick); - REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick); - REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); - REFLECT_EXPORT_END - -protected: - EType _Type; - - // State - bool _Pushed : 1; - bool _Over : 1; - bool _OverWhenPushed : 1; - bool _Frozen : 1; - bool _FrozenHalfTone : 1; - bool _ClickWhenPushed : 1; - bool _ModulateGlobalColorNormal : 1; - bool _ModulateGlobalColorPushed : 1; - bool _ModulateGlobalColorOver : 1; - bool _LeftLongClickHandled : 1; // Is it already handled ? - bool _LeftDblClickHandled : 1; - - - ///\name radio button specific - //@{ - CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference - // There is only one radio button per group that own the reference (the first one) - CCtrlBaseButton **_RBRef; // The pointer onto the reference button - //@} - - - // Colors - NLMISC::CRGBA _ColorNormal; - NLMISC::CRGBA _ColorPushed; - NLMISC::CRGBA _ColorOver; - - ///\name Long click specific - //@{ - sint64 _LeftLongClickDate; // Time we left click down - //@} - - // for double click : last date at which last left click occurred - static sint64 _LastLeftClickDate; - static NLMISC::CRefPtr _LastLeftClickButton; - - ///\name Action Handler - //@{ - IActionHandler *_AHOnOver; - CStringShared _AHOverParams; - std::string _AHOnLeftClickString; - std::string _AHOnLeftClickStringParams; - IActionHandler *_AHOnLeftClick; - CStringShared _AHLeftClickParams; - IActionHandler *_AHOnLeftDblClick; - CStringShared _AHLeftDblClickParams; - IActionHandler *_AHOnRightClick; - CStringShared _AHRightClickParams; - IActionHandler *_AHOnClockTick; - CStringShared _AHClockTickParams; - IActionHandler *_AHOnLeftLongClick; - CStringShared _AHLeftLongClickParams; - //@} - CStringShared _ListMenuLeft; - CStringShared _ListMenuRight; - - // get the colors modulated on request - NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const + class CCtrlBaseButton : public CCtrlBase { - NLMISC::CRGBA rgba = _ColorNormal; - if(_ModulateGlobalColorNormal) - rgba.modulateFromColor(rgba, globalColor); - return rgba; - } - NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const - { - NLMISC::CRGBA rgba = _ColorPushed; - if(_ModulateGlobalColorPushed) - rgba.modulateFromColor(rgba, globalColor); - return rgba; - } - NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const - { - NLMISC::CRGBA rgba = _ColorOver; - if(_ModulateGlobalColorOver) - rgba.modulateFromColor(rgba, globalColor); - return rgba; - } - // call it at draw - void updateOver(bool &lastOver); - virtual void elementCaptured(CCtrlBase *capturedElement); -}; + public: + enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount }; + /// Constructor + CCtrlBaseButton(const TCtorParam ¶m); + + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual bool handleEvent (const NLGUI::CEventDescriptor& event); + + /// \name Misc + // @{ + void setType (EType t) { _Type = t; } + EType getType() { return _Type; } + + void setClickWhenPushed(bool click) { _ClickWhenPushed = click; } + bool getClickWhenPushed() const { return _ClickWhenPushed; } + + void setPushed (bool state); + bool getPushed () const { return _Pushed; } + + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + // Set half tone mode for the display of frozen buttons. Default is true. + void setFrozenHalfTone(bool enabled); + bool getFrozenHalfTone() const { return _FrozenHalfTone; } + + // if the radio is a radio button, then all radio button are unselected + void unselect(); + // @} + + + /// \name Colors + // @{ + void setColor(NLMISC::CRGBA col) { _ColorNormal = col; } + void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; } + void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; } + + NLMISC::CRGBA getColor() const { return _ColorNormal; } + NLMISC::CRGBA getColorPushed() const { return _ColorPushed; } + NLMISC::CRGBA getColorOver() const { return _ColorOver; } + + // Override because mustupdate 3 states + void setModulateGlobalColorAll(bool state); + void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;} + void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;} + void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;} + + virtual sint32 getAlpha() const { return _ColorNormal.A; } + virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; } + + std::string getColorAsString() const + { return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " + + NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); } + std::string getColorOverAsString() const + { return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); } + std::string getColorPushedAsString() const + { return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " + + NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); } + + void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); } + void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); } + void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); } + // @} + + ///\name radio button specific + //@{ + /** Initialize radio button reference + * Advanced: + * NB: must call initRBRef() for radio button if button is created without parse(). + * NB: setParent() must be called before (else assert) + */ + void initRBRef(); + //@} + void initRBRefFromRadioButton(CCtrlBaseButton * pBut); + + + /// \name Handlers + // @{ + // Event part + void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } + void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; } + void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } + void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } + void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; } + void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; } + void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } + + // get Event part + std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); } + IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } + IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } + IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } + std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); } + const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } + const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } + const std::string &getParamsOnClockTick () const { return _AHClockTickParams; } + + // run action on left click + void runLeftClickAction(); + + // Context menu accessor/ One for each button + void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; } + void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; } + void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; } + std::string getListMenuLeft () { return _ListMenuLeft.toString(); } + std::string getListMenuRight () { return _ListMenuRight.toString(); } + // @} + + + + int luaRunLeftClickAction(CLuaState &ls); + REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase) + REFLECT_BOOL("pushed", getPushed, setPushed); + REFLECT_STRING("col_normal", getColorAsString, setColorAsString); + REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString); + REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString); + REFLECT_RGBA("col_normal_rgba", getColor, setColor); + REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver); + REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed); + REFLECT_BOOL("frozen", getFrozen, setFrozen); + REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone); + REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick); + REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick); + REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); + REFLECT_EXPORT_END + + protected: + EType _Type; + + // State + bool _Pushed : 1; + bool _Over : 1; + bool _OverWhenPushed : 1; + bool _Frozen : 1; + bool _FrozenHalfTone : 1; + bool _ClickWhenPushed : 1; + bool _ModulateGlobalColorNormal : 1; + bool _ModulateGlobalColorPushed : 1; + bool _ModulateGlobalColorOver : 1; + bool _LeftLongClickHandled : 1; // Is it already handled ? + bool _LeftDblClickHandled : 1; + + + ///\name radio button specific + //@{ + CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference + // There is only one radio button per group that own the reference (the first one) + CCtrlBaseButton **_RBRef; // The pointer onto the reference button + //@} + + + // Colors + NLMISC::CRGBA _ColorNormal; + NLMISC::CRGBA _ColorPushed; + NLMISC::CRGBA _ColorOver; + + ///\name Long click specific + //@{ + sint64 _LeftLongClickDate; // Time we left click down + //@} + + // for double click : last date at which last left click occurred + static sint64 _LastLeftClickDate; + static NLMISC::CRefPtr _LastLeftClickButton; + + ///\name Action Handler + //@{ + IActionHandler *_AHOnOver; + CStringShared _AHOverParams; + std::string _AHOnLeftClickString; + std::string _AHOnLeftClickStringParams; + IActionHandler *_AHOnLeftClick; + CStringShared _AHLeftClickParams; + IActionHandler *_AHOnLeftDblClick; + CStringShared _AHLeftDblClickParams; + IActionHandler *_AHOnRightClick; + CStringShared _AHRightClickParams; + IActionHandler *_AHOnClockTick; + CStringShared _AHClockTickParams; + IActionHandler *_AHOnLeftLongClick; + CStringShared _AHLeftLongClickParams; + //@} + CStringShared _ListMenuLeft; + CStringShared _ListMenuRight; + + // get the colors modulated on request + NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorNormal; + if(_ModulateGlobalColorNormal) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorPushed; + if(_ModulateGlobalColorPushed) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorOver; + if(_ModulateGlobalColorOver) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + + // call it at draw + void updateOver(bool &lastOver); + virtual void elementCaptured(CCtrlBase *capturedElement); + }; + +} #endif // NL_CTRL_BASE_BUTTON_H diff --git a/code/nel/src/gui/ctrl_base_button.cpp b/code/nel/src/gui/ctrl_base_button.cpp index 39e6f0d14..2d1a61f9b 100644 --- a/code/nel/src/gui/ctrl_base_button.cpp +++ b/code/nel/src/gui/ctrl_base_button.cpp @@ -26,490 +26,495 @@ using namespace std; using namespace NLMISC; - -// *************************************************************************** -static const uint KEY_REPEAT_MIN = 100; -static const uint KEY_REPEAT_MAX = 750; - - -sint64 CCtrlBaseButton::_LastLeftClickDate = 0; -NLMISC::CRefPtr CCtrlBaseButton::_LastLeftClickButton; - - -// *************************************************************************** -CCtrlBaseButton::CCtrlBaseButton(const TCtorParam ¶m) : CCtrlBase(param), _Type(ToggleButton) +namespace { - _Pushed = _Over = false; - _Frozen = false; - _FrozenHalfTone = true; - _OverWhenPushed = true; - _ColorOver = _ColorPushed = _ColorNormal = NLMISC::CRGBA(255,255,255,255); - _ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= true; - _LeftLongClickHandled = true; - _LeftDblClickHandled = false; - _ClickWhenPushed = false; - _RBRefBut = NULL; - _RBRef = NULL; - - _AHOnOver = NULL; - _AHOnLeftClick = NULL; - _AHOnRightClick = NULL; - _AHOnClockTick = NULL; - _AHOnLeftLongClick = NULL; - _AHOnLeftDblClick = NULL; + const uint KEY_REPEAT_MIN = 100; + const uint KEY_REPEAT_MAX = 750; } - - -// *************************************************************************** -bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) +namespace NLGUI { - CXMLAutoPtr prop; - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - if (! CCtrlBase::parse(cur,parentGroup) ) - return false; + sint64 CCtrlBaseButton::_LastLeftClickDate = 0; + NLMISC::CRefPtr CCtrlBaseButton::_LastLeftClickButton; - _Over = false; - // *** try to get the NEEDED specific props - prop = xmlGetProp (cur, (xmlChar*)"button_type"); - string type; - if (prop) type = (const char*) prop; - if (type.empty() || type == "toggle_button") + // *************************************************************************** + CCtrlBaseButton::CCtrlBaseButton(const TCtorParam ¶m) : CCtrlBase(param), _Type(ToggleButton) { - _Type = ToggleButton; - } - else if (type == "push_button") - { - _Type = PushButton; - } - else if (type == "radio_button") - { - _Type = RadioButton; + _Pushed = _Over = false; + _Frozen = false; + _FrozenHalfTone = true; + _OverWhenPushed = true; + _ColorOver = _ColorPushed = _ColorNormal = NLMISC::CRGBA(255,255,255,255); + _ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= true; + _LeftLongClickHandled = true; + _LeftDblClickHandled = false; + _ClickWhenPushed = false; + _RBRefBut = NULL; + _RBRef = NULL; - initRBRef(); - if (_Pushed) - *_RBRef = this; - } - else - { - nlinfo(("cannot parse button type for button " + getId()).c_str()); + _AHOnOver = NULL; + _AHOnLeftClick = NULL; + _AHOnRightClick = NULL; + _AHOnClockTick = NULL; + _AHOnLeftLongClick = NULL; + _AHOnLeftDblClick = NULL; } - prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed"); - _Pushed = false; - if (prop) - _Pushed = convertBool(prop); - - prop= (char*) xmlGetProp (cur, (xmlChar*)"over_when_pushed"); - _OverWhenPushed = true; - if (prop) - _OverWhenPushed = convertBool(prop); - - prop= (char*) xmlGetProp (cur, (xmlChar*)"click_when_pushed"); - _ClickWhenPushed = false; - if (prop) - _ClickWhenPushed = convertBool(prop); - - // *** Read Colors - // get color normal - prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _ColorNormal = CRGBA(255,255,255,255); - if (prop) - _ColorNormal = convertColor (prop); - - // Get ColorPushed - prop= (char*) xmlGetProp( cur, (xmlChar*)"col_pushed" ); - _ColorPushed = CRGBA(255,255,255,255); - if (prop) - _ColorPushed = convertColor(prop); - - // Get ColorOver - prop= (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); - _ColorOver = CRGBA(255,255,255,255); - if (prop) - _ColorOver = convertColor(prop); - - // Default: take "global_color" param interface_element option. - _ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= getModulateGlobalColor(); - - // Read special global_color for each state - prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_normal" ); - if (prop) _ModulateGlobalColorNormal= convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_pushed" ); - if (prop) _ModulateGlobalColorPushed= convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_over" ); - if (prop) _ModulateGlobalColorOver= convertBool(prop); - // *** Read Action handlers - CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams); - CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); - CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams); - CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); - CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams); - CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams); - - // Context menu association - prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); - if (prop) + // *************************************************************************** + bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) { - _ListMenuLeft = NLMISC::toLower(std::string((const char *) prop)); - } - prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); - if (prop) - { - _ListMenuRight = NLMISC::toLower(std::string((const char *) prop)); - } - // list menu on both clicks - prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" ); - if (prop) - { - setListMenuBoth(NLMISC::toLower(std::string((const char *) prop))); - } + CXMLAutoPtr prop; - prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen"); - _Frozen = false; - if (prop) - _Frozen = convertBool(prop); - - prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen_half_tone"); - _FrozenHalfTone = true; - if (prop) - _FrozenHalfTone = convertBool(prop); - - return true; -} - - -// *************************************************************************** -void CCtrlBaseButton::setModulateGlobalColorAll(bool state) -{ - setModulateGlobalColor(state); - setModulateGlobalColorNormal(state); - setModulateGlobalColorPushed(state); - setModulateGlobalColorOver(state); -} - - -// *************************************************************************** -bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active || _Frozen) - return false; - - sint64 T1 = NLMISC::CTime::getLocalTime(); - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) - return false; - _LeftLongClickHandled = true; - } - - if (!((eventDesc.getX() >= _XReal) && - (eventDesc.getX() < (_XReal + _WReal))&& - (eventDesc.getY() > _YReal) && - (eventDesc.getY() <= (_YReal+ _HReal)))) + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + if (! CCtrlBase::parse(cur,parentGroup) ) return false; - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - if (_AHOnLeftDblClick) - { - if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay()) - { - CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams); - _LeftDblClickHandled = true; - _LastLeftClickButton = NULL; - return true; - } - } + _Over = false; - if (_AHOnLeftLongClick != NULL) - { - _LeftLongClickHandled = false; - _LeftLongClickDate = T1; - } - _LeftDblClickHandled = false; - _LastLeftClickButton = NULL; - return true; + // *** try to get the NEEDED specific props + prop = xmlGetProp (cur, (xmlChar*)"button_type"); + string type; + if (prop) type = (const char*) prop; + if (type.empty() || type == "toggle_button") + { + _Type = ToggleButton; + } + else if (type == "push_button") + { + _Type = PushButton; + } + else if (type == "radio_button") + { + _Type = RadioButton; + + initRBRef(); + if (_Pushed) + *_RBRef = this; + } + else + { + nlinfo(("cannot parse button type for button " + getId()).c_str()); } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed"); + _Pushed = false; + if (prop) + _Pushed = convertBool(prop); + + prop= (char*) xmlGetProp (cur, (xmlChar*)"over_when_pushed"); + _OverWhenPushed = true; + if (prop) + _OverWhenPushed = convertBool(prop); + + prop= (char*) xmlGetProp (cur, (xmlChar*)"click_when_pushed"); + _ClickWhenPushed = false; + if (prop) + _ClickWhenPushed = convertBool(prop); + + // *** Read Colors + // get color normal + prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _ColorNormal = CRGBA(255,255,255,255); + if (prop) + _ColorNormal = convertColor (prop); + + // Get ColorPushed + prop= (char*) xmlGetProp( cur, (xmlChar*)"col_pushed" ); + _ColorPushed = CRGBA(255,255,255,255); + if (prop) + _ColorPushed = convertColor(prop); + + // Get ColorOver + prop= (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); + _ColorOver = CRGBA(255,255,255,255); + if (prop) + _ColorOver = convertColor(prop); + + // Default: take "global_color" param interface_element option. + _ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= getModulateGlobalColor(); + + // Read special global_color for each state + prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_normal" ); + if (prop) _ModulateGlobalColorNormal= convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_pushed" ); + if (prop) _ModulateGlobalColorPushed= convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_over" ); + if (prop) _ModulateGlobalColorOver= convertBool(prop); + + + // *** Read Action handlers + CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams); + CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams); + CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams); + CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams); + CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams); + CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams); + + // Context menu association + prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); + if (prop) { - if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + _ListMenuLeft = NLMISC::toLower(std::string((const char *) prop)); + } + prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); + if (prop) + { + _ListMenuRight = NLMISC::toLower(std::string((const char *) prop)); + } + // list menu on both clicks + prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" ); + if (prop) + { + setListMenuBoth(NLMISC::toLower(std::string((const char *) prop))); + } + + prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen"); + _Frozen = false; + if (prop) + _Frozen = convertBool(prop); + + prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen_half_tone"); + _FrozenHalfTone = true; + if (prop) + _FrozenHalfTone = convertBool(prop); + + return true; + } + + + // *************************************************************************** + void CCtrlBaseButton::setModulateGlobalColorAll(bool state) + { + setModulateGlobalColor(state); + setModulateGlobalColorNormal(state); + setModulateGlobalColorPushed(state); + setModulateGlobalColorOver(state); + } + + + // *************************************************************************** + bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active || _Frozen) + return false; + + sint64 T1 = NLMISC::CTime::getLocalTime(); + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + return false; + _LeftLongClickHandled = true; + } + + if (!((eventDesc.getX() >= _XReal) && + (eventDesc.getX() < (_XReal + _WReal))&& + (eventDesc.getY() > _YReal) && + (eventDesc.getY() <= (_YReal+ _HReal)))) return false; - if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) { + if (_AHOnLeftDblClick) + { + if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay()) + { + CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams); + _LeftDblClickHandled = true; + _LastLeftClickButton = NULL; + return true; + } + } + + if (_AHOnLeftLongClick != NULL) + { + _LeftLongClickHandled = false; + _LeftLongClickDate = T1; + } _LeftDblClickHandled = false; + _LastLeftClickButton = NULL; return true; } - // Do not launch 2 times action handler if we are already pushed ! except if we want. - if (!_ClickWhenPushed) + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) { - if ((_Type == RadioButton) && _RBRef && (*_RBRef == this)) - return true; - } + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + return false; - if (_Type == RadioButton) - { - _Pushed = true; - if(_RBRef) *_RBRef = this; - } - - if (_Type == ToggleButton) - _Pushed = !_Pushed; - - /* - // RunAction - if(_AHOnLeftClick != NULL) - { - //nlinfo("clicked on %s", _Id.c_str()); - pIM->submitEvent ("button_click:"+getId());//TEMP - CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); - //pIM->submitEvent ("button_click:"+getId()); - } - */ - runLeftClickAction(); - if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example) - - // Run Menu - if (!_ListMenuLeft.empty()) - CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft); - - if (_AHOnLeftDblClick != NULL) - { - _LastLeftClickDate = T1; - _LastLeftClickButton = this; - } - - // Always return true on LeftClick. - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) - { - _LastLeftClickButton = NULL; - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) - { - _LastLeftClickButton = NULL; - bool handled= false; - if (CWidgetManager::getInstance()->getCapturePointerRight() != this) - return false; - - // RunAction - if(_AHOnRightClick != NULL) - { - handled= true; - CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); - } - if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted - // Run Menu - if (!_ListMenuRight .empty()) - { - handled= true; - CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); - } - // If not handled here, ret to parent - return handled; - } - - - } - else if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) - { - if (_AHOnClockTick != NULL) - { - CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams); - } - - if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) - { - if (!_LeftLongClickHandled) + if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled { - uint nVal = 50; - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED"); - if (pNL != NULL) - nVal = pNL->getValue32(); - uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f); - if ((T1 - _LeftLongClickDate) > repeatDelay) + _LeftDblClickHandled = false; + return true; + } + + // Do not launch 2 times action handler if we are already pushed ! except if we want. + if (!_ClickWhenPushed) + { + if ((_Type == RadioButton) && _RBRef && (*_RBRef == this)) + return true; + } + + if (_Type == RadioButton) + { + _Pushed = true; + if(_RBRef) *_RBRef = this; + } + + if (_Type == ToggleButton) + _Pushed = !_Pushed; + + /* + // RunAction + if(_AHOnLeftClick != NULL) + { + //nlinfo("clicked on %s", _Id.c_str()); + pIM->submitEvent ("button_click:"+getId());//TEMP + CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); + //pIM->submitEvent ("button_click:"+getId()); + } + */ + runLeftClickAction(); + if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example) + + // Run Menu + if (!_ListMenuLeft.empty()) + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft); + + if (_AHOnLeftDblClick != NULL) + { + _LastLeftClickDate = T1; + _LastLeftClickButton = this; + } + + // Always return true on LeftClick. + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) + { + _LastLeftClickButton = NULL; + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + { + _LastLeftClickButton = NULL; + bool handled= false; + if (CWidgetManager::getInstance()->getCapturePointerRight() != this) + return false; + + // RunAction + if(_AHOnRightClick != NULL) + { + handled= true; + CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams); + } + if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted + // Run Menu + if (!_ListMenuRight .empty()) + { + handled= true; + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); + } + // If not handled here, ret to parent + return handled; + } + + + } + else if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) + { + if (_AHOnClockTick != NULL) + { + CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams); + } + + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) + { + if (!_LeftLongClickHandled) { - _LeftLongClickHandled = true; - CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams); + uint nVal = 50; + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED"); + if (pNL != NULL) + nVal = pNL->getValue32(); + uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f); + if ((T1 - _LeftLongClickDate) > repeatDelay) + { + _LeftLongClickHandled = true; + CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams); + } } } } } + return false; } - return false; -} -// *************************************************************************** -void CCtrlBaseButton::initRBRef() -{ - if (_RBRef != NULL) return; - nlassert(_Parent); - const vector &vCB = _Parent->getControls(); - uint i = 0; - for (i = 0; i < vCB.size(); ++i) + // *************************************************************************** + void CCtrlBaseButton::initRBRef() { - CCtrlBaseButton *pBut = dynamic_cast(vCB[i]); - if (pBut && pBut->_Type == RadioButton) + if (_RBRef != NULL) return; + nlassert(_Parent); + const vector &vCB = _Parent->getControls(); + uint i = 0; + for (i = 0; i < vCB.size(); ++i) { - _RBRef = &pBut->_RBRefBut; - break; + CCtrlBaseButton *pBut = dynamic_cast(vCB[i]); + if (pBut && pBut->_Type == RadioButton) + { + _RBRef = &pBut->_RBRefBut; + break; + } + } + // If we are the first radio button of the group and not added + if (i == vCB.size()) + _RBRef = &this->_RBRefBut; + } + + // *************************************************************************** + void CCtrlBaseButton::initRBRefFromRadioButton(CCtrlBaseButton * pBut) + { + if(pBut && pBut->_Type == RadioButton) + { + _RBRef = &(pBut->_RBRefBut); + _RBRefBut=NULL; } } - // If we are the first radio button of the group and not added - if (i == vCB.size()) - _RBRef = &this->_RBRefBut; -} -// *************************************************************************** -void CCtrlBaseButton::initRBRefFromRadioButton(CCtrlBaseButton * pBut) -{ - if(pBut && pBut->_Type == RadioButton) + + // *************************************************************************** + void CCtrlBaseButton::setPushed (bool state) { - _RBRef = &(pBut->_RBRefBut); - _RBRefBut=NULL; - } -} + _Pushed = state; - -// *************************************************************************** -void CCtrlBaseButton::setPushed (bool state) -{ - _Pushed = state; - - if (_Type == RadioButton && _RBRef) - { - if (state == true) + if (_Type == RadioButton && _RBRef) { - *_RBRef = this; + if (state == true) + { + *_RBRef = this; + } + else + { + if (*_RBRef == this) // I have to be pushed to unpush me + *_RBRef = NULL; // After that : All radio buttons are NOT pushed + } + } + } + + // *************************************************************************** + void CCtrlBaseButton::setFrozen (bool state) + { + _Frozen = state; + if (_Frozen) + { + _Pushed = false; + _Over = false; + } + } + + // *************************************************************************** + void CCtrlBaseButton::setFrozenHalfTone(bool enabled) + { + _FrozenHalfTone = enabled; + } + + // *************************************************************************** + void CCtrlBaseButton::unselect() + { + if (_Type == RadioButton) + { + if (_RBRef) *_RBRef = NULL; + } + } + + + // *************************************************************************** + void CCtrlBaseButton::updateOver(bool &lastOver) + { + if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + _Over = false; + return; + } + + if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) + { + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + { + _Over = false; + } + return; + } + + const vector &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer (); + + if (!_Frozen) + { + uint32 i; + lastOver = _Over; + // show over if it is the last control that has the same father + CCtrlBase *candidate = NULL; + for (i = 0; i < rVB.size(); ++i) + { + if (rVB[i]->getParent() == this->getParent()) + { + candidate = rVB[i]; + } + } + _Over = (candidate == this); } else - { - if (*_RBRef == this) // I have to be pushed to unpush me - *_RBRef = NULL; // After that : All radio buttons are NOT pushed - } - } -} - -// *************************************************************************** -void CCtrlBaseButton::setFrozen (bool state) -{ - _Frozen = state; - if (_Frozen) - { - _Pushed = false; - _Over = false; - } -} - -// *************************************************************************** -void CCtrlBaseButton::setFrozenHalfTone(bool enabled) -{ - _FrozenHalfTone = enabled; -} - -// *************************************************************************** -void CCtrlBaseButton::unselect() -{ - if (_Type == RadioButton) - { - if (_RBRef) *_RBRef = NULL; - } -} + _Over = false; -// *************************************************************************** -void CCtrlBaseButton::updateOver(bool &lastOver) -{ - if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - _Over = false; - return; } - if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) + // *************************************************************************** + void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement) { - if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + // if not me, then reset my '_Over' + if (capturedElement != this) { _Over = false; } - return; } - const vector &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer (); - if (!_Frozen) + // *************************************************************************** + void CCtrlBaseButton::runLeftClickAction() { - uint32 i; - lastOver = _Over; - // show over if it is the last control that has the same father - CCtrlBase *candidate = NULL; - for (i = 0; i < rVB.size(); ++i) + if(_AHOnLeftClick != NULL) { - if (rVB[i]->getParent() == this->getParent()) - { - candidate = rVB[i]; - } + + //nlinfo("clicked on %s", _Id.c_str()); + CAHManager::getInstance()->submitEvent( "button_click:" + getId() ); + CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); + //pIM->submitEvent ("button_click:"+getId()); } - _Over = (candidate == this); } - else - _Over = false; - -} - -// *************************************************************************** -void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement) -{ - // if not me, then reset my '_Over' - if (capturedElement != this) + // *************************************************************************** + int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls) { - _Over = false; + const char *funcName = "onLeftClick"; + CLuaIHM::checkArgCount(ls, funcName, 0); + + runLeftClickAction(); + + return 0; } -} - - -// *************************************************************************** -void CCtrlBaseButton::runLeftClickAction() -{ - if(_AHOnLeftClick != NULL) - { - - //nlinfo("clicked on %s", _Id.c_str()); - CAHManager::getInstance()->submitEvent( "button_click:" + getId() ); - CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); - //pIM->submitEvent ("button_click:"+getId()); - } -} - -// *************************************************************************** -int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls) -{ - const char *funcName = "onLeftClick"; - CLuaIHM::checkArgCount(ls, funcName, 0); - - runLeftClickAction(); - - return 0; + } diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h index bcbd1e972..75a162dd5 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h @@ -26,9 +26,14 @@ #include "game_share/skills.h" +namespace NLGUI +{ + class CCtrlBaseButton; +} + + // *************************************************************************** class CDBCtrlSheet; -class CCtrlBaseButton; class CSBrickSheet; class CViewBitmap; class CViewText; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h index 69c1754c0..90e1a2036 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h @@ -22,11 +22,13 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" - +namespace NLGUI +{ + class CCtrlBaseButton; +} // *************************************************************************** class CViewText; -class CCtrlBaseButton; class CGroupMenu; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index 171152cfc..894a34ea8 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -23,9 +23,12 @@ #include "list_sheet_base.h" #include "dbctrl_sheet.h" +namespace NLGUI +{ + class CCtrlBaseButton; +} // *************************************************************************** -class CCtrlBaseButton; class CCtrlScroll; class CGroupContainer; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h index 4a103161b..a02708e87 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h @@ -23,11 +23,15 @@ #include "nel/gui/interface_group.h" +namespace NLGUI +{ + class CCtrlBaseButton; +} + // *************************************************************************** class CViewBitmap; class CViewText; -class CCtrlBaseButton; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h index 520a416af..e0b11b91d 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.h @@ -23,9 +23,13 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" +namespace NLGUI +{ + class CCtrlBaseButton; +} + class CGroupList; class CCtrlScroll; -class CCtrlBaseButton; // Can be used to build a chat window or anything that displays sequences of strings /** diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index 817c927ae..e0e193baa 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -25,6 +25,7 @@ namespace NLGUI { class CInterfaceElement; class CCtrlBase; + class CCtrlBaseButton; class CInterfaceGroup; } @@ -62,7 +63,7 @@ typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; typedef CInterfacePtr::TInterfacePtr CViewTextPtr; typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; -typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; +typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; typedef CInterfacePtr::TInterfacePtr CGroupContainerPtr; #endif // NL_INTERFACE_POINTER_H diff --git a/code/ryzom/client/src/libwww.h b/code/ryzom/client/src/libwww.h index 2c6ed2ae0..ec1462bc9 100644 --- a/code/ryzom/client/src/libwww.h +++ b/code/ryzom/client/src/libwww.h @@ -25,9 +25,13 @@ extern "C" #include "WWWInit.h" } +namespace NLGUI +{ + class CCtrlBaseButton; +} + class CGroupList; class CCtrlScroll; -class CCtrlBaseButton; // *************************************************************************** From 84fe4773fb10f9e5f029899b06ada01850049241 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 00:23:20 +0200 Subject: [PATCH 063/339] CHANGED: #1471 CCtrlButton is now part of the NEL GUI library. --- .../include/nel/gui}/ctrl_button.h | 1 - .../interface_v3 => nel/src/gui}/ctrl_button.cpp | 14 +++----------- code/ryzom/client/src/connection.cpp | 2 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_misc.cpp | 2 +- .../src/interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 2 +- .../client/src/interface_v3/dbgroup_combo_box.cpp | 2 +- .../client/src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../src/interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../src/interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../src/interface_v3/dbgroup_select_number.cpp | 2 +- .../client/src/interface_v3/group_container.cpp | 2 +- code/ryzom/client/src/interface_v3/group_html.cpp | 2 +- code/ryzom/client/src/interface_v3/group_html.h | 2 +- code/ryzom/client/src/interface_v3/group_map.cpp | 2 +- code/ryzom/client/src/interface_v3/group_map.h | 2 +- .../src/interface_v3/group_modal_get_key.cpp | 2 +- .../client/src/interface_v3/group_paragraph.h | 2 +- .../client/src/interface_v3/group_scrolltext.cpp | 2 +- code/ryzom/client/src/interface_v3/group_table.h | 2 +- .../client/src/interface_v3/interface_ddx.cpp | 2 +- .../client/src/interface_v3/interface_manager.cpp | 2 +- .../client/src/interface_v3/interface_parser.cpp | 2 +- .../ryzom/client/src/interface_v3/macrocmd_key.cpp | 2 +- .../client/src/interface_v3/macrocmd_manager.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../interface_v3/register_interface_elements.cpp | 2 +- .../client/src/interface_v3/task_bar_manager.cpp | 2 +- code/ryzom/client/src/login.cpp | 2 +- 30 files changed, 31 insertions(+), 40 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_button.h (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_button.cpp (90%) diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h similarity index 95% rename from code/ryzom/client/src/interface_v3/ctrl_button.h rename to code/nel/include/nel/gui/ctrl_button.h index 64b8ecab0..dbeb8fa0a 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.h +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -26,7 +26,6 @@ namespace NLGUI { class CEventDescriptor; } -class CInterfaceManager; /** * diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp similarity index 90% rename from code/ryzom/client/src/interface_v3/ctrl_button.cpp rename to code/nel/src/gui/ctrl_button.cpp index ec8db869d..6be493cf8 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -16,12 +16,11 @@ -// ---------------------------------------------------------------------------- -#include "stdpch.h" -#include "ctrl_button.h" -#include "interface_manager.h" +#include "nel/gui/ctrl_button.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" // ---------------------------------------------------------------------------- using namespace std; @@ -106,7 +105,6 @@ void CCtrlButton::draw () sint32 nTxId = -1; CRGBA color; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); @@ -248,7 +246,6 @@ void CCtrlButton::updateCoords() { if (!_Scale) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 txw, txh; rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); @@ -285,7 +282,6 @@ void CCtrlButton::setTextureOver(const std::string&name) // ---------------------------------------------------------------------------- std::string CCtrlButton::getTexture() const { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdNormal); } @@ -293,7 +289,6 @@ std::string CCtrlButton::getTexture() const // ---------------------------------------------------------------------------- std::string CCtrlButton::getTexturePushed() const { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdPushed); } @@ -301,7 +296,6 @@ std::string CCtrlButton::getTexturePushed() const // ---------------------------------------------------------------------------- std::string CCtrlButton::getTextureOver() const { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId(_TextureIdOver); } @@ -310,7 +304,6 @@ std::string CCtrlButton::getTextureOver() const sint32 CCtrlButton::getMaxUsedW() const { sint32 txw, txh; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); return txw; @@ -325,7 +318,6 @@ sint32 CCtrlButton::getMinUsedW() const // *************************************************************************** void CCtrlButton::fitTexture() { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(_TextureIdNormal, w, h); diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 1da19926a..0bf8c8222 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -64,7 +64,7 @@ // Interface part #include "interface_v3/interface_manager.h" #include "interface_v3/character_3d.h" -#include "interface_v3/ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "interface_v3/input_handler_manager.h" #include "interface_v3/group_editbox.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index ddaad5b5e..9de7ed7c4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -83,7 +83,7 @@ // Game Config #include "dbgroup_combo_box.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "../global.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 5c3fb746a..dfbbeafc3 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -17,7 +17,7 @@ #include "action_handler_misc.h" #include "interface_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_container.h" #include "group_editbox.h" #include "people_interraction.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index a4cefa3bb..8c60170b2 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -34,7 +34,7 @@ #include "group_container.h" #include "sphrase_manager.h" #include "sbrick_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "../user_entity.h" #include "skill_manager.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index d6ee00ef1..521fd3605 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "dbctrl_sheet.h" #include "view_bitmap.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "../client_cfg.h" #include "view_text.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 5dfa3810e..b861cee1d 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -21,7 +21,7 @@ #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index 77d234b12..c6b9f7a23 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -21,7 +21,7 @@ #include "dbgroup_list_sheet.h" #include "group_container.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 61687b4f7..1ec3d9420 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "view_text.h" #include "nel/gui/action_handler.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index 04c40f9d5..defdeff6c 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -22,7 +22,7 @@ #include "inventory_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "view_text.h" #include "nel/gui/action_handler.h" #include "sphrase_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index 69440ff5a..02e44236e 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -23,7 +23,7 @@ #include "dbgroup_select_number.h" #include "view_text.h" #include "view_bitmap.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 907d08553..dcc8b2a4d 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -32,7 +32,7 @@ #include "nel/gui/lua_ihm.h" #include "group_list.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "ctrl_scroll.h" #include "view_text.h" #include "view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 950990e82..254a2a2c9 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -33,7 +33,7 @@ extern "C" #include "group_container.h" #include "view_link.h" #include "ctrl_scroll.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "dbctrl_sheet.h" #include "ctrl_text_button.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 5d5fc9041..7990baa61 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -27,7 +27,7 @@ #include "nel/gui/interface_group.h" #include "group_scrolltext.h" #include "group_tree.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_table.h" typedef std::map TStyle; diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 99bf1edf6..01aabff64 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -24,7 +24,7 @@ #include "../continent.h" #include "../zone_util.h" #include "../user_entity.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "../string_manager_client.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index a4d162068..a276e5a5b 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -26,7 +26,7 @@ #include "../client_sheets/world_sheet.h" #include "nel/gui/interface_group.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "view_bitmap.h" #include "view_text.h" #include "animal_position_state.h" diff --git a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp index 06845d30f..d73729f03 100644 --- a/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp +++ b/code/ryzom/client/src/interface_v3/group_modal_get_key.cpp @@ -20,7 +20,7 @@ #include "group_modal_get_key.h" #include "interface_manager.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/misc/events.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index f2c38bd05..d73174a90 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -23,7 +23,7 @@ #include "nel/gui/group_frame.h" #include "view_text.h" #include "view_link.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" class CCtrlLink : public CCtrlButton { diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index c3321e185..411b3714f 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -24,7 +24,7 @@ #include "group_list.h" #include "view_text.h" #include "ctrl_scroll.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.h b/code/ryzom/client/src/interface_v3/group_table.h index f4aa0b8fd..7c7ac640e 100644 --- a/code/ryzom/client/src/interface_v3/group_table.h +++ b/code/ryzom/client/src/interface_v3/group_table.h @@ -23,7 +23,7 @@ #include "nel/gui/group_frame.h" #include "view_text.h" #include "view_link.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" /** * This group is used to simulate HTML cells. diff --git a/code/ryzom/client/src/interface_v3/interface_ddx.cpp b/code/ryzom/client/src/interface_v3/interface_ddx.cpp index 5447ea2cd..bf4c23515 100644 --- a/code/ryzom/client/src/interface_v3/interface_ddx.cpp +++ b/code/ryzom/client/src/interface_v3/interface_ddx.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "interface_ddx.h" #include "nel/gui/action_handler.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "nel/gui/group_modal.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 067c946ea..53af9d8e4 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -52,7 +52,7 @@ #include "view_text.h" // Ctrl #include "ctrl_scroll.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "ctrl_text_button.h" // DBCtrl #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index a8b42df12..73d1208b8 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -53,7 +53,7 @@ #include "dbview_digit.h" // Ctrl #include "ctrl_scroll.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "ctrl_col_pick.h" #include "ctrl_tooltip.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 1b91b3dd4..8eb74210a 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -24,7 +24,7 @@ #include "interface_manager.h" #include "nel/gui/action_handler.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "group_list.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 679fa5900..e66fc16d7 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -25,7 +25,7 @@ #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "dbctrl_sheet.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "group_list.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index ead0fe307..ee20006ce 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -31,7 +31,7 @@ #include "../client_chat_manager.h" #include "../string_manager_client.h" #include "nel/gui/interface_expr.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "ctrl_text_button.h" #include "filtered_chat_summary.h" #include "input_handler_manager.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 196497e65..bb9d482a8 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -32,7 +32,7 @@ #include "group_container.h" #include "group_list.h" #include "dbgroup_select_number.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "ctrl_text_button.h" #include "ctrl_col_pick.h" #include "nel/gui/ctrl_draggable.h" diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp index 5b780aa9f..0edece1a1 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -27,7 +27,7 @@ #include "nel/gui/action_handler.h" #include "group_container.h" #include "../actions_client.h" -#include "ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "interface_options_ryzom.h" diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index e730942d3..c981f083f 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -38,7 +38,7 @@ #include "interface_v3/group_editbox.h" #include "interface_v3/group_quick_help.h" #include "interface_v3/view_text.h" -#include "interface_v3/ctrl_button.h" +#include "nel/gui/ctrl_button.h" #include "interface_v3/ctrl_text_button.h" #include "sound_manager.h" #include "far_tp.h" From 892a8131ca636b1662631213dde1b8fd958bb70b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 00:49:40 +0200 Subject: [PATCH 064/339] CHANGED: #1471 CCtrlButton is now under the NLGUI namespace. --- code/nel/include/nel/gui/ctrl_button.h | 102 ++-- code/nel/src/gui/ctrl_button.cpp | 567 +++++++++--------- .../interface_v3/dbgroup_list_sheet_text.h | 6 +- .../interface_v3/dbgroup_list_sheet_trade.h | 6 +- .../client/src/interface_v3/group_container.h | 2 +- .../client/src/interface_v3/group_html.h | 6 +- 6 files changed, 352 insertions(+), 337 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h index dbeb8fa0a..f3367968b 100644 --- a/code/nel/include/nel/gui/ctrl_button.h +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -25,77 +25,77 @@ namespace NLGUI { class CEventDescriptor; -} -/** - * - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 - */ -class CCtrlButton : public CCtrlBaseButton -{ -public: - - /// Constructor - CCtrlButton(const TCtorParam ¶m) : CCtrlBaseButton(param) + /** + * + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CCtrlButton : public CCtrlBaseButton { - _Scale = false; - _Align = 0; - } + public: - // Init part - virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + /// Constructor + CCtrlButton(const TCtorParam ¶m) : CCtrlBaseButton(param) + { + _Scale = false; + _Align = 0; + } - virtual void updateCoords(); + // Init part + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords(); - virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - // Display part - virtual void draw(); + virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */); - void setTexture (const std::string&name); - void setTexturePushed (const std::string&name); - void setTextureOver (const std::string&name); + // Display part + virtual void draw(); - void fitTexture(); + void setTexture (const std::string&name); + void setTexturePushed (const std::string&name); + void setTextureOver (const std::string&name); - std::string getTexture () const; - std::string getTexturePushed () const; - std::string getTextureOver() const; + void fitTexture(); - bool isTextureValid() const { return _TextureIdNormal != -1; } + std::string getTexture () const; + std::string getTexturePushed () const; + std::string getTextureOver() const; - // test if the texture must scale - bool getScale() const { return _Scale; } - void setScale(bool scale) { _Scale = scale; } + bool isTextureValid() const { return _TextureIdNormal != -1; } + + // test if the texture must scale + bool getScale() const { return _Scale; } + void setScale(bool scale) { _Scale = scale; } - /// \from CInterfaceElement - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; + /// \from CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; - REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton) - REFLECT_STRING("texture", getTexture, setTexture); - REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed); - REFLECT_STRING("texture_over", getTextureOver, setTextureOver); - REFLECT_BOOL("scale", getScale, setScale); - REFLECT_EXPORT_END + REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton) + REFLECT_STRING("texture", getTexture, setTexture); + REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed); + REFLECT_STRING("texture_over", getTextureOver, setTextureOver); + REFLECT_BOOL("scale", getScale, setScale); + REFLECT_EXPORT_END -protected: + protected: - CViewRenderer::CTextureId _TextureIdNormal; - CViewRenderer::CTextureId _TextureIdPushed; - CViewRenderer::CTextureId _TextureIdOver; + CViewRenderer::CTextureId _TextureIdNormal; + CViewRenderer::CTextureId _TextureIdPushed; + CViewRenderer::CTextureId _TextureIdOver; -private: + private: - bool _Scale; - sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1) -}; + bool _Scale; + sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1) + }; +} #endif // RZ_CTRL_BUTTON_H diff --git a/code/nel/src/gui/ctrl_button.cpp b/code/nel/src/gui/ctrl_button.cpp index 6be493cf8..3890065b0 100644 --- a/code/nel/src/gui/ctrl_button.cpp +++ b/code/nel/src/gui/ctrl_button.cpp @@ -14,9 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - #include "nel/gui/ctrl_button.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/widget_manager.h" @@ -29,139 +26,158 @@ using namespace NL3D; NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button"); -// ---------------------------------------------------------------------------- -bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) +namespace NLGUI { - CXMLAutoPtr prop; - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - if (! CCtrlBaseButton::parse(cur,parentGroup) ) + + // ---------------------------------------------------------------------------- + bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { - string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - return false; - } - - - // *** Read Textures - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); - if (prop) - { - string TxName = (const char *) prop; - TxName = strlwr(TxName); - _TextureIdNormal.setTexture(TxName.c_str()); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); - if (prop) - { - string TxName = (const char *) prop; - TxName = strlwr(TxName); - _TextureIdPushed.setTexture(TxName.c_str()); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); - if (prop) - { - string TxName = (const char *) prop; - TxName = strlwr(TxName); - _TextureIdOver.setTexture(TxName.c_str()); - } - - // *** Misc. - prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" ); - _Scale = false; - if (prop) - _Scale = convertBool(prop); - - - prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); - _Align = 0; - if (prop) - { - const char *seekPtr = prop.getDatas(); - while (*seekPtr != 0) + CXMLAutoPtr prop; + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + if (! CCtrlBaseButton::parse(cur,parentGroup) ) { - if ((*seekPtr=='l')||(*seekPtr=='L')) - _Align &= ~1; - if ((*seekPtr=='r')||(*seekPtr=='R')) - _Align |= 1; - if ((*seekPtr=='b')||(*seekPtr=='B')) - _Align &= ~2; - if ((*seekPtr=='t')||(*seekPtr=='T')) - _Align |= 2; - ++seekPtr; + string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + return false; } - } - return true; -} - -// ---------------------------------------------------------------------------- -void CCtrlButton::draw () -{ - sint32 nTxId = -1; - CRGBA color; - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); - - // *** Detect Over - bool lastOver = false; - - updateOver(lastOver); - - - sint32 x = _XReal; - sint32 y = _YReal; - sint32 txw, txh; - // the pointer is over the button - if (_Scale) - { - x = _XReal; - y = _YReal; - txw = _WReal; - txh = _HReal; - } - else - { - x = _XReal; - y = _YReal; - } - - switch(_Type) - { - case ToggleButton: + // *** Read Textures + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); + if (prop) { - if (_Pushed) + string TxName = (const char *) prop; + TxName = strlwr(TxName); + _TextureIdNormal.setTexture(TxName.c_str()); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); + if (prop) + { + string TxName = (const char *) prop; + TxName = strlwr(TxName); + _TextureIdPushed.setTexture(TxName.c_str()); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); + if (prop) + { + string TxName = (const char *) prop; + TxName = strlwr(TxName); + _TextureIdOver.setTexture(TxName.c_str()); + } + + // *** Misc. + prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" ); + _Scale = false; + if (prop) + _Scale = convertBool(prop); + + + prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); + _Align = 0; + if (prop) + { + const char *seekPtr = prop.getDatas(); + while (*seekPtr != 0) { - nTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); - } - else - { - nTxId = _TextureIdNormal; - color = getCurrentColorNormal(globalColor); + if ((*seekPtr=='l')||(*seekPtr=='L')) + _Align &= ~1; + if ((*seekPtr=='r')||(*seekPtr=='R')) + _Align |= 1; + if ((*seekPtr=='b')||(*seekPtr=='B')) + _Align &= ~2; + if ((*seekPtr=='t')||(*seekPtr=='T')) + _Align |= 2; + ++seekPtr; } } - break; - case RadioButton: - { -// CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer(); - // Init the radio button - initRBRef(); - if (*_RBRef == this) + + return true; + } + + // ---------------------------------------------------------------------------- + void CCtrlButton::draw () + { + sint32 nTxId = -1; + CRGBA color; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); + + // *** Detect Over + bool lastOver = false; + + updateOver(lastOver); + + + sint32 x = _XReal; + sint32 y = _YReal; + sint32 txw, txh; + // the pointer is over the button + if (_Scale) + { + x = _XReal; + y = _YReal; + txw = _WReal; + txh = _HReal; + } + else + { + x = _XReal; + y = _YReal; + } + + switch(_Type) + { + case ToggleButton: { - // if it is equal to the ref value, then the button must appear pushed - nTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); + if (_Pushed) + { + nTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + nTxId = _TextureIdNormal; + color = getCurrentColorNormal(globalColor); + } } - else + break; + case RadioButton: { - if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) + // CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer(); + // Init the radio button + initRBRef(); + + if (*_RBRef == this) + { + // if it is equal to the ref value, then the button must appear pushed + nTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) + { + nTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + nTxId = _TextureIdNormal; + color = getCurrentColorNormal(globalColor); + _Pushed = false; + } + } + } + break; + case PushButton: + { + if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) { nTxId = _TextureIdPushed; color = getCurrentColorPushed(globalColor); @@ -173,175 +189,162 @@ void CCtrlButton::draw () _Pushed = false; } } + break; + default: + break; } - break; - case PushButton: + + color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); + + // Fromzen ? + if (getFrozen() && getFrozenHalfTone()) + color.A >>= 2; + + if (!_Scale) { - if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) + CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh); + if (_Align&1) + x = x + _WReal - txw; + if (_Align&2) + y = y + _HReal - txh; + } + rVR.drawRotFlipBitmap ( _RenderLayer, x, y, txw, txh, + 0, false, + nTxId, + color ); + + if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this))) + return; + + + + if (_Over) + { + + if ((lastOver == false) && (_AHOnOver != NULL)) + CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); + + // the pointer is over the button + color= getCurrentColorOver(globalColor); + color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); + + // Frozen ? + if (getFrozen()) + color.A >>= 2; + + // draw the over. force upper layer to avoid problem with DXTC/tga + rVR.drawRotFlipBitmap ( _RenderLayer+1, x, y, txw, txh, + 0, false, + _TextureIdOver, + color ); + } + } + + + // ---------------------------------------------------------------------------- + void CCtrlButton::updateCoords() + { + if (!_Scale) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 txw, txh; + rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); + _W = txw; + _H = txh; + } + CViewBase::updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CCtrlButton::setTexture(const std::string&name) + { + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureIdNormal.setTexture(name.c_str()); + } + + // ---------------------------------------------------------------------------- + void CCtrlButton::setTexturePushed(const std::string&name) + { + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureIdPushed.setTexture(name.c_str()); + } + + // ---------------------------------------------------------------------------- + void CCtrlButton::setTextureOver(const std::string&name) + { + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureIdOver.setTexture(name.c_str()); + } + + // ---------------------------------------------------------------------------- + std::string CCtrlButton::getTexture() const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId(_TextureIdNormal); + } + + // ---------------------------------------------------------------------------- + std::string CCtrlButton::getTexturePushed() const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId(_TextureIdPushed); + } + + // ---------------------------------------------------------------------------- + std::string CCtrlButton::getTextureOver() const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId(_TextureIdOver); + } + + // *************************************************************************** + sint32 CCtrlButton::getMaxUsedW() const + { + sint32 txw, txh; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); + return txw; + } + + // *************************************************************************** + sint32 CCtrlButton::getMinUsedW() const + { + return getMaxUsedW(); + } + + // *************************************************************************** + void CCtrlButton::fitTexture() + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 w, h; + rVR.getTextureSizeFromId(_TextureIdNormal, w, h); + setW(w); + setH(h); + } + + // *************************************************************************** + bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col) + { + if (_AHOnLeftClickString == "browse") + { + if (!_AHOnLeftClickStringParams.empty()) { - nTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); + texName = "@curs_pick.tga@"+_AHOnLeftClickStringParams; } else { - nTxId = _TextureIdNormal; - color = getCurrentColorNormal(globalColor); - _Pushed = false; + texName = "curs_pick.tga"; } + rot= 0; + col = CRGBA::White; + return true; } - break; - default: - break; + + return false; } - color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); - - // Fromzen ? - if (getFrozen() && getFrozenHalfTone()) - color.A >>= 2; - - if (!_Scale) - { - CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh); - if (_Align&1) - x = x + _WReal - txw; - if (_Align&2) - y = y + _HReal - txh; - } - rVR.drawRotFlipBitmap ( _RenderLayer, x, y, txw, txh, - 0, false, - nTxId, - color ); - - if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this))) - return; - - - - if (_Over) - { - - if ((lastOver == false) && (_AHOnOver != NULL)) - CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); - - // the pointer is over the button - color= getCurrentColorOver(globalColor); - color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); - - // Frozen ? - if (getFrozen()) - color.A >>= 2; - - // draw the over. force upper layer to avoid problem with DXTC/tga - rVR.drawRotFlipBitmap ( _RenderLayer+1, x, y, txw, txh, - 0, false, - _TextureIdOver, - color ); - } } - -// ---------------------------------------------------------------------------- -void CCtrlButton::updateCoords() -{ - if (!_Scale) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 txw, txh; - rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); - _W = txw; - _H = txh; - } - CViewBase::updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CCtrlButton::setTexture(const std::string&name) -{ -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureIdNormal.setTexture(name.c_str()); -} - -// ---------------------------------------------------------------------------- -void CCtrlButton::setTexturePushed(const std::string&name) -{ -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureIdPushed.setTexture(name.c_str()); -} - -// ---------------------------------------------------------------------------- -void CCtrlButton::setTextureOver(const std::string&name) -{ -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureIdOver.setTexture(name.c_str()); -} - -// ---------------------------------------------------------------------------- -std::string CCtrlButton::getTexture() const -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId(_TextureIdNormal); -} - -// ---------------------------------------------------------------------------- -std::string CCtrlButton::getTexturePushed() const -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId(_TextureIdPushed); -} - -// ---------------------------------------------------------------------------- -std::string CCtrlButton::getTextureOver() const -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId(_TextureIdOver); -} - -// *************************************************************************** -sint32 CCtrlButton::getMaxUsedW() const -{ - sint32 txw, txh; - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh); - return txw; -} - -// *************************************************************************** -sint32 CCtrlButton::getMinUsedW() const -{ - return getMaxUsedW(); -} - -// *************************************************************************** -void CCtrlButton::fitTexture() -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 w, h; - rVR.getTextureSizeFromId(_TextureIdNormal, w, h); - setW(w); - setH(h); -} - -// *************************************************************************** -bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col) -{ - if (_AHOnLeftClickString == "browse") - { - if (!_AHOnLeftClickStringParams.empty()) - { - texName = "@curs_pick.tga@"+_AHOnLeftClickStringParams; - } - else - { - texName = "curs_pick.tga"; - } - rot= 0; - col = CRGBA::White; - return true; - } - - return false; -} diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index ef1a00f9d..f27dd02e7 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -27,9 +27,13 @@ #include "dbctrl_sheet.h" #include "view_text.h" +namespace NLGUI +{ + class CCtrlButton; +} + // *************************************************************************** -class CCtrlButton; class CCtrlScroll; class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h index 54b7dba75..23c96c0c3 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h @@ -23,9 +23,13 @@ #include "dbgroup_list_sheet_text.h" #include "game_share/bot_chat_types.h" +namespace NLGUI +{ + class CCtrlButton; +} + // *************************************************************************** -class CCtrlButton; class CCtrlScroll; class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 330342ed1..bd23a8b38 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -26,10 +26,10 @@ namespace NLGUI { class CEventDescriptorLocalised; + class CCtrlButton; } class CInterfaceList; -class CCtrlButton; class CCtrlScroll; class CViewText; class COptionsContainerInsertion; diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 7990baa61..333137651 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -37,9 +37,13 @@ extern "C" #include "WWWInit.h" } +namespace NLGUI +{ + class CCtrlButton; +} + class CGroupList; class CCtrlScroll; -class CCtrlButton; class CDBGroupComboBox; class CGroupParagraph; From 4bde602411a7e704ee918e054db550c09c588f7c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 02:06:53 +0200 Subject: [PATCH 065/339] CHANGED: #1471 CCtrlScroll is now part of NELGUI, and is under the NLGUI namespace. Also added a new class CGroupSubMenuBase. --- code/nel/include/nel/gui/ctrl_scroll.h | 200 ++++ code/nel/include/nel/gui/group_submenu_base.h | 48 + code/nel/include/nel/gui/widget_manager.h | 3 + code/nel/src/gui/ctrl_scroll.cpp | 1062 +++++++++++++++++ code/nel/src/gui/group_submenu_base.cpp | 47 + .../client/src/interface_v3/ctrl_scroll.cpp | 1058 ---------------- .../client/src/interface_v3/ctrl_scroll.h | 196 --- .../src/interface_v3/dbgroup_list_sheet.h | 2 +- .../interface_v3/dbgroup_list_sheet_text.h | 2 +- .../interface_v3/dbgroup_list_sheet_trade.h | 4 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_container.h | 2 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_html.h | 2 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../client/src/interface_v3/group_menu.h | 12 +- .../src/interface_v3/group_scrolltext.cpp | 2 +- .../src/interface_v3/group_scrolltext.h | 2 +- .../src/interface_v3/interface_config.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/list_sheet_base.h | 5 +- .../register_interface_elements.cpp | 6 +- code/ryzom/client/src/libwww.h | 2 +- 25 files changed, 1392 insertions(+), 1277 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_scroll.h create mode 100644 code/nel/include/nel/gui/group_submenu_base.h create mode 100644 code/nel/src/gui/ctrl_scroll.cpp create mode 100644 code/nel/src/gui/group_submenu_base.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll.h diff --git a/code/nel/include/nel/gui/ctrl_scroll.h b/code/nel/include/nel/gui/ctrl_scroll.h new file mode 100644 index 000000000..c20e41e4e --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_scroll.h @@ -0,0 +1,200 @@ +// Ryzom - MMORPG Framework +// 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 RZ_CTRL_SCROLL_H +#define RZ_CTRL_SCROLL_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/ctrl_scroll_base.h" + + +namespace NLGUI +{ + + /** + * Class handling scollbar function + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver + { + + public: + DECLARE_UI_CLASS( CCtrlScroll ) + CCtrlScroll(const TCtorParam ¶m); + ~CCtrlScroll(); + + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + virtual void draw(); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + void setTarget (CInterfaceGroup *pIG); + // Return the delta value the track has moved + sint32 moveTrackX (sint32 dx); + sint32 moveTrackY (sint32 dy); + + /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. + * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) + */ + void moveTargetX (sint32 dx); + void moveTargetY (sint32 dy); + + void setAlign (sint32 nAlign) { _Aligned = nAlign; } + // invert the factor for target + void setInverted(bool invert) { _Inverted = invert; } + + void setTextureBottomOrLeft (const std::string &txName); + void setTextureMiddle (const std::string &txName); + void setTextureTopOrRight (const std::string &txName); + + void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; } + void setTextureMiddle (sint32 txid) { _TxIdM = txid; } + void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR) + void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; } + + // number scroller + sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; } + // NB: the value is clamped (see setMinMax) and stepped (see setStepValue()) + void setValue(sint32 value); + void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; } + void setStepValue(uint32 step) { _StepValue= step; } + + void setTrackPos(sint32 pos); + sint32 getTrackPos() const { return _TrackPos; } + sint32 getTrackSize() const { return _TrackSize; } + // dummy set for track size (forlua export) + void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); } + + + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + int luaSetTarget(CLuaState &ls); + int luaEnsureVisible(CLuaState &ls); + + // name + void setName(const std::string & val) {_Name = val;} + std::string getName() const {return _Name;} + + // max + void setMax(sint32 max) {_Max = max;} + sint32 getMax() const {return _Max;} + + REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase) + REFLECT_LUA_METHOD("setTarget", luaSetTarget) + REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible); + REFLECT_SINT32("value", getValue, setValue); + REFLECT_SINT32("trackPos", getTrackPos, setTrackPos); + REFLECT_SINT32("trackSize", getTrackSize, setTrackSize); + REFLECT_STRING("name", getName, setName); + REFLECT_SINT32("max", getMax, setMax); + REFLECT_EXPORT_END + + /** Ensure that a child element be visible into the frame through which + * its parent group is displayed. + * Example : Had we a list of items for which we want some item 'itemPtr' to have its top position + * matching the middle of the list, we would do : + * this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx); + * + * The scrollbar will be moved accordingly. + */ + void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot); + + + protected: + + CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db + sint32 _Value; // Or we can use a normal value + sint32 _InitialValue; + + sint32 _Min, _Max; + std::string _AHOnScroll; + std::string _AHOnScrollParams; + // + std::string _AHOnScrollEnd; + std::string _AHOnScrollEndParams; + // + // + std::string _AHOnScrollCancel; + std::string _AHOnScrollCancelParams; + + + sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right + + sint32 _TrackDispPos; + sint32 _TrackPos; + sint32 _TrackSize; + sint32 _TrackSizeMin; + + sint32 _MouseDownOffsetX; + sint32 _MouseDownOffsetY; + + sint32 _TxIdB; // Same as Left if Horizontal sb + sint32 _TxIdM; + sint32 _TxIdT; // Same as Right if Horizontal sb + + uint8 _TileM; + + sint32 _LastTargetHReal; + sint32 _LastTargetMaxHReal; + sint32 _LastTargetOfsY; + sint32 _LastTargetWReal; + sint32 _LastTargetMaxWReal; + sint32 _LastTargetOfsX; + + bool _Vertical : 1; // true if vertical track bar + bool _IsDBLink : 1; + bool _ObserverOn : 1; + bool _Inverted : 1; + bool _MouseDown : 1; + bool _CallingAH : 1; + bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button + bool _Frozen : 1; + + // For Target Scroller only: the target offset step in pixel. + sint32 _TargetStepX; + sint32 _TargetStepY; + + // For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step + uint32 _StepValue; + + // Slider's name + std::string _Name; + + void computeTargetOfsFromPos(); + + // from IPropertyObserver + virtual void update(NLMISC::ICDBNode *node); + + // step the value, and clamp it + void normalizeValue(sint32 &value); + + void runAH(const std::string &name, const std::string ¶ms); + + }; +} + +#endif // RZ_CTRL_SCROLL_H + +/* End of ctrl_scroll.h */ + + diff --git a/code/nel/include/nel/gui/group_submenu_base.h b/code/nel/include/nel/gui/group_submenu_base.h new file mode 100644 index 000000000..9489109f8 --- /dev/null +++ b/code/nel/include/nel/gui/group_submenu_base.h @@ -0,0 +1,48 @@ +// Ryzom - MMORPG Framework +// 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_SUBMENU_BASE +#define GROUP_SUBMENU_BASE + +#include "nel/gui/group_frame.h" + +namespace NLGUI +{ + + class CGroupSubMenuBase : public CGroupFrame + { + public: + DECLARE_UI_CLASS( CGroupSubMenuBase ) + + CGroupSubMenuBase( const TCtorParam ¶m ); + ~CGroupSubMenuBase(); + + virtual void openSubMenu( sint32 nb ); + virtual void hideSubMenus(); + + REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame ) + REFLECT_EXPORT_END + + protected: + + private: + + }; + +} + +#endif + diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index a5a7b45b8..1c15ac357 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -20,6 +20,9 @@ #include #include +#include +#include "nel/misc/smart_ptr.h" +#include "nel/misc/rgba.h" #include "nel/misc/types_nl.h" #include "nel/gui/interface_common.h" diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp new file mode 100644 index 000000000..597ccc3cd --- /dev/null +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -0,0 +1,1062 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/widget_manager.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/ctrl_scroll.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/group_submenu_base.h" +#include "nel/gui/lua_ihm.h" + +using namespace NLMISC; +using namespace std; + +NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); + +namespace NLGUI +{ + + // ------------------------------------------------------------------------------------------------ + CCtrlScroll::CCtrlScroll(const TCtorParam ¶m) + : CCtrlScrollBase(param) + { + _Vertical = true; + _Aligned = 1; + _TrackPos = 0; + _TrackDispPos = 0; + _TrackSize = _TrackSizeMin = 16; + _Min = 0; + _Max = 100; + _Value = 0; + _InitialValue = 0; + _MouseDown = false; + _CallingAH = false; + _Cancelable = false; + _Target = NULL; + _Inverted = false; + _IsDBLink = false; + _LastTargetHReal = 0; + _LastTargetMaxHReal = 0; + _LastTargetWReal = 0; + _LastTargetMaxWReal = 0; + _LastTargetOfsX = 0; + _LastTargetOfsY = 0; + _ObserverOn = true; + _TargetStepX = 1; + _TargetStepY = 1; + _StepValue = 0; + _TileM = false; + _Frozen = false; + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::runAH(const std::string &name, const std::string ¶ms) + { + if (name.empty()) return; + if (_CallingAH) return; // avoid infinite loop + _CallingAH = true; + CAHManager::getInstance()->runActionHandler(name, this, params); + _CallingAH = false; + } + + // ------------------------------------------------------------------------------------------------ + CCtrlScroll::~CCtrlScroll() + { + if (_IsDBLink) + { + ICDBNode::CTextId textId; + _DBLink.getNodePtr()->removeObserver(this, textId); + } + } + + // ------------------------------------------------------------------------------------------------ + bool CCtrlScroll::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) + { + if (!CCtrlBase::parse(node, parentGroup)) + return false; + + CXMLAutoPtr prop; + // Read textures + prop = (char*) xmlGetProp( node, (xmlChar*)"tx_bottomleft" ); + if(prop) setTextureBottomOrLeft(string((const char*)prop)); + else setTextureBottomOrLeft ("w_scroll_l0_b.tga"); + + prop = (char*) xmlGetProp( node, (xmlChar*)"tx_middle" ); + if(prop) setTextureMiddle(string((const char*)prop)); + else setTextureMiddle ("w_scroll_l0_m.tga"); + + prop = (char*) xmlGetProp( node, (xmlChar*)"tx_topright" ); + if(prop) setTextureTopOrRight(string((const char*)prop)); + else setTextureTopOrRight ("w_scroll_l0_t.tga"); + + // Read properties + prop = (char*) xmlGetProp( node, (xmlChar*)"vertical" ); + if (prop) _Vertical = convertBool((const char*)prop); + + prop = (char*) xmlGetProp (node, (xmlChar*)"align"); + _Aligned = 1; + if (prop) + { + if (stricmp(prop, "T") == 0) _Aligned = 0; + else if (stricmp(prop, "B") == 0) _Aligned = 1; + else if (stricmp(prop, "L") == 0) _Aligned = 2; + else if (stricmp(prop, "R") == 0) _Aligned = 3; + } + + prop = (char*) xmlGetProp( node, (xmlChar*)"min" ); + if (prop) fromString((const char*)prop, _Min); + + prop = (char*) xmlGetProp( node, (xmlChar*)"max" ); + if (prop) fromString((const char*)prop, _Max); + + prop = (char*) xmlGetProp( node, (xmlChar*)"value" ); + if (prop) + { + if ( isdigit(*prop) || *prop=='-') + { + _IsDBLink = false; + fromString((const char*)prop, _Value); + } + else + { + _IsDBLink = true; + _DBLink.link(prop); + ICDBNode::CTextId textId; + _DBLink.getNodePtr()->addObserver(this, textId); + + } + } + + prop = (char*) xmlGetProp( node, (xmlChar*)"tracksize" ); + if (prop) fromString((const char*)prop, _TrackSize); + + // Read Action handlers + prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" ); + if (prop) _AHOnScroll = NLMISC::strlwr(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"params" ); + if (prop) _AHOnScrollParams = string((const char*)prop); + // + prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" ); + if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" ); + if (prop) _AHOnScrollEndParams = string((const char*)prop); + // + prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" ); + if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" ); + if (prop) _AHOnScrollCancelParams = string((const char*)prop); + + + // auto-target + prop = (char*) xmlGetProp( node, (xmlChar*)"target" ); + if (prop) + { + CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); + if(group == NULL) + group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop)); + + if(group != NULL) + setTarget (group); + } + + + // auto-step + prop = (char*) xmlGetProp( node, (xmlChar*)"target_stepx" ); + if(prop) fromString((const char*)prop, _TargetStepX); + prop = (char*) xmlGetProp( node, (xmlChar*)"target_stepy" ); + if(prop) fromString((const char*)prop, _TargetStepY); + _TargetStepX= max((sint32)1, _TargetStepX); + _TargetStepY= max((sint32)1, _TargetStepY); + + // Scroll Step + prop = (char*) xmlGetProp( node, (xmlChar*)"step_value" ); + if(prop) fromString((const char*)prop, _StepValue); + + prop = (char*) xmlGetProp( node, (xmlChar*)"cancelable" ); + if (prop) _Cancelable = convertBool(prop); + + prop= (char*) xmlGetProp (node, (xmlChar*)"frozen"); + _Frozen = false; + if (prop) + _Frozen = convertBool(prop); + + + return true; + } + + // ------------------------------------------------------------------------------------------------ + + int CCtrlScroll::luaSetTarget(CLuaState &ls) + { + const char *funcName = "setTarget"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + std::string targetId = ls.toString(1); + + CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(targetId)); + if(group != NULL) + { + setTarget (group); + } + + return 0; + } + + void CCtrlScroll::updateCoords() + { + if (_Target) + { + // update only if visible + if (_Target->getActive()) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 w, h; + rVR.getTextureSizeFromId (_TxIdB, w, h); + + if (_Vertical) + { + _W = w; + _H = _Target->getMaxHReal(); + } + else + { + _W = _Target->getMaxWReal(); + _H = h; + } + + CCtrlBase::updateCoords (); + if (_Vertical) + { + if(_Target->getHReal()!=_LastTargetHReal || _Target->getMaxHReal()!=_LastTargetMaxHReal || + _Target->getOfsY() != _LastTargetOfsY + ) + { + _LastTargetHReal= _Target->getHReal(); + _LastTargetMaxHReal= _Target->getMaxHReal(); + _LastTargetOfsY = _Target->getOfsY(); + + // Activate only if needed + setActive(_Target->getHReal() > _Target->getMaxHReal()); + CCtrlBase::updateCoords(); + + // Calculate size of the track button + if ((_Target->getHReal() <= _Target->getMaxHReal()) || (_Target->getHReal() == 0)) + { + _TrackSize = _Target->getMaxHReal(); + } + else + { + float factor = (float)_Target->getMaxHReal() / (float)_Target->getHReal(); + factor = _TrackSizeMin + factor * (this->getHReal() - _TrackSizeMin); + _TrackSize = (sint32)factor; + } + // Calculate pos of the track button + if (_Target->getHReal() <= _Target->getMaxHReal()) + { + if (_Aligned == 1) // BOTTOM + _TrackPos = 0; + else // TOP + _TrackPos = getHReal()-_TrackSize; + } + else + { + if (_Aligned == 1) // BOTTOM + { + float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); + factor = -(float)_Target->getOfsY() / factor; + if (factor < 0.0f) factor = 0.0f; + if (factor > 1.0f) factor = 1.0f; + factor = factor * (getHReal()-_TrackSize); + _TrackPos = (sint32)factor; + } + else // TOP + { + float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); + factor = (float)_Target->getOfsY() / factor; + if (factor < 0.0f) factor = 0.0f; + if (factor > 1.0f) factor = 1.0f; + sint32 hreal = getHReal(); + factor = (1.0f-factor) * (hreal - _TrackSize); + _TrackPos = (sint32)factor; + } + } + + // invalidate coords. + computeTargetOfsFromPos(); + } + } + else // Horizontal Tracker + { + if(_Target->getWReal()!=_LastTargetWReal || _Target->getMaxWReal()!=_LastTargetMaxWReal || + _Target->getOfsX() != _LastTargetOfsX) + { + _LastTargetWReal= _Target->getWReal(); + _LastTargetMaxWReal= _Target->getMaxWReal(); + _LastTargetOfsX = _Target->getOfsX(); + + // Activate only if needed + setActive(_Target->getWReal() > _Target->getMaxWReal()); + CCtrlBase::updateCoords(); + + // Calculate size of the track button + if ((_Target->getWReal() <= _Target->getMaxWReal()) || (_Target->getWReal() == 0)) + { + _TrackSize = _Target->getMaxWReal(); + } + else + { + float factor = (float)_Target->getMaxWReal() / (float)_Target->getWReal(); + factor = _TrackSizeMin + factor * (this->getWReal() - _TrackSizeMin); + _TrackSize = (sint32)factor; + } + // Calculate pos of the track button + if (_Target->getWReal() <= _Target->getMaxWReal()) + { + if (_Aligned == 2) // LEFT + _TrackPos = 0; + else // RIGHT + _TrackPos = getWReal()-_TrackSize; + } + else + { + if (_Aligned == 2) // LEFT + { + float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); + factor = -(float)_Target->getOfsX() / factor; + if (factor < 0.0f) factor = 0.0f; + if (factor > 1.0f) factor = 1.0f; + factor = factor * (getWReal()-_TrackSize); + _TrackPos = (sint32)factor; + } + else // RIGHT + { + float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); + factor = (float)_Target->getOfsX() / factor; + if (factor < 0.0f) factor = 0.0f; + if (factor > 1.0f) factor = 1.0f; + sint32 hreal = getWReal(); + factor = (1.0f-factor) * (hreal - _TrackSize); + _TrackPos = (sint32)factor; + } + } + + // invalidate coords. + computeTargetOfsFromPos(); + } + } + } + // reset cache + else + { + _LastTargetHReal= 0; + _LastTargetMaxHReal= 0; + _LastTargetWReal= 0; + _LastTargetMaxWReal= 0; + _LastTargetOfsX = 0; + _LastTargetOfsY = 0; + setActive(false); + } + } + else + { + CCtrlBase::updateCoords (); + if (_IsDBLink) + _Value = _DBLink.getSInt32(); + if (_Vertical) + { + float factor; + if (_Aligned == 1) // BOTTOM + factor = ((float)_Value-_Min) / (_Max-_Min); + else // TOP + factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); + factor *= (this->getHReal() - _TrackSize); + + _TrackDispPos = (sint32)factor; + } + else + { + float factor; + if (_Aligned == 2) // LEFT + factor = ((float)_Value-_Min) / (_Max-_Min); + else // RIGHT + factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); + factor *= (this->getWReal() - _TrackSize); + + _TrackDispPos = (sint32)factor; + } + } + CCtrlBase::updateCoords (); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::draw() + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + CRGBA col = CWidgetManager::getInstance()->getGlobalColorForContent(); + + if (_Target) + { + if (_Vertical) + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos, _WReal, 4, 0, false, _TxIdB, col ); + if (_TileM == 0) + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, col ); + else + rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal, _YReal+_TrackPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, _TileM-1, col ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos+_TrackSize-4, _WReal, 4, 0, false, _TxIdT, col ); + } + else + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos, _YReal, 4, _HReal, 0, false, _TxIdB, col ); + if (_TileM == 0) + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, col ); + else + rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal+_TrackPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, _TileM-1, col ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos+_TrackSize-4, _YReal, 4, _HReal, 0, false, _TxIdT, col ); + } + } + else + { + if (_Vertical) + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos, _WReal, 4, 0, false, _TxIdB, col ); + if (_TileM == 0) + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, col ); + else + rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal, _YReal+_TrackDispPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, _TileM-1, col ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos+_TrackSize-4, _WReal, 4, 0, false, _TxIdT, col ); + } + else + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos, _YReal, 4, _HReal, 0, false, _TxIdB, col ); + if (_TileM == 0) + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, col ); + else + rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal+_TrackDispPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, _TileM-1, col ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos+_TrackSize-4, _YReal, 4, _HReal, 0, false, _TxIdT, col ); + } + } + } + + // ------------------------------------------------------------------------------------------------ + bool CCtrlScroll::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active || _Frozen) + return false; + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && + (!((eventDesc.getX() >= _XReal) && + (eventDesc.getX() < (_XReal + _WReal))&& + (eventDesc.getY() > _YReal) && + (eventDesc.getY() <= (_YReal+ _HReal))))) + return false; + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + _MouseDown = true; + _InitialValue = getValue(); + if (!_Target) + _TrackPos = _TrackDispPos; + _MouseDownOffsetX = eventDesc.getX() - (getXReal() + (_Vertical ? 0 : _TrackPos)); + _MouseDownOffsetY = eventDesc.getY() - (getYReal() + (_Vertical ? _TrackPos : 0)); + + // if target is a menu, hidde its sub menus + if(_Target && _Target->getParent()) + { + CGroupSubMenuBase *menu = dynamic_cast(_Target->getParent()); + if(menu) + menu->hideSubMenus(); + } + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + _MouseDown = false; + runAH(_AHOnScrollEnd, _AHOnScrollEndParams.empty() ? _AHOnScrollParams : _AHOnScrollEndParams); // backward compatibility + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown && _MouseDown && _Cancelable) + { + _MouseDown = false; + setValue(_InitialValue); + runAH(_AHOnScrollCancel, _AHOnScrollCancelParams); // backward compatibility + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) + { + if (_MouseDown) + { + sint32 dx = eventDesc.getX() - (getXReal() + (_Vertical ? 0 : _TrackPos) + _MouseDownOffsetX); + sint32 dy = eventDesc.getY() - (getYReal() + (_Vertical ? _TrackPos : 0 ) + _MouseDownOffsetY); + if (dx != 0) moveTrackX (dx); + if (dy != 0) moveTrackY (dy); + } + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && _Vertical) + { + moveTrackY (eventDesc.getWheel() * 12); + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setTarget (CInterfaceGroup *pIG) + { + _Target = pIG; + + if (_Vertical) + { + if (_Target->getPosRef()&Hotspot_Tx) + _Aligned = 0; + else + _Aligned = 1; + + if (_Target->getPosRef()&Hotspot_Tx) + _Inverted = true; + else + _Inverted = true; + } + else + { + if (_Target->getPosRef()&Hotspot_xL) + _Aligned = 2; + else + _Aligned = 3; + + if (_Target->getPosRef()&Hotspot_xL) + _Inverted = true; + else + _Inverted = true; + } + } + // ------------------------------------------------------------------------------------------------ + sint32 CCtrlScroll::moveTrackX (sint32 dx) + { + if (_Vertical) + return 0; + if ((getWReal()-_TrackSize) <= 0) + return 0; + + sint32 newtpos; + sint32 tpos = _TrackPos; + sint32 tsize = _TrackSize; + + // Limit the scroller to the defined area + newtpos = tpos + dx; + if (newtpos < 0) newtpos = 0; + if (newtpos > (getWReal()-tsize)) newtpos = (getWReal()-tsize); + dx = newtpos - tpos; + + if (_Target) + { + _TrackPos = newtpos; + + computeTargetOfsFromPos(); + } + else // This is a number scroller + { + float factor = (float)(_Max - _Min); + + if (_Aligned == 2) // LEFT + factor = -factor * newtpos / (float)(getWReal()-tsize) - _Min; + else // RIGHT + factor = factor * (1.0f-(newtpos / (float)(getWReal()-tsize))) + _Min; + + _TrackPos = newtpos; + + if (_Aligned == 2) // LEFT + _Value = (sint32) (_Inverted ? factor : -factor); + else // RIGHT + _Value = (sint32) (_Inverted ? factor : -factor); + + // step and clamp value + normalizeValue(_Value); + + { + float factor; + if (_Aligned == 2) // LEFT + factor = ((float)_Value-_Min) / (_Max-_Min); + else // RIGHT + factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); + factor *= (this->getWReal() - _TrackSize); + + _TrackDispPos = (sint32)factor; + } + + if (_IsDBLink) + { + _ObserverOn = false; + _DBLink.setSInt32 (_Value); + _ObserverOn = true; + } + } + + // Launch the scroller event if any + runAH(_AHOnScroll, _AHOnScrollParams); + + return dx; + } + + // ------------------------------------------------------------------------------------------------ + sint32 CCtrlScroll::moveTrackY (sint32 dy) + { + if (!_Vertical) + return 0; + if ((getHReal()-_TrackSize) <= 0) + return 0; + + sint32 newtpos; + sint32 tpos = _TrackPos; + sint32 tsize = _TrackSize; + + // Limit the scroller to the defined area + newtpos = tpos + dy; + if (newtpos < 0) newtpos = 0; + if (newtpos > (getHReal()-tsize)) newtpos = (getHReal()-tsize); + dy = newtpos - tpos; + + if (_Target) + { + _TrackPos = newtpos; + + computeTargetOfsFromPos(); + } + else // This is a number scroller + { + float factor = (float)(_Max - _Min); + + if (_Aligned == 1) // BOTTOM + factor = -factor * newtpos / (float)(getHReal()-tsize) - _Min; + else // TOP + factor = factor * (1.0f-(newtpos / (float)(getHReal()-tsize))) + _Min; + + _TrackPos = newtpos; + + if (_Aligned == 1) // BOTTOM + _Value = (sint32) (_Inverted ? factor : -factor); + else // TOP + _Value = (sint32) (_Inverted ? factor : -factor); + + // step and clamp value + normalizeValue(_Value); + + { + float factor; + if (_Aligned == 1) // BOTTOM + factor = ((float)_Value-_Min) / (_Max-_Min); + else // TOP + factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); + factor *= (this->getHReal() - _TrackSize); + + _TrackDispPos = (sint32)factor; + } + + if (_IsDBLink) + { + _ObserverOn = false; + _DBLink.setSInt32 (_Value); + _ObserverOn = true; + } + } + + // Launch the scroller event if any + runAH(_AHOnScroll, _AHOnScrollParams); + + return dy; + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TxIdB = rVR.getTextureIdFromName(txName); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setTextureMiddle (const std::string &txName) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TxIdM = rVR.getTextureIdFromName(txName); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setTextureTopOrRight (const std::string &txName) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TxIdT = rVR.getTextureIdFromName(txName); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setValue(sint32 value) + { + normalizeValue(value); + + if (_IsDBLink) + { + _ObserverOn = false; + _DBLink.setSInt32(value); + _ObserverOn = true; + } + else + { + _Value = value; + } + invalidateCoords(); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::setTrackPos(sint32 pos) + { + if (_Vertical) + { + moveTrackY(pos - _TrackPos); + } + else + { + moveTrackX(pos - _TrackPos); + } + invalidateCoords(); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::computeTargetOfsFromPos() + { + if(_Vertical) + { + float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); + + if (_Aligned == 1) // BOTTOM + factor = -factor * _TrackPos / favoid0((float)(getHReal()-_TrackSize)); + else // TOP + factor = factor * (1.0f-(_TrackPos / favoid0((float)(getHReal()-_TrackSize)))); + + // Compute Steped target + sint32 nexOfsY= (sint32) (_Inverted ? factor : -factor); + if(_TargetStepY>1) + nexOfsY= ((nexOfsY+_TargetStepY/2)/_TargetStepY) * _TargetStepY; + _Target->setOfsY (nexOfsY); + _LastTargetOfsY = nexOfsY; + + // invalidate only XReal/YReal, doing only 1 pass + _Target->invalidateCoords(1); + } + else + { + float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); + + if (_Aligned == 2) // LEFT + factor = -factor * _TrackPos / favoid0((float)(getWReal()-_TrackSize)); + else // RIGHT + factor = factor * (1.0f-(_TrackPos / favoid0((float)(getWReal()-_TrackSize)))); + + // Compute Steped target + sint32 nexOfsX= (sint32) (_Inverted ? factor : -factor); + if(_TargetStepX>1) + nexOfsX= ((nexOfsX+_TargetStepX/2)/_TargetStepX) * _TargetStepX; + _Target->setOfsX (nexOfsX); + _LastTargetOfsX = nexOfsX; + + // invalidate only XReal/YReal, doing only 1 pass + _Target->invalidateCoords(1); + } + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::update(ICDBNode * /* node */) + { + if (!_ObserverOn) return; + _Value = _DBLink.getSInt32(); + // the value in the db changed + invalidateCoords(1); + if (_Target) _Target->invalidateCoords(1); + } + + + // *************************************************************************** + void CCtrlScroll::moveTargetX (sint32 dx) + { + if(!_Target) + return; + sint32 maxWReal= _Target->getMaxWReal(); + sint32 wReal= _Target->getWReal(); + if(wReal <= maxWReal) + return; + + // compute the new ofsX. + sint32 ofsX= _Target->getOfsX(); + ofsX+= dx; + clamp(ofsX, 0, wReal-maxWReal); + _Target->setOfsX(ofsX); + + // compute new trackPos. + if (_Aligned == 2) // LEFT + { + float factor = (float)(wReal-maxWReal); + factor = -(float)ofsX / factor; + clamp(factor, 0.f, 1.f); + factor = factor * (getWReal()-_TrackSize); + _TrackPos = (sint32)factor; + } + else // RIGHT + { + float factor = (float)(wReal-maxWReal); + factor = (float)ofsX / factor; + clamp(factor, 0.f, 1.f); + factor = (1.0f-factor) * (getWReal() - _TrackSize); + _TrackPos = (sint32)factor; + } + + // invalidate only position. 1 pass is sufficient + invalidateCoords(1); + } + + // *************************************************************************** + void CCtrlScroll::moveTargetY (sint32 dy) + { + if(!_Target) + return; + sint32 maxHReal= _Target->getMaxHReal(); + sint32 hReal= _Target->getHReal(); + if(hReal <= maxHReal) + return; + + // compute the new ofsY. + sint32 ofsY= _Target->getOfsY(); + ofsY+= dy; + + // compute new trackPos. + if (_Aligned == 1) // BOTTOM + { + clamp(ofsY, maxHReal - hReal, 0); + _Target->setOfsY(ofsY); + float factor = (float)(hReal-maxHReal); + factor = -(float)ofsY / factor; + clamp(factor, 0.f, 1.f); + factor = factor * (getHReal()-_TrackSize); + _TrackPos = (sint32)factor; + } + else // TOP + { + clamp(ofsY, 0, hReal-maxHReal); + _Target->setOfsY(ofsY); + float factor = (float)(hReal-maxHReal); + factor = (float)ofsY / factor; + clamp(factor, 0.f, 1.f); + factor = (1.0f-factor) * (getHReal() - _TrackSize); + _TrackPos = (sint32)factor; + } + + // invalidate only position. 1 pass is sufficient + invalidateCoords(1); + } + + // *************************************************************************** + void CCtrlScroll::normalizeValue(sint32 &value) + { + // if, 0 no step + if(_StepValue==0 || _StepValue==1) + return; + // if interval is null, force min! + if(_Max==_Min) + { + value= _Min; + return; + } + + // get range of possible position + // sint32 size= _Max - _Min; + + // step (round) + sint32 val= (value + (_StepValue/2) -_Min) / _StepValue; + val= _Min + val * _StepValue; + clamp(val, _Min, _Max); + value= val; + } + + // *************************************************************************** + void CCtrlScroll::setFrozen (bool state) + { + _Frozen = state; + if (_Frozen) + { + _Value = 0; + } + } + + + // ------------------------------------------------------------------------------------------------ + int CCtrlScroll::luaEnsureVisible(CLuaState &ls) + { + const char *funcName = "ensureVisible"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + THotSpot hs[2]; + std::string hsStr[] = { ls.toString(2), ls.toString(3) }; + // + for (uint hsIndex = 0; hsIndex < 2; ++ hsIndex) + { + if (_Vertical) + { + if (NLMISC::nlstricmp(hsStr[hsIndex], "T") == 0) + { + hs[hsIndex] = Hotspot_Tx; + } + else + if (NLMISC::nlstricmp(hsStr[hsIndex], "M") == 0) + { + hs[hsIndex] = Hotspot_Mx; + } + else + if (NLMISC::nlstricmp(hsStr[hsIndex], "B") == 0) + { + hs[hsIndex] = Hotspot_Bx; + } + else + { + CLuaIHM::fails(ls, "%s : couldn't parse hotspot for vertical scrollbar", funcName); + } + } + else + { + if (NLMISC::nlstricmp(hsStr[hsIndex], "L") == 0) + { + hs[hsIndex] = Hotspot_xL; + } + else + if (NLMISC::nlstricmp(hsStr[hsIndex], "M") == 0) + { + hs[hsIndex] = Hotspot_xM; + } + else + if (NLMISC::nlstricmp(hsStr[hsIndex], "R") == 0) + { + hs[hsIndex] = Hotspot_xR; + } + else + { + CLuaIHM::fails(ls, "%s : couldn't parse hotspot for horizontal scrollbar", funcName); + } + } + } + ensureVisible(CLuaIHM::getUIOnStack(ls, 1), hs[0], hs[1]); + return 0; + } + + + // ------------------------------------------------------------------------------------------------ + void CCtrlScroll::ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot) + { + if (!_Target) return; // not connected to a target yet + if (!childElement) return; + // compute corners of interest for enclosed element & enclosing group + sint32 childX, childY; + childElement->getCorner(childX, childY, childHotSpot); + if (_Vertical) + { + sint32 maxHReal= _Target->getMaxHReal(); + sint32 hReal= _Target->getHReal(); + if(hReal > maxHReal) + { + sint enclosingDY; + switch (parentHotSpot) + { + case Hotspot_Bx: + enclosingDY = maxHReal; + break; + case Hotspot_Mx: + enclosingDY = maxHReal / 2; + break; + case Hotspot_Tx: + enclosingDY = 0; + break; + default: + nlassert(0); + break; + } + if (_Aligned == 0) + { + // Top aligned case + sint32 offsetY = (_Target->getYReal() + _Target->getHReal() - childY) - enclosingDY; + NLMISC::clamp(offsetY, 0, hReal - maxHReal); + _Target->setOfsY(offsetY); + _Target->invalidateCoords(); + } + else if (_Aligned == 1) + { + // Bottom aligned case + sint32 offsetY = (maxHReal - enclosingDY) - (childY - _Target->getYReal()); + NLMISC::clamp(offsetY, maxHReal - hReal, 0); + _Target->setOfsY(offsetY); + _Target->invalidateCoords(); + } + } + // else, ... fully visible (not occluded by parent group) + } + else + { + sint32 maxWReal= _Target->getMaxWReal(); + sint32 wReal= _Target->getWReal(); + if(wReal > maxWReal) + { + sint enclosingDX; + switch (parentHotSpot) + { + case Hotspot_xL: + enclosingDX = maxWReal; + break; + case Hotspot_xM: + enclosingDX = maxWReal / 2; + break; + case Hotspot_xR: + enclosingDX = 0; + break; + default: + nlassert(0); + break; + } + if (_Aligned == 3) + { + // right aligned case + sint32 offsetX = (_Target->getXReal() + _Target->getWReal() - childX) - enclosingDX; + NLMISC::clamp(offsetX, 0, wReal - maxWReal); + _Target->setOfsX(offsetX); + _Target->invalidateCoords(); + } + else if (_Aligned == 2) + { + // Left aligned case + sint32 offsetX = (maxWReal - enclosingDX) - (childX - _Target->getXReal()); + NLMISC::clamp(offsetX, maxWReal - wReal, 0); + _Target->setOfsX(offsetX); + _Target->invalidateCoords(); + } + } + // else, ... fully visible (not occluded by parent group) + } + } +} + diff --git a/code/nel/src/gui/group_submenu_base.cpp b/code/nel/src/gui/group_submenu_base.cpp new file mode 100644 index 000000000..365f3f85e --- /dev/null +++ b/code/nel/src/gui/group_submenu_base.cpp @@ -0,0 +1,47 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_submenu_base.h" + +namespace NLGUI +{ + + CGroupSubMenuBase::CGroupSubMenuBase( const NLGUI::CViewBase::TCtorParam ¶m ) : + CGroupFrame( param ) + { + } + + CGroupSubMenuBase::~CGroupSubMenuBase() + { + } + + void CGroupSubMenuBase::openSubMenu( sint32 nb ) + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + + void CGroupSubMenuBase::hideSubMenus() + { + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp deleted file mode 100644 index 834d3ee5e..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ /dev/null @@ -1,1058 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_manager.h" -#include "nel/gui/widget_manager.h" -#include "ctrl_scroll.h" -#include "nel/misc/xml_auto_ptr.h" -#include "group_menu.h" - -#include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" - -using namespace NLMISC; -using namespace std; - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); - -// ------------------------------------------------------------------------------------------------ -CCtrlScroll::CCtrlScroll(const TCtorParam ¶m) -: CCtrlScrollBase(param) -{ - _Vertical = true; - _Aligned = 1; - _TrackPos = 0; - _TrackDispPos = 0; - _TrackSize = _TrackSizeMin = 16; - _Min = 0; - _Max = 100; - _Value = 0; - _InitialValue = 0; - _MouseDown = false; - _CallingAH = false; - _Cancelable = false; - _Target = NULL; - _Inverted = false; - _IsDBLink = false; - _LastTargetHReal = 0; - _LastTargetMaxHReal = 0; - _LastTargetWReal = 0; - _LastTargetMaxWReal = 0; - _LastTargetOfsX = 0; - _LastTargetOfsY = 0; - _ObserverOn = true; - _TargetStepX = 1; - _TargetStepY = 1; - _StepValue = 0; - _TileM = false; - _Frozen = false; -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::runAH(const std::string &name, const std::string ¶ms) -{ - if (name.empty()) return; - if (_CallingAH) return; // avoid infinite loop - _CallingAH = true; - CAHManager::getInstance()->runActionHandler(name, this, params); - _CallingAH = false; -} - -// ------------------------------------------------------------------------------------------------ -CCtrlScroll::~CCtrlScroll() -{ - if (_IsDBLink) - { - ICDBNode::CTextId textId; - _DBLink.getNodePtr()->removeObserver(this, textId); - } -} - -// ------------------------------------------------------------------------------------------------ -bool CCtrlScroll::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) -{ - if (!CCtrlBase::parse(node, parentGroup)) - return false; - - CXMLAutoPtr prop; - // Read textures - prop = (char*) xmlGetProp( node, (xmlChar*)"tx_bottomleft" ); - if(prop) setTextureBottomOrLeft(string((const char*)prop)); - else setTextureBottomOrLeft ("w_scroll_l0_b.tga"); - - prop = (char*) xmlGetProp( node, (xmlChar*)"tx_middle" ); - if(prop) setTextureMiddle(string((const char*)prop)); - else setTextureMiddle ("w_scroll_l0_m.tga"); - - prop = (char*) xmlGetProp( node, (xmlChar*)"tx_topright" ); - if(prop) setTextureTopOrRight(string((const char*)prop)); - else setTextureTopOrRight ("w_scroll_l0_t.tga"); - - // Read properties - prop = (char*) xmlGetProp( node, (xmlChar*)"vertical" ); - if (prop) _Vertical = convertBool((const char*)prop); - - prop = (char*) xmlGetProp (node, (xmlChar*)"align"); - _Aligned = 1; - if (prop) - { - if (stricmp(prop, "T") == 0) _Aligned = 0; - else if (stricmp(prop, "B") == 0) _Aligned = 1; - else if (stricmp(prop, "L") == 0) _Aligned = 2; - else if (stricmp(prop, "R") == 0) _Aligned = 3; - } - - prop = (char*) xmlGetProp( node, (xmlChar*)"min" ); - if (prop) fromString((const char*)prop, _Min); - - prop = (char*) xmlGetProp( node, (xmlChar*)"max" ); - if (prop) fromString((const char*)prop, _Max); - - prop = (char*) xmlGetProp( node, (xmlChar*)"value" ); - if (prop) - { - if ( isdigit(*prop) || *prop=='-') - { - _IsDBLink = false; - fromString((const char*)prop, _Value); - } - else - { - _IsDBLink = true; - _DBLink.link(prop); - ICDBNode::CTextId textId; - _DBLink.getNodePtr()->addObserver(this, textId); - - } - } - - prop = (char*) xmlGetProp( node, (xmlChar*)"tracksize" ); - if (prop) fromString((const char*)prop, _TrackSize); - - // Read Action handlers - prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" ); - if (prop) _AHOnScroll = NLMISC::strlwr(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"params" ); - if (prop) _AHOnScrollParams = string((const char*)prop); - // - prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" ); - if (prop) _AHOnScrollEnd = NLMISC::strlwr(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" ); - if (prop) _AHOnScrollEndParams = string((const char*)prop); - // - prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" ); - if (prop) _AHOnScrollCancel = NLMISC::strlwr(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" ); - if (prop) _AHOnScrollCancelParams = string((const char*)prop); - - - // auto-target - prop = (char*) xmlGetProp( node, (xmlChar*)"target" ); - if (prop) - { - CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); - if(group == NULL) - group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(this->getId(), prop)); - - if(group != NULL) - setTarget (group); - } - - - // auto-step - prop = (char*) xmlGetProp( node, (xmlChar*)"target_stepx" ); - if(prop) fromString((const char*)prop, _TargetStepX); - prop = (char*) xmlGetProp( node, (xmlChar*)"target_stepy" ); - if(prop) fromString((const char*)prop, _TargetStepY); - _TargetStepX= max((sint32)1, _TargetStepX); - _TargetStepY= max((sint32)1, _TargetStepY); - - // Scroll Step - prop = (char*) xmlGetProp( node, (xmlChar*)"step_value" ); - if(prop) fromString((const char*)prop, _StepValue); - - prop = (char*) xmlGetProp( node, (xmlChar*)"cancelable" ); - if (prop) _Cancelable = convertBool(prop); - - prop= (char*) xmlGetProp (node, (xmlChar*)"frozen"); - _Frozen = false; - if (prop) - _Frozen = convertBool(prop); - - - return true; -} - -// ------------------------------------------------------------------------------------------------ - -int CCtrlScroll::luaSetTarget(CLuaState &ls) -{ - const char *funcName = "setTarget"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - std::string targetId = ls.toString(1); - - CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(targetId)); - if(group != NULL) - { - setTarget (group); - } - - return 0; -} - -void CCtrlScroll::updateCoords() -{ - if (_Target) - { - // update only if visible - if (_Target->getActive()) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 w, h; - rVR.getTextureSizeFromId (_TxIdB, w, h); - - if (_Vertical) - { - _W = w; - _H = _Target->getMaxHReal(); - } - else - { - _W = _Target->getMaxWReal(); - _H = h; - } - - CCtrlBase::updateCoords (); - if (_Vertical) - { - if(_Target->getHReal()!=_LastTargetHReal || _Target->getMaxHReal()!=_LastTargetMaxHReal || - _Target->getOfsY() != _LastTargetOfsY - ) - { - _LastTargetHReal= _Target->getHReal(); - _LastTargetMaxHReal= _Target->getMaxHReal(); - _LastTargetOfsY = _Target->getOfsY(); - - // Activate only if needed - setActive(_Target->getHReal() > _Target->getMaxHReal()); - CCtrlBase::updateCoords(); - - // Calculate size of the track button - if ((_Target->getHReal() <= _Target->getMaxHReal()) || (_Target->getHReal() == 0)) - { - _TrackSize = _Target->getMaxHReal(); - } - else - { - float factor = (float)_Target->getMaxHReal() / (float)_Target->getHReal(); - factor = _TrackSizeMin + factor * (this->getHReal() - _TrackSizeMin); - _TrackSize = (sint32)factor; - } - // Calculate pos of the track button - if (_Target->getHReal() <= _Target->getMaxHReal()) - { - if (_Aligned == 1) // BOTTOM - _TrackPos = 0; - else // TOP - _TrackPos = getHReal()-_TrackSize; - } - else - { - if (_Aligned == 1) // BOTTOM - { - float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); - factor = -(float)_Target->getOfsY() / factor; - if (factor < 0.0f) factor = 0.0f; - if (factor > 1.0f) factor = 1.0f; - factor = factor * (getHReal()-_TrackSize); - _TrackPos = (sint32)factor; - } - else // TOP - { - float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); - factor = (float)_Target->getOfsY() / factor; - if (factor < 0.0f) factor = 0.0f; - if (factor > 1.0f) factor = 1.0f; - sint32 hreal = getHReal(); - factor = (1.0f-factor) * (hreal - _TrackSize); - _TrackPos = (sint32)factor; - } - } - - // invalidate coords. - computeTargetOfsFromPos(); - } - } - else // Horizontal Tracker - { - if(_Target->getWReal()!=_LastTargetWReal || _Target->getMaxWReal()!=_LastTargetMaxWReal || - _Target->getOfsX() != _LastTargetOfsX) - { - _LastTargetWReal= _Target->getWReal(); - _LastTargetMaxWReal= _Target->getMaxWReal(); - _LastTargetOfsX = _Target->getOfsX(); - - // Activate only if needed - setActive(_Target->getWReal() > _Target->getMaxWReal()); - CCtrlBase::updateCoords(); - - // Calculate size of the track button - if ((_Target->getWReal() <= _Target->getMaxWReal()) || (_Target->getWReal() == 0)) - { - _TrackSize = _Target->getMaxWReal(); - } - else - { - float factor = (float)_Target->getMaxWReal() / (float)_Target->getWReal(); - factor = _TrackSizeMin + factor * (this->getWReal() - _TrackSizeMin); - _TrackSize = (sint32)factor; - } - // Calculate pos of the track button - if (_Target->getWReal() <= _Target->getMaxWReal()) - { - if (_Aligned == 2) // LEFT - _TrackPos = 0; - else // RIGHT - _TrackPos = getWReal()-_TrackSize; - } - else - { - if (_Aligned == 2) // LEFT - { - float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); - factor = -(float)_Target->getOfsX() / factor; - if (factor < 0.0f) factor = 0.0f; - if (factor > 1.0f) factor = 1.0f; - factor = factor * (getWReal()-_TrackSize); - _TrackPos = (sint32)factor; - } - else // RIGHT - { - float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); - factor = (float)_Target->getOfsX() / factor; - if (factor < 0.0f) factor = 0.0f; - if (factor > 1.0f) factor = 1.0f; - sint32 hreal = getWReal(); - factor = (1.0f-factor) * (hreal - _TrackSize); - _TrackPos = (sint32)factor; - } - } - - // invalidate coords. - computeTargetOfsFromPos(); - } - } - } - // reset cache - else - { - _LastTargetHReal= 0; - _LastTargetMaxHReal= 0; - _LastTargetWReal= 0; - _LastTargetMaxWReal= 0; - _LastTargetOfsX = 0; - _LastTargetOfsY = 0; - setActive(false); - } - } - else - { - CCtrlBase::updateCoords (); - if (_IsDBLink) - _Value = _DBLink.getSInt32(); - if (_Vertical) - { - float factor; - if (_Aligned == 1) // BOTTOM - factor = ((float)_Value-_Min) / (_Max-_Min); - else // TOP - factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); - factor *= (this->getHReal() - _TrackSize); - - _TrackDispPos = (sint32)factor; - } - else - { - float factor; - if (_Aligned == 2) // LEFT - factor = ((float)_Value-_Min) / (_Max-_Min); - else // RIGHT - factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); - factor *= (this->getWReal() - _TrackSize); - - _TrackDispPos = (sint32)factor; - } - } - CCtrlBase::updateCoords (); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::draw() -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = CWidgetManager::getInstance()->getGlobalColorForContent(); - - if (_Target) - { - if (_Vertical) - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos, _WReal, 4, 0, false, _TxIdB, col ); - if (_TileM == 0) - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, col ); - else - rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal, _YReal+_TrackPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, _TileM-1, col ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackPos+_TrackSize-4, _WReal, 4, 0, false, _TxIdT, col ); - } - else - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos, _YReal, 4, _HReal, 0, false, _TxIdB, col ); - if (_TileM == 0) - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, col ); - else - rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal+_TrackPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, _TileM-1, col ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackPos+_TrackSize-4, _YReal, 4, _HReal, 0, false, _TxIdT, col ); - } - } - else - { - if (_Vertical) - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos, _WReal, 4, 0, false, _TxIdB, col ); - if (_TileM == 0) - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, col ); - else - rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal, _YReal+_TrackDispPos+4, _WReal, _TrackSize-8, 0, false, _TxIdM, _TileM-1, col ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_TrackDispPos+_TrackSize-4, _WReal, 4, 0, false, _TxIdT, col ); - } - else - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos, _YReal, 4, _HReal, 0, false, _TxIdB, col ); - if (_TileM == 0) - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, col ); - else - rVR.drawRotFlipBitmapTiled (_RenderLayer, _XReal+_TrackDispPos+4, _YReal, _TrackSize-8, _HReal, 0, false, _TxIdM, _TileM-1, col ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_TrackDispPos+_TrackSize-4, _YReal, 4, _HReal, 0, false, _TxIdT, col ); - } - } -} - -// ------------------------------------------------------------------------------------------------ -bool CCtrlScroll::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active || _Frozen) - return false; - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && - (!((eventDesc.getX() >= _XReal) && - (eventDesc.getX() < (_XReal + _WReal))&& - (eventDesc.getY() > _YReal) && - (eventDesc.getY() <= (_YReal+ _HReal))))) - return false; - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - _MouseDown = true; - _InitialValue = getValue(); - if (!_Target) - _TrackPos = _TrackDispPos; - _MouseDownOffsetX = eventDesc.getX() - (getXReal() + (_Vertical ? 0 : _TrackPos)); - _MouseDownOffsetY = eventDesc.getY() - (getYReal() + (_Vertical ? _TrackPos : 0)); - - // if target is a menu, hidde its sub menus - if(_Target && _Target->getParent()) - { - CGroupSubMenu * menu = dynamic_cast(_Target->getParent()); - if(menu) - menu->hideSubMenus(); - } - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - _MouseDown = false; - runAH(_AHOnScrollEnd, _AHOnScrollEndParams.empty() ? _AHOnScrollParams : _AHOnScrollEndParams); // backward compatibility - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown && _MouseDown && _Cancelable) - { - _MouseDown = false; - setValue(_InitialValue); - runAH(_AHOnScrollCancel, _AHOnScrollCancelParams); // backward compatibility - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) - { - if (_MouseDown) - { - sint32 dx = eventDesc.getX() - (getXReal() + (_Vertical ? 0 : _TrackPos) + _MouseDownOffsetX); - sint32 dy = eventDesc.getY() - (getYReal() + (_Vertical ? _TrackPos : 0 ) + _MouseDownOffsetY); - if (dx != 0) moveTrackX (dx); - if (dy != 0) moveTrackY (dy); - } - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel && _Vertical) - { - moveTrackY (eventDesc.getWheel() * 12); - return true; - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setTarget (CInterfaceGroup *pIG) -{ - _Target = pIG; - - if (_Vertical) - { - if (_Target->getPosRef()&Hotspot_Tx) - _Aligned = 0; - else - _Aligned = 1; - - if (_Target->getPosRef()&Hotspot_Tx) - _Inverted = true; - else - _Inverted = true; - } - else - { - if (_Target->getPosRef()&Hotspot_xL) - _Aligned = 2; - else - _Aligned = 3; - - if (_Target->getPosRef()&Hotspot_xL) - _Inverted = true; - else - _Inverted = true; - } -} -// ------------------------------------------------------------------------------------------------ -sint32 CCtrlScroll::moveTrackX (sint32 dx) -{ - if (_Vertical) - return 0; - if ((getWReal()-_TrackSize) <= 0) - return 0; - - sint32 newtpos; - sint32 tpos = _TrackPos; - sint32 tsize = _TrackSize; - - // Limit the scroller to the defined area - newtpos = tpos + dx; - if (newtpos < 0) newtpos = 0; - if (newtpos > (getWReal()-tsize)) newtpos = (getWReal()-tsize); - dx = newtpos - tpos; - - if (_Target) - { - _TrackPos = newtpos; - - computeTargetOfsFromPos(); - } - else // This is a number scroller - { - float factor = (float)(_Max - _Min); - - if (_Aligned == 2) // LEFT - factor = -factor * newtpos / (float)(getWReal()-tsize) - _Min; - else // RIGHT - factor = factor * (1.0f-(newtpos / (float)(getWReal()-tsize))) + _Min; - - _TrackPos = newtpos; - - if (_Aligned == 2) // LEFT - _Value = (sint32) (_Inverted ? factor : -factor); - else // RIGHT - _Value = (sint32) (_Inverted ? factor : -factor); - - // step and clamp value - normalizeValue(_Value); - - { - float factor; - if (_Aligned == 2) // LEFT - factor = ((float)_Value-_Min) / (_Max-_Min); - else // RIGHT - factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); - factor *= (this->getWReal() - _TrackSize); - - _TrackDispPos = (sint32)factor; - } - - if (_IsDBLink) - { - _ObserverOn = false; - _DBLink.setSInt32 (_Value); - _ObserverOn = true; - } - } - - // Launch the scroller event if any - runAH(_AHOnScroll, _AHOnScrollParams); - - return dx; -} - -// ------------------------------------------------------------------------------------------------ -sint32 CCtrlScroll::moveTrackY (sint32 dy) -{ - if (!_Vertical) - return 0; - if ((getHReal()-_TrackSize) <= 0) - return 0; - - sint32 newtpos; - sint32 tpos = _TrackPos; - sint32 tsize = _TrackSize; - - // Limit the scroller to the defined area - newtpos = tpos + dy; - if (newtpos < 0) newtpos = 0; - if (newtpos > (getHReal()-tsize)) newtpos = (getHReal()-tsize); - dy = newtpos - tpos; - - if (_Target) - { - _TrackPos = newtpos; - - computeTargetOfsFromPos(); - } - else // This is a number scroller - { - float factor = (float)(_Max - _Min); - - if (_Aligned == 1) // BOTTOM - factor = -factor * newtpos / (float)(getHReal()-tsize) - _Min; - else // TOP - factor = factor * (1.0f-(newtpos / (float)(getHReal()-tsize))) + _Min; - - _TrackPos = newtpos; - - if (_Aligned == 1) // BOTTOM - _Value = (sint32) (_Inverted ? factor : -factor); - else // TOP - _Value = (sint32) (_Inverted ? factor : -factor); - - // step and clamp value - normalizeValue(_Value); - - { - float factor; - if (_Aligned == 1) // BOTTOM - factor = ((float)_Value-_Min) / (_Max-_Min); - else // TOP - factor = 1.0f - ((float)_Value-_Min) / (_Max-_Min); - factor *= (this->getHReal() - _TrackSize); - - _TrackDispPos = (sint32)factor; - } - - if (_IsDBLink) - { - _ObserverOn = false; - _DBLink.setSInt32 (_Value); - _ObserverOn = true; - } - } - - // Launch the scroller event if any - runAH(_AHOnScroll, _AHOnScrollParams); - - return dy; -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setTextureBottomOrLeft (const std::string &txName) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TxIdB = rVR.getTextureIdFromName(txName); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setTextureMiddle (const std::string &txName) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TxIdM = rVR.getTextureIdFromName(txName); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setTextureTopOrRight (const std::string &txName) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TxIdT = rVR.getTextureIdFromName(txName); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setValue(sint32 value) -{ - normalizeValue(value); - - if (_IsDBLink) - { - _ObserverOn = false; - _DBLink.setSInt32(value); - _ObserverOn = true; - } - else - { - _Value = value; - } - invalidateCoords(); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::setTrackPos(sint32 pos) -{ - if (_Vertical) - { - moveTrackY(pos - _TrackPos); - } - else - { - moveTrackX(pos - _TrackPos); - } - invalidateCoords(); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::computeTargetOfsFromPos() -{ - if(_Vertical) - { - float factor = ((float)_Target->getHReal() - (float)_Target->getMaxHReal()); - - if (_Aligned == 1) // BOTTOM - factor = -factor * _TrackPos / favoid0((float)(getHReal()-_TrackSize)); - else // TOP - factor = factor * (1.0f-(_TrackPos / favoid0((float)(getHReal()-_TrackSize)))); - - // Compute Steped target - sint32 nexOfsY= (sint32) (_Inverted ? factor : -factor); - if(_TargetStepY>1) - nexOfsY= ((nexOfsY+_TargetStepY/2)/_TargetStepY) * _TargetStepY; - _Target->setOfsY (nexOfsY); - _LastTargetOfsY = nexOfsY; - - // invalidate only XReal/YReal, doing only 1 pass - _Target->invalidateCoords(1); - } - else - { - float factor = ((float)_Target->getWReal() - (float)_Target->getMaxWReal()); - - if (_Aligned == 2) // LEFT - factor = -factor * _TrackPos / favoid0((float)(getWReal()-_TrackSize)); - else // RIGHT - factor = factor * (1.0f-(_TrackPos / favoid0((float)(getWReal()-_TrackSize)))); - - // Compute Steped target - sint32 nexOfsX= (sint32) (_Inverted ? factor : -factor); - if(_TargetStepX>1) - nexOfsX= ((nexOfsX+_TargetStepX/2)/_TargetStepX) * _TargetStepX; - _Target->setOfsX (nexOfsX); - _LastTargetOfsX = nexOfsX; - - // invalidate only XReal/YReal, doing only 1 pass - _Target->invalidateCoords(1); - } -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::update(ICDBNode * /* node */) -{ - if (!_ObserverOn) return; - _Value = _DBLink.getSInt32(); - // the value in the db changed - invalidateCoords(1); - if (_Target) _Target->invalidateCoords(1); -} - - -// *************************************************************************** -void CCtrlScroll::moveTargetX (sint32 dx) -{ - if(!_Target) - return; - sint32 maxWReal= _Target->getMaxWReal(); - sint32 wReal= _Target->getWReal(); - if(wReal <= maxWReal) - return; - - // compute the new ofsX. - sint32 ofsX= _Target->getOfsX(); - ofsX+= dx; - clamp(ofsX, 0, wReal-maxWReal); - _Target->setOfsX(ofsX); - - // compute new trackPos. - if (_Aligned == 2) // LEFT - { - float factor = (float)(wReal-maxWReal); - factor = -(float)ofsX / factor; - clamp(factor, 0.f, 1.f); - factor = factor * (getWReal()-_TrackSize); - _TrackPos = (sint32)factor; - } - else // RIGHT - { - float factor = (float)(wReal-maxWReal); - factor = (float)ofsX / factor; - clamp(factor, 0.f, 1.f); - factor = (1.0f-factor) * (getWReal() - _TrackSize); - _TrackPos = (sint32)factor; - } - - // invalidate only position. 1 pass is sufficient - invalidateCoords(1); -} - -// *************************************************************************** -void CCtrlScroll::moveTargetY (sint32 dy) -{ - if(!_Target) - return; - sint32 maxHReal= _Target->getMaxHReal(); - sint32 hReal= _Target->getHReal(); - if(hReal <= maxHReal) - return; - - // compute the new ofsY. - sint32 ofsY= _Target->getOfsY(); - ofsY+= dy; - - // compute new trackPos. - if (_Aligned == 1) // BOTTOM - { - clamp(ofsY, maxHReal - hReal, 0); - _Target->setOfsY(ofsY); - float factor = (float)(hReal-maxHReal); - factor = -(float)ofsY / factor; - clamp(factor, 0.f, 1.f); - factor = factor * (getHReal()-_TrackSize); - _TrackPos = (sint32)factor; - } - else // TOP - { - clamp(ofsY, 0, hReal-maxHReal); - _Target->setOfsY(ofsY); - float factor = (float)(hReal-maxHReal); - factor = (float)ofsY / factor; - clamp(factor, 0.f, 1.f); - factor = (1.0f-factor) * (getHReal() - _TrackSize); - _TrackPos = (sint32)factor; - } - - // invalidate only position. 1 pass is sufficient - invalidateCoords(1); -} - -// *************************************************************************** -void CCtrlScroll::normalizeValue(sint32 &value) -{ - // if, 0 no step - if(_StepValue==0 || _StepValue==1) - return; - // if interval is null, force min! - if(_Max==_Min) - { - value= _Min; - return; - } - - // get range of possible position -// sint32 size= _Max - _Min; - - // step (round) - sint32 val= (value + (_StepValue/2) -_Min) / _StepValue; - val= _Min + val * _StepValue; - clamp(val, _Min, _Max); - value= val; -} - -// *************************************************************************** -void CCtrlScroll::setFrozen (bool state) -{ - _Frozen = state; - if (_Frozen) - { - _Value = 0; - } -} - - -// ------------------------------------------------------------------------------------------------ -int CCtrlScroll::luaEnsureVisible(CLuaState &ls) -{ - const char *funcName = "ensureVisible"; - CLuaIHM::checkArgCount(ls, funcName, 3); - CLuaIHM::checkArgTypeUIElement(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); - THotSpot hs[2]; - std::string hsStr[] = { ls.toString(2), ls.toString(3) }; - // - for (uint hsIndex = 0; hsIndex < 2; ++ hsIndex) - { - if (_Vertical) - { - if (NLMISC::nlstricmp(hsStr[hsIndex], "T") == 0) - { - hs[hsIndex] = Hotspot_Tx; - } - else - if (NLMISC::nlstricmp(hsStr[hsIndex], "M") == 0) - { - hs[hsIndex] = Hotspot_Mx; - } - else - if (NLMISC::nlstricmp(hsStr[hsIndex], "B") == 0) - { - hs[hsIndex] = Hotspot_Bx; - } - else - { - CLuaIHM::fails(ls, "%s : couldn't parse hotspot for vertical scrollbar", funcName); - } - } - else - { - if (NLMISC::nlstricmp(hsStr[hsIndex], "L") == 0) - { - hs[hsIndex] = Hotspot_xL; - } - else - if (NLMISC::nlstricmp(hsStr[hsIndex], "M") == 0) - { - hs[hsIndex] = Hotspot_xM; - } - else - if (NLMISC::nlstricmp(hsStr[hsIndex], "R") == 0) - { - hs[hsIndex] = Hotspot_xR; - } - else - { - CLuaIHM::fails(ls, "%s : couldn't parse hotspot for horizontal scrollbar", funcName); - } - } - } - ensureVisible(CLuaIHM::getUIOnStack(ls, 1), hs[0], hs[1]); - return 0; -} - - -// ------------------------------------------------------------------------------------------------ -void CCtrlScroll::ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot) -{ - if (!_Target) return; // not connected to a target yet - if (!childElement) return; - // compute corners of interest for enclosed element & enclosing group - sint32 childX, childY; - childElement->getCorner(childX, childY, childHotSpot); - if (_Vertical) - { - sint32 maxHReal= _Target->getMaxHReal(); - sint32 hReal= _Target->getHReal(); - if(hReal > maxHReal) - { - sint enclosingDY; - switch (parentHotSpot) - { - case Hotspot_Bx: - enclosingDY = maxHReal; - break; - case Hotspot_Mx: - enclosingDY = maxHReal / 2; - break; - case Hotspot_Tx: - enclosingDY = 0; - break; - default: - nlassert(0); - break; - } - if (_Aligned == 0) - { - // Top aligned case - sint32 offsetY = (_Target->getYReal() + _Target->getHReal() - childY) - enclosingDY; - NLMISC::clamp(offsetY, 0, hReal - maxHReal); - _Target->setOfsY(offsetY); - _Target->invalidateCoords(); - } - else if (_Aligned == 1) - { - // Bottom aligned case - sint32 offsetY = (maxHReal - enclosingDY) - (childY - _Target->getYReal()); - NLMISC::clamp(offsetY, maxHReal - hReal, 0); - _Target->setOfsY(offsetY); - _Target->invalidateCoords(); - } - } - // else, ... fully visible (not occluded by parent group) - } - else - { - sint32 maxWReal= _Target->getMaxWReal(); - sint32 wReal= _Target->getWReal(); - if(wReal > maxWReal) - { - sint enclosingDX; - switch (parentHotSpot) - { - case Hotspot_xL: - enclosingDX = maxWReal; - break; - case Hotspot_xM: - enclosingDX = maxWReal / 2; - break; - case Hotspot_xR: - enclosingDX = 0; - break; - default: - nlassert(0); - break; - } - if (_Aligned == 3) - { - // right aligned case - sint32 offsetX = (_Target->getXReal() + _Target->getWReal() - childX) - enclosingDX; - NLMISC::clamp(offsetX, 0, wReal - maxWReal); - _Target->setOfsX(offsetX); - _Target->invalidateCoords(); - } - else if (_Aligned == 2) - { - // Left aligned case - sint32 offsetX = (maxWReal - enclosingDX) - (childX - _Target->getXReal()); - NLMISC::clamp(offsetX, maxWReal - wReal, 0); - _Target->setOfsX(offsetX); - _Target->invalidateCoords(); - } - } - // else, ... fully visible (not occluded by parent group) - } -} - diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h deleted file mode 100644 index d1e6fe2d3..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ /dev/null @@ -1,196 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_CTRL_SCROLL_H -#define RZ_CTRL_SCROLL_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/ctrl_scroll_base.h" - -/** - * Class handling scollbar function - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver -{ - -public: - DECLARE_UI_CLASS( CCtrlScroll ) - CCtrlScroll(const TCtorParam ¶m); - ~CCtrlScroll(); - - - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - - virtual void updateCoords(); - virtual void draw(); - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - void setTarget (CInterfaceGroup *pIG); - // Return the delta value the track has moved - sint32 moveTrackX (sint32 dx); - sint32 moveTrackY (sint32 dy); - - /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. - * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) - */ - void moveTargetX (sint32 dx); - void moveTargetY (sint32 dy); - - void setAlign (sint32 nAlign) { _Aligned = nAlign; } - // invert the factor for target - void setInverted(bool invert) { _Inverted = invert; } - - void setTextureBottomOrLeft (const std::string &txName); - void setTextureMiddle (const std::string &txName); - void setTextureTopOrRight (const std::string &txName); - - void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; } - void setTextureMiddle (sint32 txid) { _TxIdM = txid; } - void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR) - void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; } - - // number scroller - sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; } - // NB: the value is clamped (see setMinMax) and stepped (see setStepValue()) - void setValue(sint32 value); - void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; } - void setStepValue(uint32 step) { _StepValue= step; } - - void setTrackPos(sint32 pos); - sint32 getTrackPos() const { return _TrackPos; } - sint32 getTrackSize() const { return _TrackSize; } - // dummy set for track size (forlua export) - void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); } - - - void setFrozen (bool state); - bool getFrozen () const { return _Frozen; } - - int luaSetTarget(CLuaState &ls); - int luaEnsureVisible(CLuaState &ls); - - // name - void setName(const std::string & val) {_Name = val;} - std::string getName() const {return _Name;} - - // max - void setMax(sint32 max) {_Max = max;} - sint32 getMax() const {return _Max;} - - REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase) - REFLECT_LUA_METHOD("setTarget", luaSetTarget) - REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible); - REFLECT_SINT32("value", getValue, setValue); - REFLECT_SINT32("trackPos", getTrackPos, setTrackPos); - REFLECT_SINT32("trackSize", getTrackSize, setTrackSize); - REFLECT_STRING("name", getName, setName); - REFLECT_SINT32("max", getMax, setMax); - REFLECT_EXPORT_END - - /** Ensure that a child element be visible into the frame through which - * its parent group is displayed. - * Example : Had we a list of items for which we want some item 'itemPtr' to have its top position - * matching the middle of the list, we would do : - * this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx); - * - * The scrollbar will be moved accordingly. - */ - void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot); - - -protected: - - CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db - sint32 _Value; // Or we can use a normal value - sint32 _InitialValue; - - sint32 _Min, _Max; - std::string _AHOnScroll; - std::string _AHOnScrollParams; - // - std::string _AHOnScrollEnd; - std::string _AHOnScrollEndParams; - // - // - std::string _AHOnScrollCancel; - std::string _AHOnScrollCancelParams; - - - sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right - - sint32 _TrackDispPos; - sint32 _TrackPos; - sint32 _TrackSize; - sint32 _TrackSizeMin; - - sint32 _MouseDownOffsetX; - sint32 _MouseDownOffsetY; - - sint32 _TxIdB; // Same as Left if Horizontal sb - sint32 _TxIdM; - sint32 _TxIdT; // Same as Right if Horizontal sb - - uint8 _TileM; - - sint32 _LastTargetHReal; - sint32 _LastTargetMaxHReal; - sint32 _LastTargetOfsY; - sint32 _LastTargetWReal; - sint32 _LastTargetMaxWReal; - sint32 _LastTargetOfsX; - - bool _Vertical : 1; // true if vertical track bar - bool _IsDBLink : 1; - bool _ObserverOn : 1; - bool _Inverted : 1; - bool _MouseDown : 1; - bool _CallingAH : 1; - bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button - bool _Frozen : 1; - - // For Target Scroller only: the target offset step in pixel. - sint32 _TargetStepX; - sint32 _TargetStepY; - - // For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step - uint32 _StepValue; - - // Slider's name - std::string _Name; - - void computeTargetOfsFromPos(); - - // from IPropertyObserver - virtual void update(NLMISC::ICDBNode *node); - - // step the value, and clamp it - void normalizeValue(sint32 &value); - - void runAH(const std::string &name, const std::string ¶ms); - -}; - - -#endif // RZ_CTRL_SCROLL_H - -/* End of ctrl_scroll.h */ - - diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index 894a34ea8..f9b29d83e 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -26,10 +26,10 @@ namespace NLGUI { class CCtrlBaseButton; + class CCtrlScroll; } // *************************************************************************** -class CCtrlScroll; class CGroupContainer; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index f27dd02e7..f11faabbf 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -30,11 +30,11 @@ namespace NLGUI { class CCtrlButton; + class CCtrlScroll; } // *************************************************************************** -class CCtrlScroll; class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; class CGroupContainer; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h index 23c96c0c3..30957ae43 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.h @@ -25,12 +25,12 @@ namespace NLGUI { - class CCtrlButton; + class CCtrlButton; + class CCtrlScroll; } // *************************************************************************** -class CCtrlScroll; class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index dcc8b2a4d..e4b80a016 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -33,7 +33,7 @@ #include "group_list.h" #include "nel/gui/ctrl_button.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "view_text.h" #include "view_bitmap.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index bd23a8b38..0a79f0931 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -27,10 +27,10 @@ namespace NLGUI { class CEventDescriptorLocalised; class CCtrlButton; + class CCtrlScroll; } class CInterfaceList; -class CCtrlScroll; class CViewText; class COptionsContainerInsertion; class COptionsContainerMove; diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 254a2a2c9..51b65d236 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -32,7 +32,7 @@ extern "C" #include "group_list.h" #include "group_container.h" #include "view_link.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "dbctrl_sheet.h" #include "ctrl_text_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 333137651..beca17afd 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -40,10 +40,10 @@ extern "C" namespace NLGUI { class CCtrlButton; + class CCtrlScroll; } class CGroupList; -class CCtrlScroll; class CDBGroupComboBox; class CGroupParagraph; diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index bd2f44088..da2681f53 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -112,7 +112,7 @@ void CViewTextMenu::setAlpha (sint32 a) // ------------------------------------------------------------------------------------------------ CGroupSubMenu::CGroupSubMenu(const TCtorParam ¶m) -: CGroupFrame(param) +: CGroupSubMenuBase(param) { _SelectionView = NULL; _GroupList = NULL; diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index 8f3098996..41bcae76a 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -21,14 +21,18 @@ #include "nel/gui/interface_group.h" #include "nel/gui/group_modal.h" +#include "nel/gui/group_submenu_base.h" #include "view_text.h" - #include "ctrl_text_button.h" +namespace NLGUI +{ + class CCtrlScroll; +} + class CViewBitmap; class CGroupMenu; class CGroupList; -class CCtrlScroll; /** @@ -92,7 +96,7 @@ private: * \date 2002 */ -class CGroupSubMenu : public CGroupFrame +class CGroupSubMenu : public CGroupSubMenuBase { public: @@ -198,7 +202,7 @@ public: int luaReset(CLuaState &ls); int luaSetMaxVisibleLine(CLuaState &ls); // - REFLECT_EXPORT_START(CGroupSubMenu, CGroupFrame) + REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase) REFLECT_LUA_METHOD("getNumLine", luaGetNumLine); REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index 411b3714f..89e556870 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -23,7 +23,7 @@ #include "group_scrolltext.h" #include "group_list.h" #include "view_text.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h index e0b11b91d..cfedb76bc 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.h @@ -26,10 +26,10 @@ namespace NLGUI { class CCtrlBaseButton; + class CCtrlScroll; } class CGroupList; -class CCtrlScroll; // Can be used to build a chat window or anything that displays sequences of strings /** diff --git a/code/ryzom/client/src/interface_v3/interface_config.cpp b/code/ryzom/client/src/interface_v3/interface_config.cpp index 34fb9d52e..de9924061 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.cpp +++ b/code/ryzom/client/src/interface_v3/interface_config.cpp @@ -21,7 +21,7 @@ #include "interface_config.h" #include "interface_manager.h" #include "group_container.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" using namespace NLMISC; using namespace std; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 53af9d8e4..89c1bc64b 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -51,7 +51,7 @@ #include "view_bitmap_combo.h" #include "view_text.h" // Ctrl -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "ctrl_text_button.h" // DBCtrl diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 2171ecb4c..d70a1def9 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -30,7 +30,7 @@ #include "view_pointer.h" #include "nel/gui/ctrl_base.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 73d1208b8..eba6b9094 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -52,7 +52,7 @@ #include "dbview_quantity.h" #include "dbview_digit.h" // Ctrl -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "ctrl_col_pick.h" #include "ctrl_tooltip.h" diff --git a/code/ryzom/client/src/interface_v3/list_sheet_base.h b/code/ryzom/client/src/interface_v3/list_sheet_base.h index 1ef13e4ca..609ee95ae 100644 --- a/code/ryzom/client/src/interface_v3/list_sheet_base.h +++ b/code/ryzom/client/src/interface_v3/list_sheet_base.h @@ -22,9 +22,12 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" +namespace NLGUI +{ + class CCtrlScroll; +} class CDBCtrlSheet; -class CCtrlScroll; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index bb9d482a8..6a2e54483 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -24,6 +24,7 @@ #include "view_text_id.h" #include "view_bitmap.h" #include "view_radar.h" +#include "nel/gui/group_submenu_base.h" #include "group_menu.h" #include "nel/gui/ctrl_base.h" #include "nel/gui/interface_group.h" @@ -46,7 +47,7 @@ #include "dbview_bar3.h" #include "group_list.h" #include "nel/gui/ctrl_scroll_base.h" -#include "ctrl_scroll.h" +#include "nel/gui/ctrl_scroll.h" #include "dbgroup_combo_box.h" #include "group_tab.h" #include "group_html.h" @@ -94,7 +95,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase); REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlScrollBase); REGISTER_REFLECTABLE_CLASS(CGroupMenu, CGroupModal) - REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupFrame) + REGISTER_REFLECTABLE_CLASS(CGroupSubMenuBase, CGroupFrame) + REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupSubMenuBase) REGISTER_REFLECTABLE_CLASS(CGroupTab, CInterfaceGroup) REGISTER_REFLECTABLE_CLASS(CGroupScrollText, CInterfaceGroup) REGISTER_REFLECTABLE_CLASS(CGroupHTML, CGroupScrollText) diff --git a/code/ryzom/client/src/libwww.h b/code/ryzom/client/src/libwww.h index ec1462bc9..b82a75534 100644 --- a/code/ryzom/client/src/libwww.h +++ b/code/ryzom/client/src/libwww.h @@ -28,10 +28,10 @@ extern "C" namespace NLGUI { class CCtrlBaseButton; + class CCtrlScroll; } class CGroupList; -class CCtrlScroll; // *************************************************************************** From 3929588a04c6e043bb8a26a2ebb6d2948566df6d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 02:34:07 +0200 Subject: [PATCH 066/339] CHANGED: #1471 CCtrlQuad is now in the NELGUI library under the NLGUI namespace. --- code/nel/include/nel/gui/ctrl_quad.h | 116 +++++ code/nel/src/gui/ctrl_quad.cpp | 435 ++++++++++++++++++ .../client/src/interface_v3/ctrl_quad.cpp | 435 ------------------ .../ryzom/client/src/interface_v3/ctrl_quad.h | 112 ----- .../client/src/interface_v3/group_map.cpp | 2 +- .../ryzom/client/src/interface_v3/group_map.h | 13 +- .../r2/displayer_visual_activity_sequence.cpp | 2 +- .../client/src/r2/displayer_visual_group.cpp | 2 +- .../ryzom/client/src/r2/instance_map_deco.cpp | 2 +- code/ryzom/client/src/r2/instance_map_deco.h | 6 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- code/ryzom/client/src/r2/tool_draw_prim.cpp | 2 +- 12 files changed, 572 insertions(+), 557 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_quad.h create mode 100644 code/nel/src/gui/ctrl_quad.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_quad.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_quad.h diff --git a/code/nel/include/nel/gui/ctrl_quad.h b/code/nel/include/nel/gui/ctrl_quad.h new file mode 100644 index 000000000..2be7b5b94 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_quad.h @@ -0,0 +1,116 @@ +// Ryzom - MMORPG Framework +// 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 RZ_CTRL_QUAD_H +#define RZ_CTRL_QUAD_H + +#include "nel/gui/ctrl_base.h" +#include "nel/gui/view_renderer.h" +#include "nel/misc/geom_ext.h" + +namespace NLGUI +{ + + /** Display of an arbitrary textured quad in the UI. The applied texture is filtered. + * Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates + * are driven by the quad vertices coordinates (see setQuad). + * + * Derives from CCtrlBase for tooltipping support + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 12/2005 + */ + class CCtrlQuad : public CCtrlBase + { + public: + enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount }; + + + CCtrlQuad(); + + // from CInterfaceElement + bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup); + virtual void updateCoords(); + virtual void draw(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha (sint32 a); + + // texture + void setTexture(const std::string &texName); + std::string getTexture () const; + + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + + /** Set a new quad relative to parent pos + * x,y, w, h & hotspot are updated to fit the bounding rect of the quad + */ + void setQuad(const NLMISC::CQuad &quad); + void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness); + /** Fit the given texture size (no hotspot for now, always centered) + * NB : current texture is not modified. + */ + void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f); + void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f); + const NLMISC::CQuad &getQuad() const { return _Quad; } + + void setAdditif(bool additif); + bool getAdditif() const { return _Additif; } + + void setFiltered(bool filtered); + bool getFiltered() const { return _Filtered; } + + void setPattern(float umin, float umax, TWrapMode wrapMode); + + /** Set uvs for each corners -> this will change the wrap mode to CustomUVs + * Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior + */ + void setCustomUVs(const NLMISC::CUV uvs[4]); + + + // from CCtrlBase, no op by default + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + // see if this control contains the given point (in parent coords) + bool contains(const NLMISC::CVector2f &pos) const; + + // no capturable by default (just tooltip capability wanted) + virtual bool isCapturable() const { return false; } + + + private: + NLMISC::CRGBA _Color; + NLMISC::CQuad _Quad; + NLMISC::CQuadUV _RealQuad; // absolute coords + float _ClampedUCorrection; + CViewRenderer::CTextureId _TextureId; /// Accelerator + bool _Additif; + bool _Filtered; + float _UMin; + float _UMax; + TWrapMode _WrapMode; + NLMISC::CUV _CustomUVs[4]; + }; + +} + +#endif diff --git a/code/nel/src/gui/ctrl_quad.cpp b/code/nel/src/gui/ctrl_quad.cpp new file mode 100644 index 000000000..23a43fbd3 --- /dev/null +++ b/code/nel/src/gui/ctrl_quad.cpp @@ -0,0 +1,435 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/ctrl_quad.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/polygon.h" + +using namespace NLMISC; + +namespace NLGUI +{ + + // ********************************************************************************* + CCtrlQuad::CCtrlQuad() : CCtrlBase(TCtorParam()), _Color(CRGBA::White), + _Additif(false), + _Filtered(true), + _UMin(0.f), + _UMax(1.f), + _WrapMode(Repeat) + { + setQuad(CQuad(CVector::Null, CVector::Null, CVector::Null, CVector::Null)); + // preset uvs for real quad + _RealQuad.Uv0.set(0.f, 0.f); + _RealQuad.Uv1.set(1.f, 0.f); + _RealQuad.Uv2.set(1.f, 1.f); + _RealQuad.Uv3.set(0.f, 1.f); + } + + // ********************************************************************************* + bool CCtrlQuad::parse(xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */) + { + nlassert(0); // NOT IMPLEMENTED (only created dynamically at this time) + return false; + } + + // ********************************************************************************* + void CCtrlQuad::updateCoords() + { + H_AUTO(Rz_CCtrlQuad_updateCoords) + CViewBase::updateCoords(); + nlassert(_Parent); + // don't use _XReal && _YReal, because coords are given relative to parent + CVector delta((float) _Parent->getXReal(), (float) _Parent->getYReal(), 0.f); + _RealQuad.set(_Quad.V0 + delta, _Quad.V1 + delta, _Quad.V2 + delta, _Quad.V3 + delta); + } + + // ********************************************************************************* + void CCtrlQuad::draw() + { + H_AUTO(Rz_CCtrlQuad_draw) + nlassert(_Parent); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + CRGBA col; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _Color; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + /*if (_InheritGCAlpha) + { + // search a parent container + CInterfaceGroup *gr = getParent(); + while (gr) + { + if (gr->isGroupContainer()) + { + CGroupContainer *gc = static_cast(gr); + col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); + break; + } + gr = gr->getParent(); + } + }*/ + if (_UMin == 0.f && _UMax == 1.f && _WrapMode != CustomUVs) + { + // no pattern applied, can draw the quad in a single piece + rVR.drawQuad(_RenderLayer, _RealQuad, _TextureId, col, _Additif, _Filtered); + } + else + { + NLMISC::CQuadUV quv; + if (_WrapMode == Repeat) + { + if (_UMax == _UMin) + { + (CQuad &) quv = _RealQuad; // copy CQuad part + float u = fmodf(_UMin, 1.f); + quv.Uv0.set(u, 0.f); + quv.Uv1.set(u, 0.f); + quv.Uv2.set(u, 1.f); + quv.Uv3.set(u, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + else + { + // reverse corners if needed to handle case where _UVMin < _UVmax + NLMISC::CQuad srcQuad; + float umin, umax; + if (_UMax < _UMin) + { + umin = _UMax; + umax = _UMin; + srcQuad.V0 = _RealQuad.V1; + srcQuad.V1 = _RealQuad.V0; + srcQuad.V2 = _RealQuad.V3; + srcQuad.V3 = _RealQuad.V2; + } + else + { + umin = _UMin; + umax = _UMax; + srcQuad = _RealQuad; + } + + + float unitRatio = 1.f / fabsf(umax - umin); // ratio of the real quad delta x in screen for du = 1 + // texture is stretched, mutiple parts needed + float ceilUMin = ceilf(umin); + float firstDeltaU = ceilUMin - umin; + if (firstDeltaU != 0.f) + { + + // start quad + quv.V0 = srcQuad.V0; + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f, (firstDeltaU * unitRatio))); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f, (firstDeltaU * unitRatio))); + quv.V3 = srcQuad.V3; + float lastU = std::min(umax + 1.f - ceilUMin, 1.f); + quv.Uv0.set(1.f - firstDeltaU, 0.f); + quv.Uv1.set(lastU, 0.f); + quv.Uv2.set(lastU, 1.f); + quv.Uv3.set(1.f - firstDeltaU, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + + if (firstDeltaU * unitRatio >= 1.f) return; + } + + // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) + + // intermediate quads + sint numQuads = (sint) (floorf(umax) - ceilf(umin)); + + for(sint k = 0; k < numQuads; ++k) + { + float deltaU = firstDeltaU + k; + // start quad + quv.V0 = blend(srcQuad.V0, srcQuad.V1, deltaU * unitRatio); + quv.V1 = blend(srcQuad.V0, srcQuad.V1, (deltaU + 1.f) * unitRatio); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, (deltaU + 1.f) * unitRatio); + quv.V3 = blend(srcQuad.V3, srcQuad.V2, deltaU * unitRatio); + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(1.f, 0.f); + quv.Uv2.set(1.f, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + // end quad + float lastDeltaU = umax - floorf(umax); + if (lastDeltaU != 0.f) + { + + // start quad + quv.V0 = blend(srcQuad.V1, srcQuad.V0, lastDeltaU * unitRatio); + quv.V1 = srcQuad.V1; + quv.V2 = srcQuad.V2; + quv.V3 = blend(srcQuad.V2, srcQuad.V3, lastDeltaU * unitRatio); + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(lastDeltaU, 0.f); + quv.Uv2.set(lastDeltaU, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + } + + } + else if (_WrapMode == Clamp) + { + if (_UMin == _UMax) + { + (CQuad &) quv = _RealQuad; // copy CQuad part + // special case + float u = _UMin; + clamp(u, 0.f, 1.f); + quv.Uv0.set(u, 0.f); + quv.Uv1.set(u, 1.f); + quv.Uv2.set(u, 1.f); + quv.Uv3.set(u, 0.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + else + { + NLMISC::CQuad srcQuad; + float umin, umax; + if (_UMax < _UMin) + { + umin = _UMax; + umax = _UMin; + srcQuad.V0 = _RealQuad.V1; + srcQuad.V1 = _RealQuad.V0; + srcQuad.V2 = _RealQuad.V3; + srcQuad.V3 = _RealQuad.V2; + } + else + { + umin = _UMin; + umax = _UMax; + srcQuad = _RealQuad; + } + float startRatio = - umin / (umax - umin); // start of unclamped u (actually (0.f - umin) / (umax - umin) ) + if (umin < 0.f) + { + quv.V0 = srcQuad.V0; + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f ,startRatio)); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f ,startRatio)); + quv.V3 = srcQuad.V3; + // draw first clamped part + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(0.f, 0.f); + quv.Uv2.set(0.f, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + if (startRatio >= 1.f) return; + float endRatio = (1.f - umin) / (umax - umin); + if (endRatio > 0.f) + { + // draw middle part if visible + // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) + quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , startRatio)); + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f , endRatio)); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f , endRatio)); + quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , startRatio)); + // draw first clamped part + quv.Uv0.set(std::max(0.f, umin), 0.f); + quv.Uv1.set(std::min(1.f, umax), 0.f); + quv.Uv2.set(std::min(1.f, umax), 1.f); + quv.Uv3.set(std::max(0.f, umin), 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + if (endRatio >= 1.f) return; + // draw end part + quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , endRatio)); + quv.V1 = srcQuad.V1; + quv.V2 = srcQuad.V2; + quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , endRatio)); + // draw end clamped part + quv.Uv0.set(1.f, 0.f); + quv.Uv1.set(1.f, 0.f); + quv.Uv2.set(1.f, 1.f); + quv.Uv3.set(1.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + } + else + { + nlassert(_WrapMode == CustomUVs); + quv.V0 = _RealQuad.V0; + quv.V1 = _RealQuad.V1; + quv.V2 = _RealQuad.V2; + quv.V3 = _RealQuad.V3; + quv.Uv0 = _CustomUVs[0]; + quv.Uv1 = _CustomUVs[1]; + quv.Uv2 = _CustomUVs[2]; + quv.Uv3 = _CustomUVs[3]; + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); + } + } + } + + // ********************************************************************************* + void CCtrlQuad::setAlpha(sint32 a) + { + H_AUTO(Rz_CCtrlQuad_setAlpha) + _Color.A = (uint8) a; + } + + // ********************************************************************************* + void CCtrlQuad::setTexture(const std::string &texName) + { + H_AUTO(Rz_CCtrlQuad_setTexture) + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureId.setTexture(texName.c_str()); + } + + // ********************************************************************************* + std::string CCtrlQuad::getTexture() const + { + H_AUTO(Rz_CCtrlQuad_getTexture) + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId (_TextureId); + } + + // ********************************************************************************* + void CCtrlQuad::setQuad(const CQuad &quad) + { + H_AUTO(Rz_CCtrlQuad_setQuad) + float qXMin = minof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); + float qXMax = maxof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); + float qYMin = minof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); + float qYMax = maxof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); + setPosRef(Hotspot_BL); + setX((sint32) floorf(qXMin)); + setY((sint32) floorf(qYMin)); + setW((sint32) ceilf(qXMax) - getX()); + setH((sint32) ceilf(qYMax) - getY()); + _Quad = quad; + } + + // ********************************************************************************* + void CCtrlQuad::setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness) + { + H_AUTO(Rz_CCtrlQuad_setQuad) + CVector right = end - start; + CVector up(-right.y, right.x, 0.f); + up = thickness * up.normed(); + setQuad(CQuad(start + up, end + up, end - up, start - up)); + } + + // ********************************************************************************* + void CCtrlQuad::setQuad(const NLMISC::CVector &pos, float radius, float angle /*=0.f*/) + { + H_AUTO(Rz_CCtrlQuad_setQuad) + if (angle == 0.f) + { + setQuad(pos - radius * CVector::I, pos + radius * CVector::I, radius); + } + else + { + CVector right(radius * cosf(angle), radius * sinf(angle), 0.f); + setQuad(pos - right, pos + right, radius); + } + } + + // ********************************************************************************* + void CCtrlQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPos, float angle /*= 0.f*/, float offCenter /* = 0.f*/) + { + H_AUTO(Rz_CCtrlQuad_setQuad) + NLMISC::CVector pos = srcPos; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 w, h; + rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); + if (angle == 0.f) + { + if (offCenter != 0.f) + { + pos.x += offCenter; + } + setQuad(pos - 0.5f * w * CVector::I, pos + 0.5f * w * CVector::I, 0.5f * h); + } + else + { + CVector unitRadius(cosf(angle), sinf(angle), 0.f); + CVector radius = 0.5f * w * unitRadius; + pos += offCenter * unitRadius; + setQuad(pos - radius, pos + radius, 0.5f * h); + } + } + + // ********************************************************************************* + void CCtrlQuad::setAdditif(bool additif) + { + H_AUTO(Rz_CCtrlQuad_setAdditif) + _Additif = additif; + } + + // ********************************************************************************* + void CCtrlQuad::setFiltered(bool filtered) + { + H_AUTO(Rz_CCtrlQuad_setFiltered) + _Filtered = filtered; + } + + // ********************************************************************************* + void CCtrlQuad::setPattern(float umin, float umax, TWrapMode wrapMode) + { + H_AUTO(Rz_CCtrlQuad_setPattern) + nlassert((uint) wrapMode < CustomUVs); + _UMin = umin; + _UMax = umax; + _WrapMode = wrapMode; + } + + // ********************************************************************************* + void CCtrlQuad::setCustomUVs(const CUV uvs[4]) + { + H_AUTO(Rz_CCtrlQuad_setCustomUVs) + std::copy(uvs, uvs + 4, _CustomUVs ); + _WrapMode = CustomUVs; + } + + // ********************************************************************************* + bool CCtrlQuad::handleEvent(const NLGUI::CEventDescriptor &/* event */) + { + H_AUTO(Rz_CCtrlQuad_handleEvent) + return false; + } + + // ********************************************************************************* + bool CCtrlQuad::contains(const NLMISC::CVector2f &pos) const + { + H_AUTO(Rz_CCtrlQuad_contains) + static NLMISC::CPolygon2D poly; + poly.Vertices.resize(4); + poly.Vertices[0] = _Quad.V0; + poly.Vertices[1] = _Quad.V1; + poly.Vertices[2] = _Quad.V2; + poly.Vertices[3] = _Quad.V3; + return poly.contains(pos, false); + } + +} + + + diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp b/code/ryzom/client/src/interface_v3/ctrl_quad.cpp deleted file mode 100644 index f1da0754b..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.cpp +++ /dev/null @@ -1,435 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "ctrl_quad.h" -#include "nel/gui/interface_group.h" -#include "interface_manager.h" - -using namespace NLMISC; - -// ********************************************************************************* -CCtrlQuad::CCtrlQuad() : CCtrlBase(TCtorParam()), _Color(CRGBA::White), - _Additif(false), - _Filtered(true), - _UMin(0.f), - _UMax(1.f), - _WrapMode(Repeat) -{ - setQuad(CQuad(CVector::Null, CVector::Null, CVector::Null, CVector::Null)); - // preset uvs for real quad - _RealQuad.Uv0.set(0.f, 0.f); - _RealQuad.Uv1.set(1.f, 0.f); - _RealQuad.Uv2.set(1.f, 1.f); - _RealQuad.Uv3.set(0.f, 1.f); -} - -// ********************************************************************************* -bool CCtrlQuad::parse(xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */) -{ - nlassert(0); // NOT IMPLEMENTED (only created dynamically at this time) - return false; -} - -// ********************************************************************************* -void CCtrlQuad::updateCoords() -{ - H_AUTO(Rz_CCtrlQuad_updateCoords) - CViewBase::updateCoords(); - nlassert(_Parent); - // don't use _XReal && _YReal, because coords are given relative to parent - CVector delta((float) _Parent->getXReal(), (float) _Parent->getYReal(), 0.f); - _RealQuad.set(_Quad.V0 + delta, _Quad.V1 + delta, _Quad.V2 + delta, _Quad.V3 + delta); -} - -// ********************************************************************************* -void CCtrlQuad::draw() -{ - H_AUTO(Rz_CCtrlQuad_draw) - nlassert(_Parent); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - CRGBA col; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - /*if (_InheritGCAlpha) - { - // search a parent container - CInterfaceGroup *gr = getParent(); - while (gr) - { - if (gr->isGroupContainer()) - { - CGroupContainer *gc = static_cast(gr); - col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); - break; - } - gr = gr->getParent(); - } - }*/ - if (_UMin == 0.f && _UMax == 1.f && _WrapMode != CustomUVs) - { - // no pattern applied, can draw the quad in a single piece - rVR.drawQuad(_RenderLayer, _RealQuad, _TextureId, col, _Additif, _Filtered); - } - else - { - NLMISC::CQuadUV quv; - if (_WrapMode == Repeat) - { - if (_UMax == _UMin) - { - (CQuad &) quv = _RealQuad; // copy CQuad part - float u = fmodf(_UMin, 1.f); - quv.Uv0.set(u, 0.f); - quv.Uv1.set(u, 0.f); - quv.Uv2.set(u, 1.f); - quv.Uv3.set(u, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - else - { - // reverse corners if needed to handle case where _UVMin < _UVmax - NLMISC::CQuad srcQuad; - float umin, umax; - if (_UMax < _UMin) - { - umin = _UMax; - umax = _UMin; - srcQuad.V0 = _RealQuad.V1; - srcQuad.V1 = _RealQuad.V0; - srcQuad.V2 = _RealQuad.V3; - srcQuad.V3 = _RealQuad.V2; - } - else - { - umin = _UMin; - umax = _UMax; - srcQuad = _RealQuad; - } - - - float unitRatio = 1.f / fabsf(umax - umin); // ratio of the real quad delta x in screen for du = 1 - // texture is stretched, mutiple parts needed - float ceilUMin = ceilf(umin); - float firstDeltaU = ceilUMin - umin; - if (firstDeltaU != 0.f) - { - - // start quad - quv.V0 = srcQuad.V0; - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f, (firstDeltaU * unitRatio))); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f, (firstDeltaU * unitRatio))); - quv.V3 = srcQuad.V3; - float lastU = std::min(umax + 1.f - ceilUMin, 1.f); - quv.Uv0.set(1.f - firstDeltaU, 0.f); - quv.Uv1.set(lastU, 0.f); - quv.Uv2.set(lastU, 1.f); - quv.Uv3.set(1.f - firstDeltaU, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - - if (firstDeltaU * unitRatio >= 1.f) return; - } - - // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) - - // intermediate quads - sint numQuads = (sint) (floorf(umax) - ceilf(umin)); - - for(sint k = 0; k < numQuads; ++k) - { - float deltaU = firstDeltaU + k; - // start quad - quv.V0 = blend(srcQuad.V0, srcQuad.V1, deltaU * unitRatio); - quv.V1 = blend(srcQuad.V0, srcQuad.V1, (deltaU + 1.f) * unitRatio); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, (deltaU + 1.f) * unitRatio); - quv.V3 = blend(srcQuad.V3, srcQuad.V2, deltaU * unitRatio); - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(1.f, 0.f); - quv.Uv2.set(1.f, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - // end quad - float lastDeltaU = umax - floorf(umax); - if (lastDeltaU != 0.f) - { - - // start quad - quv.V0 = blend(srcQuad.V1, srcQuad.V0, lastDeltaU * unitRatio); - quv.V1 = srcQuad.V1; - quv.V2 = srcQuad.V2; - quv.V3 = blend(srcQuad.V2, srcQuad.V3, lastDeltaU * unitRatio); - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(lastDeltaU, 0.f); - quv.Uv2.set(lastDeltaU, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - } - - } - else if (_WrapMode == Clamp) - { - if (_UMin == _UMax) - { - (CQuad &) quv = _RealQuad; // copy CQuad part - // special case - float u = _UMin; - clamp(u, 0.f, 1.f); - quv.Uv0.set(u, 0.f); - quv.Uv1.set(u, 1.f); - quv.Uv2.set(u, 1.f); - quv.Uv3.set(u, 0.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - else - { - NLMISC::CQuad srcQuad; - float umin, umax; - if (_UMax < _UMin) - { - umin = _UMax; - umax = _UMin; - srcQuad.V0 = _RealQuad.V1; - srcQuad.V1 = _RealQuad.V0; - srcQuad.V2 = _RealQuad.V3; - srcQuad.V3 = _RealQuad.V2; - } - else - { - umin = _UMin; - umax = _UMax; - srcQuad = _RealQuad; - } - float startRatio = - umin / (umax - umin); // start of unclamped u (actually (0.f - umin) / (umax - umin) ) - if (umin < 0.f) - { - quv.V0 = srcQuad.V0; - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f ,startRatio)); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f ,startRatio)); - quv.V3 = srcQuad.V3; - // draw first clamped part - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(0.f, 0.f); - quv.Uv2.set(0.f, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - if (startRatio >= 1.f) return; - float endRatio = (1.f - umin) / (umax - umin); - if (endRatio > 0.f) - { - // draw middle part if visible - // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) - quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , startRatio)); - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f , endRatio)); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f , endRatio)); - quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , startRatio)); - // draw first clamped part - quv.Uv0.set(std::max(0.f, umin), 0.f); - quv.Uv1.set(std::min(1.f, umax), 0.f); - quv.Uv2.set(std::min(1.f, umax), 1.f); - quv.Uv3.set(std::max(0.f, umin), 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - if (endRatio >= 1.f) return; - // draw end part - quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , endRatio)); - quv.V1 = srcQuad.V1; - quv.V2 = srcQuad.V2; - quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , endRatio)); - // draw end clamped part - quv.Uv0.set(1.f, 0.f); - quv.Uv1.set(1.f, 0.f); - quv.Uv2.set(1.f, 1.f); - quv.Uv3.set(1.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - } - else - { - nlassert(_WrapMode == CustomUVs); - quv.V0 = _RealQuad.V0; - quv.V1 = _RealQuad.V1; - quv.V2 = _RealQuad.V2; - quv.V3 = _RealQuad.V3; - quv.Uv0 = _CustomUVs[0]; - quv.Uv1 = _CustomUVs[1]; - quv.Uv2 = _CustomUVs[2]; - quv.Uv3 = _CustomUVs[3]; - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif, _Filtered); - } - } -} - -// ********************************************************************************* -void CCtrlQuad::setAlpha(sint32 a) -{ - H_AUTO(Rz_CCtrlQuad_setAlpha) - _Color.A = (uint8) a; -} - -// ********************************************************************************* -void CCtrlQuad::setTexture(const std::string &texName) -{ - H_AUTO(Rz_CCtrlQuad_setTexture) -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureId.setTexture(texName.c_str()); -} - -// ********************************************************************************* -std::string CCtrlQuad::getTexture() const -{ - H_AUTO(Rz_CCtrlQuad_getTexture) - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId (_TextureId); -} - -// ********************************************************************************* -void CCtrlQuad::setQuad(const CQuad &quad) -{ - H_AUTO(Rz_CCtrlQuad_setQuad) - float qXMin = minof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); - float qXMax = maxof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); - float qYMin = minof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); - float qYMax = maxof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); - setPosRef(Hotspot_BL); - setX((sint32) floorf(qXMin)); - setY((sint32) floorf(qYMin)); - setW((sint32) ceilf(qXMax) - getX()); - setH((sint32) ceilf(qYMax) - getY()); - _Quad = quad; -} - -// ********************************************************************************* -void CCtrlQuad::setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness) -{ - H_AUTO(Rz_CCtrlQuad_setQuad) - CVector right = end - start; - CVector up(-right.y, right.x, 0.f); - up = thickness * up.normed(); - setQuad(CQuad(start + up, end + up, end - up, start - up)); -} - -// ********************************************************************************* -void CCtrlQuad::setQuad(const NLMISC::CVector &pos, float radius, float angle /*=0.f*/) -{ - H_AUTO(Rz_CCtrlQuad_setQuad) - if (angle == 0.f) - { - setQuad(pos - radius * CVector::I, pos + radius * CVector::I, radius); - } - else - { - CVector right(radius * cosf(angle), radius * sinf(angle), 0.f); - setQuad(pos - right, pos + right, radius); - } -} - -// ********************************************************************************* -void CCtrlQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPos, float angle /*= 0.f*/, float offCenter /* = 0.f*/) -{ - H_AUTO(Rz_CCtrlQuad_setQuad) - NLMISC::CVector pos = srcPos; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 w, h; - rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); - if (angle == 0.f) - { - if (offCenter != 0.f) - { - pos.x += offCenter; - } - setQuad(pos - 0.5f * w * CVector::I, pos + 0.5f * w * CVector::I, 0.5f * h); - } - else - { - CVector unitRadius(cosf(angle), sinf(angle), 0.f); - CVector radius = 0.5f * w * unitRadius; - pos += offCenter * unitRadius; - setQuad(pos - radius, pos + radius, 0.5f * h); - } -} - -// ********************************************************************************* -void CCtrlQuad::setAdditif(bool additif) -{ - H_AUTO(Rz_CCtrlQuad_setAdditif) - _Additif = additif; -} - -// ********************************************************************************* -void CCtrlQuad::setFiltered(bool filtered) -{ - H_AUTO(Rz_CCtrlQuad_setFiltered) - _Filtered = filtered; -} - -// ********************************************************************************* -void CCtrlQuad::setPattern(float umin, float umax, TWrapMode wrapMode) -{ - H_AUTO(Rz_CCtrlQuad_setPattern) - nlassert((uint) wrapMode < CustomUVs); - _UMin = umin; - _UMax = umax; - _WrapMode = wrapMode; -} - -// ********************************************************************************* -void CCtrlQuad::setCustomUVs(const CUV uvs[4]) -{ - H_AUTO(Rz_CCtrlQuad_setCustomUVs) - std::copy(uvs, uvs + 4, _CustomUVs ); - _WrapMode = CustomUVs; -} - -// ********************************************************************************* -bool CCtrlQuad::handleEvent(const NLGUI::CEventDescriptor &/* event */) -{ - H_AUTO(Rz_CCtrlQuad_handleEvent) - return false; -} - -// ********************************************************************************* -bool CCtrlQuad::contains(const NLMISC::CVector2f &pos) const -{ - H_AUTO(Rz_CCtrlQuad_contains) - static NLMISC::CPolygon2D poly; - poly.Vertices.resize(4); - poly.Vertices[0] = _Quad.V0; - poly.Vertices[1] = _Quad.V1; - poly.Vertices[2] = _Quad.V2; - poly.Vertices[3] = _Quad.V3; - return poly.contains(pos, false); -} - - - - - diff --git a/code/ryzom/client/src/interface_v3/ctrl_quad.h b/code/ryzom/client/src/interface_v3/ctrl_quad.h deleted file mode 100644 index 2e4ec17ca..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_quad.h +++ /dev/null @@ -1,112 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_CTRL_QUAD_H -#define RZ_CTRL_QUAD_H - -#include "nel/gui/ctrl_base.h" -#include "nel/gui/view_renderer.h" -#include "nel/misc/geom_ext.h" - -/** Display of an arbitrary textured quad in the UI. The applied texture is filtered. - * Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates - * are driven by the quad vertices coordinates (see setQuad). - * - * Derives from CCtrlBase for tooltipping support - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 12/2005 - */ -class CCtrlQuad : public CCtrlBase -{ -public: - enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount }; - - - CCtrlQuad(); - - // from CInterfaceElement - bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup); - virtual void updateCoords(); - virtual void draw(); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - // from CViewBase - virtual sint32 getAlpha() const { return (sint32) _Color.A; } - virtual void setAlpha (sint32 a); - - // texture - void setTexture(const std::string &texName); - std::string getTexture () const; - - // color - void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } - NLMISC::CRGBA getColorRGBA() const { return _Color; } - - /** Set a new quad relative to parent pos - * x,y, w, h & hotspot are updated to fit the bounding rect of the quad - */ - void setQuad(const NLMISC::CQuad &quad); - void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness); - /** Fit the given texture size (no hotspot for now, always centered) - * NB : current texture is not modified. - */ - void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f); - void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f); - const NLMISC::CQuad &getQuad() const { return _Quad; } - - void setAdditif(bool additif); - bool getAdditif() const { return _Additif; } - - void setFiltered(bool filtered); - bool getFiltered() const { return _Filtered; } - - void setPattern(float umin, float umax, TWrapMode wrapMode); - - /** Set uvs for each corners -> this will change the wrap mode to CustomUVs - * Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior - */ - void setCustomUVs(const NLMISC::CUV uvs[4]); - - - // from CCtrlBase, no op by default - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - // see if this control contains the given point (in parent coords) - bool contains(const NLMISC::CVector2f &pos) const; - - // no capturable by default (just tooltip capability wanted) - virtual bool isCapturable() const { return false; } - - -private: - NLMISC::CRGBA _Color; - NLMISC::CQuad _Quad; - NLMISC::CQuadUV _RealQuad; // absolute coords - float _ClampedUCorrection; - CViewRenderer::CTextureId _TextureId; /// Accelerator - bool _Additif; - bool _Filtered; - float _UMin; - float _UMax; - TWrapMode _WrapMode; - NLMISC::CUV _CustomUVs[4]; -}; - - -#endif diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 01aabff64..68341375f 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -36,7 +36,7 @@ #include "people_interraction.h" // for MaxNumPeopleInTeam #include "../sheet_manager.h" // for MaxNumPeopleInTeam #include "../global.h" -#include "ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" // #include "nel/misc/xml_auto_ptr.h" #include "game_share/mission_desc.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index a276e5a5b..d2fa808b7 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -35,11 +35,18 @@ class CContinent; -namespace NLMISC{ -class CCDBNodeLeaf; + +namespace NLMISC +{ + class CCDBNodeLeaf; } + +namespace NLGUI +{ + class CCtrlQuad; +} + class CWorldSheet; -class CCtrlQuad; struct SMap; namespace NL3D diff --git a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp index a15d4492a..40f1823e5 100644 --- a/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_activity_sequence.cpp @@ -19,7 +19,7 @@ #include "displayer_visual_group.h" #include "r2_config.h" // -#include "../interface_v3/ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" #include "../interface_v3/interface_manager.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/r2/displayer_visual_group.cpp b/code/ryzom/client/src/r2/displayer_visual_group.cpp index fed72c85a..d4daa2e67 100644 --- a/code/ryzom/client/src/r2/displayer_visual_group.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_group.cpp @@ -34,7 +34,7 @@ #include "../misc.h" #include "../landscape_poly_drawer.h" #include "../interface_v3/ctrl_polygon.h" -#include "../interface_v3/ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" #include "../time_client.h" // diff --git a/code/ryzom/client/src/r2/instance_map_deco.cpp b/code/ryzom/client/src/r2/instance_map_deco.cpp index 476326b19..c6b1b2dae 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.cpp +++ b/code/ryzom/client/src/r2/instance_map_deco.cpp @@ -20,7 +20,7 @@ #include "r2_config.h" #include "tool.h" // -#include "../interface_v3/ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" #include "../interface_v3/group_container.h" // #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/r2/instance_map_deco.h b/code/ryzom/client/src/r2/instance_map_deco.h index 6f0f62977..074604dc7 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.h +++ b/code/ryzom/client/src/r2/instance_map_deco.h @@ -21,8 +21,12 @@ #include "../interface_v3/group_map.h" #include "displayer_visual.h" +namespace NLGUI +{ + class CCtrlQuad; +} + class CGroupMap; -class CCtrlQuad; class CViewBitmap; namespace R2 diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index 9d6c16393..19b987e09 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -23,7 +23,7 @@ #include "nel/misc/time_nl.h" // #include "../interface_v3/view_bitmap.h" -#include "../interface_v3/ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" #include "../interface_v3/ctrl_polygon.h" #include "../interface_v3/interface_manager.h" #include "nel/gui/view_renderer.h" diff --git a/code/ryzom/client/src/r2/tool_draw_prim.cpp b/code/ryzom/client/src/r2/tool_draw_prim.cpp index be0fdacf7..8bc8fdf99 100644 --- a/code/ryzom/client/src/r2/tool_draw_prim.cpp +++ b/code/ryzom/client/src/r2/tool_draw_prim.cpp @@ -32,7 +32,7 @@ #include "nel/misc/polygon.h" // // tmp tmp -#include "../interface_v3/ctrl_quad.h" +#include "nel/gui/ctrl_quad.h" using namespace NLMISC; From 3933bd73d3175c0069717b059ae2d3492dbe6edb Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 02:55:19 +0200 Subject: [PATCH 067/339] CHANGED: #1471 CCtrlPolygon is now in the NELGUI library and is under NLGUI. --- code/nel/include/nel/gui/ctrl_polygon.h | 94 ++++++ code/nel/src/gui/ctrl_polygon.cpp | 306 ++++++++++++++++++ .../client/src/interface_v3/ctrl_polygon.cpp | 305 ----------------- .../client/src/interface_v3/ctrl_polygon.h | 88 ----- code/ryzom/client/src/main_loop.cpp | 2 +- .../client/src/r2/displayer_visual_group.cpp | 2 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- code/ryzom/client/src/r2/prim_render.h | 2 +- 8 files changed, 404 insertions(+), 397 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_polygon.h create mode 100644 code/nel/src/gui/ctrl_polygon.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_polygon.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_polygon.h diff --git a/code/nel/include/nel/gui/ctrl_polygon.h b/code/nel/include/nel/gui/ctrl_polygon.h new file mode 100644 index 000000000..dc785e250 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_polygon.h @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// 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 RZ_CTRL_POLYGON_H +#define RZ_CTRL_POLYGON_H + +#include "nel/gui/ctrl_base.h" +#include "nel/gui/view_renderer.h" +#include "nel/misc/geom_ext.h" +#include "nel/misc/polygon.h" + +namespace NLMISC +{ + class CVector2f; +} + +namespace NLGUI +{ + + /** Display of an arbitrary polygon in the ui. + * polygons are clipped & batched. + * + * Derives from CCtrlBase in order to provide button / tooltip capability + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 1/2006 + */ + class CCtrlPolygon : public CCtrlBase + { + public: + CCtrlPolygon(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords(); + virtual void draw(); + /** Change the vertices. This is costly because concav / complex polys are split in a list of triangles + */ + void setVertices(const std::vector &vertices); + const std::vector &getVertices() const { return _Poly.Vertices; } + // test if current position in inside the current (transformed) poly (in window space) + bool contains(const NLMISC::CVector2f &pos) const; + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha(sint32 a); + /** Change the matrix for this poly. Changing the matrix is usually cheaper than changing + * The vertices because complex poly do not have to be split again + */ + //void setMatrix(const NLMISC::CMatrix &mat); + //const NLMISC::CMatrix &getMatrix() const { return _Matrix; } + // test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself) + bool isValid() const { return _Valid; } + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + // no capturable by default (just tooltip capability wanted) + virtual bool isCapturable() const { return false; } + private: + NLMISC::CPolygon _Poly; + NLMISC::CPolygon2D _XFormPoly; + //NLMISC::CMatrix _Matrix; + bool _Valid; + bool _Touched; + NLMISC::CRGBA _Color; + std::vector _Tris; + std::vector _RealTris; // clipped tris in screen coordinates + private: + void updateBoudingRect(); + protected: + // TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ... + virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src); + public: + void touch(); + }; + +} + + +#endif diff --git a/code/nel/src/gui/ctrl_polygon.cpp b/code/nel/src/gui/ctrl_polygon.cpp new file mode 100644 index 000000000..8280f292a --- /dev/null +++ b/code/nel/src/gui/ctrl_polygon.cpp @@ -0,0 +1,306 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/ctrl_polygon.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/interface_group.h" + +using namespace NLMISC; + +namespace NLGUI +{ + + // ********************************************************************************* + CCtrlPolygon::CCtrlPolygon() : CCtrlBase(TCtorParam()) + { + // Construct + _Color = CRGBA::White; + //_Matrix = CMatrix::Identity; + _Valid = true; + } + + // ********************************************************************************* + void CCtrlPolygon::updateBoudingRect() + { + H_AUTO(Rz_CCtrlPolygon_updateBoudingRect) + if (_Poly.Vertices.empty()) + { + setX(0); + setY(0); + setW(0); + setH(0); + return; + } + // + sint32 xmin = INT_MAX; + sint32 ymin = INT_MAX; + sint32 xmax = INT_MIN; + sint32 ymax = INT_MIN; + uint numVerts = (uint)_Poly.Vertices.size(); + _XFormPoly.Vertices.resize(numVerts); + for(uint k = 0; k < numVerts; ++k) + { + CVector2f &finalPos = _XFormPoly.Vertices[k]; + //finalPos = _Matrix * _Poly.Vertices[k]; + computeScaledVertex(finalPos, CVector2f(_Poly.Vertices[k].x, _Poly.Vertices[k].y)); + xmin = std::min(xmin, (sint32) floorf(finalPos.x)); + xmax = std::max(xmax, (sint32) ceilf(finalPos.x)); + ymin = std::min(ymin, (sint32) floorf(finalPos.y)); + ymax = std::max(ymax, (sint32) ceilf(finalPos.y)); + } + setX(xmin); + setY(ymin); + setW(xmax - xmin); + setH(ymax - ymin); + } + + // ********************************************************************************* + bool CCtrlPolygon::contains(const CVector2f &pos) const + { + H_AUTO(Rz_CCtrlPolygon_contains) + if (!_Valid) return false; + return _XFormPoly.contains(pos, false); + } + + // ********************************************************************************* + void CCtrlPolygon::setVertices(const std::vector &vertices) + { + H_AUTO(Rz_CCtrlPolygon_setVertices) + if (vertices.size() == _Poly.Vertices.size() && + std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged + + + //TTicks startTime = CTime::getPerformanceTime(); + + _Poly.Vertices = vertices; + _Tris.clear(); + std::list polys; + bool splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity); + if (!splitDone) + { + polys.clear(); + // maybe wrong orientation + std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end()); + splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity); + std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end()); + } + _Tris.clear(); + if (splitDone) + { + for(std::list::iterator it = polys.begin(); it != polys.end(); ++it) + { + it->toTriFan(_Tris); + } + } + _Touched = true; + updateBoudingRect(); + _Valid = splitDone; + + //TTicks endTime = CTime::getPerformanceTime(); + //nlinfo("%d ms for CCtrlPolygon::setVertices", (int) (1000 * CTime::ticksToSecond(endTime - startTime))); + } + + + static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) + { + return (sint32) maxCorner.x < (cx + cw) && + (sint32) minCorner.x >= cx && + (sint32) maxCorner.y < (cy + ch) && + (sint32) minCorner.y >= cy; + } + + static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) + { + return (sint32) minCorner.x >= (cx + cw) || + (sint32) maxCorner.x < cx || + (sint32) minCorner.y >= (cy + ch) || + (sint32) maxCorner.y < cy; + } + + + // ********************************************************************************* + /*void CCtrlPolygon::setMatrix(const NLMISC::CMatrix &mat) + { + const float *lhs = mat.get(); + const float *rhs = _Matrix.get(); + if (std::equal(lhs, lhs + 16, rhs)) return; // unmodified... + _Matrix = mat; + updateBoudingRect(); + _Touched = true; + }*/ + + + // ********************************************************************************* + void CCtrlPolygon::draw() + { + H_AUTO(Rz_CCtrlPolygon_draw) + if (_Tris.empty()) return; + if (!_Parent) return; + CViewRenderer &vr = *CViewRenderer::getInstance(); + if (_Touched) + { + _RealTris.clear(); + uint numTris = (uint)_Tris.size(); + sint32 cornerX, cornerY; + static std::vector winTris; + winTris.resize(numTris); + _Parent->getCorner(cornerX, cornerY, _ParentPosRef); + /*CMatrix m = _Matrix; + m.setPos(m.getPos() + CVector((float) cornerX, (float) cornerY, 0.f));*/ + for(uint k = 0; k < numTris; ++k) + { + /*winTris[k].V0 = m * _Tris[k].V0; + winTris[k].V1 = m * _Tris[k].V1; + winTris[k].V2 = m * _Tris[k].V2;*/ + + CVector2f result; + computeScaledVertex(result, _Tris[k].V0); + winTris[k].V0.set(result.x + cornerX, result.y + cornerY, 0.f); + computeScaledVertex(result, _Tris[k].V1); + winTris[k].V1.set(result.x + cornerX, result.y + cornerY, 0.f); + computeScaledVertex(result, _Tris[k].V2); + winTris[k].V2.set(result.x + cornerX, result.y + cornerY, 0.f); + } + // recompute & reclip poly + _RealTris.clear(); + sint32 cx, cy, cw, ch; + vr.getClipWindow(cx, cy, cw, ch); + // per tri clip + NLMISC::CVector minCorner; + NLMISC::CVector maxCorner; + for(uint k = 0; k < numTris; ++k) + { + winTris[k].getMinCorner(minCorner); + winTris[k].getMaxCorner(maxCorner); + if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue; + if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch)) + { + _RealTris.push_back(winTris[k]); + } + else + { + const uint maxNumCorners = 8; + static CVector outPos0[maxNumCorners]; + static CVector outPos1[maxNumCorners]; + // + outPos0[0] = winTris[k].V0; + outPos0[1] = winTris[k].V1; + outPos0[2] = winTris[k].V2; + // + CVector *pPos0 = outPos0; + CVector *pPos1 = outPos1; + // + sint count = 3; + // + if ((sint32) minCorner.x < cx) + { + // clip left + CPlane clipper(-1.f, 0.f, 0.f, (float) cx); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + if ((sint32) maxCorner.x > cx + cw) + { + // clip right + CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw)); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + // + if ((sint32) minCorner.y < cy) + { + // clip bottom + CPlane clipper(0.f, -1.f, 0.f, (float) cy); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + if ((sint32) maxCorner.y > cy + ch) + { + // clip top + CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch)); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + nlassert(count <= 8); + if (count >= 3) + { + for(uint k = 0; k < (uint) (count - 2); ++k) + { + _RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2])); + } + } + } + } + _Touched = false; + } + if (_RealTris.empty()) return; + CRGBA col; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _Color; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); + } + + // ********************************************************************************* + void CCtrlPolygon::updateCoords() + { + H_AUTO(Rz_CCtrlPolygon_updateCoords) + CCtrlBase::updateCoords(); + updateBoudingRect(); + // assume that clipping will have to be done again, real update of triangle will be done at render time + _Touched = true; + } + + // ********************************************************************************* + void CCtrlPolygon::setAlpha(sint32 a) + { + H_AUTO(Rz_CCtrlPolygon_setAlpha) + _Color.A = (uint8) a; + } + + // ********************************************************************************* + bool CCtrlPolygon::handleEvent(const NLGUI::CEventDescriptor &/* event */) + { + H_AUTO(Rz_CCtrlPolygon_handleEvent) + return false; + } + + // ********************************************************************************* + // TMP TMP + void CCtrlPolygon::computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src) + { + H_AUTO(Rz_CCtrlPolygon_computeScaledVertex) + dest.set(src.x, src.y); + } + + // ********************************************************************************* + // TMP TMP + void CCtrlPolygon::touch() + { + H_AUTO(Rz_CCtrlPolygon_touch) + updateBoudingRect(); + _Touched = true; + } + +} + diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp b/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp deleted file mode 100644 index 1b28fea13..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.cpp +++ /dev/null @@ -1,305 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "ctrl_polygon.h" -#include "nel/gui/view_renderer.h" -#include "interface_manager.h" - - -using namespace NLMISC; - -// ********************************************************************************* -CCtrlPolygon::CCtrlPolygon() : CCtrlBase(TCtorParam()) -{ - // Construct - _Color = CRGBA::White; - //_Matrix = CMatrix::Identity; - _Valid = true; -} - -// ********************************************************************************* -void CCtrlPolygon::updateBoudingRect() -{ - H_AUTO(Rz_CCtrlPolygon_updateBoudingRect) - if (_Poly.Vertices.empty()) - { - setX(0); - setY(0); - setW(0); - setH(0); - return; - } - // - sint32 xmin = INT_MAX; - sint32 ymin = INT_MAX; - sint32 xmax = INT_MIN; - sint32 ymax = INT_MIN; - uint numVerts = (uint)_Poly.Vertices.size(); - _XFormPoly.Vertices.resize(numVerts); - for(uint k = 0; k < numVerts; ++k) - { - CVector2f &finalPos = _XFormPoly.Vertices[k]; - //finalPos = _Matrix * _Poly.Vertices[k]; - computeScaledVertex(finalPos, CVector2f(_Poly.Vertices[k].x, _Poly.Vertices[k].y)); - xmin = std::min(xmin, (sint32) floorf(finalPos.x)); - xmax = std::max(xmax, (sint32) ceilf(finalPos.x)); - ymin = std::min(ymin, (sint32) floorf(finalPos.y)); - ymax = std::max(ymax, (sint32) ceilf(finalPos.y)); - } - setX(xmin); - setY(ymin); - setW(xmax - xmin); - setH(ymax - ymin); -} - -// ********************************************************************************* -bool CCtrlPolygon::contains(const CVector2f &pos) const -{ - H_AUTO(Rz_CCtrlPolygon_contains) - if (!_Valid) return false; - return _XFormPoly.contains(pos, false); -} - -// ********************************************************************************* -void CCtrlPolygon::setVertices(const std::vector &vertices) -{ - H_AUTO(Rz_CCtrlPolygon_setVertices) - if (vertices.size() == _Poly.Vertices.size() && - std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged - - - //TTicks startTime = CTime::getPerformanceTime(); - - _Poly.Vertices = vertices; - _Tris.clear(); - std::list polys; - bool splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity); - if (!splitDone) - { - polys.clear(); - // maybe wrong orientation - std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end()); - splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity); - std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end()); - } - _Tris.clear(); - if (splitDone) - { - for(std::list::iterator it = polys.begin(); it != polys.end(); ++it) - { - it->toTriFan(_Tris); - } - } - _Touched = true; - updateBoudingRect(); - _Valid = splitDone; - - //TTicks endTime = CTime::getPerformanceTime(); - //nlinfo("%d ms for CCtrlPolygon::setVertices", (int) (1000 * CTime::ticksToSecond(endTime - startTime))); -} - - -static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) -{ - return (sint32) maxCorner.x < (cx + cw) && - (sint32) minCorner.x >= cx && - (sint32) maxCorner.y < (cy + ch) && - (sint32) minCorner.y >= cy; -} - -static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) -{ - return (sint32) minCorner.x >= (cx + cw) || - (sint32) maxCorner.x < cx || - (sint32) minCorner.y >= (cy + ch) || - (sint32) maxCorner.y < cy; -} - - -// ********************************************************************************* -/*void CCtrlPolygon::setMatrix(const NLMISC::CMatrix &mat) -{ - const float *lhs = mat.get(); - const float *rhs = _Matrix.get(); - if (std::equal(lhs, lhs + 16, rhs)) return; // unmodified... - _Matrix = mat; - updateBoudingRect(); - _Touched = true; -}*/ - - -// ********************************************************************************* -void CCtrlPolygon::draw() -{ - H_AUTO(Rz_CCtrlPolygon_draw) - if (_Tris.empty()) return; - if (!_Parent) return; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = *CViewRenderer::getInstance(); - if (_Touched) - { - _RealTris.clear(); - uint numTris = (uint)_Tris.size(); - sint32 cornerX, cornerY; - static std::vector winTris; - winTris.resize(numTris); - _Parent->getCorner(cornerX, cornerY, _ParentPosRef); - /*CMatrix m = _Matrix; - m.setPos(m.getPos() + CVector((float) cornerX, (float) cornerY, 0.f));*/ - for(uint k = 0; k < numTris; ++k) - { - /*winTris[k].V0 = m * _Tris[k].V0; - winTris[k].V1 = m * _Tris[k].V1; - winTris[k].V2 = m * _Tris[k].V2;*/ - - CVector2f result; - computeScaledVertex(result, _Tris[k].V0); - winTris[k].V0.set(result.x + cornerX, result.y + cornerY, 0.f); - computeScaledVertex(result, _Tris[k].V1); - winTris[k].V1.set(result.x + cornerX, result.y + cornerY, 0.f); - computeScaledVertex(result, _Tris[k].V2); - winTris[k].V2.set(result.x + cornerX, result.y + cornerY, 0.f); - } - // recompute & reclip poly - _RealTris.clear(); - sint32 cx, cy, cw, ch; - vr.getClipWindow(cx, cy, cw, ch); - // per tri clip - NLMISC::CVector minCorner; - NLMISC::CVector maxCorner; - for(uint k = 0; k < numTris; ++k) - { - winTris[k].getMinCorner(minCorner); - winTris[k].getMaxCorner(maxCorner); - if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue; - if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch)) - { - _RealTris.push_back(winTris[k]); - } - else - { - const uint maxNumCorners = 8; - static CVector outPos0[maxNumCorners]; - static CVector outPos1[maxNumCorners]; - // - outPos0[0] = winTris[k].V0; - outPos0[1] = winTris[k].V1; - outPos0[2] = winTris[k].V2; - // - CVector *pPos0 = outPos0; - CVector *pPos1 = outPos1; - // - sint count = 3; - // - if ((sint32) minCorner.x < cx) - { - // clip left - CPlane clipper(-1.f, 0.f, 0.f, (float) cx); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - if ((sint32) maxCorner.x > cx + cw) - { - // clip right - CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw)); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - // - if ((sint32) minCorner.y < cy) - { - // clip bottom - CPlane clipper(0.f, -1.f, 0.f, (float) cy); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - if ((sint32) maxCorner.y > cy + ch) - { - // clip top - CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch)); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - nlassert(count <= 8); - if (count >= 3) - { - for(uint k = 0; k < (uint) (count - 2); ++k) - { - _RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2])); - } - } - } - } - _Touched = false; - } - if (_RealTris.empty()) return; - CRGBA col; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); -} - -// ********************************************************************************* -void CCtrlPolygon::updateCoords() -{ - H_AUTO(Rz_CCtrlPolygon_updateCoords) - CCtrlBase::updateCoords(); - updateBoudingRect(); - // assume that clipping will have to be done again, real update of triangle will be done at render time - _Touched = true; -} - -// ********************************************************************************* -void CCtrlPolygon::setAlpha(sint32 a) -{ - H_AUTO(Rz_CCtrlPolygon_setAlpha) - _Color.A = (uint8) a; -} - -// ********************************************************************************* -bool CCtrlPolygon::handleEvent(const NLGUI::CEventDescriptor &/* event */) -{ - H_AUTO(Rz_CCtrlPolygon_handleEvent) - return false; -} - -// ********************************************************************************* -// TMP TMP -void CCtrlPolygon::computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src) -{ - H_AUTO(Rz_CCtrlPolygon_computeScaledVertex) - dest.set(src.x, src.y); -} - -// ********************************************************************************* -// TMP TMP -void CCtrlPolygon::touch() -{ - H_AUTO(Rz_CCtrlPolygon_touch) - updateBoudingRect(); - _Touched = true; -} - - - diff --git a/code/ryzom/client/src/interface_v3/ctrl_polygon.h b/code/ryzom/client/src/interface_v3/ctrl_polygon.h deleted file mode 100644 index 78b852ba4..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_polygon.h +++ /dev/null @@ -1,88 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_CTRL_POLYGON_H -#define RZ_CTRL_POLYGON_H - -#include "nel/gui/ctrl_base.h" -#include "nel/gui/view_renderer.h" -#include "nel/misc/geom_ext.h" -#include "nel/misc/polygon.h" - -namespace NLMISC -{ - class CVector2f; -} - -/** Display of an arbitrary polygon in the ui. - * polygons are clipped & batched. - * - * Derives from CCtrlBase in order to provide button / tooltip capability - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 1/2006 - */ -class CCtrlPolygon : public CCtrlBase -{ -public: - CCtrlPolygon(); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - virtual void updateCoords(); - virtual void draw(); - /** Change the vertices. This is costly because concav / complex polys are split in a list of triangles - */ - void setVertices(const std::vector &vertices); - const std::vector &getVertices() const { return _Poly.Vertices; } - // test if current position in inside the current (transformed) poly (in window space) - bool contains(const NLMISC::CVector2f &pos) const; - // color - void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } - NLMISC::CRGBA getColorRGBA() const { return _Color; } - // from CViewBase - virtual sint32 getAlpha() const { return (sint32) _Color.A; } - virtual void setAlpha(sint32 a); - /** Change the matrix for this poly. Changing the matrix is usually cheaper than changing - * The vertices because complex poly do not have to be split again - */ - //void setMatrix(const NLMISC::CMatrix &mat); - //const NLMISC::CMatrix &getMatrix() const { return _Matrix; } - // test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself) - bool isValid() const { return _Valid; } - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - // no capturable by default (just tooltip capability wanted) - virtual bool isCapturable() const { return false; } -private: - NLMISC::CPolygon _Poly; - NLMISC::CPolygon2D _XFormPoly; - //NLMISC::CMatrix _Matrix; - bool _Valid; - bool _Touched; - NLMISC::CRGBA _Color; - std::vector _Tris; - std::vector _RealTris; // clipped tris in screen coordinates -private: - void updateBoudingRect(); -protected: - // TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ... - virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src); -public: - void touch(); -}; - -#endif diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index ab53744c3..61dda28bd 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -125,7 +125,7 @@ #include "nel/misc/check_fpu.h" // TMP TMP -#include "interface_v3/ctrl_polygon.h" +#include "nel/gui/ctrl_polygon.h" // TMP TMP #include "game_share/scenario_entry_points.h" #include "nel/3d/driver.h" diff --git a/code/ryzom/client/src/r2/displayer_visual_group.cpp b/code/ryzom/client/src/r2/displayer_visual_group.cpp index d4daa2e67..5197398a7 100644 --- a/code/ryzom/client/src/r2/displayer_visual_group.cpp +++ b/code/ryzom/client/src/r2/displayer_visual_group.cpp @@ -33,7 +33,7 @@ #include "../global.h" #include "../misc.h" #include "../landscape_poly_drawer.h" -#include "../interface_v3/ctrl_polygon.h" +#include "nel/gui/ctrl_polygon.h" #include "nel/gui/ctrl_quad.h" #include "../time_client.h" // diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index 19b987e09..e7f881c0a 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -24,7 +24,7 @@ // #include "../interface_v3/view_bitmap.h" #include "nel/gui/ctrl_quad.h" -#include "../interface_v3/ctrl_polygon.h" +#include "nel/gui/ctrl_polygon.h" #include "../interface_v3/interface_manager.h" #include "nel/gui/view_renderer.h" #include "../interface_v3/group_map.h" diff --git a/code/ryzom/client/src/r2/prim_render.h b/code/ryzom/client/src/r2/prim_render.h index bab97d5f6..18817b46f 100644 --- a/code/ryzom/client/src/r2/prim_render.h +++ b/code/ryzom/client/src/r2/prim_render.h @@ -27,10 +27,10 @@ namespace NLGUI { class CLuaObject; + class CCtrlPolygon; } class CEntityCL; -class CCtrlPolygon; namespace R2 { From eed17cc4f4477994d45c5dc4ab29d666033586ad Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 03:39:23 +0200 Subject: [PATCH 068/339] CHANGED: #1471 CCtrlColPick is now in the NELGUI library and is under NLGUI namespace. --- code/nel/include/nel/gui/ctrl_col_pick.h | 106 +++++++++ code/nel/src/gui/ctrl_col_pick.cpp | 208 ++++++++++++++++++ .../client/src/interface_v3/ctrl_col_pick.cpp | 204 ----------------- .../client/src/interface_v3/ctrl_col_pick.h | 100 --------- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- 7 files changed, 317 insertions(+), 307 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_col_pick.h create mode 100644 code/nel/src/gui/ctrl_col_pick.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_col_pick.h diff --git a/code/nel/include/nel/gui/ctrl_col_pick.h b/code/nel/include/nel/gui/ctrl_col_pick.h new file mode 100644 index 000000000..e3ea28df0 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_col_pick.h @@ -0,0 +1,106 @@ +// Ryzom - MMORPG Framework +// 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 RZ_CTRL_COL_PICK_H +#define RZ_CTRL_COL_PICK_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/ctrl_base.h" + + +namespace NLGUI +{ + + /** + * Class handling a Color Picker + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2003 + */ + class CCtrlColPick : public CCtrlBase + { + + public: + + CCtrlColPick(const TCtorParam ¶m); + ~CCtrlColPick(); + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + virtual void draw(); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + sint32 getColorR () const { return _ColorSelect.R; } + sint32 getColorG () const { return _ColorSelect.G; } + sint32 getColorB () const { return _ColorSelect.B; } + sint32 getColorA () const { return _ColorSelect.A; } + + void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; } + void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; } + void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; } + void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; } + + + std::string getColor () const; // Get Color Selected + void setColor (const std::string &col); // Set Color Selected + + std::string getColorOver () const; // Get Color Over + void setColorOver (const std::string &col); // Set Color Over + + REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase) + REFLECT_SINT32("r", getColorR, setColorR); + REFLECT_SINT32("g", getColorG, setColorG); + REFLECT_SINT32("b", getColorB, setColorB); + REFLECT_SINT32("a", getColorA, setColorA); + REFLECT_STRING("color", getColor, setColor); + REFLECT_STRING("color_over", getColorOver, setColorOver); + REFLECT_EXPORT_END + + + protected: + + void selectColor (sint32 x, sint32 y); + NLMISC::CRGBA getColor (sint32 x, sint32 y); + + protected: + + bool _MouseDown; + + sint32 _Texture; + + NLMISC::CRGBA _ColorSelect; // Last Color selected + NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer + + std::string _AHOnChange; + std::string _AHOnChangeParams; + + CInterfaceProperty _ColSelR; + CInterfaceProperty _ColSelG; + CInterfaceProperty _ColSelB; + CInterfaceProperty _ColSelA; + }; + +} + + +#endif // RZ_CTRL_COL_PICK_H + +/* End of ctrl_col_pick.h */ + + diff --git a/code/nel/src/gui/ctrl_col_pick.cpp b/code/nel/src/gui/ctrl_col_pick.cpp new file mode 100644 index 000000000..1140625ec --- /dev/null +++ b/code/nel/src/gui/ctrl_col_pick.cpp @@ -0,0 +1,208 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/ctrl_col_pick.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" + + +using namespace NLMISC; +using namespace std; + +NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick"); + +namespace NLGUI +{ + + // ------------------------------------------------------------------------------------------------ + CCtrlColPick::CCtrlColPick(const TCtorParam ¶m) + :CCtrlBase(param) + { + _MouseDown = false; + _Texture = -2; + } + + // ------------------------------------------------------------------------------------------------ + CCtrlColPick::~CCtrlColPick() + { + // Texture has been created ? + if (_Texture>=0) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.deleteTexture (_Texture); + } + } + + // ------------------------------------------------------------------------------------------------ + bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) + { + if (!CCtrlBase::parse(node, parentGroup)) + return false; + + CXMLAutoPtr prop; + // Read textures + prop = (char*) xmlGetProp( node, (xmlChar*)"texture" ); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if(prop) + { + string sTmp = NLMISC::strlwr((const char*)prop); + _Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false); + } + + prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" ); + if (prop) _AHOnChange = NLMISC::strlwr(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" ); + if (prop) _AHOnChangeParams = string((const char*)prop); + + prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolr" ); + if (prop) _ColSelR.link(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolg" ); + if (prop) _ColSelG.link(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolb" ); + if (prop) _ColSelB.link(prop); + prop = (char*) xmlGetProp( node, (xmlChar*)"dbcola" ); + if (prop) _ColSelA.link(prop); + + return true; + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlColPick::updateCoords() + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 txw, txh; + rVR.getTextureSizeFromId (_Texture, txw, txh); + _W = txw; + _H = txh; + CCtrlBase::updateCoords(); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlColPick::draw() + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A); + + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, + _WReal, _HReal, + 0, false, + _Texture, + col ); + } + + // ------------------------------------------------------------------------------------------------ + bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active) + return false; + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && + (!((eventDesc.getX() >= _XReal) && + (eventDesc.getX() < (_XReal + _WReal))&& + (eventDesc.getY() > _YReal) && + (eventDesc.getY() <= (_YReal+ _HReal))))) + return false; + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + _MouseDown = true; + selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal); + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + _MouseDown = false; + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) + { + if (_MouseDown) + { + selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal); + } + return true; + } + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + string CCtrlColPick::getColor () const + { + return NLMISC::toString(_ColorSelect.R) + " " + NLMISC::toString(_ColorSelect.G) + " " + NLMISC::toString(_ColorSelect.B) + " " + NLMISC::toString(_ColorSelect.A); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlColPick::setColor (const string &col) + { + _ColorSelect = convertColor (col.c_str()); + } + + // ------------------------------------------------------------------------------------------------ + string CCtrlColPick::getColorOver () const + { + return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlColPick::setColorOver (const string &col) + { + _ColorOver = convertColor (col.c_str()); + } + + // ------------------------------------------------------------------------------------------------ + void CCtrlColPick::selectColor (sint32 x, sint32 y) + { + + _ColorSelect = getColor (x, y); + + if (_ColSelR.getNodePtr() != NULL) + _ColSelR.setSInt32(_ColorSelect.R); + if (_ColSelG.getNodePtr() != NULL) + _ColSelG.setSInt32(_ColorSelect.G); + if (_ColSelB.getNodePtr() != NULL) + _ColSelB.setSInt32(_ColorSelect.B); + if (_ColSelA.getNodePtr() != NULL) + _ColSelA.setSInt32(_ColorSelect.A); + + if (!_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _AHOnChangeParams); + } + + // ------------------------------------------------------------------------------------------------ + CRGBA CCtrlColPick::getColor (sint32 x, sint32 y) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + if (x < 0) x = 0; + if (y < 0) y = 0; + if (x >= _WReal) x = _WReal-1; + if (y >= _HReal) y = _HReal-1; + return rVR.getTextureColor (_Texture, x, y); + } + +} + + diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp b/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp deleted file mode 100644 index b39c381a7..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_manager.h" -#include "ctrl_col_pick.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace NLMISC; -using namespace std; - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick"); - -// ------------------------------------------------------------------------------------------------ -CCtrlColPick::CCtrlColPick(const TCtorParam ¶m) -:CCtrlBase(param) -{ - _MouseDown = false; - _Texture = -2; -} - -// ------------------------------------------------------------------------------------------------ -CCtrlColPick::~CCtrlColPick() -{ - // Texture has been created ? - if (_Texture>=0) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.deleteTexture (_Texture); - } -} - -// ------------------------------------------------------------------------------------------------ -bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup) -{ - if (!CCtrlBase::parse(node, parentGroup)) - return false; - - CXMLAutoPtr prop; - // Read textures - prop = (char*) xmlGetProp( node, (xmlChar*)"texture" ); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if(prop) - { - string sTmp = NLMISC::strlwr((const char*)prop); - _Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false); - } - - prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" ); - if (prop) _AHOnChange = NLMISC::strlwr(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" ); - if (prop) _AHOnChangeParams = string((const char*)prop); - - prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolr" ); - if (prop) _ColSelR.link(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolg" ); - if (prop) _ColSelG.link(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolb" ); - if (prop) _ColSelB.link(prop); - prop = (char*) xmlGetProp( node, (xmlChar*)"dbcola" ); - if (prop) _ColSelA.link(prop); - - return true; -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlColPick::updateCoords() -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 txw, txh; - rVR.getTextureSizeFromId (_Texture, txw, txh); - _W = txw; - _H = txh; - CCtrlBase::updateCoords(); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlColPick::draw() -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A); - - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - 0, false, - _Texture, - col ); -} - -// ------------------------------------------------------------------------------------------------ -bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active) - return false; - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && - (!((eventDesc.getX() >= _XReal) && - (eventDesc.getX() < (_XReal + _WReal))&& - (eventDesc.getY() > _YReal) && - (eventDesc.getY() <= (_YReal+ _HReal))))) - return false; - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - _MouseDown = true; - selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal); - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - _MouseDown = false; - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) - { - if (_MouseDown) - { - selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal); - } - return true; - } - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -string CCtrlColPick::getColor () const -{ - return NLMISC::toString(_ColorSelect.R) + " " + NLMISC::toString(_ColorSelect.G) + " " + NLMISC::toString(_ColorSelect.B) + " " + NLMISC::toString(_ColorSelect.A); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlColPick::setColor (const string &col) -{ - _ColorSelect = convertColor (col.c_str()); -} - -// ------------------------------------------------------------------------------------------------ -string CCtrlColPick::getColorOver () const -{ - return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlColPick::setColorOver (const string &col) -{ - _ColorOver = convertColor (col.c_str()); -} - -// ------------------------------------------------------------------------------------------------ -void CCtrlColPick::selectColor (sint32 x, sint32 y) -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - - _ColorSelect = getColor (x, y); - - if (_ColSelR.getNodePtr() != NULL) - _ColSelR.setSInt32(_ColorSelect.R); - if (_ColSelG.getNodePtr() != NULL) - _ColSelG.setSInt32(_ColorSelect.G); - if (_ColSelB.getNodePtr() != NULL) - _ColSelB.setSInt32(_ColorSelect.B); - if (_ColSelA.getNodePtr() != NULL) - _ColSelA.setSInt32(_ColorSelect.A); - - if (!_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _AHOnChangeParams); -} - -// ------------------------------------------------------------------------------------------------ -CRGBA CCtrlColPick::getColor (sint32 x, sint32 y) -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if (x < 0) x = 0; - if (y < 0) y = 0; - if (x >= _WReal) x = _WReal-1; - if (y >= _HReal) y = _HReal-1; - return rVR.getTextureColor (_Texture, x, y); -} diff --git a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h b/code/ryzom/client/src/interface_v3/ctrl_col_pick.h deleted file mode 100644 index 956f077a7..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_col_pick.h +++ /dev/null @@ -1,100 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_CTRL_COL_PICK_H -#define RZ_CTRL_COL_PICK_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/ctrl_base.h" - -/** - * Class handling a Color Picker - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2003 - */ -class CCtrlColPick : public CCtrlBase -{ - -public: - - CCtrlColPick(const TCtorParam ¶m); - ~CCtrlColPick(); - - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - - virtual void updateCoords(); - virtual void draw(); - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - sint32 getColorR () const { return _ColorSelect.R; } - sint32 getColorG () const { return _ColorSelect.G; } - sint32 getColorB () const { return _ColorSelect.B; } - sint32 getColorA () const { return _ColorSelect.A; } - - void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; } - void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; } - void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; } - void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; } - - - std::string getColor () const; // Get Color Selected - void setColor (const std::string &col); // Set Color Selected - - std::string getColorOver () const; // Get Color Over - void setColorOver (const std::string &col); // Set Color Over - - REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase) - REFLECT_SINT32("r", getColorR, setColorR); - REFLECT_SINT32("g", getColorG, setColorG); - REFLECT_SINT32("b", getColorB, setColorB); - REFLECT_SINT32("a", getColorA, setColorA); - REFLECT_STRING("color", getColor, setColor); - REFLECT_STRING("color_over", getColorOver, setColorOver); - REFLECT_EXPORT_END - - -protected: - - void selectColor (sint32 x, sint32 y); - NLMISC::CRGBA getColor (sint32 x, sint32 y); - -protected: - - bool _MouseDown; - - sint32 _Texture; - - NLMISC::CRGBA _ColorSelect; // Last Color selected - NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer - - std::string _AHOnChange; - std::string _AHOnChangeParams; - - CInterfaceProperty _ColSelR; - CInterfaceProperty _ColSelG; - CInterfaceProperty _ColSelB; - CInterfaceProperty _ColSelA; -}; - - -#endif // RZ_CTRL_COL_PICK_H - -/* End of ctrl_col_pick.h */ - - diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index eba6b9094..4d0b76ed8 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -54,7 +54,7 @@ // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" -#include "ctrl_col_pick.h" +#include "nel/gui/ctrl_col_pick.h" #include "ctrl_tooltip.h" #include "ctrl_text_button.h" #include "group_paragraph.h" // For CCtrlLink diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 6a2e54483..d9ac41023 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -35,7 +35,7 @@ #include "dbgroup_select_number.h" #include "nel/gui/ctrl_button.h" #include "ctrl_text_button.h" -#include "ctrl_col_pick.h" +#include "nel/gui/ctrl_col_pick.h" #include "nel/gui/ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index ed0cdae23..a78a4b47f 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -20,7 +20,7 @@ #include "view_pointer.h" #include "interface_manager.h" #include "nel/gui/view_renderer.h" -#include "ctrl_col_pick.h" +#include "nel/gui/ctrl_col_pick.h" #include "group_paragraph.h" #include "group_html.h" #include "group_map.h" From c560575a563feca4d87f9e35b035a73c9a262b51 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 04:16:12 +0200 Subject: [PATCH 069/339] CHANGED: #1471 CCtrlTooltip is now in the NELGUI library and is under NLGUI namespace. --- .../include/nel/gui}/ctrl_tooltip.h | 49 +++++++++--------- .../src/gui}/ctrl_tooltip.cpp | 50 +++++++++++-------- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/view_text.cpp | 2 +- .../ryzom/client/src/interface_v3/view_text.h | 6 ++- 5 files changed, 61 insertions(+), 48 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/ctrl_tooltip.h (60%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/ctrl_tooltip.cpp (58%) diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h b/code/nel/include/nel/gui/ctrl_tooltip.h similarity index 60% rename from code/ryzom/client/src/interface_v3/ctrl_tooltip.h rename to code/nel/include/nel/gui/ctrl_tooltip.h index 67fa2ccd3..6c49a194c 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h +++ b/code/nel/include/nel/gui/ctrl_tooltip.h @@ -25,31 +25,34 @@ namespace NLGUI { class CEventDescriptor; + + + /** + * \author Matthieu 'Mr TRAP' Besson + * \author Nevrax France + * \date 2003 + */ + class CCtrlToolTip : public CCtrlBase + { + public: + DECLARE_UI_CLASS(CCtrlToolTip) + /// Constructor + CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {} + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + virtual void draw(); + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + // Can do nothing with tooltip (but display it :) ) + virtual bool isCapturable() const {return false;} + virtual void serial(NLMISC::IStream &f); + public: + + }; + + } -/** - * \author Matthieu 'Mr TRAP' Besson - * \author Nevrax France - * \date 2003 - */ -class CCtrlToolTip : public CCtrlBase -{ -public: - DECLARE_UI_CLASS(CCtrlToolTip) - /// Constructor - CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {} - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - virtual void draw(); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - // Can do nothing with tooltip (but display it :) ) - virtual bool isCapturable() const {return false;} - virtual void serial(NLMISC::IStream &f); -public: - -}; - - #endif // RZ_CTRL_TOOLTIP_H /* End of ctrl_tooltip.h */ + diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp b/code/nel/src/gui/ctrl_tooltip.cpp similarity index 58% rename from code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp rename to code/nel/src/gui/ctrl_tooltip.cpp index 8b17a7073..0900084a9 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.cpp +++ b/code/nel/src/gui/ctrl_tooltip.cpp @@ -17,7 +17,7 @@ // ---------------------------------------------------------------------------- -#include "ctrl_tooltip.h" +#include "nel/gui/ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" // ---------------------------------------------------------------------------- @@ -29,27 +29,33 @@ NLMISC_REGISTER_OBJECT(CViewBase, CCtrlToolTip, std::string, "tooltip"); REGISTER_UI_CLASS(CCtrlToolTip) -// ---------------------------------------------------------------------------- -void CCtrlToolTip::draw () +namespace NLGUI { + + // ---------------------------------------------------------------------------- + void CCtrlToolTip::draw () + { + } + + // ---------------------------------------------------------------------------- + bool CCtrlToolTip::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (CCtrlBase::handleEvent(event)) return true; + return false; + } + + // ---------------------------------------------------------------------------- + bool CCtrlToolTip::parse(xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if (!CCtrlBase::parse(cur, parentGroup)) return false; + return true; + } + + // ---------------------------------------------------------------------------- + void CCtrlToolTip::serial(NLMISC::IStream &f) + { + CCtrlBase::serial(f); + } + } -// ---------------------------------------------------------------------------- -bool CCtrlToolTip::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (CCtrlBase::handleEvent(event)) return true; - return false; -} - -// ---------------------------------------------------------------------------- -bool CCtrlToolTip::parse(xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if (!CCtrlBase::parse(cur, parentGroup)) return false; - return true; -} - -// ---------------------------------------------------------------------------- -void CCtrlToolTip::serial(NLMISC::IStream &f) -{ - CCtrlBase::serial(f); -} diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 4d0b76ed8..be1f38175 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -55,7 +55,7 @@ #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_col_pick.h" -#include "ctrl_tooltip.h" +#include "nel/gui/ctrl_tooltip.h" #include "ctrl_text_button.h" #include "group_paragraph.h" // For CCtrlLink // DBCtrl diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 895aadda6..af81274c1 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -24,7 +24,7 @@ #include "view_text.h" #include "interface_manager.h" #include "group_container.h" // CCtrlResizer -#include "ctrl_tooltip.h" +#include "nel/gui/ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/view_text.h b/code/ryzom/client/src/interface_v3/view_text.h index 3620bbe77..623e2c2aa 100644 --- a/code/ryzom/client/src/interface_v3/view_text.h +++ b/code/ryzom/client/src/interface_v3/view_text.h @@ -23,7 +23,11 @@ #include "../misc.h" #include "nel/3d/u_text_context.h" -class CCtrlToolTip; +namespace NLGUI +{ + class CCtrlToolTip; +} + /** * class implementing a text view From 6115a122c91e8425fbeac8e6a51af7d5eb183ef6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 20:53:58 +0200 Subject: [PATCH 070/339] CHANGED: #1471 CViewQuad is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/view_quad.h | 94 +++++ code/nel/src/gui/view_quad.cpp | 374 ++++++++++++++++++ .../client/src/interface_v3/view_quad.cpp | 374 ------------------ .../ryzom/client/src/interface_v3/view_quad.h | 90 ----- 4 files changed, 468 insertions(+), 464 deletions(-) create mode 100644 code/nel/include/nel/gui/view_quad.h create mode 100644 code/nel/src/gui/view_quad.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_quad.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_quad.h diff --git a/code/nel/include/nel/gui/view_quad.h b/code/nel/include/nel/gui/view_quad.h new file mode 100644 index 000000000..85f4430cb --- /dev/null +++ b/code/nel/include/nel/gui/view_quad.h @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// 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 RZ_VIEW_QUAD_H +#define RZ_VIEW_QUAD_H + +#include "nel/gui/view_base.h" +#include "nel/gui/view_renderer.h" +#include "nel/misc/geom_ext.h" + +namespace NLGUI +{ + + /** Display of an arbitrary textured quad in the UI. The applied texture is filtered. + * Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates + * are driven by the quad vertices coordinates (see setQuad) + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 12/2005 + */ + class CViewQuad : public CViewBase + { + public: + enum TWrapMode { Repeat = 0, Clamp, WrapModeCount }; + + + CViewQuad(); + + // from CInterfaceElement + bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup); + virtual void updateCoords(); + virtual void draw(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha (sint32 a); + + // texture + void setTexture(const std::string &texName); + std::string getTexture () const; + + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + + /** Set a new quad relative to parent pos + * x,y, w, h & hotspot are updated to fit the bounding rect of the quad + */ + void setQuad(const NLMISC::CQuad &quad); + void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness); + /** Fit the given texture size (no hotspot for now, always centered) + * NB : current texture is not modified. + */ + void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f); + void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f); + const NLMISC::CQuad &getQuad() const { return _Quad; } + + void setAdditif(bool additif); + bool getAdditif() const { return _Additif; } + + void setPattern(float umin, float umax, TWrapMode wrapMode); + + private: + NLMISC::CRGBA _Color; + NLMISC::CQuad _Quad; + NLMISC::CQuadUV _RealQuad; // absolute coords + float _ClampedUCorrection; + CViewRenderer::CTextureId _TextureId; /// Accelerator + bool _Additif; + float _UMin; + float _UMax; + TWrapMode _WrapMode; + }; + +} + +#endif + diff --git a/code/nel/src/gui/view_quad.cpp b/code/nel/src/gui/view_quad.cpp new file mode 100644 index 000000000..91ac93832 --- /dev/null +++ b/code/nel/src/gui/view_quad.cpp @@ -0,0 +1,374 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_quad.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" + +using namespace NLMISC; + +namespace NLGUI +{ + + // ********************************************************************************* + CViewQuad::CViewQuad() : CViewBase(TCtorParam()), _Color(CRGBA::White), + _Additif(false), + _UMin(0.f), + _UMax(1.f), + _WrapMode(Repeat) + { + setQuad(CQuad(CVector::Null, CVector::Null, CVector::Null, CVector::Null)); + // preset uvs for real quad + _RealQuad.Uv0.set(0.f, 0.f); + _RealQuad.Uv1.set(1.f, 0.f); + _RealQuad.Uv2.set(1.f, 1.f); + _RealQuad.Uv3.set(0.f, 1.f); + } + + // ********************************************************************************* + bool CViewQuad::parse(xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */) + { + nlassert(0); // NOT IMPLEMENTED (only created dynamically at this time) + return false; + } + + // ********************************************************************************* + void CViewQuad::updateCoords() + { + CViewBase::updateCoords(); + nlassert(_Parent); + // don't use _XReal && _YReal, because coords are given relative to parent + CVector delta((float) _Parent->getXReal(), (float) _Parent->getYReal(), 0.f); + _RealQuad.set(_Quad.V0 + delta, _Quad.V1 + delta, _Quad.V2 + delta, _Quad.V3 + delta); + } + + // ********************************************************************************* + void CViewQuad::draw() + { + nlassert(_Parent); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + CRGBA col; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _Color; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + /*if (_InheritGCAlpha) + { + // search a parent container + CInterfaceGroup *gr = getParent(); + while (gr) + { + if (gr->isGroupContainer()) + { + CGroupContainer *gc = static_cast(gr); + col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); + break; + } + gr = gr->getParent(); + } + }*/ + if (_UMin == 0.f && _UMax == 1.f) + { + // no pattern applied, can draw the quad in a single piece + rVR.drawQuad(_RenderLayer, _RealQuad, _TextureId, col, _Additif); + } + else + { + NLMISC::CQuadUV quv; + if (_WrapMode == Repeat) + { + if (_UMax == _UMin) + { + (CQuad &) quv = _RealQuad; // copy CQuad part + float u = fmodf(_UMin, 1.f); + quv.Uv0.set(u, 0.f); + quv.Uv1.set(u, 0.f); + quv.Uv2.set(u, 1.f); + quv.Uv3.set(u, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + else + { + // reverse corners if needed to handle case where _UVMin < _UVmax + NLMISC::CQuad srcQuad; + float umin, umax; + if (_UMax < _UMin) + { + umin = _UMax; + umax = _UMin; + srcQuad.V0 = _RealQuad.V1; + srcQuad.V1 = _RealQuad.V0; + srcQuad.V2 = _RealQuad.V3; + srcQuad.V3 = _RealQuad.V2; + } + else + { + umin = _UMin; + umax = _UMax; + srcQuad = _RealQuad; + } + + + float unitRatio = 1.f / fabsf(umax - umin); // ratio of the real quad delta x in screen for du = 1 + // texture is stretched, mutiple parts needed + float ceilUMin = ceilf(umin); + float firstDeltaU = ceilUMin - umin; + if (firstDeltaU != 0.f) + { + + // start quad + quv.V0 = srcQuad.V0; + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f, (firstDeltaU * unitRatio))); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f, (firstDeltaU * unitRatio))); + quv.V3 = srcQuad.V3; + float lastU = std::min(umax + 1.f - ceilUMin, 1.f); + quv.Uv0.set(1.f - firstDeltaU, 0.f); + quv.Uv1.set(lastU, 0.f); + quv.Uv2.set(lastU, 1.f); + quv.Uv3.set(1.f - firstDeltaU, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + + if (firstDeltaU * unitRatio >= 1.f) return; + } + + // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) + + // intermediate quads + sint numQuads = (sint) (floorf(umax) - ceilf(umin)); + + for(sint k = 0; k < numQuads; ++k) + { + float deltaU = firstDeltaU + k; + // start quad + quv.V0 = blend(srcQuad.V0, srcQuad.V1, deltaU * unitRatio); + quv.V1 = blend(srcQuad.V0, srcQuad.V1, (deltaU + 1.f) * unitRatio); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, (deltaU + 1.f) * unitRatio); + quv.V3 = blend(srcQuad.V3, srcQuad.V2, deltaU * unitRatio); + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(1.f, 0.f); + quv.Uv2.set(1.f, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + // end quad + float lastDeltaU = umax - floorf(umax); + if (lastDeltaU != 0.f) + { + + // start quad + quv.V0 = blend(srcQuad.V1, srcQuad.V0, lastDeltaU * unitRatio); + quv.V1 = srcQuad.V1; + quv.V2 = srcQuad.V2; + quv.V3 = blend(srcQuad.V2, srcQuad.V3, lastDeltaU * unitRatio); + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(lastDeltaU, 0.f); + quv.Uv2.set(lastDeltaU, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + } + + } + else + { + nlassert(_WrapMode == Clamp); + if (_UMin == _UMax) + { + (CQuad &) quv = _RealQuad; // copy CQuad part + // special case + float u = _UMin; + clamp(u, 0.f, 1.f); + quv.Uv0.set(u, 0.f); + quv.Uv1.set(u, 1.f); + quv.Uv2.set(u, 1.f); + quv.Uv3.set(u, 0.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + else + { + NLMISC::CQuad srcQuad; + float umin, umax; + if (_UMax < _UMin) + { + umin = _UMax; + umax = _UMin; + srcQuad.V0 = _RealQuad.V1; + srcQuad.V1 = _RealQuad.V0; + srcQuad.V2 = _RealQuad.V3; + srcQuad.V3 = _RealQuad.V2; + } + else + { + umin = _UMin; + umax = _UMax; + srcQuad = _RealQuad; + } + float startRatio = - umin / (umax - umin); // start of unclamped u (actually (0.f - umin) / (umax - umin) ) + if (umin < 0.f) + { + quv.V0 = srcQuad.V0; + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f ,startRatio)); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f ,startRatio)); + quv.V3 = srcQuad.V3; + // draw first clamped part + quv.Uv0.set(0.f, 0.f); + quv.Uv1.set(0.f, 0.f); + quv.Uv2.set(0.f, 1.f); + quv.Uv3.set(0.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + if (startRatio >= 1.f) return; + float endRatio = (1.f - umin) / (umax - umin); + if (endRatio > 0.f) + { + // draw middle part if visible + // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) + quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , startRatio)); + quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f , endRatio)); + quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f , endRatio)); + quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , startRatio)); + // draw first clamped part + quv.Uv0.set(std::max(0.f, umin), 0.f); + quv.Uv1.set(std::min(1.f, umax), 0.f); + quv.Uv2.set(std::min(1.f, umax), 1.f); + quv.Uv3.set(std::max(0.f, umin), 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + if (endRatio >= 1.f) return; + // draw end part + quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , endRatio)); + quv.V1 = srcQuad.V1; + quv.V2 = srcQuad.V2; + quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , endRatio)); + // draw end clamped part + quv.Uv0.set(1.f, 0.f); + quv.Uv1.set(1.f, 0.f); + quv.Uv2.set(1.f, 1.f); + quv.Uv3.set(1.f, 1.f); + rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); + } + } + } + } + + // ********************************************************************************* + void CViewQuad::setAlpha(sint32 a) + { + _Color.A = (uint8) a; + } + + // ********************************************************************************* + void CViewQuad::setTexture(const std::string &texName) + { + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureId.setTexture(texName.c_str()); + } + + // ********************************************************************************* + std::string CViewQuad::getTexture() const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId (_TextureId); + } + + // ********************************************************************************* + void CViewQuad::setQuad(const CQuad &quad) + { + float qXMin = minof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); + float qXMax = maxof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); + float qYMin = minof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); + float qYMax = maxof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); + setPosRef(Hotspot_BL); + setX((sint32) floorf(qXMin)); + setY((sint32) floorf(qYMin)); + setW((sint32) ceilf(qXMax) - getX()); + setH((sint32) ceilf(qYMax) - getY()); + _Quad = quad; + } + + // ********************************************************************************* + void CViewQuad::setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness) + { + CVector right = end - start; + CVector up(-right.y, right.x, 0.f); + up = thickness * up.normed(); + setQuad(CQuad(start + up, end + up, end - up, start - up)); + } + + // ********************************************************************************* + void CViewQuad::setQuad(const NLMISC::CVector &pos, float radius, float angle /*=0.f*/) + { + if (angle == 0.f) + { + setQuad(pos - radius * CVector::I, pos + radius * CVector::I, radius); + } + else + { + CVector right(radius * cosf(angle), radius * sinf(angle), 0.f); + setQuad(pos - right, pos + right, radius); + } + } + + // ********************************************************************************* + void CViewQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPos, float angle /*= 0.f*/, float offCenter /* = 0.f*/) + { + NLMISC::CVector pos = srcPos; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 w, h; + rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); + if (angle == 0.f) + { + if (offCenter != 0.f) + { + pos.x += offCenter; + } + setQuad(pos - 0.5f * w * CVector::I, pos + 0.5f * w * CVector::I, 0.5f * h); + } + else + { + CVector unitRadius(cosf(angle), sinf(angle), 0.f); + CVector radius = 0.5f * w * unitRadius; + pos += offCenter * unitRadius; + setQuad(pos - radius, pos + radius, 0.5f * h); + } + } + + // ********************************************************************************* + void CViewQuad::setAdditif(bool additif) + { + _Additif = additif; + } + + // ********************************************************************************* + void CViewQuad::setPattern(float umin, float umax, TWrapMode wrapMode) + { + nlassert((uint) wrapMode < WrapModeCount); + _UMin = umin; + _UMax = umax; + _WrapMode = wrapMode; + } + +} + + diff --git a/code/ryzom/client/src/interface_v3/view_quad.cpp b/code/ryzom/client/src/interface_v3/view_quad.cpp deleted file mode 100644 index 424868331..000000000 --- a/code/ryzom/client/src/interface_v3/view_quad.cpp +++ /dev/null @@ -1,374 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_quad.h" -#include "nel/gui/interface_group.h" -#include "interface_manager.h" - -using namespace NLMISC; - -// ********************************************************************************* -CViewQuad::CViewQuad() : CViewBase(TCtorParam()), _Color(CRGBA::White), - _Additif(false), - _UMin(0.f), - _UMax(1.f), - _WrapMode(Repeat) -{ - setQuad(CQuad(CVector::Null, CVector::Null, CVector::Null, CVector::Null)); - // preset uvs for real quad - _RealQuad.Uv0.set(0.f, 0.f); - _RealQuad.Uv1.set(1.f, 0.f); - _RealQuad.Uv2.set(1.f, 1.f); - _RealQuad.Uv3.set(0.f, 1.f); -} - -// ********************************************************************************* -bool CViewQuad::parse(xmlNodePtr /* cur */, CInterfaceGroup * /* parentGroup */) -{ - nlassert(0); // NOT IMPLEMENTED (only created dynamically at this time) - return false; -} - -// ********************************************************************************* -void CViewQuad::updateCoords() -{ - CViewBase::updateCoords(); - nlassert(_Parent); - // don't use _XReal && _YReal, because coords are given relative to parent - CVector delta((float) _Parent->getXReal(), (float) _Parent->getYReal(), 0.f); - _RealQuad.set(_Quad.V0 + delta, _Quad.V1 + delta, _Quad.V2 + delta, _Quad.V3 + delta); -} - -// ********************************************************************************* -void CViewQuad::draw() -{ - nlassert(_Parent); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - CRGBA col; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - /*if (_InheritGCAlpha) - { - // search a parent container - CInterfaceGroup *gr = getParent(); - while (gr) - { - if (gr->isGroupContainer()) - { - CGroupContainer *gc = static_cast(gr); - col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); - break; - } - gr = gr->getParent(); - } - }*/ - if (_UMin == 0.f && _UMax == 1.f) - { - // no pattern applied, can draw the quad in a single piece - rVR.drawQuad(_RenderLayer, _RealQuad, _TextureId, col, _Additif); - } - else - { - NLMISC::CQuadUV quv; - if (_WrapMode == Repeat) - { - if (_UMax == _UMin) - { - (CQuad &) quv = _RealQuad; // copy CQuad part - float u = fmodf(_UMin, 1.f); - quv.Uv0.set(u, 0.f); - quv.Uv1.set(u, 0.f); - quv.Uv2.set(u, 1.f); - quv.Uv3.set(u, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - else - { - // reverse corners if needed to handle case where _UVMin < _UVmax - NLMISC::CQuad srcQuad; - float umin, umax; - if (_UMax < _UMin) - { - umin = _UMax; - umax = _UMin; - srcQuad.V0 = _RealQuad.V1; - srcQuad.V1 = _RealQuad.V0; - srcQuad.V2 = _RealQuad.V3; - srcQuad.V3 = _RealQuad.V2; - } - else - { - umin = _UMin; - umax = _UMax; - srcQuad = _RealQuad; - } - - - float unitRatio = 1.f / fabsf(umax - umin); // ratio of the real quad delta x in screen for du = 1 - // texture is stretched, mutiple parts needed - float ceilUMin = ceilf(umin); - float firstDeltaU = ceilUMin - umin; - if (firstDeltaU != 0.f) - { - - // start quad - quv.V0 = srcQuad.V0; - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f, (firstDeltaU * unitRatio))); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f, (firstDeltaU * unitRatio))); - quv.V3 = srcQuad.V3; - float lastU = std::min(umax + 1.f - ceilUMin, 1.f); - quv.Uv0.set(1.f - firstDeltaU, 0.f); - quv.Uv1.set(lastU, 0.f); - quv.Uv2.set(lastU, 1.f); - quv.Uv3.set(1.f - firstDeltaU, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - - if (firstDeltaU * unitRatio >= 1.f) return; - } - - // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) - - // intermediate quads - sint numQuads = (sint) (floorf(umax) - ceilf(umin)); - - for(sint k = 0; k < numQuads; ++k) - { - float deltaU = firstDeltaU + k; - // start quad - quv.V0 = blend(srcQuad.V0, srcQuad.V1, deltaU * unitRatio); - quv.V1 = blend(srcQuad.V0, srcQuad.V1, (deltaU + 1.f) * unitRatio); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, (deltaU + 1.f) * unitRatio); - quv.V3 = blend(srcQuad.V3, srcQuad.V2, deltaU * unitRatio); - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(1.f, 0.f); - quv.Uv2.set(1.f, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - // end quad - float lastDeltaU = umax - floorf(umax); - if (lastDeltaU != 0.f) - { - - // start quad - quv.V0 = blend(srcQuad.V1, srcQuad.V0, lastDeltaU * unitRatio); - quv.V1 = srcQuad.V1; - quv.V2 = srcQuad.V2; - quv.V3 = blend(srcQuad.V2, srcQuad.V3, lastDeltaU * unitRatio); - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(lastDeltaU, 0.f); - quv.Uv2.set(lastDeltaU, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - } - - } - else - { - nlassert(_WrapMode == Clamp); - if (_UMin == _UMax) - { - (CQuad &) quv = _RealQuad; // copy CQuad part - // special case - float u = _UMin; - clamp(u, 0.f, 1.f); - quv.Uv0.set(u, 0.f); - quv.Uv1.set(u, 1.f); - quv.Uv2.set(u, 1.f); - quv.Uv3.set(u, 0.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - else - { - NLMISC::CQuad srcQuad; - float umin, umax; - if (_UMax < _UMin) - { - umin = _UMax; - umax = _UMin; - srcQuad.V0 = _RealQuad.V1; - srcQuad.V1 = _RealQuad.V0; - srcQuad.V2 = _RealQuad.V3; - srcQuad.V3 = _RealQuad.V2; - } - else - { - umin = _UMin; - umax = _UMax; - srcQuad = _RealQuad; - } - float startRatio = - umin / (umax - umin); // start of unclamped u (actually (0.f - umin) / (umax - umin) ) - if (umin < 0.f) - { - quv.V0 = srcQuad.V0; - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f ,startRatio)); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f ,startRatio)); - quv.V3 = srcQuad.V3; - // draw first clamped part - quv.Uv0.set(0.f, 0.f); - quv.Uv1.set(0.f, 0.f); - quv.Uv2.set(0.f, 1.f); - quv.Uv3.set(0.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - if (startRatio >= 1.f) return; - float endRatio = (1.f - umin) / (umax - umin); - if (endRatio > 0.f) - { - // draw middle part if visible - // TODO optim: reuse of previous uv & pos ... (prb is that they are not always computed) - quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , startRatio)); - quv.V1 = blend(srcQuad.V0, srcQuad.V1, std::min(1.f , endRatio)); - quv.V2 = blend(srcQuad.V3, srcQuad.V2, std::min(1.f , endRatio)); - quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , startRatio)); - // draw first clamped part - quv.Uv0.set(std::max(0.f, umin), 0.f); - quv.Uv1.set(std::min(1.f, umax), 0.f); - quv.Uv2.set(std::min(1.f, umax), 1.f); - quv.Uv3.set(std::max(0.f, umin), 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - if (endRatio >= 1.f) return; - // draw end part - quv.V0 = blend(srcQuad.V0, srcQuad.V1, std::max(0.f , endRatio)); - quv.V1 = srcQuad.V1; - quv.V2 = srcQuad.V2; - quv.V3 = blend(srcQuad.V3, srcQuad.V2, std::max(0.f , endRatio)); - // draw end clamped part - quv.Uv0.set(1.f, 0.f); - quv.Uv1.set(1.f, 0.f); - quv.Uv2.set(1.f, 1.f); - quv.Uv3.set(1.f, 1.f); - rVR.drawQuad(_RenderLayer, quv, _TextureId, col, _Additif); - } - } - } -} - -// ********************************************************************************* -void CViewQuad::setAlpha(sint32 a) -{ - _Color.A = (uint8) a; -} - -// ********************************************************************************* -void CViewQuad::setTexture(const std::string &texName) -{ -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureId.setTexture(texName.c_str()); -} - -// ********************************************************************************* -std::string CViewQuad::getTexture() const -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId (_TextureId); -} - -// ********************************************************************************* -void CViewQuad::setQuad(const CQuad &quad) -{ - float qXMin = minof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); - float qXMax = maxof(quad.V0.x, quad.V1.x, quad.V2.x, quad.V3.x); - float qYMin = minof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); - float qYMax = maxof(quad.V0.y, quad.V1.y, quad.V2.y, quad.V3.y); - setPosRef(Hotspot_BL); - setX((sint32) floorf(qXMin)); - setY((sint32) floorf(qYMin)); - setW((sint32) ceilf(qXMax) - getX()); - setH((sint32) ceilf(qYMax) - getY()); - _Quad = quad; -} - -// ********************************************************************************* -void CViewQuad::setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness) -{ - CVector right = end - start; - CVector up(-right.y, right.x, 0.f); - up = thickness * up.normed(); - setQuad(CQuad(start + up, end + up, end - up, start - up)); -} - -// ********************************************************************************* -void CViewQuad::setQuad(const NLMISC::CVector &pos, float radius, float angle /*=0.f*/) -{ - if (angle == 0.f) - { - setQuad(pos - radius * CVector::I, pos + radius * CVector::I, radius); - } - else - { - CVector right(radius * cosf(angle), radius * sinf(angle), 0.f); - setQuad(pos - right, pos + right, radius); - } -} - -// ********************************************************************************* -void CViewQuad::setQuad(const std::string &texName, const NLMISC::CVector &srcPos, float angle /*= 0.f*/, float offCenter /* = 0.f*/) -{ - NLMISC::CVector pos = srcPos; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 w, h; - rVR.getTextureSizeFromId(rVR.getTextureIdFromName(texName), w, h); - if (angle == 0.f) - { - if (offCenter != 0.f) - { - pos.x += offCenter; - } - setQuad(pos - 0.5f * w * CVector::I, pos + 0.5f * w * CVector::I, 0.5f * h); - } - else - { - CVector unitRadius(cosf(angle), sinf(angle), 0.f); - CVector radius = 0.5f * w * unitRadius; - pos += offCenter * unitRadius; - setQuad(pos - radius, pos + radius, 0.5f * h); - } -} - -// ********************************************************************************* -void CViewQuad::setAdditif(bool additif) -{ - _Additif = additif; -} - -// ********************************************************************************* -void CViewQuad::setPattern(float umin, float umax, TWrapMode wrapMode) -{ - nlassert((uint) wrapMode < WrapModeCount); - _UMin = umin; - _UMax = umax; - _WrapMode = wrapMode; -} - - - diff --git a/code/ryzom/client/src/interface_v3/view_quad.h b/code/ryzom/client/src/interface_v3/view_quad.h deleted file mode 100644 index e16becb69..000000000 --- a/code/ryzom/client/src/interface_v3/view_quad.h +++ /dev/null @@ -1,90 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_VIEW_QUAD_H -#define RZ_VIEW_QUAD_H - -#include "nel/gui/view_base.h" -#include "nel/gui/view_renderer.h" -#include "nel/misc/geom_ext.h" - -/** Display of an arbitrary textured quad in the UI. The applied texture is filtered. - * Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates - * are driven by the quad vertices coordinates (see setQuad) - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 12/2005 - */ -class CViewQuad : public CViewBase -{ -public: - enum TWrapMode { Repeat = 0, Clamp, WrapModeCount }; - - - CViewQuad(); - - // from CInterfaceElement - bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup); - virtual void updateCoords(); - virtual void draw(); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - // from CViewBase - virtual sint32 getAlpha() const { return (sint32) _Color.A; } - virtual void setAlpha (sint32 a); - - // texture - void setTexture(const std::string &texName); - std::string getTexture () const; - - // color - void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } - NLMISC::CRGBA getColorRGBA() const { return _Color; } - - /** Set a new quad relative to parent pos - * x,y, w, h & hotspot are updated to fit the bounding rect of the quad - */ - void setQuad(const NLMISC::CQuad &quad); - void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness); - /** Fit the given texture size (no hotspot for now, always centered) - * NB : current texture is not modified. - */ - void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f); - void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f); - const NLMISC::CQuad &getQuad() const { return _Quad; } - - void setAdditif(bool additif); - bool getAdditif() const { return _Additif; } - - void setPattern(float umin, float umax, TWrapMode wrapMode); - -private: - NLMISC::CRGBA _Color; - NLMISC::CQuad _Quad; - NLMISC::CQuadUV _RealQuad; // absolute coords - float _ClampedUCorrection; - CViewRenderer::CTextureId _TextureId; /// Accelerator - bool _Additif; - float _UMin; - float _UMax; - TWrapMode _WrapMode; -}; - - -#endif - From e28e452649b40bc2e7fa3853d6b03c03c2da7047 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 21:05:16 +0200 Subject: [PATCH 071/339] CHANGED: #1471 CViewPolygon is now part of the NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/view_polygon.h | 60 +++--- code/nel/src/gui/view_polygon.cpp | 196 ++++++++++++++++++ .../client/src/interface_v3/view_polygon.cpp | 192 ----------------- 3 files changed, 228 insertions(+), 220 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_polygon.h (50%) create mode 100644 code/nel/src/gui/view_polygon.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_polygon.cpp diff --git a/code/ryzom/client/src/interface_v3/view_polygon.h b/code/nel/include/nel/gui/view_polygon.h similarity index 50% rename from code/ryzom/client/src/interface_v3/view_polygon.h rename to code/nel/include/nel/gui/view_polygon.h index 1c9c97463..3bcc21985 100644 --- a/code/ryzom/client/src/interface_v3/view_polygon.h +++ b/code/nel/include/nel/gui/view_polygon.h @@ -20,38 +20,42 @@ #include "nel/gui/view_base.h" #include "nel/gui/view_renderer.h" -// #include "nel/misc/geom_ext.h" #include "nel/misc/polygon.h" -/** Display of an arbitrary polygon in the ui. - * polygon is clipped & batched - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 1/2006 - */ -class CViewPolygon : public CViewBase +namespace NLGUI { -public: - CViewPolygon(); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - virtual void updateCoords(); - virtual void draw(); - void setVertices(const std::vector &vertices); - // color - void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } - NLMISC::CRGBA getColorRGBA() const { return _Color; } - // from CViewBase - virtual sint32 getAlpha() const { return (sint32) _Color.A; } - virtual void setAlpha (sint32 a); -private: - NLMISC::CPolygon _Poly; - bool _Touched; - NLMISC::CRGBA _Color; - std::vector _Tris; - std::vector _RealTris; // clipped tris in screen coordinates -}; + + /** Display of an arbitrary polygon in the ui. + * polygon is clipped & batched + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 1/2006 + */ + class CViewPolygon : public CViewBase + { + public: + CViewPolygon(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords(); + virtual void draw(); + void setVertices(const std::vector &vertices); + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha (sint32 a); + private: + NLMISC::CPolygon _Poly; + bool _Touched; + NLMISC::CRGBA _Color; + std::vector _Tris; + std::vector _RealTris; // clipped tris in screen coordinates + }; + +} #endif diff --git a/code/nel/src/gui/view_polygon.cpp b/code/nel/src/gui/view_polygon.cpp new file mode 100644 index 000000000..ca11a3bd0 --- /dev/null +++ b/code/nel/src/gui/view_polygon.cpp @@ -0,0 +1,196 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_polygon.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" + +using namespace NLMISC; + +namespace NLGUI +{ + + // ********************************************************************************* + CViewPolygon::CViewPolygon() : CViewBase(TCtorParam()) + { + // Construct + _Color = CRGBA::White; + } + + + // ********************************************************************************* + void CViewPolygon::setVertices(const std::vector &vertices) + { + if (vertices.size() == _Poly.Vertices.size() && + std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged + _Poly.Vertices = vertices; + _Tris.clear(); + std::list polys; + if (_Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity)) + { + _Tris.clear(); + for(std::list::iterator it = polys.begin(); it != polys.end(); ++it) + { + it->toTriFan(_Tris); + } + } + else + { + nlwarning("CViewPolygon : conversion to conex polygons failed"); + _Tris.clear(); + } + _Touched = true; + } + + + static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) + { + return (sint32) maxCorner.x < (cx + cw) && + (sint32) minCorner.x >= cx && + (sint32) maxCorner.y < (cy + ch) && + (sint32) minCorner.y >= cy; + } + + static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) + { + return (sint32) minCorner.x >= (cx + cw) || + (sint32) maxCorner.x < cx || + (sint32) minCorner.y >= (cy + ch) || + (sint32) maxCorner.y < cy; + } + + // ********************************************************************************* + void CViewPolygon::draw() + { + if (_Tris.empty()) return; + if (!_Parent) return; + CViewRenderer &vr = *CViewRenderer::getInstance(); + if (_Touched) + { + _RealTris.clear(); + uint numTris = (uint)_Tris.size(); + sint32 cornerX, cornerY; + static std::vector winTris; + winTris.resize(numTris); + _Parent->getCorner(cornerX, cornerY, _ParentPosRef); + for(uint k = 0; k < numTris; ++k) + { + winTris[k].V0.set((float) (_Tris[k].V0.x + cornerX), (float) (_Tris[k].V0.y + cornerY), 0.f); + winTris[k].V1.set((float) (_Tris[k].V1.x + cornerX), (float) (_Tris[k].V1.y + cornerY), 0.f); + winTris[k].V2.set((float) (_Tris[k].V2.x + cornerX), (float) (_Tris[k].V2.y + cornerY), 0.f); + } + // recompute & reclip poly + _RealTris.clear(); + sint32 cx, cy, cw, ch; + vr.getClipWindow(cx, cy, cw, ch); + // per tri clip + NLMISC::CVector minCorner; + NLMISC::CVector maxCorner; + for(uint k = 0; k < numTris; ++k) + { + winTris[k].getMinCorner(minCorner); + winTris[k].getMaxCorner(maxCorner); + if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue; + if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch)) + { + _RealTris.push_back(winTris[k]); + } + else + { + const uint maxNumCorners = 8; + static CVector outPos0[maxNumCorners]; + static CVector outPos1[maxNumCorners]; + // + outPos0[0] = winTris[k].V0; + outPos0[1] = winTris[k].V1; + outPos0[2] = winTris[k].V2; + // + CVector *pPos0 = outPos0; + CVector *pPos1 = outPos1; + // + sint count = 3; + // + if ((sint32) minCorner.x < cx) + { + // clip left + CPlane clipper(-1.f, 0.f, 0.f, (float) cx); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + if ((sint32) maxCorner.x > cx + cw) + { + // clip right + CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw)); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + // + if ((sint32) minCorner.y < cy) + { + // clip bottom + CPlane clipper(0.f, -1.f, 0.f, (float) cy); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + if ((sint32) maxCorner.y > cy + ch) + { + // clip top + CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch)); + count = clipper.clipPolygonBack(pPos0, pPos1, count); + std::swap(pPos0, pPos1); + } + nlassert(count <= 8); + if (count >= 3) + { + for(uint k = 0; k < (uint) (count - 2); ++k) + { + _RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2])); + } + } + } + } + _Touched = false; + } + if (_RealTris.empty()) return; + CRGBA col; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _Color; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); + } + + // ********************************************************************************* + void CViewPolygon::updateCoords() + { + // assume that clipping will have to be done again, real update of triangle will be done at render time + _Touched = true; + } + + // ********************************************************************************* + void CViewPolygon::setAlpha(sint32 a) + { + _Color.A = (uint8) a; + } + +} + diff --git a/code/ryzom/client/src/interface_v3/view_polygon.cpp b/code/ryzom/client/src/interface_v3/view_polygon.cpp deleted file mode 100644 index 089b6614e..000000000 --- a/code/ryzom/client/src/interface_v3/view_polygon.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_polygon.h" -#include "nel/gui/view_renderer.h" -#include "interface_manager.h" - - -using namespace NLMISC; - -// ********************************************************************************* -CViewPolygon::CViewPolygon() : CViewBase(TCtorParam()) -{ - // Construct - _Color = CRGBA::White; -} - - -// ********************************************************************************* -void CViewPolygon::setVertices(const std::vector &vertices) -{ - if (vertices.size() == _Poly.Vertices.size() && - std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged - _Poly.Vertices = vertices; - _Tris.clear(); - std::list polys; - if (_Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity)) - { - _Tris.clear(); - for(std::list::iterator it = polys.begin(); it != polys.end(); ++it) - { - it->toTriFan(_Tris); - } - } - else - { - nlwarning("CViewPolygon : conversion to conex polygons failed"); - _Tris.clear(); - } - _Touched = true; -} - - -static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) -{ - return (sint32) maxCorner.x < (cx + cw) && - (sint32) minCorner.x >= cx && - (sint32) maxCorner.y < (cy + ch) && - (sint32) minCorner.y >= cy; -} - -static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch) -{ - return (sint32) minCorner.x >= (cx + cw) || - (sint32) maxCorner.x < cx || - (sint32) minCorner.y >= (cy + ch) || - (sint32) maxCorner.y < cy; -} - -// ********************************************************************************* -void CViewPolygon::draw() -{ - if (_Tris.empty()) return; - if (!_Parent) return; - CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewRenderer &vr = *CViewRenderer::getInstance(); - if (_Touched) - { - _RealTris.clear(); - uint numTris = (uint)_Tris.size(); - sint32 cornerX, cornerY; - static std::vector winTris; - winTris.resize(numTris); - _Parent->getCorner(cornerX, cornerY, _ParentPosRef); - for(uint k = 0; k < numTris; ++k) - { - winTris[k].V0.set((float) (_Tris[k].V0.x + cornerX), (float) (_Tris[k].V0.y + cornerY), 0.f); - winTris[k].V1.set((float) (_Tris[k].V1.x + cornerX), (float) (_Tris[k].V1.y + cornerY), 0.f); - winTris[k].V2.set((float) (_Tris[k].V2.x + cornerX), (float) (_Tris[k].V2.y + cornerY), 0.f); - } - // recompute & reclip poly - _RealTris.clear(); - sint32 cx, cy, cw, ch; - vr.getClipWindow(cx, cy, cw, ch); - // per tri clip - NLMISC::CVector minCorner; - NLMISC::CVector maxCorner; - for(uint k = 0; k < numTris; ++k) - { - winTris[k].getMinCorner(minCorner); - winTris[k].getMaxCorner(maxCorner); - if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue; - if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch)) - { - _RealTris.push_back(winTris[k]); - } - else - { - const uint maxNumCorners = 8; - static CVector outPos0[maxNumCorners]; - static CVector outPos1[maxNumCorners]; - // - outPos0[0] = winTris[k].V0; - outPos0[1] = winTris[k].V1; - outPos0[2] = winTris[k].V2; - // - CVector *pPos0 = outPos0; - CVector *pPos1 = outPos1; - // - sint count = 3; - // - if ((sint32) minCorner.x < cx) - { - // clip left - CPlane clipper(-1.f, 0.f, 0.f, (float) cx); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - if ((sint32) maxCorner.x > cx + cw) - { - // clip right - CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw)); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - // - if ((sint32) minCorner.y < cy) - { - // clip bottom - CPlane clipper(0.f, -1.f, 0.f, (float) cy); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - if ((sint32) maxCorner.y > cy + ch) - { - // clip top - CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch)); - count = clipper.clipPolygonBack(pPos0, pPos1, count); - std::swap(pPos0, pPos1); - } - nlassert(count <= 8); - if (count >= 3) - { - for(uint k = 0; k < (uint) (count - 2); ++k) - { - _RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2])); - } - } - } - } - _Touched = false; - } - if (_RealTris.empty()) return; - CRGBA col; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col); -} - -// ********************************************************************************* -void CViewPolygon::updateCoords() -{ - // assume that clipping will have to be done again, real update of triangle will be done at render time - _Touched = true; -} - -// ********************************************************************************* -void CViewPolygon::setAlpha(sint32 a) -{ - _Color.A = (uint8) a; -} From f8df1159ffe3386eb01679d2a78035eb169e4a86 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 16 Jun 2012 22:21:14 +0200 Subject: [PATCH 072/339] CHANGED: #1471 moved some ucstring handling code to the NELGUI library ( required for CViewText ) --- code/nel/include/nel/gui/string_case.h | 29 ++++++ code/nel/src/gui/string_case.cpp | 99 +++++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 + code/ryzom/client/src/connection.cpp | 2 + .../client/src/interface_v3/guild_manager.cpp | 2 + .../src/interface_v3/inventory_manager.cpp | 2 + .../src/interface_v3/people_interraction.cpp | 2 + .../client/src/interface_v3/view_text.cpp | 11 +-- .../ryzom/client/src/interface_v3/view_text.h | 6 +- code/ryzom/client/src/login.cpp | 2 + code/ryzom/client/src/misc.cpp | 94 ------------------ code/ryzom/client/src/misc.h | 18 ---- 12 files changed, 145 insertions(+), 124 deletions(-) create mode 100644 code/nel/include/nel/gui/string_case.h create mode 100644 code/nel/src/gui/string_case.cpp diff --git a/code/nel/include/nel/gui/string_case.h b/code/nel/include/nel/gui/string_case.h new file mode 100644 index 000000000..9788bbf9e --- /dev/null +++ b/code/nel/include/nel/gui/string_case.h @@ -0,0 +1,29 @@ +#ifndef STRING_CASE_H +#define STRING_CASE_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/ucstring.h" + +namespace NLGUI +{ + + enum TCaseMode + { + CaseNormal = 0, // Nothing done + CaseLower, // All letters in lowercase + CaseUpper, // All letters in uppercase + CaseFirstStringLetterUp, // The first letter of the string is uppercase, the others are lowercase + CaseFirstSentenceLetterUp, // The first letter of the string and each sentences are uppercase, the others are lowercase. Sentences are seprated with '.'. + CaseFirstWordLetterUp, // The first letter of each word is uppercase, the others are lowercase + CaseCount + }; + + + void setCase( ucstring &str, TCaseMode mode ); + + +} + +#endif + + diff --git a/code/nel/src/gui/string_case.cpp b/code/nel/src/gui/string_case.cpp new file mode 100644 index 000000000..193716f12 --- /dev/null +++ b/code/nel/src/gui/string_case.cpp @@ -0,0 +1,99 @@ +#include "nel/gui/string_case.h" + +namespace NLGUI +{ + inline bool isSeparator (ucchar c) + { + return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); + } + + // *************************************************************************** + + inline bool isEndSentence (ucstring& str, uint index) + { + // Ex: One sentence. Another sentence. + // ^ + // Counterexample: nevrax.com + // ^ + ucchar c = str[index]; + if ((str[index] == ' ') || (str[index] == '\n')) + { + if (index < 1) + return false; + c = str[index-1]; + return (c == '.') || (c == '!') || (c == '?'); + } + return false; + } + + + void setCase( ucstring &str, TCaseMode mode ) + { + const uint length = (uint)str.length(); + uint i; + bool newString = true; + bool newSentence = true; + bool newWord = true; + switch (mode) + { + case CaseLower: + str = NLMISC::toLower (str); + break; + case CaseUpper: + str = NLMISC::toUpper (str); + break; + case CaseFirstStringLetterUp: + for (i=0; i +#include "../misc.h" + using namespace NLMISC; using namespace std; diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index af81274c1..b58ca9eaa 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -14,21 +14,18 @@ // 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/misc/bit_mem_stream.h" #include "nel/misc/i18n.h" #include "view_text.h" #include "interface_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" #include "group_container.h" // CCtrlResizer #include "nel/gui/ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" using namespace std; using namespace NLMISC; @@ -2415,7 +2412,7 @@ void CViewText::setTextFormatTaged(const ucstring &text) // color format is available only if multilined if (!_MultiLine) - CLuaIHMRyzom::debugInfo(toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str())); + nlwarning( toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); } @@ -2472,7 +2469,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text) // this color format is available only if not multilined if (_MultiLine) - CLuaIHMRyzom::debugInfo(toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str())); + nlwarning( toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); } diff --git a/code/ryzom/client/src/interface_v3/view_text.h b/code/ryzom/client/src/interface_v3/view_text.h index 623e2c2aa..9fe54825b 100644 --- a/code/ryzom/client/src/interface_v3/view_text.h +++ b/code/ryzom/client/src/interface_v3/view_text.h @@ -20,7 +20,7 @@ #define NL_VIEW_TEXT_H #include "nel/gui/view_base.h" -#include "../misc.h" +#include "nel/gui/string_case.h" #include "nel/3d/u_text_context.h" namespace NLGUI @@ -408,10 +408,6 @@ private: void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; }; -// change case of a string -void setCase (ucstring &str, TCaseMode mode); - - #endif // NL_VIEW_TEXT_H /* End of view_text.h */ diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index c981f083f..0b96b0782 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -60,6 +60,8 @@ #include "game_share/crypt.h" #include "game_share/bg_downloader_msg.h" +#include "misc.h" + void ConnectToShard(); // *************************************************************************** diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index 2dd72ad52..bb8cc7387 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -976,100 +976,6 @@ std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest) } -// *************************************************************************** - -inline bool isSeparator (ucchar c) -{ - return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r'); -} - -// *************************************************************************** - -inline bool isEndSentence (ucstring& str, uint index) -{ - // Ex: One sentence. Another sentence. - // ^ - // Counterexample: nevrax.com - // ^ - ucchar c = str[index]; - if ((str[index] == ' ') || (str[index] == '\n')) - { - if (index < 1) - return false; - c = str[index-1]; - return (c == '.') || (c == '!') || (c == '?'); - } - return false; -} - - -void setCase (ucstring &str, TCaseMode mode) -{ - const uint length = (uint)str.length(); - uint i; - bool newString = true; - bool newSentence = true; - bool newWord = true; - switch (mode) - { - case CaseLower: - str = toLower (str); - break; - case CaseUpper: - str = toUpper (str); - break; - case CaseFirstStringLetterUp: - for (i=0; i Date: Sat, 16 Jun 2012 23:03:29 +0200 Subject: [PATCH 073/339] CHANGED: #1471 decoupled CViewText from CGroupContainer and CCtrlResizer. --- code/nel/include/nel/gui/ctrl_base.h | 4 ++++ code/nel/include/nel/gui/group_container_base.h | 2 ++ code/ryzom/client/src/interface_v3/group_container.cpp | 1 + code/ryzom/client/src/interface_v3/view_text.cpp | 8 +++----- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h index b22148b88..18c5c6535 100644 --- a/code/nel/include/nel/gui/ctrl_base.h +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -50,6 +50,7 @@ namespace NLGUI // see interface.txt for meaning of auto _ToolTipParentPosRef= Hotspot_TTAuto; _ToolTipPosRef= Hotspot_TTAuto; + resizer = false; } /// Destructor @@ -125,6 +126,8 @@ namespace NLGUI // true if this ctrl is capturable (true by default, false for tooltip) virtual bool isCapturable() const {return true;} + bool isResizer() const{ return resizer; } + // from CInterfaceElement virtual void visit(CInterfaceElementVisitor *visitor); @@ -158,6 +161,7 @@ namespace NLGUI THotSpot _ToolTipPosRefAlt : 6; protected: void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS); + bool resizer; }; } diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index 9122f1027..a4c2a0ba6 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -76,6 +76,8 @@ namespace NLGUI REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); REFLECT_EXPORT_END + virtual bool isMoving() const{ return false; } + protected: void triggerAlphaSettingsChangedAH(); diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index e4b80a016..ee6379722 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -107,6 +107,7 @@ CCtrlResizer::CCtrlResizer(const TCtorParam ¶m) _MouseDown = false; _XBias = 0; _YBias = 0; + resizer = true; } diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index b58ca9eaa..19812d86b 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -21,9 +21,8 @@ #include "interface_manager.h" #include "nel/gui/view_renderer.h" #include "nel/gui/widget_manager.h" -#include "group_container.h" // CCtrlResizer +#include "nel/gui/group_container_base.h" #include "nel/gui/ctrl_tooltip.h" - #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" @@ -381,8 +380,7 @@ void CViewText::checkCoords () CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { - CCtrlResizer *pCR = dynamic_cast(pCB); - if (pCR != NULL) + if( pCB->isResizer() ) { // We are resizing !!!! } @@ -644,7 +642,7 @@ void CViewText::draw () if(bFound) { // last check: the window must not be currently moved - CGroupContainer *gc= dynamic_cast(pIG); + CGroupContainerBase *gc= dynamic_cast(pIG); if(!gc || !gc->isMoving()) { CRGBA col= pIM->getSystemOption(CInterfaceManager::OptionViewTextOverBackColor).getValColor(); From 4e67289d6df177c7d9b032e6fab6de655c6dfd5e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 17 Jun 2012 02:08:21 +0200 Subject: [PATCH 074/339] CHANGED: #1471 CViewText no longer depends on CInterfaceManager. --- code/nel/include/nel/gui/interface_group.h | 2 + code/nel/include/nel/gui/interface_options.h | 2 + code/nel/include/nel/gui/view_renderer.h | 2 + code/nel/include/nel/gui/widget_manager.h | 47 +++++++++++++++ code/nel/src/gui/interface_group.cpp | 1 + code/nel/src/gui/interface_options.cpp | 1 - code/nel/src/gui/widget_manager.cpp | 28 ++++++++- .../client/src/interface_v3/dbctrl_sheet.cpp | 4 +- .../dbgroup_list_sheet_mission.cpp | 12 ++-- .../interface_v3/dbgroup_list_sheet_text.cpp | 4 +- .../interface_v3/group_in_scene_bubble.cpp | 16 ++--- .../client/src/interface_v3/group_list.cpp | 1 + .../client/src/interface_v3/group_tree.cpp | 2 +- .../src/interface_v3/interface_anim.cpp | 6 +- .../src/interface_v3/interface_manager.cpp | 44 +++----------- .../src/interface_v3/interface_manager.h | 42 +------------ .../client/src/interface_v3/macrocmd_key.cpp | 4 +- .../client/src/interface_v3/view_text.cpp | 59 +++++++++---------- 18 files changed, 144 insertions(+), 133 deletions(-) diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h index 451e38ff3..38d0c1e32 100644 --- a/code/nel/include/nel/gui/interface_group.h +++ b/code/nel/include/nel/gui/interface_group.h @@ -252,6 +252,7 @@ namespace NLGUI bool isGroupContainer() const { return _IsGroupContainer; } bool isGroupScrollText() const{ return _IsGroupScrollText; } bool isGroupInScene() const{ return _IsGroupInScene; } + bool isGroupList() const{ return _IsGroupList; } CInterfaceGroup* getEnclosingContainer(); @@ -354,6 +355,7 @@ namespace NLGUI bool _IsGroupContainer : 1; // faster than a virual call bool _IsGroupScrollText : 1; bool _IsGroupInScene : 1; + bool _IsGroupList : 1; bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene sint32 _ResizeFromChildWMargin; sint32 _ResizeFromChildHMargin; diff --git a/code/nel/include/nel/gui/interface_options.h b/code/nel/include/nel/gui/interface_options.h index 7ca938140..6fcd6c18d 100644 --- a/code/nel/include/nel/gui/interface_options.h +++ b/code/nel/include/nel/gui/interface_options.h @@ -22,6 +22,8 @@ #include "nel/misc/debug.h" #include "nel/misc/smart_ptr.h" #include "nel/misc/rgba.h" +#include "libxml/globals.h" +#include "nel/misc/xml_auto_ptr.h" namespace NL3D { diff --git a/code/nel/include/nel/gui/view_renderer.h b/code/nel/include/nel/gui/view_renderer.h index 5adde3cb3..83b45f79f 100644 --- a/code/nel/include/nel/gui/view_renderer.h +++ b/code/nel/include/nel/gui/view_renderer.h @@ -578,6 +578,8 @@ namespace NLGUI static NL3D::UTextContext *textcontext; public: + static NL3D::UTextContext* getTextContext(){ return textcontext; } + static std::set< std::string > *hwCursors; static float hwCursorScale; diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 1c15ac357..8188a68cb 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -25,6 +25,7 @@ #include "nel/misc/rgba.h" #include "nel/misc/types_nl.h" #include "nel/gui/interface_common.h" +#include "nel/gui/interface_options.h" namespace NLMISC { @@ -302,6 +303,45 @@ namespace NLGUI // Get the User DblClick Delay (according to save...), in milisecond uint getUserDblClickDelay(); + /// \name Global Interface Options + // @{ + + // List of system options + enum TSystemOption{ + OptionCtrlSheetGrayColor=0, + OptionCtrlTextGrayColor, + OptionCtrlSheetRedifyColor, + OptionCtrlTextRedifyColor, + OptionCtrlSheetGreenifyColor, + OptionCtrlTextGreenifyColor, + OptionViewTextOverBackColor, + OptionFont, + OptionAddCoefFont, + OptionMulCoefAnim, + OptionTimeoutBubbles, + OptionTimeoutMessages, + OptionTimeoutContext, + OptionTimeoutContextHtml, + NumSystemOptions + }; + + void setupOptions(); + /** Get a system option by its enum (faster than getOptions() and getVal()) + * NB: array updated after each parseInterface() + */ + const CInterfaceOptionValue &getSystemOption( TSystemOption o ) const{ return _SystemOptions[ o ]; } + + // @} + + CInterfaceElement* getOverExtendViewText(){ return _OverExtendViewText; } + NLMISC::CRGBA& getOverExtendViewTextBackColor(){ return _OverExtendViewTextBackColor; } + + // For single lined ViewText that are clipped: on over of viewText too big, the text is drawn on top. A CRefPtr is kept + void setOverExtendViewText( CInterfaceElement *vt, NLMISC::CRGBA backGround ){ + _OverExtendViewText = vt; + _OverExtendViewTextBackColor = backGround; + } + static IParser *parser; private: @@ -345,6 +385,13 @@ namespace NLGUI NLMISC::CCDBNodeLeaf *_AProp; bool _MouseHandlingEnabled; + + // System Options + CInterfaceOptionValue _SystemOptions[ NumSystemOptions ]; + + // The next ViewText to draw for Over + NLMISC::CRefPtr< CInterfaceElement > _OverExtendViewText; + NLMISC::CRGBA _OverExtendViewTextBackColor; }; } diff --git a/code/nel/src/gui/interface_group.cpp b/code/nel/src/gui/interface_group.cpp index bfa58b535..ac8842b81 100644 --- a/code/nel/src/gui/interface_group.cpp +++ b/code/nel/src/gui/interface_group.cpp @@ -60,6 +60,7 @@ namespace NLGUI _IsGroupContainer = false; _IsGroupScrollText = false; _IsGroupInScene = false; + _IsGroupList = false; _AHOnActive = NULL; _AHOnDeactive = NULL; _AHOnLeftClick = NULL; diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 1a01bce6e..c4cd33f2c 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -17,7 +17,6 @@ #include "nel/gui/interface_element.h" -#include "nel/misc/xml_auto_ptr.h" #include "nel/gui/interface_options.h" using namespace std; diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 76b0afcc7..483df5887 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1419,8 +1419,32 @@ namespace NLGUI uint dbclickDelay = (uint)(DOUBLE_CLICK_MIN + (DOUBLE_CLICK_MAX-DOUBLE_CLICK_MIN) * (float)nVal / 100.0f); return dbclickDelay; } - - + + // ------------------------------------------------------------------------------------------------ + void CWidgetManager::setupOptions() + { + // After parsing options and templates node -> init system options. + CInterfaceOptions *opt = getOptions( "system" ); + if( opt != NULL ) + { + // List here all Special options + _SystemOptions[OptionCtrlSheetGrayColor]= opt->getValue("ctrl_sheet_gray_color"); + _SystemOptions[OptionCtrlTextGrayColor]= opt->getValue("ctrl_text_gray_color"); + _SystemOptions[OptionCtrlSheetRedifyColor]= opt->getValue("ctrl_sheet_redify_color"); + _SystemOptions[OptionCtrlTextRedifyColor]= opt->getValue("ctrl_text_redify_color"); + _SystemOptions[OptionCtrlSheetGreenifyColor]= opt->getValue("ctrl_sheet_greenify_color"); + _SystemOptions[OptionCtrlTextGreenifyColor]= opt->getValue("ctrl_text_greenify_color"); + _SystemOptions[OptionViewTextOverBackColor]= opt->getValue("text_over_back_color"); + _SystemOptions[OptionFont]= opt->getValue("font"); + _SystemOptions[OptionAddCoefFont]= opt->getValue("add_coef_font"); + _SystemOptions[OptionMulCoefAnim]= opt->getValue("mul_coef_anim"); + _SystemOptions[OptionTimeoutBubbles]= opt->getValue("bubbles_timeout"); + _SystemOptions[OptionTimeoutMessages]= opt->getValue("messages_timeout"); + _SystemOptions[OptionTimeoutContext]= opt->getValue("context_timeout"); + _SystemOptions[OptionTimeoutContextHtml]= opt->getValue("context_html_timeout"); + } + + } CWidgetManager::CWidgetManager() { diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 586817ac4..c02b21caf 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -2108,8 +2108,8 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti curNoSheetColor= CRGBA(255,255,255, CWidgetManager::getInstance()->getGlobalColorForContent().A); // The gray color - CRGBA grayColor= pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetGrayColor).getValColor(); - CRGBA redifyColor= pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetRedifyColor).getValColor(); + CRGBA grayColor= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetGrayColor).getValColor(); + CRGBA redifyColor= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetRedifyColor).getValColor(); // The color of the number. CRGBA numberColor; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index 68c0a8260..fe56bf1d9 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -89,34 +89,34 @@ void CDBGroupListSheetMission::CSheetChildMission::updateViewText(CDBGroupListSh if (CachePreReqState == MISSION_DESC::PreReqFail) { // If mission prerequesits failed for miscellaneaous reasons : COLOR RED - CRGBA color = pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetRedifyColor).getValColor(); + CRGBA color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetRedifyColor).getValColor(); Ctrl->setGrayed(true); Ctrl->setSheetColor(color); - color = pIM->getSystemOption(CInterfaceManager::OptionCtrlTextRedifyColor).getValColor(); + color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextRedifyColor).getValColor(); Text->setColor(color); } else if (CachePreReqState == MISSION_DESC::PreReqFailAlreadyDone) { // If mission prerequesits failed because mission is already done : COLOR GREEN - CRGBA color = pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetGreenifyColor).getValColor(); + CRGBA color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetGreenifyColor).getValColor(); Ctrl->setGrayed(true); Ctrl->setSheetColor(color); - color = pIM->getSystemOption(CInterfaceManager::OptionCtrlTextGreenifyColor).getValColor(); + color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGreenifyColor).getValColor(); Text->setColor(color); } else if (CachePreReqState == MISSION_DESC::PreReqFailRunning) { // If mission prerequesits failed because the mission is in progress : COLOR GRAY - CRGBA color = pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetGrayColor).getValColor(); + CRGBA color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetGrayColor).getValColor(); Ctrl->setGrayed(true); Ctrl->setSheetColor(color); - color = pIM->getSystemOption(CInterfaceManager::OptionCtrlTextGrayColor).getValColor(); + color = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor(); Text->setColor(color); } else diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 1ec3d9420..b76ef53fb 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -506,8 +506,8 @@ void CDBGroupListSheetText::checkCoords () { // The gray color CRGBA normalColor= _TextTemplate.getColor(); - CRGBA grayColor= pIM->getSystemOption(CInterfaceManager::OptionCtrlSheetGrayColor).getValColor(); - CRGBA redifyColor= pIM->getSystemOption(CInterfaceManager::OptionCtrlTextRedifyColor).getValColor(); + CRGBA grayColor= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlSheetGrayColor).getValColor(); + CRGBA redifyColor= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextRedifyColor).getValColor(); grayColor.modulateFromColor(grayColor, normalColor); redifyColor.modulateFromColor(redifyColor, normalColor); diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 32ab05086..603c7f5e5 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -73,7 +73,7 @@ void contextHelp (const std::string &name) completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html"; // Add bubble InSceneBubbleManager.addContextHelpHTML(completeURL, target, - pIM->getSystemOption(CInterfaceManager::OptionTimeoutContextHtml).getValSInt32()); + CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutContextHtml).getValSInt32()); } // Found one help @@ -565,7 +565,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA // default timeout? if(time==0) - time=pIM->getSystemOption(CInterfaceManager::OptionTimeoutMessages).getValSInt32(); + time=CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutMessages).getValSInt32(); // Create a skill popup string id = "message_popup_"+toString(_PopupCount++); @@ -614,7 +614,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, // default timeout? if(time==0) - time= pIM->getSystemOption(CInterfaceManager::OptionTimeoutMessages).getValSInt32(); + time= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutMessages).getValSInt32(); // Create a skill popup string id = "message_popup_"+toString(_PopupCount++); @@ -825,7 +825,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, CCharacterCL *pChar = dynamic_cast(EntitiesMngr.getEntityByCompressedIndex(nUID)); if (pChar == NULL || nUID==CLFECOMMON::INVALID_CLIENT_DATASET_INDEX) return; - if (bubbleTimer == 0) bubbleTimer = pIM->getSystemOption(CInterfaceManager::OptionTimeoutBubbles).getValSInt32(); + if (bubbleTimer == 0) bubbleTimer = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); // Output the message in a bubble @@ -1575,7 +1575,7 @@ class CHandlerCharacterBubble : public IActionHandler string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) - duration = pIM->getSystemOption(CInterfaceManager::OptionTimeoutBubbles).getValSInt32(); + duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); else fromString(sTime, duration); @@ -1602,7 +1602,7 @@ class CHandlerSkillPopup : public IActionHandler string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) - duration = pIM->getSystemOption(CInterfaceManager::OptionTimeoutMessages).getValSInt32(); + duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutMessages).getValSInt32(); else fromString(sTime, duration); @@ -1626,7 +1626,7 @@ class CHandlerMessagePopup : public IActionHandler string sTime = getParam (sParams, "time"); uint duration; if (sTime.empty()) - duration = pIM->getSystemOption(CInterfaceManager::OptionTimeoutMessages).getValSInt32(); + duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutMessages).getValSInt32(); else fromString(sTime, duration); @@ -1651,7 +1651,7 @@ class CHandlerContextHelp : public IActionHandler if (itext.empty()) itext = CI18N::get(text); - InSceneBubbleManager.addContextHelp (itext, targetName, pIM->getSystemOption(CInterfaceManager::OptionTimeoutContext).getValSInt32()); + InSceneBubbleManager.addContextHelp (itext, targetName, CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutContext).getValSInt32()); } }; REGISTER_ACTION_HANDLER( CHandlerContextHelp, "context_help"); diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index e77f675d6..64fe82706 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -53,6 +53,7 @@ CGroupList::CGroupList(const TCtorParam ¶m) _Over = false; _OverColor = CRGBA(255, 255, 255, 32); _OverElt = -1; + _IsGroupList = true; } // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index c739be7dd..17c0bff09 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -685,7 +685,7 @@ void CGroupTree::draw() } // will be drawn over all the interface - pIM->setOverExtendViewText(viewTextExtend, col); + CWidgetManager::getInstance()->setOverExtendViewText(viewTextExtend, col); } } } diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index be39bc9b1..6f3001dd9 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -123,7 +123,7 @@ bool CInterfaceTrack::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) { double dTime; fromString(k.Time, dTime); - k.Time = toString(dTime * CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionMulCoefAnim).getValFloat()); + k.Time = toString(dTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat()); } // Depending on the type of the track read extra values @@ -193,7 +193,7 @@ bool CInterfaceTrack::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) float fAnimTime; fromString((const char*)time, fAnimTime); - TAnimationTime animTime = fAnimTime * CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionMulCoefAnim).getValFloat(); + TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); double animValue; fromString(value, animValue); @@ -544,7 +544,7 @@ bool CInterfaceAnim::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) fromString((const char*)ptr, _Duration); if (_Duration == 0) _Duration = 1.0; - _Duration *= CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionMulCoefAnim).getValFloat(); + _Duration *= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); ptr = xmlGetProp (cur, (xmlChar*)"disable_buttons"); if (ptr) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 89c1bc64b..1e9ebb20e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1343,36 +1343,17 @@ void CInterfaceManager::updateFrameViews(NL3D::UCamera camera) } -// ------------------------------------------------------------------------------------------------ void CInterfaceManager::setupOptions() { - // After parsing options and templates node -> init system options. - CInterfaceOptions *opt= CWidgetManager::getInstance()->getOptions("system"); - if(opt) - { - // List here all Special options - _SystemOptions[OptionCtrlSheetGrayColor]= opt->getValue("ctrl_sheet_gray_color"); - _SystemOptions[OptionCtrlTextGrayColor]= opt->getValue("ctrl_text_gray_color"); - _SystemOptions[OptionCtrlSheetRedifyColor]= opt->getValue("ctrl_sheet_redify_color"); - _SystemOptions[OptionCtrlTextRedifyColor]= opt->getValue("ctrl_text_redify_color"); - _SystemOptions[OptionCtrlSheetGreenifyColor]= opt->getValue("ctrl_sheet_greenify_color"); - _SystemOptions[OptionCtrlTextGreenifyColor]= opt->getValue("ctrl_text_greenify_color"); - _SystemOptions[OptionViewTextOverBackColor]= opt->getValue("text_over_back_color"); - _SystemOptions[OptionFont]= opt->getValue("font"); - _SystemOptions[OptionAddCoefFont]= opt->getValue("add_coef_font"); - _SystemOptions[OptionMulCoefAnim]= opt->getValue("mul_coef_anim"); - _SystemOptions[OptionTimeoutBubbles]= opt->getValue("bubbles_timeout"); - _SystemOptions[OptionTimeoutMessages]= opt->getValue("messages_timeout"); - _SystemOptions[OptionTimeoutContext]= opt->getValue("context_timeout"); - _SystemOptions[OptionTimeoutContextHtml]= opt->getValue("context_html_timeout"); - } - + CWidgetManager *wm = CWidgetManager::getInstance(); + wm->setupOptions(); + // Try to change font if any - string sFont = _SystemOptions[OptionFont].getValStr(); + string sFont = wm->getSystemOption( CWidgetManager::OptionFont ).getValStr(); + extern void resetTextContext( const char*, bool ); if ((!sFont.empty()) && (driver != NULL)) resetTextContext(sFont.c_str(), true); - // Continue to parse the rest of the interface } @@ -4029,21 +4010,14 @@ void CInterfaceManager::incLocalSyncActionCounter() } -// *************************************************************************** -void CInterfaceManager::setOverExtendViewText(CViewText *vt, CRGBA backGround) -{ - _OverExtendViewText= vt; - _OverExtendViewTextBackColor= backGround; -} - // *************************************************************************** void CInterfaceManager::drawOverExtendViewText() { // CViewRenderer &rVR= getViewRenderer(); - if(_OverExtendViewText) + if( CWidgetManager::getInstance()->getOverExtendViewText() ) { - CViewText *vtSrc= safe_cast((CInterfaceElement*)_OverExtendViewText); + CViewText *vtSrc= safe_cast( CWidgetManager::getInstance()->getOverExtendViewText() ); CInterfaceGroup *groupOver = getWindowForActiveMasterGroup("over_extend_view_text"); if(groupOver) @@ -4065,7 +4039,7 @@ void CInterfaceManager::drawOverExtendViewText() CViewBitmap *pBack= dynamic_cast(groupOver->getView("midback")); CViewBitmap *pOutline= dynamic_cast(groupOver->getView("midoutline")); if(pBack) - pBack->setColor(_OverExtendViewTextBackColor); + pBack->setColor( CWidgetManager::getInstance()->getOverExtendViewTextBackColor() ); if(pOutline) { pOutline->setColor(vtSrc->getColor()); @@ -4112,7 +4086,7 @@ void CInterfaceManager::drawOverExtendViewText() } // Reset the ptr so at next frame, won't be rendered (but if reset) - _OverExtendViewText= NULL; + CWidgetManager::getInstance()->setOverExtendViewText( NULL, CWidgetManager::getInstance()->getOverExtendViewTextBackColor() ); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index d70a1def9..46e0d9cac 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -315,39 +315,8 @@ public: // display a system info string void displaySystemInfo(const ucstring &str, const std::string &Category = "SYS"); NLMISC::CRGBA getSystemInfoColor(const std::string &Category = "SYS"); - /// \name Global Interface Options - // @{ - - // List of system options - enum TSystemOption - { - OptionCtrlSheetGrayColor=0, - OptionCtrlTextGrayColor, - OptionCtrlSheetRedifyColor, - OptionCtrlTextRedifyColor, - OptionCtrlSheetGreenifyColor, - OptionCtrlTextGreenifyColor, - OptionViewTextOverBackColor, - OptionFont, - OptionAddCoefFont, - OptionMulCoefAnim, - OptionTimeoutBubbles, - OptionTimeoutMessages, - OptionTimeoutContext, - OptionTimeoutContextHtml, - - NumSystemOptions, - }; - - virtual void setupOptions(); - - /** Get a system option by its enum (faster than getOptions() and getVal()) - * NB: array updated after each parseInterface() - */ - const CInterfaceOptionValue &getSystemOption(TSystemOption o) const {return _SystemOptions[o];} - - // @} + void setupOptions(); /** Open a MessageBox. this is a simple ModalWindow with a Ok button * ui:interface:message_box must be defined in xml, with a "text" ViewText son @@ -493,9 +462,6 @@ public: return fTmp*fTmp*fTmp; } - // For single lined ViewText that are clipped: on over of viewText too big, the text is drawn on top. A CRefPtr is kept - void setOverExtendViewText(CViewText *vt, NLMISC::CRGBA backGround); - // Item Carac Test, get the value bool isItemCaracRequirementMet(CHARACTERISTICS::TCharacteristics type, sint32 value) { @@ -730,9 +696,6 @@ private: bool isControlInWindow (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentWnd); uint getDepth (CCtrlBase *ctrl, CInterfaceGroup *pNewCurrentWnd); - // System Options - CInterfaceOptionValue _SystemOptions[NumSystemOptions]; - // Modes CInterfaceConfig::CDesktopImage _Modes[MAX_NUM_MODES]; uint8 _CurrentMode; @@ -758,9 +721,6 @@ private: NLMISC::CCDBNodeLeaf *_ErrorColor; NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; - // The next ViewText to draw for Over - NLMISC::CRefPtr _OverExtendViewText; - NLMISC::CRGBA _OverExtendViewTextBackColor; void drawOverExtendViewText(); CInterfaceGroup *getWindowForActiveMasterGroup(const std::string &windowName); diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 8eb74210a..7ffe97d27 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -97,14 +97,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s if (pViewKeyName != NULL) { pViewKeyName->setText (keyName); - pViewKeyName->setColor(grayed?pIM->getSystemOption(CInterfaceManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); + pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } CViewText *pViewShortcutName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME)); if (pViewShortcutName != NULL) { pViewShortcutName->setText (shortcutName); - pViewShortcutName->setColor(grayed?pIM->getSystemOption(CInterfaceManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); + pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White); } pKeysLine->setParent (pParent); diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp index 19812d86b..fc50c1b76 100644 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ b/code/ryzom/client/src/interface_v3/view_text.cpp @@ -18,13 +18,13 @@ #include "nel/misc/i18n.h" #include "view_text.h" -#include "interface_manager.h" #include "nel/gui/view_renderer.h" #include "nel/gui/widget_manager.h" #include "nel/gui/group_container_base.h" #include "nel/gui/ctrl_tooltip.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/lua_ihm.h" +#include "nel/gui/view_pointer_base.h" using namespace std; using namespace NLMISC; @@ -51,7 +51,8 @@ void CViewText::setupDefault () _ParentPosRef = Hotspot_BL; _PosRef = Hotspot_BL; - _FontSize = 12+CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + _FontSize = 12 + + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); _Color = CRGBA(255,255,255,255); _Shadow = false; _ShadowColor = CRGBA(0,0,0,255); @@ -109,7 +110,7 @@ CViewText:: CViewText (const std::string& id, const std::string Text, sint FontS _Id = id; setupDefault (); - _FontSize = FontSize+CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); _Color = Color; _Shadow = Shadow; setText(Text); @@ -120,7 +121,7 @@ CViewText:: CViewText (const std::string& id, const std::string Text, sint FontS CViewText::~CViewText() { if (_Index != 0xFFFFFFFF) - CInterfaceManager::getInstance()->getTextContext()->erase (_Index); + CViewRenderer::getTextContext()->erase (_Index); clearLines(); if (!_Setuped) @@ -134,7 +135,7 @@ CViewText::~CViewText() CViewText &CViewText::operator=(const CViewText &vt) { if (_Index != 0xFFFFFFFF) - CInterfaceManager::getInstance()->getTextContext()->erase (_Index); + CViewRenderer::getTextContext()->erase (_Index); // Create database entries _Active = vt._Active; @@ -187,11 +188,11 @@ void CViewText::parseTextOptions (xmlNodePtr cur) _ModulateGlobalColor= convertBool(prop); prop = (char*) xmlGetProp( cur, (xmlChar*)"fontsize" ); - _FontSize = 12+CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + _FontSize = 12 + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); if (prop) { fromString((const char*)prop, _FontSize); - _FontSize += CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); } prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow" ); @@ -376,7 +377,6 @@ void CViewText::checkCoords () } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { @@ -412,7 +412,6 @@ void CViewText::draw () { H_AUTO( RZ_Interface_CViewText_draw ) - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); // *** Out Of Clip? @@ -430,7 +429,7 @@ void CViewText::draw () return; rVR.getScreenOOSize (oow, ooh); - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); // *** get current color @@ -455,7 +454,7 @@ void CViewText::draw () { if (_Lines.size() == 0) return; - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -645,8 +644,8 @@ void CViewText::draw () CGroupContainerBase *gc= dynamic_cast(pIG); if(!gc || !gc->isMoving()) { - CRGBA col= pIM->getSystemOption(CInterfaceManager::OptionViewTextOverBackColor).getValColor(); - pIM->setOverExtendViewText(this, col); + CRGBA col= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionViewTextOverBackColor).getValColor(); + CWidgetManager::getInstance()->setOverExtendViewText(this, col); } } } @@ -716,7 +715,7 @@ void CViewText::setText(const ucstring & text) // *************************************************************************** void CViewText::setFontSize (sint nFontSize) { - _FontSize = nFontSize+CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + _FontSize = nFontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); computeFontSize (); invalidateContent(); } @@ -724,7 +723,7 @@ void CViewText::setFontSize (sint nFontSize) // *************************************************************************** sint CViewText::getFontSize() const { - return _FontSize - CInterfaceManager::getInstance()->getSystemOption(CInterfaceManager::OptionAddCoefFont).getValSInt32(); + return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); } // *************************************************************************** @@ -862,7 +861,7 @@ void CViewText::updateTextContextMultiLine(uint nMaxWidth) rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); } - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); // Parse the letter { @@ -1040,7 +1039,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS // Get the word value. wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd); // compute width of word - si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(wordValue); + si = CViewRenderer::getTextContext()->getStringInfo(wordValue); // compute size of spaces/Tab + word newLineWidth = lineWidth + numSpaces * _SpaceWidth; @@ -1119,7 +1118,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS for(currChar = 0; currChar < wordValue.length(); ++currChar) { oneChar = wordValue[currChar]; - si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(oneChar); + si = CViewRenderer::getTextContext()->getStringInfo(oneChar); if ((uint) (px + si.StringWidth) > nMaxWidth) break; px += si.StringWidth; } @@ -1238,7 +1237,7 @@ void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandS // *************************************************************************** void CViewText::updateTextContext () { - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); @@ -1413,7 +1412,7 @@ void CViewText::updateCoords() { CInterfaceGroup *parent = _Parent; // avoid resizing parents to compute the limiter - while (parent && (parent->getResizeFromChildW() || dynamic_cast(parent))) + while (parent && (parent->getResizeFromChildW() || parent->isGroupList() )) { // NB nico : the dynamic_cast for CGroupList is bad!! // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords @@ -1550,7 +1549,7 @@ void CViewText::setColorRGBA(NLMISC::CRGBA col) void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const { NLMISC::clamp(index, 0, (sint) _Text.length()); - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -1662,7 +1661,7 @@ static uint getCharacterIndex(const ucstring &textValue, float x) { // get character width singleChar[0] = textValue[i]; - si = CInterfaceManager::getInstance()->getTextContext()->getStringInfo(singleChar); + si = CViewRenderer::getTextContext()->getStringInfo(singleChar); px += si.StringWidth; // the character is at the i - 1 position if (px > x) @@ -1679,7 +1678,7 @@ static uint getCharacterIndex(const ucstring &textValue, float x) // *************************************************************************** void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const { - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); // setup the text context TextContext->setHotSpot (UTextContext::BottomLeft); @@ -1819,7 +1818,7 @@ void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &te quadSize--; } // select what quad to skip - CInterfaceManager::getInstance()->getTextContext()->setStringSelection(stringId, quadStart, quadSize); + CViewRenderer::getTextContext()->setStringSelection(stringId, quadStart, quadSize); } // *************************************************************************** @@ -1911,7 +1910,7 @@ void CViewText::CLine::clear() for(uint k = 0; k < _Words.size(); ++k) { if (_Words[k].Index != 0xffffffff) - CInterfaceManager::getInstance()->getTextContext()->erase(_Words[k].Index); + CViewRenderer::getTextContext()->erase(_Words[k].Index); } _Words.clear(); _NumChars = 0; @@ -1932,7 +1931,7 @@ void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/) { Text = text; NumSpaces = numSpaces; - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); Index = TextContext->textPush(text); Info = TextContext->getStringInfo(Index); } @@ -1955,7 +1954,7 @@ sint32 CViewText::getMaxUsedW() const static const ucstring lineFeedStr("\n"); float maxWidth = 0; - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2039,7 +2038,7 @@ sint32 CViewText::getMinUsedW() const // If we can't clip the words, return the size of the largest word else if ((_TextMode == DontClipWord) || (_TextMode == Justified)) { - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2090,7 +2089,7 @@ void CViewText::onInvalidateContent() // *************************************************************************** void CViewText::computeFontSize () { - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); TextContext->setHotSpot (UTextContext::BottomLeft); TextContext->setShaded (_Shadow); TextContext->setFontSize (_FontSize); @@ -2444,7 +2443,7 @@ void CViewText::setSingleLineTextFormatTaged(const ucstring &text) } // convert in ULetterColors - NL3D::UTextContext *TextContext = CInterfaceManager::getInstance()->getTextContext(); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); ULetterColors * letterColors = TextContext->createLetterColors(); for(uint i=0; i Date: Sun, 17 Jun 2012 02:49:00 +0200 Subject: [PATCH 075/339] CHANGED: #1471 CViewText is now part of NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/view_text.h | 413 +++ code/nel/src/gui/view_text.cpp | 2603 +++++++++++++++++ .../src/interface_v3/chat_text_manager.cpp | 2 +- .../client/src/interface_v3/chat_window.h | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../src/interface_v3/ctrl_text_button.h | 3 +- .../client/src/interface_v3/dbctrl_sheet.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.h | 2 +- .../src/interface_v3/dbgroup_combo_box.h | 2 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.h | 2 +- .../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +- .../interface_v3/dbgroup_select_number.cpp | 2 +- .../src/interface_v3/dbgroup_select_number.h | 2 +- .../client/src/interface_v3/dbview_number.h | 2 +- .../client/src/interface_v3/dbview_quantity.h | 2 +- .../src/interface_v3/flying_text_manager.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_container.h | 2 +- .../client/src/interface_v3/group_editbox.cpp | 2 +- .../client/src/interface_v3/group_editbox.h | 2 +- .../client/src/interface_v3/group_list.h | 2 +- .../ryzom/client/src/interface_v3/group_map.h | 2 +- .../client/src/interface_v3/group_menu.h | 2 +- .../client/src/interface_v3/group_paragraph.h | 2 +- .../group_phrase_skill_filter.cpp | 2 +- .../src/interface_v3/group_scrolltext.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_table.h | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../client/src/interface_v3/group_tree.h | 6 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_pointer.h | 3 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../src/interface_v3/view_bitmap_faber_mp.h | 2 +- .../ryzom/client/src/interface_v3/view_link.h | 2 +- .../client/src/interface_v3/view_text.cpp | 2597 ---------------- .../ryzom/client/src/interface_v3/view_text.h | 413 --- .../src/interface_v3/view_text_formated.h | 2 +- .../client/src/interface_v3/view_text_id.h | 2 +- code/ryzom/client/src/login.cpp | 2 +- 45 files changed, 3062 insertions(+), 3052 deletions(-) create mode 100644 code/nel/include/nel/gui/view_text.h create mode 100644 code/nel/src/gui/view_text.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text.h diff --git a/code/nel/include/nel/gui/view_text.h b/code/nel/include/nel/gui/view_text.h new file mode 100644 index 000000000..5c22f7110 --- /dev/null +++ b/code/nel/include/nel/gui/view_text.h @@ -0,0 +1,413 @@ +// Ryzom - MMORPG Framework +// 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 NL_VIEW_TEXT_H +#define NL_VIEW_TEXT_H + +#include "nel/gui/view_base.h" +#include "nel/gui/string_case.h" +#include "nel/3d/u_text_context.h" + +namespace NLGUI +{ + class CCtrlToolTip; + + /** + * class implementing a text view + * \author Matthieu 'TrapII' Besson + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CViewText : public CViewBase + { + public: + enum TTextMode { ClipWord, DontClipWord, Justified }; + public: + + DECLARE_UI_CLASS(CViewText) + + + /// Constructor + CViewText (const TCtorParam ¶m); + + /// Constructor + CViewText (const std::string& id, const std::string Text="", sint FontSize=12, + NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false); + + virtual ~CViewText(); + + CViewText &operator=(const CViewText &vt); + + void parseTextOptions (xmlNodePtr cur); + bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + /// Updating + virtual void draw (); + void updateTextContext (); + virtual void checkCoords(); + virtual void updateCoords(); + virtual void onAddToGroup(); + + /// From CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + /// Accessors + + /// Set + + void setText (const ucstring &text); + void setFontSize (sint nFontSize); + void setColor (const NLMISC::CRGBA &color); + void setShadow (bool bShadow); + void setShadowColor (const NLMISC::CRGBA &color); + void setLineMaxW (sint nMaxW, bool invalidate=true); + void setMultiLine (bool bMultiLine); + void setMultiLineSpace (sint nMultiLineSpace); + void setMultiLineMaxWOnly (bool state); + void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance + void setFirstLineX (uint firstLineX); + void setMultiMaxLine(uint l) { _MultiMaxLine = l; } + + // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF + void enableStringSelection(uint start, uint end); + void disableStringSelection(); + + /// Get + + ucstring getText() const { return _Text; } + sint getFontSize() const; + NLMISC::CRGBA getColor() { return _Color; } + bool getShadow() { return _Shadow; } + NLMISC::CRGBA getShadowColor() { return _ShadowColor; } + sint getLineMaxW() const { return _LineMaxW; } + bool getMultiLine() const { return _MultiLine; } + sint getMultiLineSpace() const { return _MultiLineSpace; } + bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } + uint32 getMultiMaxLine() const { return _MultiMaxLine; } + + // get current Hint font width, in pixels + uint getFontWidth() const; + // get current font height, in pixels + uint getFontHeight() const; + // get current font leg height, in pixels + uint getFontLegHeight() const; + // Set the display mode (supported with multiline only for now) + void setTextMode(TTextMode mode); + TTextMode getTextMode() const { return _TextMode; } + uint getNumLine() const; + uint getFirstLineX() const; + uint getLastLineW () const; + void setUnderlined (bool underlined) { _Underlined = underlined; } + bool getUnderlined () const { return _Underlined; } + // true if the viewText is a single line clamped. + bool isSingleLineTextClamped() const {return _SingleLineTextClamped;} + + // Character positions + + /** Get position of the ith character, position are relative to the BR corner of the text. + * \param lineEnd. When set to true, return the coordinate of the previous line if the index is at the start of a line. + * When looking at standard edit box, we see that if a line is split accross to line with no + * This also returns the height of the line + */ + void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const; + /** From a coordinate relative to the BR BR corner of the text, return the index of a character. + * If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text) + */ + void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const; + /** From a character index, get the index of the line it belongs to, or -1 if the index is invalid + * \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index + */ + sint getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine = true) const; + /// From a line number, get the character at which it starts, or -1 if invalid + sint getLineStartIndex(uint line) const; + /// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid + void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; + + std::string getHardText() const { std::string result; _Text.toString (result); return result; } + void setHardText (const std::string &ht); + + std::string getColorAsString() const; + void setColorAsString(const std::string &ht); + + NLMISC::CRGBA getColorRGBA() const; + void setColorRGBA(NLMISC::CRGBA col); + + virtual sint32 getAlpha() const { return _Color.A; } + virtual void setAlpha (sint32 a) { _ShadowColor.A = _Color.A = (uint8)a; } + + /** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association + */ + void setTextFormatTaged(const ucstring &text); + + void setSingleLineTextFormatTaged(const ucstring &text); + + // Remove end space + void removeEndSpaces(); + + // Reset the text index because the text context has changed + void resetTextIndex(); + + // Case mode + void setCaseMode (TCaseMode caseMode); + TCaseMode getCaseMode () const; + + // OverExtendViewText + void setOverExtendViewText(bool state) {_OverExtendViewText= state;} + bool getOverExtendViewText() const {return _OverExtendViewText;} + + // OverExtendViewTextUseParentRect + void setOverExtendViewTextUseParentRect(bool state) {_OverExtendViewTextUseParentRect= state;} + bool getOverExtendViewTextUseParentRect() const {return _OverExtendViewTextUseParentRect;} + + // see if text ellipsis if done at right side of the text + bool isClampRight() const { return _ClampRight; } + + int luaSetLineMaxW(CLuaState &ls); + + REFLECT_EXPORT_START(CViewText, CViewBase) + REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_UCSTRING("uc_hardtext", getText, setText); + REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged); + REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged); + REFLECT_STRING ("color", getColorAsString, setColorAsString); + REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); + REFLECT_SINT32 ("alpha", getAlpha, setAlpha); + REFLECT_BOOL ("overExtendViewText", getOverExtendViewText, setOverExtendViewText); + REFLECT_BOOL ("overExtendViewTextUseParentRect", getOverExtendViewTextUseParentRect, setOverExtendViewTextUseParentRect); + REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW); + REFLECT_EXPORT_END + + + virtual void serial(NLMISC::IStream &f); + + protected: + + /// Text to display. + ucstring _Text; + /// index of the computed String associated to this text control + uint _Index; + /// info on the computed String associated to this text control + NL3D::UTextContext::CStringInfo _Info; + /// the font size + sint _FontSize; + // width of the font in pixel. Just a Hint for tabing format (computed with '_') + uint _FontWidth; + // height of the font in pixel. + // use getFontHeight + uint _FontHeight; + uint _FontLegHeight; + float _SpaceWidth; + /// the text color + NLMISC::CRGBA _Color; + /// the shadow mode + bool _Shadow; + /// the case mode + TCaseMode _CaseMode; + /// the text shadow color + NLMISC::CRGBA _ShadowColor; + /// Is the line (under p loop) should be considered at bottom (if false bottom is under p leg) + /// maxw for the line/multiline + sint32 _LineMaxW; + /// For single line, true if the text is clamped (ie displayed with "...") + bool _SingleLineTextClamped; + + /// Multiple lines handling + bool _MultiLine; + bool _MultiLineMaxWOnly; + bool _MultiLineClipEndSpace; + uint8 _AutoClampOffset; + TTextMode _TextMode; + sint _MultiLineSpace; + sint _LastMultiLineMaxW; + uint32 _MultiMaxLine; + + + /// FormatTag handling + struct CFormatInfo + { + // The color to change + NLMISC::CRGBA Color; + // The Tabulation to apply, in number of "_" characters. + uint TabX; + // Index in vector + sint IndexTt; + + CFormatInfo() + { + Color= NLMISC::CRGBA::White; + TabX= 0; + IndexTt = -1; + } + + bool operator==(const CFormatInfo &o) const {return Color==o.Color && TabX==o.TabX && IndexTt==o.IndexTt;} + bool operator!=(const CFormatInfo &o) const {return !operator==(o);} + }; + struct CFormatTag : public CFormatInfo + { + uint Index; + + // compare 2 tags, not a tag and a CFormatInfo + bool sameTag(const CFormatTag &o) const + { + return CFormatInfo::operator==(o) && Index==o.Index; + } + }; + std::vector _FormatTags; + + /// Get the current maxW for multiline, accordgin to parent and _MultiLineOptionMaxW + sint getCurrentMultiLineMaxW() const; + + + + + NL3D::ULetterColors * _LetterColors; + + private: + // A word in a line + class CWord + { + public: + // default ctor + CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {} + ucstring Text; + uint Index; // index of the info for this word + NL3D::UTextContext::CStringInfo Info; + uint NumSpaces; // number of spaces before this word + // The specialized color/format of this word. White if none + CFormatInfo Format; + public: + // build from a string, using the current text context + void build(const ucstring &text, uint numSpaces= 0); + }; + typedef std::vector TWordVect; + + // A line of text (which is made of one word with space, or of several words with no spaces in them) + class CLine : public NLMISC::CRefCount + { + public: + // ctor + CLine(); + // Clear the line & remove text contexts + void clear(); + // Add a new word (and its context) in the line + a number of spaces to append at the end of the line + void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth); + void addWord(const CWord &word, uint fontWidth); + uint getNumWords() const { return (uint)_Words.size(); } + CWord &getWord(uint index) { return _Words[index]; } + float getSpaceWidth() const { return _SpaceWidth; } + void setSpaceWidth(float width) { _SpaceWidth = width; } + // Get the number of chars in the line, not counting the end spaces, but couting the spaces in words + uint getNumChars() const { return _NumChars; } + // Get the total number of spaces between words (not including those in words, but there should not be if text is justified) + uint getNumSpaces() const { return _NumSpaces; } + float getStringLine() const { return _StringLine; } + float getWidthWithoutSpaces() const { return _WidthWithoutSpaces; } + // get total width including spaces, but not including end spaces + float getWidth() const { return _WidthWithoutSpaces + _SpaceWidth * _NumSpaces; } + // Get the number of spaces at the end of the line + void setEndSpaces(uint numSpaces) { _EndSpaces = numSpaces; } + // Set the number of spaces at the end of the line + uint getEndSpaces() const { return _EndSpaces; } + // Test if there's a line feed at the end of the line + bool getLF() const { return _HasLF; } + void setLF(bool lf) { _HasLF = lf; } + void resetTextIndex(); + private: + TWordVect _Words; + uint _NumChars; + uint _NumSpaces; + float _SpaceWidth; // width of a space, in pixels (used with multispace alignment) + float _StringLine; + float _WidthWithoutSpaces; // width without space (see the Field NumSpaces in the CWord class). + // NB : space inserted inside a word are counted, however! + uint _EndSpaces; // spaces at the end of the line + bool _HasLF; // a linefeed is at end of line (no breaking due to line full) + }; + /// NB : we keep pointers on lines (each line contains a vector, that we don't want to be copied, and this occurs as the vector of lines grows..) + + typedef NLMISC::CSmartPtr TLineSPtr; + typedef std::vector TLinePtVect; + private: + /** Data of the updated text for multiline. It is built from the _Text field in the updateTextContext member function, + * and is used to perform the draw + */ + TLinePtVect _Lines; + + /// if true, and if the view text is isSingleLineTextClamped(), then an over will be drawn, with the text + bool _OverExtendViewText : 1; + /// if true and _OverExtendViewText true too, use the parent rectangle to know if must display the over or not + bool _OverExtendViewTextUseParentRect : 1; + /// Letter selection handling + bool _AutoClamp : 1; + bool _ClampRight : 1; + bool _TextSelection : 1; + bool _InvalidTextContext : 1; + bool _Underlined : 1; + bool _ContinuousUpdate : 1; + bool _Setuped : 1; + + uint _TextSelectionStart; + uint _TextSelectionEnd; + + // First line X coordinate + uint _FirstLineX; + + /// Dynamic tooltips + std::vector _Tooltips; + + + private: + void setup (); + void setupDefault (); + + void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd); + + // void pushString(const ucstring &str, bool deleteSpaceAtStart = false); + + /// \from CInterfaceElement + void onInvalidateContent(); + + // may append a new line, and append a word to the last line (no spaces) + void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); + // Clear all the lines and free their datas + void clearLines(); + // Update in the case of a multiline text + void updateTextContextMultiLine(uint nMaxWidth); + // Update in the case of a multiline text with justification + void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces); + // Recompute font size info + void computeFontSize (); + + // used for "donctClipWord" case in updateTextContextMultiLineJustified(). currLine is reseted + void addDontClipWordLine(std::vector &currLine); + + // FormatTag build. + static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips); + // FormatTag parsing. + bool isFormatTagChange(uint textIndex, uint ctIndex) const; + void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; + }; + +} + +#endif // NL_VIEW_TEXT_H + +/* End of view_text.h */ diff --git a/code/nel/src/gui/view_text.cpp b/code/nel/src/gui/view_text.cpp new file mode 100644 index 000000000..4c29b5146 --- /dev/null +++ b/code/nel/src/gui/view_text.cpp @@ -0,0 +1,2603 @@ +// Ryzom - MMORPG Framework +// 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 "nel/misc/bit_mem_stream.h" +#include "nel/misc/i18n.h" + +#include "nel/gui/view_text.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/ctrl_tooltip.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/view_pointer_base.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; + +typedef std::string::size_type TCharPos; // index of a chracter in a string + +REGISTER_UI_CLASS(CViewText) + +namespace NLGUI +{ + + // *************************************************************************** + void CViewText::setupDefault () + { + _CaseMode = CaseNormal; + _Underlined = false; + _ContinuousUpdate = false; + _Active = true; + _X = 0; + _Y = 0; + _W = 0;; + _H = 0; + _SizeRef = 0; + _SizeDivW = 10; + _SizeDivH = 10; + _ParentPosRef = Hotspot_BL; + _PosRef = Hotspot_BL; + + _FontSize = 12 + + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); + _Color = CRGBA(255,255,255,255); + _Shadow = false; + _ShadowColor = CRGBA(0,0,0,255); + + _MultiLine = false; + _TextMode = DontClipWord; + _MultiLineSpace = 8; + _LineMaxW = 16384; + _MultiLineMaxWOnly = false; + _MultiLineClipEndSpace = false; + _LastMultiLineMaxW = 0; + _MultiMaxLine = 0; + _Index = 0xFFFFFFFF; + + _FontWidth= 0; + _FontHeight = 0; + _FontLegHeight = 0; + + _TextSelection= false; + _TextSelectionStart= 0; + _TextSelectionEnd= std::numeric_limits::max(); + + _InvalidTextContext= true; + _FirstLineX = 0; + computeFontSize (); + + _SingleLineTextClamped= false; + _OverExtendViewText= false; + _OverExtendViewTextUseParentRect= false; + + _AutoClamp = false; + _ClampRight = true; // clamp on the right of the text + + _LetterColors = NULL; + _Setuped= false; + _AutoClampOffset = 0; + } + + // *************************************************************************** + + NLMISC_REGISTER_OBJECT(CViewBase, CViewText, std::string, "text"); + + CViewText::CViewText(const TCtorParam ¶m) + :CViewBase(param) + { + setupDefault (); + } + + ///constructor + // *************************************************************************** + CViewText:: CViewText (const std::string& id, const std::string Text, sint FontSize, + NLMISC::CRGBA Color, bool Shadow) + :CViewBase(TCtorParam()) + { + _Id = id; + setupDefault (); + + _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + _Color = Color; + _Shadow = Shadow; + setText(Text); + computeFontSize (); + } + + // *************************************************************************** + CViewText::~CViewText() + { + if (_Index != 0xFFFFFFFF) + CViewRenderer::getTextContext()->erase (_Index); + clearLines(); + + if (!_Setuped) + for (uint i=0 ; i<_Tooltips.size() ; ++i) + delete _Tooltips[i]; + + _Tooltips.clear(); + } + + // *************************************************************************** + CViewText &CViewText::operator=(const CViewText &vt) + { + if (_Index != 0xFFFFFFFF) + CViewRenderer::getTextContext()->erase (_Index); + + // Create database entries + _Active = vt._Active; + _X = vt._X; + _Y = vt._Y; + _W = vt._W; + _H = vt._H; + _SizeRef = vt._SizeRef; + _SizeDivW = vt._SizeDivW; + _SizeDivH = vt._SizeDivH; + _ParentPosRef = vt._ParentPosRef; + _PosRef = vt._PosRef; + + _FontSize = vt._FontSize; + _Color = vt._Color; + _Shadow = vt._Shadow; + _ShadowColor = vt._ShadowColor; + + _MultiLine = false; + _MultiLineSpace = 8; + _LineMaxW= 16384; + _MultiLineMaxWOnly = false; + _MultiLineClipEndSpace = false; + _LastMultiLineMaxW = 0; + _Index = 0xFFFFFFFF; + + _ModulateGlobalColor= vt._ModulateGlobalColor; + + + // remove previous lines + clearLines(); + _InvalidTextContext = true; + computeFontSize (); + + return *this; + } + + // *************************************************************************** + void CViewText::parseTextOptions (xmlNodePtr cur) + { + CXMLAutoPtr prop; + + prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _Color = CRGBA(255,255,255,255); + if (prop) + _Color = convertColor(prop); + + prop= (char*) xmlGetProp (cur, (xmlChar*)"global_color"); + if(prop) + _ModulateGlobalColor= convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"fontsize" ); + _FontSize = 12 + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + if (prop) + { + fromString((const char*)prop, _FontSize); + _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow" ); + _Shadow = false; + if (prop) + _Shadow = convertBool(prop); + + prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_color" ); + _ShadowColor = CRGBA(0,0,0,255); + if (prop) + _ShadowColor = convertColor(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line" ); + _MultiLine = false; + if (prop) + _MultiLine = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"justification" ); + if (prop) + { + if (nlstricmp("clip_word", (const char *) prop) == 0) _TextMode = ClipWord; + else if (nlstricmp("dont_clip_word", (const char *) prop) == 0) _TextMode = DontClipWord; + else if (nlstricmp("justified", (const char *) prop) == 0) _TextMode = Justified; + else nlwarning(" bad text mode"); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"line_maxw" ); + _LineMaxW = 16384; + if (prop) + fromString((const char*)prop, _LineMaxW); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line_space" ); + _MultiLineSpace = 8; + if (prop) + fromString((const char*)prop, _MultiLineSpace); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line_maxw_only" ); + _MultiLineMaxWOnly = false; + if (prop) + _MultiLineMaxWOnly = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_max_line" ); + _MultiMaxLine = 0; + if (prop) + fromString((const char*)prop, _MultiMaxLine); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"underlined" ); + _Underlined = false; + if (prop) + _Underlined = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"case_mode" ); + _CaseMode = CaseNormal; + if (prop) + { + sint32 caseMode; + fromString((const char*)prop, caseMode); + _CaseMode = (TCaseMode)caseMode; + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"over_extend_view_text" ); + _OverExtendViewText= false; + if(prop) + _OverExtendViewText= convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"over_extend_parent_rect" ); + _OverExtendViewTextUseParentRect= false; + if(prop) + _OverExtendViewTextUseParentRect= convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"auto_clamp" ); + _AutoClamp = false; + if (prop) + _AutoClamp = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"clamp_right" ); + _ClampRight = true; + if (prop) + _ClampRight = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"auto_clamp_offset" ); + _AutoClampOffset = 0; + if (prop) + fromString((const char*)prop, _AutoClampOffset); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"continuous_update" ); + if (prop) + { + _ContinuousUpdate = convertBool(prop); + } + + + computeFontSize (); + } + + /* + * parse an xml node and initialize the base view mambers. Must call CViewBase::parse + * \param cur : pointer to the xml node to be parsed + * \param parentGroup : the parent group of the view + * \partam id : a refence to the string that will receive the view ID + * \return true if success + */ + // *************************************************************************** + bool CViewText::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + + // const ucstring* tmp; + CXMLAutoPtr prop; + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + + if (! CViewBase::parse(cur,parentGroup) ) + return false; + + //set w and h to 0 : they depend on the string contained + _W = 0; + _H = 0; + + //try to get the NEEDED specific props + parseTextOptions(cur); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); + if (prop) + { + const char *propPtr = prop; + _Text = ucstring(propPtr); + + if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) + _Text = CI18N::get (propPtr); + setCase (_Text, _CaseMode); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext_format" ); + if (prop) + { + const char *propPtr = prop; + if (_MultiLine) + { + setTextFormatTaged(CI18N::get(propPtr)); + } + else + { + setSingleLineTextFormatTaged(CI18N::get(propPtr)); + } + } + + invalidateContent (); + + return true; + } + + // *************************************************************************** + sint CViewText::getCurrentMultiLineMaxW() const + { + if(_MultiLineMaxWOnly) + return _LineMaxW; + else + { + sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + return std::min(parentWidth-(sint)(_XReal-_Parent->getXReal()), (sint)_LineMaxW); + } + } + + + // *************************************************************************** + void CViewText::checkCoords () + { + if ((_MultiLine)&&(_Parent != NULL)) + { + // If never setuped, and if text is not empty + if (_Lines.size() == 0 && !_Text.empty()) + invalidateContent (); + + sint currentMaxW= getCurrentMultiLineMaxW(); + if ( _LastMultiLineMaxW != currentMaxW ) + { + if (_ContinuousUpdate) + { + _LastMultiLineMaxW = currentMaxW; + invalidateContent(); + } + else + { + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); + if (pCB != NULL) + { + if( pCB->isResizer() ) + { + // We are resizing !!!! + } + else + { + _LastMultiLineMaxW = currentMaxW; + invalidateContent(); + } + } + else + { + _LastMultiLineMaxW = currentMaxW; + invalidateContent(); + } + } + } + } + else + { + if (_Index == 0xFFFFFFFF) + invalidateContent (); + } + } + /* + * draw the view + */ + // *************************************************************************** + void CViewText::draw () + { + H_AUTO( RZ_Interface_CViewText_draw ) + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + // *** Out Of Clip? + sint32 ClipX, ClipY, ClipW, ClipH; + rVR.getClipWindow (ClipX, ClipY, ClipW, ClipH); + if (((_XReal) > (ClipX+ClipW)) || ((_XReal+_WReal) < ClipX) || + ((_YReal) > (ClipY+ClipH)) || ((_YReal+_HReal) < ClipY)) + return; + + // *** Screen Minimized? + uint32 w, h; + float oow, ooh; + rVR.getScreenSize (w, h); + if (rVR.isMinimized()) + return; + rVR.getScreenOOSize (oow, ooh); + + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + + + // *** get current color + CRGBA col, shcol; + if(getModulateGlobalColor()) + { + CRGBA gcfc = CWidgetManager::getInstance()->getGlobalColorForContent(); + col.modulateFromColor (_Color, gcfc); + shcol.modulateFromColor (_ShadowColor, gcfc); + } + else + { + col = _Color; + shcol = _ShadowColor; + col.A = (uint8)(((sint)col.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + shcol.A = (uint8)(((sint)shcol.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + + // *** Draw multiline + if ((_MultiLine)&&(_Parent != NULL)) + { + if (_Lines.size() == 0) return; + + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setShadeColor (shcol); + TextContext->setFontSize (_FontSize); + + float y = (float)(_YReal) * ooh; // y is expressed in scree, coordinates [0..1] + //y += _LinesInfos[_LinesInfos.size()-1].StringLine / h; + + // Y is the base line of the string, so it must be grown up. + y += (float)_FontLegHeight * ooh; + + sint y_line = _YReal+_FontLegHeight-2; + + // special selection code + if(_TextSelection) + { + sint charIndex = 0; + for (sint i = 0; i<(sint)_Lines.size(); i++) + { + CLine &currLine = *_Lines[i]; + for(uint k = 0; k < currLine.getNumWords(); ++k) + { + CWord &currWord = currLine.getWord(k); + charIndex += currWord.NumSpaces; + sint cStart= max(charIndex, (sint)_TextSelectionStart); + sint cEnd= min(charIndex+(sint)currWord.Text.length(), (sint)_TextSelectionEnd); + + // range must be valid + if(cStartsetStringSelection(currWord.Index, 0, 0); + } + + // next word + charIndex+= (sint)currWord.Text.length(); + } + charIndex += currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); + } + } + + // draw + for (sint i = (sint)_Lines.size()-1; i >= 0; --i) + { + CLine &currLine = *_Lines[i]; + // current x position + float px = (float) (_XReal + ((i==0) ? (sint)_FirstLineX : 0)); + // draw each words of the line + for(uint k = 0; k < currLine.getNumWords(); ++k) + { + CWord &currWord = currLine.getWord(k); + + // Change the current color + if(currWord.Format.Color==CRGBA::White) + TextContext->setStringColor(currWord.Index, col); + else + { + CRGBA mCol; + mCol.modulateFromColor(col, currWord.Format.Color); + TextContext->setStringColor(currWord.Index, mCol); + } + + // skip spaces before current word + float firstSpace = currWord.NumSpaces * currLine.getSpaceWidth(); + sint line_width = 0; + if (_Underlined) + { + line_width = (sint)floorf(currLine.getWidthWithoutSpaces() + currLine.getSpaceWidth()); + line_width -= (sint)floorf(firstSpace); + } + px += firstSpace; + // skip tabulation before current word + if(currWord.Format.TabX) + px= max(px, (float)(_XReal + currWord.Format.TabX*_FontWidth)); + + // draw. We take floorf px to avoid filtering of letters that are not located on a pixel boundary + rVR.drawText (_RenderLayer, floorf(px) * oow, y, currWord.Index, (float)ClipX * oow, (float)ClipY * ooh, + (float)(ClipX+ClipW) * oow, (float)(ClipY+ClipH) * ooh, *TextContext); + + // Draw a line + if (_Underlined) + rVR.drawRotFlipBitmap (_RenderLayer, (sint)floorf(px), y_line, line_width, 1, 0, false, rVR.getBlankTextureId(), col); + + // skip word + px += currWord.Info.StringWidth; + } + // go one line up + y += (_FontHeight + _MultiLineSpace) * ooh; + y_line += _FontHeight+_MultiLineSpace; + } + + // reset selection + if(_TextSelection) + { + for (sint i = 0; i<(sint)_Lines.size(); i++) + { + CLine &currLine = *_Lines[i]; + for(uint k = 0; k < currLine.getNumWords(); ++k) + { + TextContext->resetStringSelection(currLine.getWord(k).Index); + } + } + } + } + // *** Single Line Version (currently no support for text justification) + else + { + nlassert(_Index != 0xFFFFFFFF); + + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setShadeColor (shcol); + TextContext->setFontSize (_FontSize); + + + if(_LetterColors!=NULL && !TextContext->isSameLetterColors(_LetterColors, _Index)) + { + TextContext->setLetterColors(_LetterColors, _Index); + } + + + float x = (float)(_XReal) * oow; + float y = (float)(_YReal) * ooh; + + // Y is the base line of the string, so it must be grown up. + y += (float)_FontLegHeight * ooh; + + // special selection code + if(_TextSelection) + // select subset. Arg, must skip spaces because not inserted in VertexBuffer. + setStringSelectionSkipingSpace(_Index, _Text, _TextSelectionStart, _TextSelectionEnd); + + // Change the current color + TextContext->setStringColor(_Index, col); + + // draw + rVR.drawText (_RenderLayer, x, y, _Index, (float)ClipX * oow, (float)ClipY * ooh, + (float)(ClipX+ClipW) * oow, (float)(ClipY+ClipH) * ooh, *TextContext); + + // Draw a line + if (_Underlined) + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_FontLegHeight-2, _WReal, 1, 0, false, rVR.getBlankTextureId(), col); + + // reset selection + if(_TextSelection) + TextContext->resetStringSelection(_Index); + + // if single line clamped, may allow to draw an over + if(isSingleLineTextClamped() && _OverExtendViewText && CWidgetManager::getInstance()->getPointer()) + { + // but must check first if mouse is over + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); + bool mouseIn; + // use parent clip or self clip? + if(_OverExtendViewTextUseParentRect) + mouseIn= _Parent && _Parent->isIn(x,y); + else + mouseIn= isIn(x,y); + // if the mouse cursor is in the clip area + if(mouseIn) + { + // check the window under the mouse is the root window + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); + CInterfaceElement *pParent = this; + bool bFound = false; + while (pParent != NULL) + { + if (pParent == pIG) + { + bFound = true; + break; + } + pParent = pParent->getParent(); + } + + // ok => let this view text be the extend over one + if(bFound) + { + // last check: the window must not be currently moved + CGroupContainerBase *gc= dynamic_cast(pIG); + if(!gc || !gc->isMoving()) + { + CRGBA col= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionViewTextOverBackColor).getValColor(); + CWidgetManager::getInstance()->setOverExtendViewText(this, col); + } + } + } + } + } + + } + + // *************************************************************************** + void CViewText::onAddToGroup() + { + // Add tooltips if not done + if(!_Setuped) + setup(); + } + + // *************************************************************************** + void CViewText::setTextMode(TTextMode mode) + { + if (mode != _TextMode) + { + _TextMode = mode; + invalidateContent (); + } + } + + // *************************************************************************** + void CViewText::setText(const ucstring & text) + { + // common case: no special format, no case mode => easy cache test + if (_FormatTags.empty() && _CaseMode==CaseNormal) + { + if (text != _Text) + { + _Text = text; + // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: + invalidateContent (); + } + } + else + { + // if the view text had some format before, no choice, must recompute all + if(!_FormatTags.empty()) + { + _Text = text; + setCase (_Text, _CaseMode); + invalidateContent (); + } + // else test if after the case change the cache succeed + else + { + // compute the temp cased text + ucstring tempText= text; + setCase(tempText, _CaseMode); + if(tempText!=_Text) + { + _Text = tempText; + invalidateContent (); + } + } + } + + // clear format tags if any + _FormatTags.clear(); + } + + // *************************************************************************** + void CViewText::setFontSize (sint nFontSize) + { + _FontSize = nFontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + computeFontSize (); + invalidateContent(); + } + + // *************************************************************************** + sint CViewText::getFontSize() const + { + return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); + } + + // *************************************************************************** + void CViewText::setColor(const NLMISC::CRGBA & color) + { + _Color = color; + } + + // *************************************************************************** + void CViewText::setShadow (bool bShadow) + { + _Shadow = bShadow; + computeFontSize (); + invalidateContent(); + } + + // *************************************************************************** + void CViewText::setShadowColor(const NLMISC::CRGBA & color) + { + _ShadowColor = color; + } + + // *************************************************************************** + void CViewText::setLineMaxW (sint nMaxW, bool invalidate) + { + if(_LineMaxW!=nMaxW) + { + _LineMaxW = nMaxW; + if (invalidate) + invalidateContent(); + } + } + + // *************************************************************************** + int CViewText::luaSetLineMaxW(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "setLineMaxW", 1); + sint32 value; + if(CLuaIHM::popSINT32(ls, value)) + { + setLineMaxW(value); + } + return 0; + } + + // *************************************************************************** + void CViewText::setMultiLine (bool bMultiLine) + { + _MultiLine = bMultiLine; + invalidateContent(); + } + + // *************************************************************************** + void CViewText::setMultiLineSpace (sint nMultiLineSpace) + { + _MultiLineSpace = nMultiLineSpace; + invalidateContent(); + } + + // *************************************************************************** + void CViewText::setMultiLineMaxWOnly (bool state) + { + _MultiLineMaxWOnly = state; + invalidateContent(); + } + + // *************************************************************************** + void CViewText::setMultiLineClipEndSpace (bool state) + { + _MultiLineClipEndSpace= state; + invalidateContent(); + } + + // *************************************************************************** + uint CViewText::getFontWidth() const + { + return _FontWidth; + } + + // *************************************************************************** + uint CViewText::getFontHeight() const + { + return _FontHeight; + } + + // *************************************************************************** + uint CViewText::getFontLegHeight() const + { + return _FontLegHeight; + } + + // *************************************************************************** + void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat) + { + // create a new line? + if(!linePushed) + { + _Lines.push_back(TLineSPtr(new CLine)); + linePushed= true; + } + // Append to the last line + _Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth); + // reset the word + ucCurrentWord = ucstring(""); + } + + + // *************************************************************************** + void CViewText::updateTextContextMultiLine(uint nMaxWidth) + { + ucchar ucLetter; + UTextContext::CStringInfo si; + uint i; + // word state + ucstring ucCurrentWord; + CFormatInfo wordFormat; + // line state + float rWidthCurrentLine = 0, rWidthLetter; + bool linePushed= false; + // for all the text + uint textSize= (uint)_Text.size(); + uint formatTagIndex= 0; + for (i = 0; i < textSize; ++i) + { + if(isFormatTagChange(i, formatTagIndex)) + { + // If the word was not empty before this color tag + if(!ucCurrentWord.empty()) + flushWordInLine(ucCurrentWord, linePushed, wordFormat); + + // get new color and skip ctIndex. + getFormatTagChange(i, formatTagIndex, wordFormat); + + // Ensure the line witdh count the tab + rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); + } + + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + + // Parse the letter + { + ucLetter = _Text[i]; + if (ucLetter == ucchar('\n')) + { + flushWordInLine(ucCurrentWord, linePushed, wordFormat); + // reset line state + linePushed= false; + rWidthCurrentLine = 0; + } + else + { + ucstring ucStrLetter; + ucStrLetter= ucLetter; + si = TextContext->getStringInfo (ucStrLetter); + rWidthLetter = (si.StringWidth); + if ((rWidthCurrentLine + rWidthLetter) > nMaxWidth) + { + flushWordInLine(ucCurrentWord, linePushed, wordFormat); + + // reset line state, and begin with the cut letter + linePushed= false; + rWidthCurrentLine = rWidthLetter; + ucCurrentWord = ucLetter; + } + else + { + // Grow the current word + ucCurrentWord += ucLetter; + rWidthCurrentLine += rWidthLetter; + } + } + } + } + if (ucCurrentWord.length()) + { + flushWordInLine(ucCurrentWord, linePushed, wordFormat); + } + } + + + // *************************************************************************** + void CViewText::addDontClipWordLine(std::vector &currLine) + { + // create a new line + _Lines.push_back(TLineSPtr(new CLine)); + + // Fill it with words. if all words of same color, create only one CWord + if (!currLine.empty()) + { + CFormatInfo lineWordFormat= currLine[0].Format; + ucstring lineWord; + for(uint i=0;iaddWord(lineWord, 0, lineWordFormat, _FontWidth); + // get new lineWordFormat + lineWordFormat= currLine[i].Format; + // and clear + lineWord.clear(); + } + + // Append the word with space to the lineWord. + ucstring blank; + blank.resize(currLine[i].NumSpaces, (ucchar) ' '); + lineWord += blank; + lineWord += currLine[i].Text; + } + + if(!lineWord.empty()) + _Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth); + + // clear + currLine.clear(); + } + } + + // *************************************************************************** + void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces) + { + UTextContext::CStringInfo si; + // + TCharPos currPos = 0; + // + static const ucstring spaceStr(" "); + // precLineWidth valid only id precedent line is part of same paragraph. + float precLineWidth= 0; + float lineWidth = (float)_FirstLineX; // width of the current line + uint numWordsInLine = 0; // number of words in the current line + bool isParagraphStart = true; // A paragraph is a group of characters between 2 \n + bool lineFeed; + bool breakLine; + // + vector currLine; // if spaces are not expanded, all words of a line are inserted here (NB: index and stringInfo not filled) + ucstring wordValue; + CFormatInfo wordFormat; + uint formatTagIndex= 0; + // + while (currPos != _Text.length()) + { + TCharPos spaceEnd; + TCharPos wordEnd; + uint numSpaces; + float newLineWidth; + breakLine = false; + // + if (_Text[currPos] == (ucchar) '\n') + { + lineFeed = true; + } + else + { + lineFeed = false; + // Skip spaces and count them + spaceEnd = _Text.find_first_not_of(spaceStr, currPos); + if (spaceEnd == std::string::npos) + { + spaceEnd = _Text.length(); + } + numSpaces = (uint) (spaceEnd - currPos); + if (!isParagraphStart && numSpaces != 0 && numWordsInLine == 0) // Are these the first spaces of the line ? + { + if (!_Lines.empty()) + { + /* Yoyo: I changed this (added the "cut space"), because in editBox, it is so strange when + the word hit the end of line, and if you add spaces just after, nothing happens because + cursor pos is clamped at end of line. + */ + // Cannot put all of thoses spaces to the prec end of line? + if(_MultiLineClipEndSpace && precLineWidth + numSpaces * _SpaceWidth > nMaxWidth) + { + // put some of these spaces at the end of the previous line. + sint maxNumSpaces= (sint)floorf((nMaxWidth - precLineWidth) / _SpaceWidth); + _Lines.back()->setEndSpaces(maxNumSpaces); + // And start the new lines with the remaining spaces. + numSpaces-= maxNumSpaces; + currPos+= maxNumSpaces; + } + else + { + // ok, put all spaces to previous line + _Lines.back()->setEndSpaces(numSpaces); + currPos = spaceEnd; + numSpaces= 0; + } + if(currPos >=_Text.length()) + break; + } + } + + // Detect change of wordFormat at the begining of the word + if(isFormatTagChange((uint)spaceEnd, formatTagIndex)) + { + getFormatTagChange((uint)spaceEnd, formatTagIndex, wordFormat); + } + + // Get word until a space, a \n, or a FormatTagChange is encountered + uint i; + for(i= (uint)spaceEnd;i<(uint)_Text.length();i++) + { + ucchar c= _Text[i]; + if(c==' ' || c=='\n') + break; + // If change of color tag, stop the word, but don't take the new color now. + if(isFormatTagChange(i, formatTagIndex)) + break; + } + wordEnd = i; + + + // Get the word value. + wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd); + // compute width of word + si = CViewRenderer::getTextContext()->getStringInfo(wordValue); + + // compute size of spaces/Tab + word + newLineWidth = lineWidth + numSpaces * _SpaceWidth; + newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_FontWidth); + newLineWidth+= si.StringWidth; + } + // + // Does the word go beyond the end of line ? + if (!lineFeed && newLineWidth > (float) nMaxWidth) + { + // Have we enough room for this word on a line ? + bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < (float) nMaxWidth ); + + // not enough room for that word + // If it is the only word of the line, just split it + // Otherwise, scale the spaces between words so that the line as the maximum width + if (roomForThisWord) + { + if (expandSpaces) + { + nlassert(_Lines.size() > 0); + nlassert(_Lines.back()->getNumWords() > 0); + + // Yoyo: if the line has tab, then don't justify + if(wordFormat.TabX > 0) + _Lines.back()->setSpaceWidth(_SpaceWidth); + else + { + // Scale the width so that the line has the maximum width + float roomForSpaces = nMaxWidth - _Lines.back()->getWidthWithoutSpaces(); + uint startNumSpaces = _Lines.back()->getNumSpaces(); + if (startNumSpaces != 0) + { + _Lines.back()->setSpaceWidth(roomForSpaces / startNumSpaces); + } + else + { + _Lines.back()->setSpaceWidth(_SpaceWidth); + } + } + } + else + { + breakLine = true; + } + // we dont change the position in the input string so that the current will be processed on the next line + + } + else // it is the only word on the line.. + { + // .. so split it + // 1) Check if spaces go beyond the end of line + if (numSpaces * _SpaceWidth > nMaxWidth) + { + uint maxNumSpaces = std::max(1U, (uint) (nMaxWidth / _SpaceWidth)); + CWord spaceWord; // a word with only spaces in it + spaceWord.build (ucstring (""), maxNumSpaces); + spaceWord.Format= wordFormat; + _Lines.push_back(TLineSPtr(new CLine)); + _Lines.back()->addWord(spaceWord, _FontWidth); + if (expandSpaces) + { + _Lines.back()->setSpaceWidth(nMaxWidth / (float) maxNumSpaces); + } + else + { + _Lines.back()->setSpaceWidth(_SpaceWidth); + } + currPos = currPos + maxNumSpaces; + } + else + { + float px = numSpaces * _SpaceWidth; + uint currChar = 0; + ucstring oneChar(" "); + for(currChar = 0; currChar < wordValue.length(); ++currChar) + { + oneChar = wordValue[currChar]; + si = CViewRenderer::getTextContext()->getStringInfo(oneChar); + if ((uint) (px + si.StringWidth) > nMaxWidth) break; + px += si.StringWidth; + } + currChar = std::max((uint) 1, currChar); // must fit at least one character otherwise there's an infinite loop + wordValue = _Text.substr(spaceEnd, currChar); + CWord word; + word.build(wordValue, numSpaces); + word.Format= wordFormat; + _Lines.push_back(TLineSPtr(new CLine)); + float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth; + if (expandSpaces && numSpaces != 0) + { + _Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces); + } + else + { + _Lines.back()->setSpaceWidth(0); + } + _Lines.back()->addWord(word, _FontWidth); + currPos = currPos + numSpaces + currChar; + } + } + // reset line + numWordsInLine = 0; + precLineWidth= lineWidth; + lineWidth = 0; + isParagraphStart = false; + } + else if (!lineFeed) // the end of line hasn't been reached + { + if (expandSpaces) + { + // add in the current line (and create one if necessary) + if (numWordsInLine == 0) + { + _Lines.push_back(TLineSPtr(new CLine)); + _Lines.back()->setSpaceWidth(_SpaceWidth); + } + if (!wordValue.empty() || numSpaces != 0) + { + CWord word; + word.build(wordValue, numSpaces); + word.Format= wordFormat; + // update line width + _Lines.back()->addWord(word, _FontWidth); + ++numWordsInLine; + } + } + else + { + CWord word; + // Don't build here, this is used as temp data. + word.Text= wordValue; + word.NumSpaces= numSpaces; + word.Format= wordFormat; + // Append to the temp Data. + currLine.push_back(word); + + ++numWordsInLine; + } + lineWidth = newLineWidth; + currPos = wordEnd; + } + else + { + // '\n' was encountered + ++ currPos; + isParagraphStart = true; + } + if (lineFeed || breakLine) // '\n' was encoutered, or a linefeed has been asked + { + // !expandSpaces => insert minimum words according to word color. + if (!expandSpaces) + { + // Add the new line. + addDontClipWordLine(currLine); + // LineFeed? + if (lineFeed) + { + _Lines.back()->setLF(true); + } + } + // expandSpaces => just add a empty line. + else + { + if (numWordsInLine == 0) + { + // if nothing has been inserted in this line, create at least an empty line + _Lines.push_back(TLineSPtr(new CLine)); + } + if (lineFeed) + { + _Lines.back()->setLF(true); + } + } + lineWidth = 0.f; + numWordsInLine = 0; + } + } + + // if current line hasn't been pushed, add it + if (!expandSpaces && !currLine.empty()) + { + // Add new line + addDontClipWordLine(currLine); + } + + // if the text ends with \n, must insert the last line ourself + if (!_Text.empty() && _Text[_Text.length() - 1] == (ucchar) '\n') + { + _Lines.push_back(TLineSPtr(new CLine)); + } + } + + + // *************************************************************************** + void CViewText::updateTextContext () + { + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + + // default state + _SingleLineTextClamped= false; + + if ((_MultiLine)&&(_Parent != NULL)) + { + sint nMaxWidth = getCurrentMultiLineMaxW(); + _LastMultiLineMaxW = nMaxWidth; + clearLines(); + if (nMaxWidth <= 0) + { + // parent size may not be known yet + return; + } + switch(_TextMode) + { + case ClipWord: updateTextContextMultiLine(nMaxWidth); break; + case DontClipWord: updateTextContextMultiLineJustified(nMaxWidth, false); break; + case Justified: updateTextContextMultiLineJustified(nMaxWidth, true); break; + } + + // Special case for multiline limited in number of lines + if ((_Lines.size() > 0) && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) + { + while (_Lines.size() > _MultiMaxLine) + { + _Lines.back()->clear(); + _Lines.pop_back(); + } + _Lines.pop_back(); + CViewText::CLine *endLine = new CViewText::CLine; + CViewText::CWord w; + w.build(string("...")); + endLine->addWord(w, _FontWidth); + _Lines.push_back(TLineSPtr(endLine)); + } + + // Calculate size + float rTotalW = 0; + for (uint i = 0; i < _Lines.size(); ++i) + { + rTotalW = std::max(_Lines[i]->getWidth() + ((i==0)?_FirstLineX:0), rTotalW); + } + _W = (sint)rTotalW; + _H = std::max(_FontHeight, uint(_FontHeight * _Lines.size() + std::max(0, sint(_Lines.size()) - 1) * _MultiLineSpace)); + + // Compute tooltips size + if (_Tooltips.size() > 0) + for (uint i=0 ; i<_Lines.size() ; ++i) + { + for (uint j=0 ; j<_Lines[i]->getNumWords() ; ++j) + { + CWord word = _Lines[i]->getWord(j); + // float w = _Lines[i]->getWidth(); + + if (word.Format.IndexTt != -1) + { + if (_Tooltips.size() > (uint)word.Format.IndexTt) + { + CCtrlToolTip *pTooltip = _Tooltips[word.Format.IndexTt]; + + sint y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i - 1)); + + pTooltip->setX(0); + pTooltip->setY(y); + pTooltip->setW(getCurrentMultiLineMaxW()); + pTooltip->setH(_FontHeight); + } + } + } + } + } + else // Single line code + { + if (_Index != 0xFFFFFFFF) + TextContext->erase (_Index); + + // Common case: no W clamp + _Index = TextContext->textPush (_Text); + _Info = TextContext->getStringInfo (_Index); + _W = (sint)(_Info.StringWidth); + + // Rare case: clamp W => recompute slowly, cut letters + if(_W>_LineMaxW) + { + TextContext->erase (_Index); + + ucchar ucLetter; + UTextContext::CStringInfo si; + ucstring ucCurrentLine; + ucCurrentLine.reserve(_Text.size()); + // Append ... to the end of line + si = TextContext->getStringInfo (ucstring("...")); + float dotWidth= si.StringWidth; + float rWidthCurrentLine = 0, rWidthLetter; + // for all the text + if (_ClampRight) + { + for (uint i = 0; i < _Text.size(); ++i) + { + ucLetter= _Text[i]; + ucstring ucStrLetter; + ucStrLetter= ucLetter; + si = TextContext->getStringInfo (ucStrLetter); + rWidthLetter = (si.StringWidth); + if ((rWidthCurrentLine + rWidthLetter + dotWidth) > _LineMaxW) + { + break; + } + else + { + // Grow the current line + ucCurrentLine += ucLetter; + rWidthCurrentLine += rWidthLetter; + } + } + + // Add the dots + ucCurrentLine+= "..."; + } + else + { + for (sint i = (sint)_Text.size() - 1; i >= 0; --i) + { + ucLetter= _Text[i]; + ucstring ucStrLetter; + ucStrLetter= ucLetter; + si = TextContext->getStringInfo (ucStrLetter); + rWidthLetter = (si.StringWidth); + if ((rWidthCurrentLine + rWidthLetter + dotWidth) > _LineMaxW) + { + break; + } + else + { + // Grow the current line + ucCurrentLine = ucLetter + ucCurrentLine; + rWidthCurrentLine += rWidthLetter; + } + } + + // Add the dots + ucCurrentLine = "..." + ucCurrentLine; + } + + // And so setup this trunc text + _Index = TextContext->textPush (ucCurrentLine); + _Info = TextContext->getStringInfo (_Index); + _W = (sint)(_Info.StringWidth); + + _SingleLineTextClamped= true; + } + + // same height always + _H = _FontHeight; + } + + _InvalidTextContext= false; + } + + // *************************************************************************** + void CViewText::updateCoords() + { + if (_AutoClamp) + { + CViewBase::updateCoords (); + if (_Parent) + { + CInterfaceGroup *parent = _Parent; + // avoid resizing parents to compute the limiter + while (parent && (parent->getResizeFromChildW() || parent->isGroupList() )) + { + // NB nico : the dynamic_cast for CGroupList is bad!! + // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords + // ... + parent = parent->getParent(); + } + if (parent) + { + if (_ClampRight) + { + sint32 parentRight = parent->getXReal() + parent->getWReal() - (sint32) _AutoClampOffset; + setLineMaxW(std::max((sint32) 0, parentRight - _XReal)); + } + else + { + sint32 parentLeft = parent->getXReal() + (sint32) _AutoClampOffset; + setLineMaxW(std::max((sint32) 0, _XReal + _WReal - parentLeft)); + } + } + } + } + + if(_InvalidTextContext) + updateTextContext(); + + CViewBase::updateCoords (); + } + + // *************************************************************************** + sint CViewText::getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine /* = true*/) const + { + if (index > _Text.length()) return -1; + if (_MultiLine) + { + uint charIndex = 0; + for(sint i = 0; i < (sint) _Lines.size(); ++i) + { + CLine &currLine = *_Lines[i]; + uint newCharIndex = charIndex + currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); + if (newCharIndex > index) + { + if (i != 0 && cursorDisplayedAtEndOfPreviousLine && charIndex == index) + { + return i - 1; + } + else + { + return i; + } + } + charIndex = newCharIndex; + } + return (sint)_Lines.size() - 1; + } + else + { + return 0; + } + } + + // *************************************************************************** + sint CViewText::getLineStartIndex(uint line) const + { + uint charIndex = 0; + if (line >= _Lines.size()) return -1; + for(uint i = 0; i < line; ++i) + { + CLine &currLine = *_Lines[i]; + charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); + } + // skip all spaces at start of line (unless there are only spaces in the line) + std::string::size_type nextPos = _Text.find_first_not_of((ucchar) ' ', charIndex); + if (nextPos != std::string::npos) + { + if (getLineFromIndex(charIndex) == (sint) line) + { + return (sint) nextPos; + } + } + return charIndex; + } + + // *************************************************************************** + void CViewText::getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const + { + sint startIndex = getLineStartIndex(line); + if (startIndex == -1) + { + index = -1; + endOfPreviousLine = false; + return; + } + index = startIndex + _Lines[line]->getNumChars() + _Lines[line]->getEndSpaces(); + endOfPreviousLine = !_Lines[line]->getLF(); + } + + // *************************************************************************** + void CViewText::setHardText (const std::string &ht) + { + // ucstring Text = ucstring(ht); + ucstring Text; + if ((ht.size()>2) && (ht[0] == 'u') && (ht[1] == 'i')) + Text = CI18N::get (ht); + else + Text.fromUtf8(ht); + setText(Text); + } + + // *************************************************************************** + string CViewText::getColorAsString() const + { + return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); + } + + // *************************************************************************** + void CViewText::setColorAsString(const string &ht) + { + _Color = convertColor (ht.c_str()); + } + + // *************************************************************************** + NLMISC::CRGBA CViewText::getColorRGBA() const + { + return _Color; + } + + // *************************************************************************** + void CViewText::setColorRGBA(NLMISC::CRGBA col) + { + _Color = col; + } + + // *************************************************************************** + void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const + { + NLMISC::clamp(index, 0, (sint) _Text.length()); + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + height = getFontHeight(); + // + if (_MultiLine) + { + uint charIndex = 0; + // special case for end of text + if (index == (sint) _Text.length()) + { + y = 0; + if (_Lines.empty()) + { + x = 0; + } + else + { + CLine &lastLine = *_Lines.back(); + x = (sint) (lastLine.getWidth() + lastLine.getEndSpaces() * lastLine.getSpaceWidth()); + sint nMaxWidth = getCurrentMultiLineMaxW(); + x = std::min(x, nMaxWidth); + } + return; + } + for(sint i = 0; i < (sint) _Lines.size(); ++i) + { + if (i != 0 && charIndex == (uint) index && cursorAtPreviousLineEnd) + { + // should display the character at the end of previous line + CLine &currLine = *_Lines[i - 1]; + y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i)); + x = (sint) (currLine.getWidth() + currLine.getEndSpaces() * currLine.getSpaceWidth()); + sint nMaxWidth = getCurrentMultiLineMaxW(); + x = std::min(x, nMaxWidth); + return; + } + CLine &currLine = *_Lines[i]; + uint newCharIndex = charIndex + currLine.getNumChars() + currLine.getEndSpaces() + (_Lines[i]->getLF() ? 1 : 0); + if ((sint) newCharIndex > index) + { + // ok, this line contains the character, now, see which word contains it. + y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - 1 - i)); + // see if the index is in the spaces at the end of line + if (index - charIndex >= currLine.getNumChars()) + { + uint numSpaces = index - charIndex - currLine.getNumChars(); + x = (sint) (currLine.getWidth() + numSpaces * _SpaceWidth); + sint nMaxWidth = getCurrentMultiLineMaxW(); + x = std::min(x, nMaxWidth); + return; + } + // now, search containing word in current line + float px = (float)_FirstLineX; + for(uint k = 0; k < currLine.getNumWords(); ++k) + { + CWord &currWord = currLine.getWord(k); + if ((sint) (charIndex + currWord.NumSpaces + currWord.Text.length()) >= index) + { + // character is in currWord or the in spaces preceding it + // check if the character is in the word + if ((uint) (index - charIndex) > currWord.NumSpaces) + { + // get the x position + ucstring subStr = currWord.Text.substr(0, index - charIndex - currWord.NumSpaces); + // compute the size + UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); + x = (sint) (px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth()); + height = getFontHeight(); + return; + } + else + { + // character is in the spaces preceding the word + x = (sint) (px + currLine.getSpaceWidth() * (index - charIndex)); + height = getFontHeight(); + return; + } + } + charIndex += (uint)currWord.Text.length() + currWord.NumSpaces; + px += currWord.NumSpaces * currLine.getSpaceWidth() + currWord.Info.StringWidth; + } + } + charIndex = newCharIndex; + } + + } + else + { + // get the x position + ucstring subStr = _Text.substr(0, index); + // compute the size + UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); + y = 0; + x = (sint) si.StringWidth; + } + } + + // *************************************************************************** + // Tool fct : From a word and a x coordinate, give the matching character index + static uint getCharacterIndex(const ucstring &textValue, float x) + { + float px = 0.f; + UTextContext::CStringInfo si; + ucstring singleChar(" "); + uint i; + for (i = 0; i < textValue.length(); ++i) + { + // get character width + singleChar[0] = textValue[i]; + si = CViewRenderer::getTextContext()->getStringInfo(singleChar); + px += si.StringWidth; + // the character is at the i - 1 position + if (px > x) + { + // if the half of the character is after the cursor, then prefer select the next one (like in Word) + if(px-si.StringWidth/2 < x) + i++; + break; + } + } + return i; + } + + // *************************************************************************** + void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const + { + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + + // setup the text context + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + // find the line where the character is + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint charPos = 0; + if (_MultiLine) + { + // seek the line + float py = 0.f; + if (py > y) + { + index = (uint)_Text.length(); + cursorAtPreviousLineEnd = false; + return; + } + sint line; + for (line = (uint)_Lines.size() - 1; line >= 0; --line) + { + float newPy = py + _FontHeight + _MultiLineSpace; + if (newPy > y) + { + break; + } + py = newPy; + } + if (line == -1) + { + index = 0; + cursorAtPreviousLineEnd = false; + return; // above the first line, so take character 0 + } + // compute character index at start of line + sint i; + for (i = 0; i < line; ++i) + { + charPos += _Lines[i]->getNumChars() + _Lines[i]->getEndSpaces() + (_Lines[i]->getLF() ? 1 : 0); + } + // seek word that contains the character + CLine &currLine = *_Lines[line]; + // See if character is in the ending spaces + if (x >= (sint) currLine.getWidth()) + { + // Add _SpaceWidth/2 to select between chars + sint numSpaces = _SpaceWidth != 0 ? (sint) (((float) x + _SpaceWidth/2 - currLine.getWidth()) / _SpaceWidth) + : 0; + clamp(numSpaces, 0, (sint)currLine.getEndSpaces()); + index = charPos + currLine.getNumChars() + numSpaces; + cursorAtPreviousLineEnd = !_Lines[i]->getLF(); + return; + } + + float px = (float)_FirstLineX; + for(uint k = 0; k < currLine.getNumWords(); ++k) + { + CWord &currWord = currLine.getWord(k); + float spacesWidth = currLine.getSpaceWidth() * currWord.NumSpaces; + float newPx = px + currWord.Info.StringWidth + spacesWidth; + if (newPx >= x) // if the word contains the x position.. + { + if (x < (px + spacesWidth)) + { + // the coords x is in the spaces that are preceding the word + // Add spaceWidth/2 to select between chars + sint numSpaces = currLine.getSpaceWidth() != 0 ? (sint) ((x + currLine.getSpaceWidth()/2 - px) / currLine.getSpaceWidth()) + : 0; + clamp(numSpaces, 0, (sint)currWord.NumSpaces); + index = numSpaces + charPos; + cursorAtPreviousLineEnd = false; + return; + } + else + { + // the coord is in the word itself + index = charPos + currWord.NumSpaces + getCharacterIndex(currWord.Text, (float) x - (px + spacesWidth)); + cursorAtPreviousLineEnd = false; + return; + } + } + px = newPx; + charPos += (uint)currWord.Text.length() + currWord.NumSpaces; + } + index = charPos; + cursorAtPreviousLineEnd = false; + return; + } + else + { + cursorAtPreviousLineEnd = false; + if (y < 0) + { + index = (uint)_Text.length(); + return; + } + if (y > (sint) _FontHeight) + { + index = 0; + return; + } + index = getCharacterIndex(_Text, (float) x); + return; + } + } + + // *************************************************************************** + void CViewText::enableStringSelection(uint start, uint end) + { + _TextSelection= true; + _TextSelectionStart= start; + _TextSelectionEnd= end; + } + + // *************************************************************************** + void CViewText::disableStringSelection() + { + _TextSelection= false; + _TextSelectionStart= 0; + _TextSelectionEnd= std::numeric_limits::max(); + } + + // *************************************************************************** + void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd) + { + sint quadStart= charStart; + sint quadSize= charEnd-charStart; + sint j; + for(j=0;jsetStringSelection(stringId, quadStart, quadSize); + } + + // *************************************************************************** + void CViewText::clearLines() + { + for(uint k = 0; k < _Lines.size(); ++k) + { + _Lines[k]->clear(); + } + _Lines.clear(); + } + + // *************************************************************************** + uint CViewText::getNumLine() const + { + if (_MultiLine) + { + return (uint)_Lines.size(); + } + else + { + return _Text.empty() ? 0 : 1; + } + } + + // *************************************************************************** + uint CViewText::getFirstLineX() const + { + return _FirstLineX; + } + + // *************************************************************************** + uint CViewText::getLastLineW () const + { + if (!_Lines.empty()) + return (uint)_Lines.back()->getWidth(); + return 0; + } + + // *************************************************************************** + void CViewText::setFirstLineX(uint firstLineX) + { + _FirstLineX = firstLineX; + } + + ///////////////////////////////////// + // CViewText::CLine implementation // + ///////////////////////////////////// + + // *************************************************************************** + CViewText::CLine::CLine() : _NumChars(0), + _NumSpaces(0), + _SpaceWidth(0.f), + _StringLine(0), + _WidthWithoutSpaces(0.f), + _EndSpaces(0), + _HasLF(false) + { + } + + // *************************************************************************** + void CViewText::CLine::addWord(const ucstring &text, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth) + { + CWord word; + word.build(text, numSpaces); + word.Format= wordFormat; + addWord(word, fontWidth); + } + + // *************************************************************************** + void CViewText::CLine::addWord(const CWord &word, uint fontWidth) + { + _Words.push_back(word); + _NumChars += word.NumSpaces + uint(word.Text.length()); + _NumSpaces += word.NumSpaces; + if (fabsf(word.Info.StringLine) > fabsf(_StringLine)) + { + _StringLine = word.Info.StringLine; + } + // the width of the line must reach at least the Tab + _WidthWithoutSpaces= max(_WidthWithoutSpaces, word.Format.TabX * float(fontWidth)); + // append the text space + _WidthWithoutSpaces += word.Info.StringWidth; + } + + // *************************************************************************** + void CViewText::CLine::clear() + { + for(uint k = 0; k < _Words.size(); ++k) + { + if (_Words[k].Index != 0xffffffff) + CViewRenderer::getTextContext()->erase(_Words[k].Index); + } + _Words.clear(); + _NumChars = 0; + _SpaceWidth = 0.f; + } + + // *************************************************************************** + void CViewText::CLine::resetTextIndex() + { + for(uint k = 0; k < _Words.size(); ++k) + { + _Words[k].Index = 0xffffffff; + } + } + + // *************************************************************************** + void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/) + { + Text = text; + NumSpaces = numSpaces; + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + Index = TextContext->textPush(text); + Info = TextContext->getStringInfo(Index); + } + + // *************************************************************************** + void CViewText::removeEndSpaces() + { + sint i = (sint)_Text.size()-1; + while ((i>=0) && ((_Text[i] < 0x20) || (_Text[i] == ' '))) + { + i--; + } + _Text.resize (i+1); + } + + // *************************************************************************** + sint32 CViewText::getMaxUsedW() const + { + static const ucstring spaceStr(" \t"); + static const ucstring lineFeedStr("\n"); + float maxWidth = 0; + + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + + TCharPos linePos = 0; + while (linePos < _Text.length()) + { + // Get the end of the line + float lineWidth = 0; + TCharPos lineEnd; + lineEnd = _Text.find_first_of(lineFeedStr, linePos); + if (lineEnd == std::string::npos) + { + lineEnd = _Text.length(); + } + + ucstring lineValue; + lineValue = _Text.substr(linePos, lineEnd - linePos); + + TCharPos currPos = 0; + while (currPos != lineValue.length()) + { + TCharPos spaceEnd; + TCharPos wordEnd; + uint numSpaces; + + // Skip spaces and count them + spaceEnd = lineValue.find_first_not_of(spaceStr, currPos); + if (spaceEnd == std::string::npos) + { + spaceEnd = lineValue.length(); + } + numSpaces = (uint) (spaceEnd - currPos); + + // Get word until a space or a \n is encountered + wordEnd = lineValue.find_first_of(spaceStr, spaceEnd); + if (wordEnd == std::string::npos) + { + wordEnd = lineValue.length(); + } + + ucstring wordValue; + wordValue = lineValue.substr(spaceEnd, wordEnd - spaceEnd); + + // compute width of word + UTextContext::CStringInfo si; + si = TextContext->getStringInfo(wordValue); + + // compute size of spaces + word + lineWidth += numSpaces * _SpaceWidth + si.StringWidth; + + currPos = wordEnd; + } + + // Update line width + if (lineWidth > maxWidth) + maxWidth = lineWidth; + + linePos = lineEnd+1; + } + + return (sint32)maxWidth; + } + + // *************************************************************************** + sint32 CViewText::getMinUsedW() const + { + static const ucstring spaceOrLineFeedStr(" \n\t"); + sint32 maxWidth = 0; + + // Not multi line ? Same size than min + if (!_MultiLine) + return getMaxUsedW(); + + // If we can clip word, size of the largest word + if (_TextMode == ClipWord) + { + // No largest font parameter, return the font height + return _FontHeight; + } + // If we can't clip the words, return the size of the largest word + else if ((_TextMode == DontClipWord) || (_TextMode == Justified)) + { + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + + // Current position in text + TCharPos currPos = 0; + while (currPos < _Text.length()) + { + // Current word + ucstring wordValue; + UTextContext::CStringInfo si; + TCharPos wordEnd; + + // Get word until a space or a \n is encountered + currPos = _Text.find_first_not_of(spaceOrLineFeedStr, currPos); + if (currPos == std::string::npos) + break; + wordEnd = _Text.find_first_of(spaceOrLineFeedStr, currPos); + if (wordEnd == std::string::npos) + wordEnd = _Text.length(); + + // Get the word + wordValue = _Text.substr(currPos, wordEnd - currPos); + + // Compute width of word + si = TextContext->getStringInfo(wordValue); + + // Larger ? + sint32 stringWidth = (sint32)si.StringWidth; + if (stringWidth>maxWidth) + maxWidth = stringWidth; + + // Next word + currPos = wordEnd; + } + } + + return maxWidth; + } + + // *************************************************************************** + void CViewText::onInvalidateContent() + { + _InvalidTextContext= true; + invalidateCoords(); + } + + // *************************************************************************** + void CViewText::computeFontSize () + { + NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); + TextContext->setHotSpot (UTextContext::BottomLeft); + TextContext->setShaded (_Shadow); + TextContext->setFontSize (_FontSize); + + // Letter size + UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext + _FontHeight = (uint) si.StringHeight + (_Shadow?1:0); + _FontLegHeight = (uint) si.StringLine + (_Shadow?1:0); + + // Space width + si = TextContext->getStringInfo(ucstring(" ")); + _SpaceWidth = si.StringWidth; + + // Font Width + si = TextContext->getStringInfo(ucstring("_")); + _FontWidth = (uint)si.StringWidth; + } + + + // *************************************************************************** + static inline bool isColorTag(const ucstring &s, uint index, uint textSize) + { + // Format is @{RGBA} + if(s[index]=='@') + { + if( textSize>index+1 && s[index+1]=='{') + { + // verify 1st letter is a xdigit + if( textSize>index+2 && isxdigit(s[index+2])) + { + // We have good chance its a color tag. Do last verification + if(textSize>index+6 && s[index+6]=='}') + { + return true; + } + } + } + } + + return false; + } + + // *************************************************************************** + // isColorTag must be ok. + static inline CRGBA getColorTag(const ucstring &s, uint &index) + { + // extract the color string: "FABC" + char tmpCol[5]; + for(uint i=0;i<4;i++) + tmpCol[i]= (char)s[index+2+i]; + tmpCol[4]= 0; + + // Convert to color + CRGBA color; + uint pCol; + sscanf(tmpCol, "%x", &pCol); + // Transform 4 bits to 8 bit. + color.R= (pCol>>12)&0xF; color.R+= color.R<<4; + color.G= (pCol>>8)&0xF; color.G+= color.G<<4; + color.B= (pCol>>4)&0xF; color.B+= color.B<<4; + color.A= (pCol)&0xF; color.A+= color.A<<4; + + // skip tag + index+= 7; + + return color; + } + + + // *************************************************************************** + const uint MaxTabDigit= 3; + static inline bool isTabTag(const ucstring &s, uint index, uint textSize) + { + // Format is @{Tvalue}, where value ,1,2,3 digit. + if(s[index]=='@') + { + if( textSize>index+1 && s[index+1]=='{') + { + if( textSize>index+2 && s[index+2]=='T') + { + // We have good chance its a Tab tag. Do last verification + for(uint i=4;i<4+MaxTabDigit;i++) + { + if(textSize>index+i && s[index+i]=='}') + { + return true; + } + } + } + } + } + + return false; + } + + // *************************************************************************** + // isTabTag must be ok. + static inline sint getTabTag(const ucstring &s, uint &index) + { + // extract the tab min X value + char tmpTab[MaxTabDigit+1]; + uint i; + for(i=0;iindex+1 && s[index+1]=='{') + { + if( textSize>index+2 && s[index+2]=='H') + { + uint i = 3; + while (textSize>index+i && s[index+i]!='}') + i++; + + if (textSize>index+i && s[index+i]=='}') + return true; + } + } + } + + return false; + } + + // *************************************************************************** + // isTooltipTag must be ok. + static inline ucstring getTooltipTag(const ucstring &s, uint &index) + { + ucstring result; + uint i = 3; + while (s[index+i] != '}') + { + result += s[index+i]; + i++; + } + + // skip tag + index += i+1; + + return result; + } + + + // *************************************************************************** + void CViewText::buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips) + { + formatTags.clear(); + tooltips.clear(); + + // Build the text without the formatTags, and get the color tags separately + textBuild.reserve(text.size()); + uint textSize= (uint)text.size(); + // Must herit all the props from old tags. + CViewText::CFormatTag precTag; // set default. + precTag.Index = 0; + for (uint i = 0; i < textSize;) + { + if(isColorTag(text, i, textSize)) + { + // get old tag. + CViewText::CFormatTag ct= precTag; + // get new color and skip tag. + ct.Color= getColorTag(text, i); + ct.Index= (uint)textBuild.size(); + formatTags.push_back(ct); + } + else if(isTabTag(text, i, textSize)) + { + // get old tag. + CViewText::CFormatTag ct= precTag; + // get new Tab and skip tag. + ct.TabX= getTabTag(text, i); + ct.Index= (uint)textBuild.size(); + formatTags.push_back(ct); + } + else if(isTooltipTag(text, i, textSize)) + { + // get old tag. + CViewText::CFormatTag ct= precTag; + // get new Tab and skip tag. + ucstring uitt = getTooltipTag(text, i); + if (uitt.empty()) + { + ct.IndexTt= -1; + } + else + { + ct.IndexTt= (uint)tooltips.size(); + tooltips.push_back(uitt); + } + + ct.Index= (uint)textBuild.size(); + formatTags.push_back(ct); + } + else + { + bool lineFeed= text[i]=='\n'; + + // append to textBuild + textBuild+= text[i]; + ++i; + + // if \n, reset tabulations + if(lineFeed) + { + CViewText::CFormatTag ct= precTag; + ct.TabX= 0; + ct.Index= (uint)textBuild.size(); + formatTags.push_back(ct); + } + } + // bkup + if(!formatTags.empty()) + precTag= formatTags.back(); + } + } + + + // *************************************************************************** + void CViewText::setTextFormatTaged(const ucstring &text) + { + + // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp + ucstring tempText; + // static to avoid reallocation + static std::vector tempFormatTags; + static std::vector tempTooltips; + buildFormatTagText(text, tempText, tempFormatTags, tempTooltips); + setCase (tempText, _CaseMode); + + // compare Tag arrays + bool sameTagArray= false; + if(_FormatTags.size()==tempFormatTags.size()) + { + sameTagArray= true; + for(uint i=0;i<_FormatTags.size();i++) + { + if(!_FormatTags[i].sameTag(tempFormatTags[i])) + { + sameTagArray= false; + break; + } + } + } + + // test transformed text with current one + if(tempText!=_Text || !sameTagArray ) + { + // copy tags + _FormatTags= tempFormatTags; + // Copy to Text (preserve Memory) + contReset(_Text); + _Text= tempText; + + CInterfaceGroup *parent = getParent(); + + // Delete old dynamic tooltips + for (uint i=0 ; i<_Tooltips.size() ; ++i) + { + if (parent) + parent->delCtrl(_Tooltips[i]); + else + delete _Tooltips[i]; + } + _Tooltips.clear(); + + // Add new dynamic tooltips + for (uint i=0 ; isetId(_Id+"_tt"+toString(i)); + pTooltip->setAvoidResizeParent(avoidResizeParent()); + pTooltip->setRenderLayer(getRenderLayer()); + pTooltip->setDefaultContextHelp(CI18N::get(tempTooltips[i].toString())); + pTooltip->setParentPos(this); + pTooltip->setParentPosRef(Hotspot_BR); + pTooltip->setPosRef(Hotspot_BR); + pTooltip->setToolTipParent(CCtrlBase::TTWindow); + pTooltip->setToolTipParentPosRef(Hotspot_TTAuto); + pTooltip->setToolTipPosRef(Hotspot_TTAuto); + pTooltip->setActive(true); + + _Tooltips.push_back(pTooltip); + + if (parent) + { + pTooltip->setParent(parent); + parent->addCtrl(_Tooltips.back()); + } + } + + if (parent) + _Setuped = true; + else + _Setuped = false; + + invalidateContent (); + } + + // color format is available only if multilined + if (!_MultiLine) + nlwarning( toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); + } + + + void CViewText::setSingleLineTextFormatTaged(const ucstring &text) + { + // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp + ucstring tempText; + static std::vector tempLetterColors; + static std::vector tempTooltips; + + // parse text + buildFormatTagText(text, tempText, tempLetterColors, tempTooltips); + setCase (tempText, _CaseMode); + + // decal for spaces (not inserted in VertexBuffer) + uint textIndex = 0; + uint spacesNb = 0; + for(uint i=0; icreateLetterColors(); + for(uint i=0; ipushLetterColor(formatTag.Index, formatTag.Color); + } + + // test transformed text with current one + if(tempText!=_Text || !_LetterColors || !_LetterColors->isSameLetterColors(letterColors)) + { + _LetterColors = letterColors; + + TextContext->setLetterColors(letterColors, _Index); + + // Copy to Text (preserve Memory) + contReset(_Text); + _Text= tempText; + invalidateContent (); + } + + // this color format is available only if not multilined + if (_MultiLine) + nlwarning( toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); + } + + + // *************************************************************************** + bool CViewText::isFormatTagChange(uint textIndex, uint ctIndex) const + { + if(ctIndex>=_FormatTags.size()) + return false; + // return true if the textIndex is > (eg if some skip with spaces) or = (common case) + return _FormatTags[ctIndex].Index <= textIndex; + } + + // *************************************************************************** + void CViewText::getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const + { + // support the possible case with multiple color tags with same textIndex. + while(ctIndex<_FormatTags.size() && _FormatTags[ctIndex].Index<=textIndex) + { + // Take the last tag. + wordFormat.Color= _FormatTags[ctIndex].Color; + wordFormat.TabX= _FormatTags[ctIndex].TabX; + wordFormat.IndexTt= _FormatTags[ctIndex].IndexTt; + // skip it. + ctIndex++; + } + } + + + // *************************************************************************** + + void CViewText::setCaseMode (TCaseMode caseMode) + { + _CaseMode = caseMode; + setCase (_Text, _CaseMode); + } + + // *************************************************************************** + + TCaseMode CViewText::getCaseMode () const + { + return _CaseMode; + } + + // *************************************************************************** + + void CViewText::resetTextIndex() + { + _Index = 0xffffffff; + for(uint k = 0; k < _Lines.size(); ++k) + _Lines[k]->resetTextIndex(); + } + + // *************************************************************************** + void CViewText::setup() + { + _Setuped= true; + + // Add dynamic tooltips + for (uint i=0 ; i<_Tooltips.size() ; ++i) + { + CInterfaceGroup *parent = getParent(); + if (parent) + { + _Tooltips[i]->setParent(parent); + parent->addCtrl(_Tooltips.back()); + } + } + } + + // *************************************************************************** + void CViewText::serial(NLMISC::IStream &f) + { + #define SERIAL_UINT(val) { uint32 tmp = (uint32) val; f.serial(tmp); val = (uint) tmp; } + #define SERIAL_SINT(val) { sint32 tmp = (sint32) val; f.serial(tmp); val = (sint) tmp; } + CViewBase::serial(f); + SERIAL_SINT(_FontSize); + SERIAL_UINT(_FontWidth); + SERIAL_UINT(_FontHeight); + SERIAL_UINT(_FontLegHeight); + f.serial(_SpaceWidth); + f.serial(_Color); + f.serial(_Shadow); + f.serialEnum(_CaseMode); + f.serial(_ShadowColor); + f.serial(_LineMaxW); + f.serial(_SingleLineTextClamped); + f.serial(_MultiLine); + f.serial(_MultiLineMaxWOnly); + f.serial(_MultiLineClipEndSpace); + f.serial(_AutoClampOffset); + f.serialEnum(_TextMode); + SERIAL_SINT(_MultiLineSpace); + SERIAL_SINT(_LastMultiLineMaxW); + f.serial(_MultiMaxLine); + + bool hasTag = !_FormatTags.empty(); + f.serial(hasTag); + if (f.isReading()) + { + ucstring text; + f.serial(text); + if (hasTag) + { + if (_MultiLine) + { + setTextFormatTaged(text); + } + else + { + setSingleLineTextFormatTaged(text); + } + } + else + { + setText(text); + } + } + else + { + f.serial(_Text); + } + + #undef SERIAL_UINT + #undef SERIAL_SINT + } + + + // *************************************************************************** + +} + diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index 8bf79b805..3b212af7e 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" // client #include "chat_text_manager.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "interface_manager.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index 8e5da91c2..285116998 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -28,12 +28,12 @@ namespace NLGUI { class CCtrlBase; + class CViewText; } class CChatWindow; class CGroupContainer; class CGroupEditBox; -class CViewText; /** Interface to react to a chat box entry * Derivers should define the msgEntered member function to handle entry event. diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index efa54d33c..62a82831b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -23,7 +23,7 @@ #include "ctrl_text_button.h" #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h index 34a93520e..fd90e2d7e 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.h @@ -26,10 +26,9 @@ namespace NLGUI { class CEventDescriptor; + class CViewText; } class CInterfaceManager; -class CViewText; - // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index c02b21caf..3f1e81378 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -20,7 +20,7 @@ #include "dbctrl_sheet.h" #include "interface_manager.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "../sheet_manager.h" #include "../client_sheets/entity_sheet.h" #include "../client_sheets/pact_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index 521fd3605..bfe7e06fe 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -26,7 +26,7 @@ #include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "../client_cfg.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "skill_manager.h" #include "../string_manager_client.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h index 75a162dd5..94af94de9 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h @@ -29,6 +29,7 @@ namespace NLGUI { class CCtrlBaseButton; + class CViewText; } @@ -36,7 +37,6 @@ namespace NLGUI class CDBCtrlSheet; class CSBrickSheet; class CViewBitmap; -class CViewText; class CGroupEditBox; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h index 90e1a2036..4429c6a13 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h @@ -25,10 +25,10 @@ namespace NLGUI { class CCtrlBaseButton; + class CViewText; } // *************************************************************************** -class CViewText; class CGroupMenu; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index b76ef53fb..fd98d08b9 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -23,7 +23,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "nel/gui/ctrl_button.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "nel/gui/action_handler.h" #include "../time_client.h" #include "game_share/animal_status.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index f11faabbf..f5d5fdb67 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -25,7 +25,7 @@ #include "nel/misc/types_nl.h" #include "list_sheet_base.h" #include "dbctrl_sheet.h" -#include "view_text.h" +#include "nel/gui/view_text.h" namespace NLGUI { diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp index defdeff6c..de7711f69 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp @@ -23,7 +23,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" #include "nel/gui/ctrl_button.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "nel/gui/action_handler.h" #include "sphrase_manager.h" #include "game_share/time_weather_season/time_and_season.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index 02e44236e..4889fa367 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -21,7 +21,7 @@ #include "dbgroup_select_number.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_bitmap.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/interface_property.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h index a02708e87..d6446ee33 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h @@ -26,12 +26,12 @@ namespace NLGUI { class CCtrlBaseButton; + class CViewText; } // *************************************************************************** class CViewBitmap; -class CViewText; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbview_number.h b/code/ryzom/client/src/interface_v3/dbview_number.h index 1c7079f06..602f0e3b9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_number.h +++ b/code/ryzom/client/src/interface_v3/dbview_number.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" -#include "view_text.h" +#include "nel/gui/view_text.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.h b/code/ryzom/client/src/interface_v3/dbview_quantity.h index 65a12086d..a693a46d3 100644 --- a/code/ryzom/client/src/interface_v3/dbview_quantity.h +++ b/code/ryzom/client/src/interface_v3/dbview_quantity.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" -#include "view_text.h" +#include "nel/gui/view_text.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp index f8ef9e29c..54b910564 100644 --- a/code/ryzom/client/src/interface_v3/flying_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/flying_text_manager.cpp @@ -20,7 +20,7 @@ #include "flying_text_manager.h" #include "interface_manager.h" #include "group_in_scene.h" -#include "view_text.h" +#include "nel/gui/view_text.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index ee6379722..c1efb9c0d 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -34,7 +34,7 @@ #include "group_list.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_scroll.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_bitmap.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 0a79f0931..35c5a851e 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -28,10 +28,10 @@ namespace NLGUI class CEventDescriptorLocalised; class CCtrlButton; class CCtrlScroll; + class CViewText; } class CInterfaceList; -class CViewText; class COptionsContainerInsertion; class COptionsContainerMove; class CGroupContainer; diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 7d51be171..529642288 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "input_handler_manager.h" #include "nel/misc/command.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/interface_options.h" #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index 99a07c093..1c0a02e68 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -26,8 +26,8 @@ namespace NLGUI { class CEventDescriptor; + class CViewText; } -class CViewText; // ---------------------------------------------------------------------------- class CGroupEditBox : public CGroupEditBoxBase diff --git a/code/ryzom/client/src/interface_v3/group_list.h b/code/ryzom/client/src/interface_v3/group_list.h index b7fe975d2..94b5d5b7f 100644 --- a/code/ryzom/client/src/interface_v3/group_list.h +++ b/code/ryzom/client/src/interface_v3/group_list.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_frame.h" -#include "view_text.h" +#include "nel/gui/view_text.h" // ---------------------------------------------------------------------------- diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index d2fa808b7..0521ede20 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -28,7 +28,7 @@ #include "nel/gui/interface_group.h" #include "nel/gui/ctrl_button.h" #include "view_bitmap.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "animal_position_state.h" #include "../continent.h" // diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index 41bcae76a..8f87f09a6 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -22,7 +22,7 @@ #include "nel/gui/interface_group.h" #include "nel/gui/group_modal.h" #include "nel/gui/group_submenu_base.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "ctrl_text_button.h" namespace NLGUI diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index d73174a90..1366e21a2 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_frame.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_link.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp index 10f23bb9a..4417509a7 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/gui/interface_expr.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "game_share/skills.h" #include "game_share/brick_families.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index 89e556870..ea8409475 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_scrolltext.h" #include "group_list.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index a4ede0d59..d866a8c5a 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "nel/gui/interface_expr.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_bitmap.h" #include "dbview_number.h" #include "dbview_bar.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.h b/code/ryzom/client/src/interface_v3/group_table.h index 7c7ac640e..ba14e7039 100644 --- a/code/ryzom/client/src/interface_v3/group_table.h +++ b/code/ryzom/client/src/interface_v3/group_table.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_frame.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_link.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 17c0bff09..4c6d48bb6 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/gui/interface_element.h" #include "view_bitmap.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "group_container.h" #include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.h b/code/ryzom/client/src/interface_v3/group_tree.h index 038db0cf0..5b158f67b 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.h +++ b/code/ryzom/client/src/interface_v3/group_tree.h @@ -23,8 +23,12 @@ #include "nel/gui/group_frame.h" #include "nel/misc/smart_ptr.h" +namespace NLGUI +{ + class CViewText; +} + class CViewBitmap; -class CViewText; // ---------------------------------------------------------------------------- class CGroupTree : public CInterfaceGroup diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index ae93f7778..a89387a82 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "../string_manager_client.h" #include "nel/gui/action_handler.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "dbctrl_sheet.h" #include "group_container.h" #include "group_menu.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 1e9ebb20e..9624e1074 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -49,7 +49,7 @@ //#include "view_bitmap_progress.h" #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" -#include "view_text.h" +#include "nel/gui/view_text.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index be1f38175..cec1aeac6 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -39,7 +39,7 @@ #include "view_bitmap.h" #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_text_formated.h" #include "view_text_id.h" #include "view_text_id_formated.h" diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index e0e193baa..62605d6e3 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -27,6 +27,7 @@ namespace NLGUI class CCtrlBase; class CCtrlBaseButton; class CInterfaceGroup; + class CViewText; } using namespace NLGUI; @@ -60,7 +61,7 @@ public: typedef CInterfacePtr::TInterfacePtr CInterfaceElementPtr; typedef CInterfacePtr::TInterfacePtr CInterfaceGroupPtr; typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; -typedef CInterfacePtr::TInterfacePtr CViewTextPtr; +typedef CInterfacePtr::TInterfacePtr CViewTextPtr; typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index e1e73deed..3f363258c 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -49,7 +49,7 @@ #include "action_handler_tools.h" #include "interface_manager.h" #include "nel/gui/interface_group.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "game_share/people_pd.h" #include "group_tree.h" #include "nel/gui/interface_link.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index d9ac41023..299ff3f4b 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -20,7 +20,7 @@ #include "nel/gui/interface_element.h" #include "interface_3d_scene.h" #include "nel/gui/view_base.h" -#include "view_text.h" +#include "nel/gui/view_text.h" #include "view_text_id.h" #include "view_bitmap.h" #include "view_radar.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h index 839286c78..22c7b3e0b 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h @@ -24,7 +24,7 @@ ///\todo nico : do the real display when item icons are available -#include "view_text.h" +#include "nel/gui/view_text.h" /** * class used to display mps for faber interface diff --git a/code/ryzom/client/src/interface_v3/view_link.h b/code/ryzom/client/src/interface_v3/view_link.h index ba30fafd2..169487a1d 100644 --- a/code/ryzom/client/src/interface_v3/view_link.h +++ b/code/ryzom/client/src/interface_v3/view_link.h @@ -19,7 +19,7 @@ #ifndef NL_VIEW_LINK_H #define NL_VIEW_LINK_H -#include "view_text.h" +#include "nel/gui/view_text.h" /** * class implementing a link view diff --git a/code/ryzom/client/src/interface_v3/view_text.cpp b/code/ryzom/client/src/interface_v3/view_text.cpp deleted file mode 100644 index fc50c1b76..000000000 --- a/code/ryzom/client/src/interface_v3/view_text.cpp +++ /dev/null @@ -1,2597 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "nel/misc/bit_mem_stream.h" -#include "nel/misc/i18n.h" - -#include "view_text.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/group_container_base.h" -#include "nel/gui/ctrl_tooltip.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/view_pointer_base.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; - -typedef std::string::size_type TCharPos; // index of a chracter in a string - -REGISTER_UI_CLASS(CViewText) - -// *************************************************************************** -void CViewText::setupDefault () -{ - _CaseMode = CaseNormal; - _Underlined = false; - _ContinuousUpdate = false; - _Active = true; - _X = 0; - _Y = 0; - _W = 0;; - _H = 0; - _SizeRef = 0; - _SizeDivW = 10; - _SizeDivH = 10; - _ParentPosRef = Hotspot_BL; - _PosRef = Hotspot_BL; - - _FontSize = 12 + - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont ).getValSInt32(); - _Color = CRGBA(255,255,255,255); - _Shadow = false; - _ShadowColor = CRGBA(0,0,0,255); - - _MultiLine = false; - _TextMode = DontClipWord; - _MultiLineSpace = 8; - _LineMaxW = 16384; - _MultiLineMaxWOnly = false; - _MultiLineClipEndSpace = false; - _LastMultiLineMaxW = 0; - _MultiMaxLine = 0; - _Index = 0xFFFFFFFF; - - _FontWidth= 0; - _FontHeight = 0; - _FontLegHeight = 0; - - _TextSelection= false; - _TextSelectionStart= 0; - _TextSelectionEnd= std::numeric_limits::max(); - - _InvalidTextContext= true; - _FirstLineX = 0; - computeFontSize (); - - _SingleLineTextClamped= false; - _OverExtendViewText= false; - _OverExtendViewTextUseParentRect= false; - - _AutoClamp = false; - _ClampRight = true; // clamp on the right of the text - - _LetterColors = NULL; - _Setuped= false; - _AutoClampOffset = 0; -} - -// *************************************************************************** - -NLMISC_REGISTER_OBJECT(CViewBase, CViewText, std::string, "text"); - -CViewText::CViewText(const TCtorParam ¶m) -:CViewBase(param) -{ - setupDefault (); -} - -///constructor -// *************************************************************************** -CViewText:: CViewText (const std::string& id, const std::string Text, sint FontSize, - NLMISC::CRGBA Color, bool Shadow) - :CViewBase(TCtorParam()) -{ - _Id = id; - setupDefault (); - - _FontSize = FontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); - _Color = Color; - _Shadow = Shadow; - setText(Text); - computeFontSize (); -} - -// *************************************************************************** -CViewText::~CViewText() -{ - if (_Index != 0xFFFFFFFF) - CViewRenderer::getTextContext()->erase (_Index); - clearLines(); - - if (!_Setuped) - for (uint i=0 ; i<_Tooltips.size() ; ++i) - delete _Tooltips[i]; - - _Tooltips.clear(); -} - -// *************************************************************************** -CViewText &CViewText::operator=(const CViewText &vt) -{ - if (_Index != 0xFFFFFFFF) - CViewRenderer::getTextContext()->erase (_Index); - - // Create database entries - _Active = vt._Active; - _X = vt._X; - _Y = vt._Y; - _W = vt._W; - _H = vt._H; - _SizeRef = vt._SizeRef; - _SizeDivW = vt._SizeDivW; - _SizeDivH = vt._SizeDivH; - _ParentPosRef = vt._ParentPosRef; - _PosRef = vt._PosRef; - - _FontSize = vt._FontSize; - _Color = vt._Color; - _Shadow = vt._Shadow; - _ShadowColor = vt._ShadowColor; - - _MultiLine = false; - _MultiLineSpace = 8; - _LineMaxW= 16384; - _MultiLineMaxWOnly = false; - _MultiLineClipEndSpace = false; - _LastMultiLineMaxW = 0; - _Index = 0xFFFFFFFF; - - _ModulateGlobalColor= vt._ModulateGlobalColor; - - - // remove previous lines - clearLines(); - _InvalidTextContext = true; - computeFontSize (); - - return *this; -} - -// *************************************************************************** -void CViewText::parseTextOptions (xmlNodePtr cur) -{ - CXMLAutoPtr prop; - - prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _Color = CRGBA(255,255,255,255); - if (prop) - _Color = convertColor(prop); - - prop= (char*) xmlGetProp (cur, (xmlChar*)"global_color"); - if(prop) - _ModulateGlobalColor= convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"fontsize" ); - _FontSize = 12 + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); - if (prop) - { - fromString((const char*)prop, _FontSize); - _FontSize += CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"shadow" ); - _Shadow = false; - if (prop) - _Shadow = convertBool(prop); - - prop= (char*) xmlGetProp( cur, (xmlChar*)"shadow_color" ); - _ShadowColor = CRGBA(0,0,0,255); - if (prop) - _ShadowColor = convertColor(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line" ); - _MultiLine = false; - if (prop) - _MultiLine = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"justification" ); - if (prop) - { - if (nlstricmp("clip_word", (const char *) prop) == 0) _TextMode = ClipWord; - else if (nlstricmp("dont_clip_word", (const char *) prop) == 0) _TextMode = DontClipWord; - else if (nlstricmp("justified", (const char *) prop) == 0) _TextMode = Justified; - else nlwarning(" bad text mode"); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"line_maxw" ); - _LineMaxW = 16384; - if (prop) - fromString((const char*)prop, _LineMaxW); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line_space" ); - _MultiLineSpace = 8; - if (prop) - fromString((const char*)prop, _MultiLineSpace); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_line_maxw_only" ); - _MultiLineMaxWOnly = false; - if (prop) - _MultiLineMaxWOnly = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"multi_max_line" ); - _MultiMaxLine = 0; - if (prop) - fromString((const char*)prop, _MultiMaxLine); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"underlined" ); - _Underlined = false; - if (prop) - _Underlined = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"case_mode" ); - _CaseMode = CaseNormal; - if (prop) - { - sint32 caseMode; - fromString((const char*)prop, caseMode); - _CaseMode = (TCaseMode)caseMode; - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"over_extend_view_text" ); - _OverExtendViewText= false; - if(prop) - _OverExtendViewText= convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"over_extend_parent_rect" ); - _OverExtendViewTextUseParentRect= false; - if(prop) - _OverExtendViewTextUseParentRect= convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"auto_clamp" ); - _AutoClamp = false; - if (prop) - _AutoClamp = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"clamp_right" ); - _ClampRight = true; - if (prop) - _ClampRight = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"auto_clamp_offset" ); - _AutoClampOffset = 0; - if (prop) - fromString((const char*)prop, _AutoClampOffset); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"continuous_update" ); - if (prop) - { - _ContinuousUpdate = convertBool(prop); - } - - - computeFontSize (); -} - -/* -* parse an xml node and initialize the base view mambers. Must call CViewBase::parse -* \param cur : pointer to the xml node to be parsed -* \param parentGroup : the parent group of the view -* \partam id : a refence to the string that will receive the view ID -* \return true if success -*/ -// *************************************************************************** -bool CViewText::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - -// const ucstring* tmp; - CXMLAutoPtr prop; - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - - if (! CViewBase::parse(cur,parentGroup) ) - return false; - - //set w and h to 0 : they depend on the string contained - _W = 0; - _H = 0; - - //try to get the NEEDED specific props - parseTextOptions(cur); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (prop) - { - const char *propPtr = prop; - _Text = ucstring(propPtr); - - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - _Text = CI18N::get (propPtr); - setCase (_Text, _CaseMode); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext_format" ); - if (prop) - { - const char *propPtr = prop; - if (_MultiLine) - { - setTextFormatTaged(CI18N::get(propPtr)); - } - else - { - setSingleLineTextFormatTaged(CI18N::get(propPtr)); - } - } - - invalidateContent (); - - return true; -} - -// *************************************************************************** -sint CViewText::getCurrentMultiLineMaxW() const -{ - if(_MultiLineMaxWOnly) - return _LineMaxW; - else - { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - return std::min(parentWidth-(sint)(_XReal-_Parent->getXReal()), (sint)_LineMaxW); - } -} - - -// *************************************************************************** -void CViewText::checkCoords () -{ - if ((_MultiLine)&&(_Parent != NULL)) - { - // If never setuped, and if text is not empty - if (_Lines.size() == 0 && !_Text.empty()) - invalidateContent (); - - sint currentMaxW= getCurrentMultiLineMaxW(); - if ( _LastMultiLineMaxW != currentMaxW ) - { - if (_ContinuousUpdate) - { - _LastMultiLineMaxW = currentMaxW; - invalidateContent(); - } - else - { - CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); - if (pCB != NULL) - { - if( pCB->isResizer() ) - { - // We are resizing !!!! - } - else - { - _LastMultiLineMaxW = currentMaxW; - invalidateContent(); - } - } - else - { - _LastMultiLineMaxW = currentMaxW; - invalidateContent(); - } - } - } - } - else - { - if (_Index == 0xFFFFFFFF) - invalidateContent (); - } -} -/* -* draw the view -*/ -// *************************************************************************** -void CViewText::draw () -{ - H_AUTO( RZ_Interface_CViewText_draw ) - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - // *** Out Of Clip? - sint32 ClipX, ClipY, ClipW, ClipH; - rVR.getClipWindow (ClipX, ClipY, ClipW, ClipH); - if (((_XReal) > (ClipX+ClipW)) || ((_XReal+_WReal) < ClipX) || - ((_YReal) > (ClipY+ClipH)) || ((_YReal+_HReal) < ClipY)) - return; - - // *** Screen Minimized? - uint32 w, h; - float oow, ooh; - rVR.getScreenSize (w, h); - if (rVR.isMinimized()) - return; - rVR.getScreenOOSize (oow, ooh); - - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - - - // *** get current color - CRGBA col, shcol; - if(getModulateGlobalColor()) - { - CRGBA gcfc = CWidgetManager::getInstance()->getGlobalColorForContent(); - col.modulateFromColor (_Color, gcfc); - shcol.modulateFromColor (_ShadowColor, gcfc); - } - else - { - col = _Color; - shcol = _ShadowColor; - col.A = (uint8)(((sint)col.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - shcol.A = (uint8)(((sint)shcol.A*((sint)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - - // *** Draw multiline - if ((_MultiLine)&&(_Parent != NULL)) - { - if (_Lines.size() == 0) return; - - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setShadeColor (shcol); - TextContext->setFontSize (_FontSize); - - float y = (float)(_YReal) * ooh; // y is expressed in scree, coordinates [0..1] - //y += _LinesInfos[_LinesInfos.size()-1].StringLine / h; - - // Y is the base line of the string, so it must be grown up. - y += (float)_FontLegHeight * ooh; - - sint y_line = _YReal+_FontLegHeight-2; - - // special selection code - if(_TextSelection) - { - sint charIndex = 0; - for (sint i = 0; i<(sint)_Lines.size(); i++) - { - CLine &currLine = *_Lines[i]; - for(uint k = 0; k < currLine.getNumWords(); ++k) - { - CWord &currWord = currLine.getWord(k); - charIndex += currWord.NumSpaces; - sint cStart= max(charIndex, (sint)_TextSelectionStart); - sint cEnd= min(charIndex+(sint)currWord.Text.length(), (sint)_TextSelectionEnd); - - // range must be valid - if(cStartsetStringSelection(currWord.Index, 0, 0); - } - - // next word - charIndex+= (sint)currWord.Text.length(); - } - charIndex += currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); - } - } - - // draw - for (sint i = (sint)_Lines.size()-1; i >= 0; --i) - { - CLine &currLine = *_Lines[i]; - // current x position - float px = (float) (_XReal + ((i==0) ? (sint)_FirstLineX : 0)); - // draw each words of the line - for(uint k = 0; k < currLine.getNumWords(); ++k) - { - CWord &currWord = currLine.getWord(k); - - // Change the current color - if(currWord.Format.Color==CRGBA::White) - TextContext->setStringColor(currWord.Index, col); - else - { - CRGBA mCol; - mCol.modulateFromColor(col, currWord.Format.Color); - TextContext->setStringColor(currWord.Index, mCol); - } - - // skip spaces before current word - float firstSpace = currWord.NumSpaces * currLine.getSpaceWidth(); - sint line_width = 0; - if (_Underlined) - { - line_width = (sint)floorf(currLine.getWidthWithoutSpaces() + currLine.getSpaceWidth()); - line_width -= (sint)floorf(firstSpace); - } - px += firstSpace; - // skip tabulation before current word - if(currWord.Format.TabX) - px= max(px, (float)(_XReal + currWord.Format.TabX*_FontWidth)); - - // draw. We take floorf px to avoid filtering of letters that are not located on a pixel boundary - rVR.drawText (_RenderLayer, floorf(px) * oow, y, currWord.Index, (float)ClipX * oow, (float)ClipY * ooh, - (float)(ClipX+ClipW) * oow, (float)(ClipY+ClipH) * ooh, *TextContext); - - // Draw a line - if (_Underlined) - rVR.drawRotFlipBitmap (_RenderLayer, (sint)floorf(px), y_line, line_width, 1, 0, false, rVR.getBlankTextureId(), col); - - // skip word - px += currWord.Info.StringWidth; - } - // go one line up - y += (_FontHeight + _MultiLineSpace) * ooh; - y_line += _FontHeight+_MultiLineSpace; - } - - // reset selection - if(_TextSelection) - { - for (sint i = 0; i<(sint)_Lines.size(); i++) - { - CLine &currLine = *_Lines[i]; - for(uint k = 0; k < currLine.getNumWords(); ++k) - { - TextContext->resetStringSelection(currLine.getWord(k).Index); - } - } - } - } - // *** Single Line Version (currently no support for text justification) - else - { - nlassert(_Index != 0xFFFFFFFF); - - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setShadeColor (shcol); - TextContext->setFontSize (_FontSize); - - - if(_LetterColors!=NULL && !TextContext->isSameLetterColors(_LetterColors, _Index)) - { - TextContext->setLetterColors(_LetterColors, _Index); - } - - - float x = (float)(_XReal) * oow; - float y = (float)(_YReal) * ooh; - - // Y is the base line of the string, so it must be grown up. - y += (float)_FontLegHeight * ooh; - - // special selection code - if(_TextSelection) - // select subset. Arg, must skip spaces because not inserted in VertexBuffer. - setStringSelectionSkipingSpace(_Index, _Text, _TextSelectionStart, _TextSelectionEnd); - - // Change the current color - TextContext->setStringColor(_Index, col); - - // draw - rVR.drawText (_RenderLayer, x, y, _Index, (float)ClipX * oow, (float)ClipY * ooh, - (float)(ClipX+ClipW) * oow, (float)(ClipY+ClipH) * ooh, *TextContext); - - // Draw a line - if (_Underlined) - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_FontLegHeight-2, _WReal, 1, 0, false, rVR.getBlankTextureId(), col); - - // reset selection - if(_TextSelection) - TextContext->resetStringSelection(_Index); - - // if single line clamped, may allow to draw an over - if(isSingleLineTextClamped() && _OverExtendViewText && CWidgetManager::getInstance()->getPointer()) - { - // but must check first if mouse is over - sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - bool mouseIn; - // use parent clip or self clip? - if(_OverExtendViewTextUseParentRect) - mouseIn= _Parent && _Parent->isIn(x,y); - else - mouseIn= isIn(x,y); - // if the mouse cursor is in the clip area - if(mouseIn) - { - // check the window under the mouse is the root window - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); - CInterfaceElement *pParent = this; - bool bFound = false; - while (pParent != NULL) - { - if (pParent == pIG) - { - bFound = true; - break; - } - pParent = pParent->getParent(); - } - - // ok => let this view text be the extend over one - if(bFound) - { - // last check: the window must not be currently moved - CGroupContainerBase *gc= dynamic_cast(pIG); - if(!gc || !gc->isMoving()) - { - CRGBA col= CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionViewTextOverBackColor).getValColor(); - CWidgetManager::getInstance()->setOverExtendViewText(this, col); - } - } - } - } - } - -} - -// *************************************************************************** -void CViewText::onAddToGroup() -{ - // Add tooltips if not done - if(!_Setuped) - setup(); -} - -// *************************************************************************** -void CViewText::setTextMode(TTextMode mode) -{ - if (mode != _TextMode) - { - _TextMode = mode; - invalidateContent (); - } -} - -// *************************************************************************** -void CViewText::setText(const ucstring & text) -{ - // common case: no special format, no case mode => easy cache test - if (_FormatTags.empty() && _CaseMode==CaseNormal) - { - if (text != _Text) - { - _Text = text; - // no need to call "setCase (_Text, _CaseMode);" since CaseNormal: - invalidateContent (); - } - } - else - { - // if the view text had some format before, no choice, must recompute all - if(!_FormatTags.empty()) - { - _Text = text; - setCase (_Text, _CaseMode); - invalidateContent (); - } - // else test if after the case change the cache succeed - else - { - // compute the temp cased text - ucstring tempText= text; - setCase(tempText, _CaseMode); - if(tempText!=_Text) - { - _Text = tempText; - invalidateContent (); - } - } - } - - // clear format tags if any - _FormatTags.clear(); -} - -// *************************************************************************** -void CViewText::setFontSize (sint nFontSize) -{ - _FontSize = nFontSize + CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); - computeFontSize (); - invalidateContent(); -} - -// *************************************************************************** -sint CViewText::getFontSize() const -{ - return _FontSize - CWidgetManager::getInstance()->getSystemOption( CWidgetManager::OptionAddCoefFont).getValSInt32(); -} - -// *************************************************************************** -void CViewText::setColor(const NLMISC::CRGBA & color) -{ - _Color = color; -} - -// *************************************************************************** -void CViewText::setShadow (bool bShadow) -{ - _Shadow = bShadow; - computeFontSize (); - invalidateContent(); -} - -// *************************************************************************** -void CViewText::setShadowColor(const NLMISC::CRGBA & color) -{ - _ShadowColor = color; -} - -// *************************************************************************** -void CViewText::setLineMaxW (sint nMaxW, bool invalidate) -{ - if(_LineMaxW!=nMaxW) - { - _LineMaxW = nMaxW; - if (invalidate) - invalidateContent(); - } -} - -// *************************************************************************** -int CViewText::luaSetLineMaxW(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "setLineMaxW", 1); - sint32 value; - if(CLuaIHM::popSINT32(ls, value)) - { - setLineMaxW(value); - } - return 0; -} - -// *************************************************************************** -void CViewText::setMultiLine (bool bMultiLine) -{ - _MultiLine = bMultiLine; - invalidateContent(); -} - -// *************************************************************************** -void CViewText::setMultiLineSpace (sint nMultiLineSpace) -{ - _MultiLineSpace = nMultiLineSpace; - invalidateContent(); -} - -// *************************************************************************** -void CViewText::setMultiLineMaxWOnly (bool state) -{ - _MultiLineMaxWOnly = state; - invalidateContent(); -} - -// *************************************************************************** -void CViewText::setMultiLineClipEndSpace (bool state) -{ - _MultiLineClipEndSpace= state; - invalidateContent(); -} - -// *************************************************************************** -uint CViewText::getFontWidth() const -{ - return _FontWidth; -} - -// *************************************************************************** -uint CViewText::getFontHeight() const -{ - return _FontHeight; -} - -// *************************************************************************** -uint CViewText::getFontLegHeight() const -{ - return _FontLegHeight; -} - -// *************************************************************************** -void CViewText::flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat) -{ - // create a new line? - if(!linePushed) - { - _Lines.push_back(TLineSPtr(new CLine)); - linePushed= true; - } - // Append to the last line - _Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth); - // reset the word - ucCurrentWord = ucstring(""); -} - - -// *************************************************************************** -void CViewText::updateTextContextMultiLine(uint nMaxWidth) -{ - ucchar ucLetter; - UTextContext::CStringInfo si; - uint i; - // word state - ucstring ucCurrentWord; - CFormatInfo wordFormat; - // line state - float rWidthCurrentLine = 0, rWidthLetter; - bool linePushed= false; - // for all the text - uint textSize= (uint)_Text.size(); - uint formatTagIndex= 0; - for (i = 0; i < textSize; ++i) - { - if(isFormatTagChange(i, formatTagIndex)) - { - // If the word was not empty before this color tag - if(!ucCurrentWord.empty()) - flushWordInLine(ucCurrentWord, linePushed, wordFormat); - - // get new color and skip ctIndex. - getFormatTagChange(i, formatTagIndex, wordFormat); - - // Ensure the line witdh count the tab - rWidthCurrentLine= max(rWidthCurrentLine, (float)wordFormat.TabX*_FontWidth); - } - - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - - // Parse the letter - { - ucLetter = _Text[i]; - if (ucLetter == ucchar('\n')) - { - flushWordInLine(ucCurrentWord, linePushed, wordFormat); - // reset line state - linePushed= false; - rWidthCurrentLine = 0; - } - else - { - ucstring ucStrLetter; - ucStrLetter= ucLetter; - si = TextContext->getStringInfo (ucStrLetter); - rWidthLetter = (si.StringWidth); - if ((rWidthCurrentLine + rWidthLetter) > nMaxWidth) - { - flushWordInLine(ucCurrentWord, linePushed, wordFormat); - - // reset line state, and begin with the cut letter - linePushed= false; - rWidthCurrentLine = rWidthLetter; - ucCurrentWord = ucLetter; - } - else - { - // Grow the current word - ucCurrentWord += ucLetter; - rWidthCurrentLine += rWidthLetter; - } - } - } - } - if (ucCurrentWord.length()) - { - flushWordInLine(ucCurrentWord, linePushed, wordFormat); - } -} - - -// *************************************************************************** -void CViewText::addDontClipWordLine(std::vector &currLine) -{ - // create a new line - _Lines.push_back(TLineSPtr(new CLine)); - - // Fill it with words. if all words of same color, create only one CWord - if (!currLine.empty()) - { - CFormatInfo lineWordFormat= currLine[0].Format; - ucstring lineWord; - for(uint i=0;iaddWord(lineWord, 0, lineWordFormat, _FontWidth); - // get new lineWordFormat - lineWordFormat= currLine[i].Format; - // and clear - lineWord.clear(); - } - - // Append the word with space to the lineWord. - ucstring blank; - blank.resize(currLine[i].NumSpaces, (ucchar) ' '); - lineWord += blank; - lineWord += currLine[i].Text; - } - - if(!lineWord.empty()) - _Lines.back()->addWord(lineWord, 0, lineWordFormat, _FontWidth); - - // clear - currLine.clear(); - } -} - -// *************************************************************************** -void CViewText::updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces) -{ - UTextContext::CStringInfo si; - // - TCharPos currPos = 0; - // - static const ucstring spaceStr(" "); - // precLineWidth valid only id precedent line is part of same paragraph. - float precLineWidth= 0; - float lineWidth = (float)_FirstLineX; // width of the current line - uint numWordsInLine = 0; // number of words in the current line - bool isParagraphStart = true; // A paragraph is a group of characters between 2 \n - bool lineFeed; - bool breakLine; - // - vector currLine; // if spaces are not expanded, all words of a line are inserted here (NB: index and stringInfo not filled) - ucstring wordValue; - CFormatInfo wordFormat; - uint formatTagIndex= 0; - // - while (currPos != _Text.length()) - { - TCharPos spaceEnd; - TCharPos wordEnd; - uint numSpaces; - float newLineWidth; - breakLine = false; - // - if (_Text[currPos] == (ucchar) '\n') - { - lineFeed = true; - } - else - { - lineFeed = false; - // Skip spaces and count them - spaceEnd = _Text.find_first_not_of(spaceStr, currPos); - if (spaceEnd == std::string::npos) - { - spaceEnd = _Text.length(); - } - numSpaces = (uint) (spaceEnd - currPos); - if (!isParagraphStart && numSpaces != 0 && numWordsInLine == 0) // Are these the first spaces of the line ? - { - if (!_Lines.empty()) - { - /* Yoyo: I changed this (added the "cut space"), because in editBox, it is so strange when - the word hit the end of line, and if you add spaces just after, nothing happens because - cursor pos is clamped at end of line. - */ - // Cannot put all of thoses spaces to the prec end of line? - if(_MultiLineClipEndSpace && precLineWidth + numSpaces * _SpaceWidth > nMaxWidth) - { - // put some of these spaces at the end of the previous line. - sint maxNumSpaces= (sint)floorf((nMaxWidth - precLineWidth) / _SpaceWidth); - _Lines.back()->setEndSpaces(maxNumSpaces); - // And start the new lines with the remaining spaces. - numSpaces-= maxNumSpaces; - currPos+= maxNumSpaces; - } - else - { - // ok, put all spaces to previous line - _Lines.back()->setEndSpaces(numSpaces); - currPos = spaceEnd; - numSpaces= 0; - } - if(currPos >=_Text.length()) - break; - } - } - - // Detect change of wordFormat at the begining of the word - if(isFormatTagChange((uint)spaceEnd, formatTagIndex)) - { - getFormatTagChange((uint)spaceEnd, formatTagIndex, wordFormat); - } - - // Get word until a space, a \n, or a FormatTagChange is encountered - uint i; - for(i= (uint)spaceEnd;i<(uint)_Text.length();i++) - { - ucchar c= _Text[i]; - if(c==' ' || c=='\n') - break; - // If change of color tag, stop the word, but don't take the new color now. - if(isFormatTagChange(i, formatTagIndex)) - break; - } - wordEnd = i; - - - // Get the word value. - wordValue = _Text.substr(spaceEnd, wordEnd - spaceEnd); - // compute width of word - si = CViewRenderer::getTextContext()->getStringInfo(wordValue); - - // compute size of spaces/Tab + word - newLineWidth = lineWidth + numSpaces * _SpaceWidth; - newLineWidth = max(newLineWidth, (float)wordFormat.TabX*_FontWidth); - newLineWidth+= si.StringWidth; - } - // - // Does the word go beyond the end of line ? - if (!lineFeed && newLineWidth > (float) nMaxWidth) - { - // Have we enough room for this word on a line ? - bool roomForThisWord = (numWordsInLine > 0) || ( (newLineWidth - lineWidth) < (float) nMaxWidth ); - - // not enough room for that word - // If it is the only word of the line, just split it - // Otherwise, scale the spaces between words so that the line as the maximum width - if (roomForThisWord) - { - if (expandSpaces) - { - nlassert(_Lines.size() > 0); - nlassert(_Lines.back()->getNumWords() > 0); - - // Yoyo: if the line has tab, then don't justify - if(wordFormat.TabX > 0) - _Lines.back()->setSpaceWidth(_SpaceWidth); - else - { - // Scale the width so that the line has the maximum width - float roomForSpaces = nMaxWidth - _Lines.back()->getWidthWithoutSpaces(); - uint startNumSpaces = _Lines.back()->getNumSpaces(); - if (startNumSpaces != 0) - { - _Lines.back()->setSpaceWidth(roomForSpaces / startNumSpaces); - } - else - { - _Lines.back()->setSpaceWidth(_SpaceWidth); - } - } - } - else - { - breakLine = true; - } - // we dont change the position in the input string so that the current will be processed on the next line - - } - else // it is the only word on the line.. - { - // .. so split it - // 1) Check if spaces go beyond the end of line - if (numSpaces * _SpaceWidth > nMaxWidth) - { - uint maxNumSpaces = std::max(1U, (uint) (nMaxWidth / _SpaceWidth)); - CWord spaceWord; // a word with only spaces in it - spaceWord.build (ucstring (""), maxNumSpaces); - spaceWord.Format= wordFormat; - _Lines.push_back(TLineSPtr(new CLine)); - _Lines.back()->addWord(spaceWord, _FontWidth); - if (expandSpaces) - { - _Lines.back()->setSpaceWidth(nMaxWidth / (float) maxNumSpaces); - } - else - { - _Lines.back()->setSpaceWidth(_SpaceWidth); - } - currPos = currPos + maxNumSpaces; - } - else - { - float px = numSpaces * _SpaceWidth; - uint currChar = 0; - ucstring oneChar(" "); - for(currChar = 0; currChar < wordValue.length(); ++currChar) - { - oneChar = wordValue[currChar]; - si = CViewRenderer::getTextContext()->getStringInfo(oneChar); - if ((uint) (px + si.StringWidth) > nMaxWidth) break; - px += si.StringWidth; - } - currChar = std::max((uint) 1, currChar); // must fit at least one character otherwise there's an infinite loop - wordValue = _Text.substr(spaceEnd, currChar); - CWord word; - word.build(wordValue, numSpaces); - word.Format= wordFormat; - _Lines.push_back(TLineSPtr(new CLine)); - float roomForSpaces = (float) nMaxWidth - word.Info.StringWidth; - if (expandSpaces && numSpaces != 0) - { - _Lines.back()->setSpaceWidth(roomForSpaces / (float) numSpaces); - } - else - { - _Lines.back()->setSpaceWidth(0); - } - _Lines.back()->addWord(word, _FontWidth); - currPos = currPos + numSpaces + currChar; - } - } - // reset line - numWordsInLine = 0; - precLineWidth= lineWidth; - lineWidth = 0; - isParagraphStart = false; - } - else if (!lineFeed) // the end of line hasn't been reached - { - if (expandSpaces) - { - // add in the current line (and create one if necessary) - if (numWordsInLine == 0) - { - _Lines.push_back(TLineSPtr(new CLine)); - _Lines.back()->setSpaceWidth(_SpaceWidth); - } - if (!wordValue.empty() || numSpaces != 0) - { - CWord word; - word.build(wordValue, numSpaces); - word.Format= wordFormat; - // update line width - _Lines.back()->addWord(word, _FontWidth); - ++numWordsInLine; - } - } - else - { - CWord word; - // Don't build here, this is used as temp data. - word.Text= wordValue; - word.NumSpaces= numSpaces; - word.Format= wordFormat; - // Append to the temp Data. - currLine.push_back(word); - - ++numWordsInLine; - } - lineWidth = newLineWidth; - currPos = wordEnd; - } - else - { - // '\n' was encountered - ++ currPos; - isParagraphStart = true; - } - if (lineFeed || breakLine) // '\n' was encoutered, or a linefeed has been asked - { - // !expandSpaces => insert minimum words according to word color. - if (!expandSpaces) - { - // Add the new line. - addDontClipWordLine(currLine); - // LineFeed? - if (lineFeed) - { - _Lines.back()->setLF(true); - } - } - // expandSpaces => just add a empty line. - else - { - if (numWordsInLine == 0) - { - // if nothing has been inserted in this line, create at least an empty line - _Lines.push_back(TLineSPtr(new CLine)); - } - if (lineFeed) - { - _Lines.back()->setLF(true); - } - } - lineWidth = 0.f; - numWordsInLine = 0; - } - } - - // if current line hasn't been pushed, add it - if (!expandSpaces && !currLine.empty()) - { - // Add new line - addDontClipWordLine(currLine); - } - - // if the text ends with \n, must insert the last line ourself - if (!_Text.empty() && _Text[_Text.length() - 1] == (ucchar) '\n') - { - _Lines.push_back(TLineSPtr(new CLine)); - } -} - - -// *************************************************************************** -void CViewText::updateTextContext () -{ - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); - - // default state - _SingleLineTextClamped= false; - - if ((_MultiLine)&&(_Parent != NULL)) - { - sint nMaxWidth = getCurrentMultiLineMaxW(); - _LastMultiLineMaxW = nMaxWidth; - clearLines(); - if (nMaxWidth <= 0) - { - // parent size may not be known yet - return; - } - switch(_TextMode) - { - case ClipWord: updateTextContextMultiLine(nMaxWidth); break; - case DontClipWord: updateTextContextMultiLineJustified(nMaxWidth, false); break; - case Justified: updateTextContextMultiLineJustified(nMaxWidth, true); break; - } - - // Special case for multiline limited in number of lines - if ((_Lines.size() > 0) && (_MultiMaxLine > 0) && (_Lines.size() > _MultiMaxLine)) - { - while (_Lines.size() > _MultiMaxLine) - { - _Lines.back()->clear(); - _Lines.pop_back(); - } - _Lines.pop_back(); - CViewText::CLine *endLine = new CViewText::CLine; - CViewText::CWord w; - w.build(string("...")); - endLine->addWord(w, _FontWidth); - _Lines.push_back(TLineSPtr(endLine)); - } - - // Calculate size - float rTotalW = 0; - for (uint i = 0; i < _Lines.size(); ++i) - { - rTotalW = std::max(_Lines[i]->getWidth() + ((i==0)?_FirstLineX:0), rTotalW); - } - _W = (sint)rTotalW; - _H = std::max(_FontHeight, uint(_FontHeight * _Lines.size() + std::max(0, sint(_Lines.size()) - 1) * _MultiLineSpace)); - - // Compute tooltips size - if (_Tooltips.size() > 0) - for (uint i=0 ; i<_Lines.size() ; ++i) - { - for (uint j=0 ; j<_Lines[i]->getNumWords() ; ++j) - { - CWord word = _Lines[i]->getWord(j); -// float w = _Lines[i]->getWidth(); - - if (word.Format.IndexTt != -1) - { - if (_Tooltips.size() > (uint)word.Format.IndexTt) - { - CCtrlToolTip *pTooltip = _Tooltips[word.Format.IndexTt]; - - sint y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i - 1)); - - pTooltip->setX(0); - pTooltip->setY(y); - pTooltip->setW(getCurrentMultiLineMaxW()); - pTooltip->setH(_FontHeight); - } - } - } - } - } - else // Single line code - { - if (_Index != 0xFFFFFFFF) - TextContext->erase (_Index); - - // Common case: no W clamp - _Index = TextContext->textPush (_Text); - _Info = TextContext->getStringInfo (_Index); - _W = (sint)(_Info.StringWidth); - - // Rare case: clamp W => recompute slowly, cut letters - if(_W>_LineMaxW) - { - TextContext->erase (_Index); - - ucchar ucLetter; - UTextContext::CStringInfo si; - ucstring ucCurrentLine; - ucCurrentLine.reserve(_Text.size()); - // Append ... to the end of line - si = TextContext->getStringInfo (ucstring("...")); - float dotWidth= si.StringWidth; - float rWidthCurrentLine = 0, rWidthLetter; - // for all the text - if (_ClampRight) - { - for (uint i = 0; i < _Text.size(); ++i) - { - ucLetter= _Text[i]; - ucstring ucStrLetter; - ucStrLetter= ucLetter; - si = TextContext->getStringInfo (ucStrLetter); - rWidthLetter = (si.StringWidth); - if ((rWidthCurrentLine + rWidthLetter + dotWidth) > _LineMaxW) - { - break; - } - else - { - // Grow the current line - ucCurrentLine += ucLetter; - rWidthCurrentLine += rWidthLetter; - } - } - - // Add the dots - ucCurrentLine+= "..."; - } - else - { - for (sint i = (sint)_Text.size() - 1; i >= 0; --i) - { - ucLetter= _Text[i]; - ucstring ucStrLetter; - ucStrLetter= ucLetter; - si = TextContext->getStringInfo (ucStrLetter); - rWidthLetter = (si.StringWidth); - if ((rWidthCurrentLine + rWidthLetter + dotWidth) > _LineMaxW) - { - break; - } - else - { - // Grow the current line - ucCurrentLine = ucLetter + ucCurrentLine; - rWidthCurrentLine += rWidthLetter; - } - } - - // Add the dots - ucCurrentLine = "..." + ucCurrentLine; - } - - // And so setup this trunc text - _Index = TextContext->textPush (ucCurrentLine); - _Info = TextContext->getStringInfo (_Index); - _W = (sint)(_Info.StringWidth); - - _SingleLineTextClamped= true; - } - - // same height always - _H = _FontHeight; - } - - _InvalidTextContext= false; -} - -// *************************************************************************** -void CViewText::updateCoords() -{ - if (_AutoClamp) - { - CViewBase::updateCoords (); - if (_Parent) - { - CInterfaceGroup *parent = _Parent; - // avoid resizing parents to compute the limiter - while (parent && (parent->getResizeFromChildW() || parent->isGroupList() )) - { - // NB nico : the dynamic_cast for CGroupList is bad!! - // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords - // ... - parent = parent->getParent(); - } - if (parent) - { - if (_ClampRight) - { - sint32 parentRight = parent->getXReal() + parent->getWReal() - (sint32) _AutoClampOffset; - setLineMaxW(std::max((sint32) 0, parentRight - _XReal)); - } - else - { - sint32 parentLeft = parent->getXReal() + (sint32) _AutoClampOffset; - setLineMaxW(std::max((sint32) 0, _XReal + _WReal - parentLeft)); - } - } - } - } - - if(_InvalidTextContext) - updateTextContext(); - - CViewBase::updateCoords (); -} - -// *************************************************************************** -sint CViewText::getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine /* = true*/) const -{ - if (index > _Text.length()) return -1; - if (_MultiLine) - { - uint charIndex = 0; - for(sint i = 0; i < (sint) _Lines.size(); ++i) - { - CLine &currLine = *_Lines[i]; - uint newCharIndex = charIndex + currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); - if (newCharIndex > index) - { - if (i != 0 && cursorDisplayedAtEndOfPreviousLine && charIndex == index) - { - return i - 1; - } - else - { - return i; - } - } - charIndex = newCharIndex; - } - return (sint)_Lines.size() - 1; - } - else - { - return 0; - } -} - -// *************************************************************************** -sint CViewText::getLineStartIndex(uint line) const -{ - uint charIndex = 0; - if (line >= _Lines.size()) return -1; - for(uint i = 0; i < line; ++i) - { - CLine &currLine = *_Lines[i]; - charIndex += currLine.getNumChars() + currLine.getEndSpaces() + (currLine.getLF() ? 1 : 0); - } - // skip all spaces at start of line (unless there are only spaces in the line) - std::string::size_type nextPos = _Text.find_first_not_of((ucchar) ' ', charIndex); - if (nextPos != std::string::npos) - { - if (getLineFromIndex(charIndex) == (sint) line) - { - return (sint) nextPos; - } - } - return charIndex; -} - -// *************************************************************************** -void CViewText::getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const -{ - sint startIndex = getLineStartIndex(line); - if (startIndex == -1) - { - index = -1; - endOfPreviousLine = false; - return; - } - index = startIndex + _Lines[line]->getNumChars() + _Lines[line]->getEndSpaces(); - endOfPreviousLine = !_Lines[line]->getLF(); -} - -// *************************************************************************** -void CViewText::setHardText (const std::string &ht) -{ -// ucstring Text = ucstring(ht); - ucstring Text; - if ((ht.size()>2) && (ht[0] == 'u') && (ht[1] == 'i')) - Text = CI18N::get (ht); - else - Text.fromUtf8(ht); - setText(Text); -} - -// *************************************************************************** -string CViewText::getColorAsString() const -{ - return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); -} - -// *************************************************************************** -void CViewText::setColorAsString(const string &ht) -{ - _Color = convertColor (ht.c_str()); -} - -// *************************************************************************** -NLMISC::CRGBA CViewText::getColorRGBA() const -{ - return _Color; -} - -// *************************************************************************** -void CViewText::setColorRGBA(NLMISC::CRGBA col) -{ - _Color = col; -} - -// *************************************************************************** -void CViewText::getCharacterPositionFromIndex(sint index, bool cursorAtPreviousLineEnd, sint &x, sint &y, sint &height) const -{ - NLMISC::clamp(index, 0, (sint) _Text.length()); - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - height = getFontHeight(); - // - if (_MultiLine) - { - uint charIndex = 0; - // special case for end of text - if (index == (sint) _Text.length()) - { - y = 0; - if (_Lines.empty()) - { - x = 0; - } - else - { - CLine &lastLine = *_Lines.back(); - x = (sint) (lastLine.getWidth() + lastLine.getEndSpaces() * lastLine.getSpaceWidth()); - sint nMaxWidth = getCurrentMultiLineMaxW(); - x = std::min(x, nMaxWidth); - } - return; - } - for(sint i = 0; i < (sint) _Lines.size(); ++i) - { - if (i != 0 && charIndex == (uint) index && cursorAtPreviousLineEnd) - { - // should display the character at the end of previous line - CLine &currLine = *_Lines[i - 1]; - y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - i)); - x = (sint) (currLine.getWidth() + currLine.getEndSpaces() * currLine.getSpaceWidth()); - sint nMaxWidth = getCurrentMultiLineMaxW(); - x = std::min(x, nMaxWidth); - return; - } - CLine &currLine = *_Lines[i]; - uint newCharIndex = charIndex + currLine.getNumChars() + currLine.getEndSpaces() + (_Lines[i]->getLF() ? 1 : 0); - if ((sint) newCharIndex > index) - { - // ok, this line contains the character, now, see which word contains it. - y = (sint) ((_FontHeight + _MultiLineSpace) * (_Lines.size() - 1 - i)); - // see if the index is in the spaces at the end of line - if (index - charIndex >= currLine.getNumChars()) - { - uint numSpaces = index - charIndex - currLine.getNumChars(); - x = (sint) (currLine.getWidth() + numSpaces * _SpaceWidth); - sint nMaxWidth = getCurrentMultiLineMaxW(); - x = std::min(x, nMaxWidth); - return; - } - // now, search containing word in current line - float px = (float)_FirstLineX; - for(uint k = 0; k < currLine.getNumWords(); ++k) - { - CWord &currWord = currLine.getWord(k); - if ((sint) (charIndex + currWord.NumSpaces + currWord.Text.length()) >= index) - { - // character is in currWord or the in spaces preceding it - // check if the character is in the word - if ((uint) (index - charIndex) > currWord.NumSpaces) - { - // get the x position - ucstring subStr = currWord.Text.substr(0, index - charIndex - currWord.NumSpaces); - // compute the size - UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); - x = (sint) (px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth()); - height = getFontHeight(); - return; - } - else - { - // character is in the spaces preceding the word - x = (sint) (px + currLine.getSpaceWidth() * (index - charIndex)); - height = getFontHeight(); - return; - } - } - charIndex += (uint)currWord.Text.length() + currWord.NumSpaces; - px += currWord.NumSpaces * currLine.getSpaceWidth() + currWord.Info.StringWidth; - } - } - charIndex = newCharIndex; - } - - } - else - { - // get the x position - ucstring subStr = _Text.substr(0, index); - // compute the size - UTextContext::CStringInfo si = TextContext->getStringInfo(subStr); - y = 0; - x = (sint) si.StringWidth; - } -} - -// *************************************************************************** -// Tool fct : From a word and a x coordinate, give the matching character index -static uint getCharacterIndex(const ucstring &textValue, float x) -{ - float px = 0.f; - UTextContext::CStringInfo si; - ucstring singleChar(" "); - uint i; - for (i = 0; i < textValue.length(); ++i) - { - // get character width - singleChar[0] = textValue[i]; - si = CViewRenderer::getTextContext()->getStringInfo(singleChar); - px += si.StringWidth; - // the character is at the i - 1 position - if (px > x) - { - // if the half of the character is after the cursor, then prefer select the next one (like in Word) - if(px-si.StringWidth/2 < x) - i++; - break; - } - } - return i; -} - -// *************************************************************************** -void CViewText::getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &cursorAtPreviousLineEnd) const -{ - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - - // setup the text context - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); - // find the line where the character is -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint charPos = 0; - if (_MultiLine) - { - // seek the line - float py = 0.f; - if (py > y) - { - index = (uint)_Text.length(); - cursorAtPreviousLineEnd = false; - return; - } - sint line; - for (line = (uint)_Lines.size() - 1; line >= 0; --line) - { - float newPy = py + _FontHeight + _MultiLineSpace; - if (newPy > y) - { - break; - } - py = newPy; - } - if (line == -1) - { - index = 0; - cursorAtPreviousLineEnd = false; - return; // above the first line, so take character 0 - } - // compute character index at start of line - sint i; - for (i = 0; i < line; ++i) - { - charPos += _Lines[i]->getNumChars() + _Lines[i]->getEndSpaces() + (_Lines[i]->getLF() ? 1 : 0); - } - // seek word that contains the character - CLine &currLine = *_Lines[line]; - // See if character is in the ending spaces - if (x >= (sint) currLine.getWidth()) - { - // Add _SpaceWidth/2 to select between chars - sint numSpaces = _SpaceWidth != 0 ? (sint) (((float) x + _SpaceWidth/2 - currLine.getWidth()) / _SpaceWidth) - : 0; - clamp(numSpaces, 0, (sint)currLine.getEndSpaces()); - index = charPos + currLine.getNumChars() + numSpaces; - cursorAtPreviousLineEnd = !_Lines[i]->getLF(); - return; - } - - float px = (float)_FirstLineX; - for(uint k = 0; k < currLine.getNumWords(); ++k) - { - CWord &currWord = currLine.getWord(k); - float spacesWidth = currLine.getSpaceWidth() * currWord.NumSpaces; - float newPx = px + currWord.Info.StringWidth + spacesWidth; - if (newPx >= x) // if the word contains the x position.. - { - if (x < (px + spacesWidth)) - { - // the coords x is in the spaces that are preceding the word - // Add spaceWidth/2 to select between chars - sint numSpaces = currLine.getSpaceWidth() != 0 ? (sint) ((x + currLine.getSpaceWidth()/2 - px) / currLine.getSpaceWidth()) - : 0; - clamp(numSpaces, 0, (sint)currWord.NumSpaces); - index = numSpaces + charPos; - cursorAtPreviousLineEnd = false; - return; - } - else - { - // the coord is in the word itself - index = charPos + currWord.NumSpaces + getCharacterIndex(currWord.Text, (float) x - (px + spacesWidth)); - cursorAtPreviousLineEnd = false; - return; - } - } - px = newPx; - charPos += (uint)currWord.Text.length() + currWord.NumSpaces; - } - index = charPos; - cursorAtPreviousLineEnd = false; - return; - } - else - { - cursorAtPreviousLineEnd = false; - if (y < 0) - { - index = (uint)_Text.length(); - return; - } - if (y > (sint) _FontHeight) - { - index = 0; - return; - } - index = getCharacterIndex(_Text, (float) x); - return; - } -} - -// *************************************************************************** -void CViewText::enableStringSelection(uint start, uint end) -{ - _TextSelection= true; - _TextSelectionStart= start; - _TextSelectionEnd= end; -} - -// *************************************************************************** -void CViewText::disableStringSelection() -{ - _TextSelection= false; - _TextSelectionStart= 0; - _TextSelectionEnd= std::numeric_limits::max(); -} - -// *************************************************************************** -void CViewText::setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd) -{ - sint quadStart= charStart; - sint quadSize= charEnd-charStart; - sint j; - for(j=0;jsetStringSelection(stringId, quadStart, quadSize); -} - -// *************************************************************************** -void CViewText::clearLines() -{ - for(uint k = 0; k < _Lines.size(); ++k) - { - _Lines[k]->clear(); - } - _Lines.clear(); -} - -// *************************************************************************** -uint CViewText::getNumLine() const -{ - if (_MultiLine) - { - return (uint)_Lines.size(); - } - else - { - return _Text.empty() ? 0 : 1; - } -} - -// *************************************************************************** -uint CViewText::getFirstLineX() const -{ - return _FirstLineX; -} - -// *************************************************************************** -uint CViewText::getLastLineW () const -{ - if (!_Lines.empty()) - return (uint)_Lines.back()->getWidth(); - return 0; -} - -// *************************************************************************** -void CViewText::setFirstLineX(uint firstLineX) -{ - _FirstLineX = firstLineX; -} - -///////////////////////////////////// -// CViewText::CLine implementation // -///////////////////////////////////// - -// *************************************************************************** -CViewText::CLine::CLine() : _NumChars(0), - _NumSpaces(0), - _SpaceWidth(0.f), - _StringLine(0), - _WidthWithoutSpaces(0.f), - _EndSpaces(0), - _HasLF(false) -{ -} - -// *************************************************************************** -void CViewText::CLine::addWord(const ucstring &text, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth) -{ - CWord word; - word.build(text, numSpaces); - word.Format= wordFormat; - addWord(word, fontWidth); -} - -// *************************************************************************** -void CViewText::CLine::addWord(const CWord &word, uint fontWidth) -{ - _Words.push_back(word); - _NumChars += word.NumSpaces + uint(word.Text.length()); - _NumSpaces += word.NumSpaces; - if (fabsf(word.Info.StringLine) > fabsf(_StringLine)) - { - _StringLine = word.Info.StringLine; - } - // the width of the line must reach at least the Tab - _WidthWithoutSpaces= max(_WidthWithoutSpaces, word.Format.TabX * float(fontWidth)); - // append the text space - _WidthWithoutSpaces += word.Info.StringWidth; -} - -// *************************************************************************** -void CViewText::CLine::clear() -{ - for(uint k = 0; k < _Words.size(); ++k) - { - if (_Words[k].Index != 0xffffffff) - CViewRenderer::getTextContext()->erase(_Words[k].Index); - } - _Words.clear(); - _NumChars = 0; - _SpaceWidth = 0.f; -} - -// *************************************************************************** -void CViewText::CLine::resetTextIndex() -{ - for(uint k = 0; k < _Words.size(); ++k) - { - _Words[k].Index = 0xffffffff; - } -} - -// *************************************************************************** -void CViewText::CWord::build(const ucstring &text, uint numSpaces/*=0*/) -{ - Text = text; - NumSpaces = numSpaces; - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - Index = TextContext->textPush(text); - Info = TextContext->getStringInfo(Index); -} - -// *************************************************************************** -void CViewText::removeEndSpaces() -{ - sint i = (sint)_Text.size()-1; - while ((i>=0) && ((_Text[i] < 0x20) || (_Text[i] == ' '))) - { - i--; - } - _Text.resize (i+1); -} - -// *************************************************************************** -sint32 CViewText::getMaxUsedW() const -{ - static const ucstring spaceStr(" \t"); - static const ucstring lineFeedStr("\n"); - float maxWidth = 0; - - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); - - TCharPos linePos = 0; - while (linePos < _Text.length()) - { - // Get the end of the line - float lineWidth = 0; - TCharPos lineEnd; - lineEnd = _Text.find_first_of(lineFeedStr, linePos); - if (lineEnd == std::string::npos) - { - lineEnd = _Text.length(); - } - - ucstring lineValue; - lineValue = _Text.substr(linePos, lineEnd - linePos); - - TCharPos currPos = 0; - while (currPos != lineValue.length()) - { - TCharPos spaceEnd; - TCharPos wordEnd; - uint numSpaces; - - // Skip spaces and count them - spaceEnd = lineValue.find_first_not_of(spaceStr, currPos); - if (spaceEnd == std::string::npos) - { - spaceEnd = lineValue.length(); - } - numSpaces = (uint) (spaceEnd - currPos); - - // Get word until a space or a \n is encountered - wordEnd = lineValue.find_first_of(spaceStr, spaceEnd); - if (wordEnd == std::string::npos) - { - wordEnd = lineValue.length(); - } - - ucstring wordValue; - wordValue = lineValue.substr(spaceEnd, wordEnd - spaceEnd); - - // compute width of word - UTextContext::CStringInfo si; - si = TextContext->getStringInfo(wordValue); - - // compute size of spaces + word - lineWidth += numSpaces * _SpaceWidth + si.StringWidth; - - currPos = wordEnd; - } - - // Update line width - if (lineWidth > maxWidth) - maxWidth = lineWidth; - - linePos = lineEnd+1; - } - - return (sint32)maxWidth; -} - -// *************************************************************************** -sint32 CViewText::getMinUsedW() const -{ - static const ucstring spaceOrLineFeedStr(" \n\t"); - sint32 maxWidth = 0; - - // Not multi line ? Same size than min - if (!_MultiLine) - return getMaxUsedW(); - - // If we can clip word, size of the largest word - if (_TextMode == ClipWord) - { - // No largest font parameter, return the font height - return _FontHeight; - } - // If we can't clip the words, return the size of the largest word - else if ((_TextMode == DontClipWord) || (_TextMode == Justified)) - { - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); - - // Current position in text - TCharPos currPos = 0; - while (currPos < _Text.length()) - { - // Current word - ucstring wordValue; - UTextContext::CStringInfo si; - TCharPos wordEnd; - - // Get word until a space or a \n is encountered - currPos = _Text.find_first_not_of(spaceOrLineFeedStr, currPos); - if (currPos == std::string::npos) - break; - wordEnd = _Text.find_first_of(spaceOrLineFeedStr, currPos); - if (wordEnd == std::string::npos) - wordEnd = _Text.length(); - - // Get the word - wordValue = _Text.substr(currPos, wordEnd - currPos); - - // Compute width of word - si = TextContext->getStringInfo(wordValue); - - // Larger ? - sint32 stringWidth = (sint32)si.StringWidth; - if (stringWidth>maxWidth) - maxWidth = stringWidth; - - // Next word - currPos = wordEnd; - } - } - - return maxWidth; -} - -// *************************************************************************** -void CViewText::onInvalidateContent() -{ - _InvalidTextContext= true; - invalidateCoords(); -} - -// *************************************************************************** -void CViewText::computeFontSize () -{ - NL3D::UTextContext *TextContext = CViewRenderer::getTextContext(); - TextContext->setHotSpot (UTextContext::BottomLeft); - TextContext->setShaded (_Shadow); - TextContext->setFontSize (_FontSize); - - // Letter size - UTextContext::CStringInfo si = TextContext->getStringInfo(ucstring("|")); // for now we can't now that directly from UTextContext - _FontHeight = (uint) si.StringHeight + (_Shadow?1:0); - _FontLegHeight = (uint) si.StringLine + (_Shadow?1:0); - - // Space width - si = TextContext->getStringInfo(ucstring(" ")); - _SpaceWidth = si.StringWidth; - - // Font Width - si = TextContext->getStringInfo(ucstring("_")); - _FontWidth = (uint)si.StringWidth; -} - - -// *************************************************************************** -static inline bool isColorTag(const ucstring &s, uint index, uint textSize) -{ - // Format is @{RGBA} - if(s[index]=='@') - { - if( textSize>index+1 && s[index+1]=='{') - { - // verify 1st letter is a xdigit - if( textSize>index+2 && isxdigit(s[index+2])) - { - // We have good chance its a color tag. Do last verification - if(textSize>index+6 && s[index+6]=='}') - { - return true; - } - } - } - } - - return false; -} - -// *************************************************************************** -// isColorTag must be ok. -static inline CRGBA getColorTag(const ucstring &s, uint &index) -{ - // extract the color string: "FABC" - char tmpCol[5]; - for(uint i=0;i<4;i++) - tmpCol[i]= (char)s[index+2+i]; - tmpCol[4]= 0; - - // Convert to color - CRGBA color; - uint pCol; - sscanf(tmpCol, "%x", &pCol); - // Transform 4 bits to 8 bit. - color.R= (pCol>>12)&0xF; color.R+= color.R<<4; - color.G= (pCol>>8)&0xF; color.G+= color.G<<4; - color.B= (pCol>>4)&0xF; color.B+= color.B<<4; - color.A= (pCol)&0xF; color.A+= color.A<<4; - - // skip tag - index+= 7; - - return color; -} - - -// *************************************************************************** -const uint MaxTabDigit= 3; -static inline bool isTabTag(const ucstring &s, uint index, uint textSize) -{ - // Format is @{Tvalue}, where value ,1,2,3 digit. - if(s[index]=='@') - { - if( textSize>index+1 && s[index+1]=='{') - { - if( textSize>index+2 && s[index+2]=='T') - { - // We have good chance its a Tab tag. Do last verification - for(uint i=4;i<4+MaxTabDigit;i++) - { - if(textSize>index+i && s[index+i]=='}') - { - return true; - } - } - } - } - } - - return false; -} - -// *************************************************************************** -// isTabTag must be ok. -static inline sint getTabTag(const ucstring &s, uint &index) -{ - // extract the tab min X value - char tmpTab[MaxTabDigit+1]; - uint i; - for(i=0;iindex+1 && s[index+1]=='{') - { - if( textSize>index+2 && s[index+2]=='H') - { - uint i = 3; - while (textSize>index+i && s[index+i]!='}') - i++; - - if (textSize>index+i && s[index+i]=='}') - return true; - } - } - } - - return false; -} - -// *************************************************************************** -// isTooltipTag must be ok. -static inline ucstring getTooltipTag(const ucstring &s, uint &index) -{ - ucstring result; - uint i = 3; - while (s[index+i] != '}') - { - result += s[index+i]; - i++; - } - - // skip tag - index += i+1; - - return result; -} - - -// *************************************************************************** -void CViewText::buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips) -{ - formatTags.clear(); - tooltips.clear(); - - // Build the text without the formatTags, and get the color tags separately - textBuild.reserve(text.size()); - uint textSize= (uint)text.size(); - // Must herit all the props from old tags. - CViewText::CFormatTag precTag; // set default. - precTag.Index = 0; - for (uint i = 0; i < textSize;) - { - if(isColorTag(text, i, textSize)) - { - // get old tag. - CViewText::CFormatTag ct= precTag; - // get new color and skip tag. - ct.Color= getColorTag(text, i); - ct.Index= (uint)textBuild.size(); - formatTags.push_back(ct); - } - else if(isTabTag(text, i, textSize)) - { - // get old tag. - CViewText::CFormatTag ct= precTag; - // get new Tab and skip tag. - ct.TabX= getTabTag(text, i); - ct.Index= (uint)textBuild.size(); - formatTags.push_back(ct); - } - else if(isTooltipTag(text, i, textSize)) - { - // get old tag. - CViewText::CFormatTag ct= precTag; - // get new Tab and skip tag. - ucstring uitt = getTooltipTag(text, i); - if (uitt.empty()) - { - ct.IndexTt= -1; - } - else - { - ct.IndexTt= (uint)tooltips.size(); - tooltips.push_back(uitt); - } - - ct.Index= (uint)textBuild.size(); - formatTags.push_back(ct); - } - else - { - bool lineFeed= text[i]=='\n'; - - // append to textBuild - textBuild+= text[i]; - ++i; - - // if \n, reset tabulations - if(lineFeed) - { - CViewText::CFormatTag ct= precTag; - ct.TabX= 0; - ct.Index= (uint)textBuild.size(); - formatTags.push_back(ct); - } - } - // bkup - if(!formatTags.empty()) - precTag= formatTags.back(); - } -} - - -// *************************************************************************** -void CViewText::setTextFormatTaged(const ucstring &text) -{ - - // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp - ucstring tempText; - // static to avoid reallocation - static std::vector tempFormatTags; - static std::vector tempTooltips; - buildFormatTagText(text, tempText, tempFormatTags, tempTooltips); - setCase (tempText, _CaseMode); - - // compare Tag arrays - bool sameTagArray= false; - if(_FormatTags.size()==tempFormatTags.size()) - { - sameTagArray= true; - for(uint i=0;i<_FormatTags.size();i++) - { - if(!_FormatTags[i].sameTag(tempFormatTags[i])) - { - sameTagArray= false; - break; - } - } - } - - // test transformed text with current one - if(tempText!=_Text || !sameTagArray ) - { - // copy tags - _FormatTags= tempFormatTags; - // Copy to Text (preserve Memory) - contReset(_Text); - _Text= tempText; - - CInterfaceGroup *parent = getParent(); - - // Delete old dynamic tooltips - for (uint i=0 ; i<_Tooltips.size() ; ++i) - { - if (parent) - parent->delCtrl(_Tooltips[i]); - else - delete _Tooltips[i]; - } - _Tooltips.clear(); - - // Add new dynamic tooltips - for (uint i=0 ; isetId(_Id+"_tt"+toString(i)); - pTooltip->setAvoidResizeParent(avoidResizeParent()); - pTooltip->setRenderLayer(getRenderLayer()); - pTooltip->setDefaultContextHelp(CI18N::get(tempTooltips[i].toString())); - pTooltip->setParentPos(this); - pTooltip->setParentPosRef(Hotspot_BR); - pTooltip->setPosRef(Hotspot_BR); - pTooltip->setToolTipParent(CCtrlBase::TTWindow); - pTooltip->setToolTipParentPosRef(Hotspot_TTAuto); - pTooltip->setToolTipPosRef(Hotspot_TTAuto); - pTooltip->setActive(true); - - _Tooltips.push_back(pTooltip); - - if (parent) - { - pTooltip->setParent(parent); - parent->addCtrl(_Tooltips.back()); - } - } - - if (parent) - _Setuped = true; - else - _Setuped = false; - - invalidateContent (); - } - - // color format is available only if multilined - if (!_MultiLine) - nlwarning( toString("ViewText isn't multilined : uc_hardtext_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); -} - - -void CViewText::setSingleLineTextFormatTaged(const ucstring &text) -{ - // to allow cache (avoid infinite recurse in updateCoords() in some case), compute in temp - ucstring tempText; - static std::vector tempLetterColors; - static std::vector tempTooltips; - - // parse text - buildFormatTagText(text, tempText, tempLetterColors, tempTooltips); - setCase (tempText, _CaseMode); - - // decal for spaces (not inserted in VertexBuffer) - uint textIndex = 0; - uint spacesNb = 0; - for(uint i=0; icreateLetterColors(); - for(uint i=0; ipushLetterColor(formatTag.Index, formatTag.Color); - } - - // test transformed text with current one - if(tempText!=_Text || !_LetterColors || !_LetterColors->isSameLetterColors(letterColors)) - { - _LetterColors = letterColors; - - TextContext->setLetterColors(letterColors, _Index); - - // Copy to Text (preserve Memory) - contReset(_Text); - _Text= tempText; - invalidateContent (); - } - - // this color format is available only if not multilined - if (_MultiLine) - nlwarning( toString("ViewText is multilined : uc_hardtext_single_line_format will not act as wanted !\n%s", text.toString().c_str()).c_str() ); -} - - -// *************************************************************************** -bool CViewText::isFormatTagChange(uint textIndex, uint ctIndex) const -{ - if(ctIndex>=_FormatTags.size()) - return false; - // return true if the textIndex is > (eg if some skip with spaces) or = (common case) - return _FormatTags[ctIndex].Index <= textIndex; -} - -// *************************************************************************** -void CViewText::getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const -{ - // support the possible case with multiple color tags with same textIndex. - while(ctIndex<_FormatTags.size() && _FormatTags[ctIndex].Index<=textIndex) - { - // Take the last tag. - wordFormat.Color= _FormatTags[ctIndex].Color; - wordFormat.TabX= _FormatTags[ctIndex].TabX; - wordFormat.IndexTt= _FormatTags[ctIndex].IndexTt; - // skip it. - ctIndex++; - } -} - - -// *************************************************************************** - -void CViewText::setCaseMode (TCaseMode caseMode) -{ - _CaseMode = caseMode; - setCase (_Text, _CaseMode); -} - -// *************************************************************************** - -TCaseMode CViewText::getCaseMode () const -{ - return _CaseMode; -} - -// *************************************************************************** - -void CViewText::resetTextIndex() -{ - _Index = 0xffffffff; - for(uint k = 0; k < _Lines.size(); ++k) - _Lines[k]->resetTextIndex(); -} - -// *************************************************************************** -void CViewText::setup() -{ - _Setuped= true; - - // Add dynamic tooltips - for (uint i=0 ; i<_Tooltips.size() ; ++i) - { - CInterfaceGroup *parent = getParent(); - if (parent) - { - _Tooltips[i]->setParent(parent); - parent->addCtrl(_Tooltips.back()); - } - } -} - -// *************************************************************************** -void CViewText::serial(NLMISC::IStream &f) -{ - #define SERIAL_UINT(val) { uint32 tmp = (uint32) val; f.serial(tmp); val = (uint) tmp; } - #define SERIAL_SINT(val) { sint32 tmp = (sint32) val; f.serial(tmp); val = (sint) tmp; } - CViewBase::serial(f); - SERIAL_SINT(_FontSize); - SERIAL_UINT(_FontWidth); - SERIAL_UINT(_FontHeight); - SERIAL_UINT(_FontLegHeight); - f.serial(_SpaceWidth); - f.serial(_Color); - f.serial(_Shadow); - f.serialEnum(_CaseMode); - f.serial(_ShadowColor); - f.serial(_LineMaxW); - f.serial(_SingleLineTextClamped); - f.serial(_MultiLine); - f.serial(_MultiLineMaxWOnly); - f.serial(_MultiLineClipEndSpace); - f.serial(_AutoClampOffset); - f.serialEnum(_TextMode); - SERIAL_SINT(_MultiLineSpace); - SERIAL_SINT(_LastMultiLineMaxW); - f.serial(_MultiMaxLine); - - bool hasTag = !_FormatTags.empty(); - f.serial(hasTag); - if (f.isReading()) - { - ucstring text; - f.serial(text); - if (hasTag) - { - if (_MultiLine) - { - setTextFormatTaged(text); - } - else - { - setSingleLineTextFormatTaged(text); - } - } - else - { - setText(text); - } - } - else - { - f.serial(_Text); - } - - #undef SERIAL_UINT - #undef SERIAL_SINT -} - - -// *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_text.h b/code/ryzom/client/src/interface_v3/view_text.h deleted file mode 100644 index 9fe54825b..000000000 --- a/code/ryzom/client/src/interface_v3/view_text.h +++ /dev/null @@ -1,413 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_VIEW_TEXT_H -#define NL_VIEW_TEXT_H - -#include "nel/gui/view_base.h" -#include "nel/gui/string_case.h" -#include "nel/3d/u_text_context.h" - -namespace NLGUI -{ - class CCtrlToolTip; -} - - -/** - * class implementing a text view - * \author Matthieu 'TrapII' Besson - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CViewText : public CViewBase -{ -public: - enum TTextMode { ClipWord, DontClipWord, Justified }; -public: - - DECLARE_UI_CLASS(CViewText) - - - /// Constructor - CViewText (const TCtorParam ¶m); - - /// Constructor - CViewText (const std::string& id, const std::string Text="", sint FontSize=12, - NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false); - - virtual ~CViewText(); - - CViewText &operator=(const CViewText &vt); - - void parseTextOptions (xmlNodePtr cur); - bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - /// Updating - virtual void draw (); - void updateTextContext (); - virtual void checkCoords(); - virtual void updateCoords(); - virtual void onAddToGroup(); - - /// From CInterfaceElement - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - - /// Accessors - - /// Set - - void setText (const ucstring &text); - void setFontSize (sint nFontSize); - void setColor (const NLMISC::CRGBA &color); - void setShadow (bool bShadow); - void setShadowColor (const NLMISC::CRGBA &color); - void setLineMaxW (sint nMaxW, bool invalidate=true); - void setMultiLine (bool bMultiLine); - void setMultiLineSpace (sint nMultiLineSpace); - void setMultiLineMaxWOnly (bool state); - void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance - void setFirstLineX (uint firstLineX); - void setMultiMaxLine(uint l) { _MultiMaxLine = l; } - - // Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF - void enableStringSelection(uint start, uint end); - void disableStringSelection(); - - /// Get - - ucstring getText() const { return _Text; } - sint getFontSize() const; - NLMISC::CRGBA getColor() { return _Color; } - bool getShadow() { return _Shadow; } - NLMISC::CRGBA getShadowColor() { return _ShadowColor; } - sint getLineMaxW() const { return _LineMaxW; } - bool getMultiLine() const { return _MultiLine; } - sint getMultiLineSpace() const { return _MultiLineSpace; } - bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; } - uint32 getMultiMaxLine() const { return _MultiMaxLine; } - - // get current Hint font width, in pixels - uint getFontWidth() const; - // get current font height, in pixels - uint getFontHeight() const; - // get current font leg height, in pixels - uint getFontLegHeight() const; - // Set the display mode (supported with multiline only for now) - void setTextMode(TTextMode mode); - TTextMode getTextMode() const { return _TextMode; } - uint getNumLine() const; - uint getFirstLineX() const; - uint getLastLineW () const; - void setUnderlined (bool underlined) { _Underlined = underlined; } - bool getUnderlined () const { return _Underlined; } - // true if the viewText is a single line clamped. - bool isSingleLineTextClamped() const {return _SingleLineTextClamped;} - - // Character positions - - /** Get position of the ith character, position are relative to the BR corner of the text. - * \param lineEnd. When set to true, return the coordinate of the previous line if the index is at the start of a line. - * When looking at standard edit box, we see that if a line is split accross to line with no - * This also returns the height of the line - */ - void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const; - /** From a coordinate relative to the BR BR corner of the text, return the index of a character. - * If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text) - */ - void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const; - /** From a character index, get the index of the line it belongs to, or -1 if the index is invalid - * \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index - */ - sint getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine = true) const; - /// From a line number, get the character at which it starts, or -1 if invalid - sint getLineStartIndex(uint line) const; - /// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid - void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; - - std::string getHardText() const { std::string result; _Text.toString (result); return result; } - void setHardText (const std::string &ht); - - std::string getColorAsString() const; - void setColorAsString(const std::string &ht); - - NLMISC::CRGBA getColorRGBA() const; - void setColorRGBA(NLMISC::CRGBA col); - - virtual sint32 getAlpha() const { return _Color.A; } - virtual void setAlpha (sint32 a) { _ShadowColor.A = _Color.A = (uint8)a; } - - /** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association - */ - void setTextFormatTaged(const ucstring &text); - - void setSingleLineTextFormatTaged(const ucstring &text); - - // Remove end space - void removeEndSpaces(); - - // Reset the text index because the text context has changed - void resetTextIndex(); - - // Case mode - void setCaseMode (TCaseMode caseMode); - TCaseMode getCaseMode () const; - - // OverExtendViewText - void setOverExtendViewText(bool state) {_OverExtendViewText= state;} - bool getOverExtendViewText() const {return _OverExtendViewText;} - - // OverExtendViewTextUseParentRect - void setOverExtendViewTextUseParentRect(bool state) {_OverExtendViewTextUseParentRect= state;} - bool getOverExtendViewTextUseParentRect() const {return _OverExtendViewTextUseParentRect;} - - // see if text ellipsis if done at right side of the text - bool isClampRight() const { return _ClampRight; } - - int luaSetLineMaxW(CLuaState &ls); - - REFLECT_EXPORT_START(CViewText, CViewBase) - REFLECT_STRING("hardtext", getHardText, setHardText); - REFLECT_UCSTRING("uc_hardtext", getText, setText); - REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged); - REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged); - REFLECT_STRING ("color", getColorAsString, setColorAsString); - REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); - REFLECT_SINT32 ("alpha", getAlpha, setAlpha); - REFLECT_BOOL ("overExtendViewText", getOverExtendViewText, setOverExtendViewText); - REFLECT_BOOL ("overExtendViewTextUseParentRect", getOverExtendViewTextUseParentRect, setOverExtendViewTextUseParentRect); - REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW); - REFLECT_EXPORT_END - - - virtual void serial(NLMISC::IStream &f); - -protected: - - /// Text to display. - ucstring _Text; - /// index of the computed String associated to this text control - uint _Index; - /// info on the computed String associated to this text control - NL3D::UTextContext::CStringInfo _Info; - /// the font size - sint _FontSize; - // width of the font in pixel. Just a Hint for tabing format (computed with '_') - uint _FontWidth; - // height of the font in pixel. - // use getFontHeight - uint _FontHeight; - uint _FontLegHeight; - float _SpaceWidth; - /// the text color - NLMISC::CRGBA _Color; - /// the shadow mode - bool _Shadow; - /// the case mode - TCaseMode _CaseMode; - /// the text shadow color - NLMISC::CRGBA _ShadowColor; - /// Is the line (under p loop) should be considered at bottom (if false bottom is under p leg) - /// maxw for the line/multiline - sint32 _LineMaxW; - /// For single line, true if the text is clamped (ie displayed with "...") - bool _SingleLineTextClamped; - - /// Multiple lines handling - bool _MultiLine; - bool _MultiLineMaxWOnly; - bool _MultiLineClipEndSpace; - uint8 _AutoClampOffset; - TTextMode _TextMode; - sint _MultiLineSpace; - sint _LastMultiLineMaxW; - uint32 _MultiMaxLine; - - - /// FormatTag handling - struct CFormatInfo - { - // The color to change - NLMISC::CRGBA Color; - // The Tabulation to apply, in number of "_" characters. - uint TabX; - // Index in vector - sint IndexTt; - - CFormatInfo() - { - Color= NLMISC::CRGBA::White; - TabX= 0; - IndexTt = -1; - } - - bool operator==(const CFormatInfo &o) const {return Color==o.Color && TabX==o.TabX && IndexTt==o.IndexTt;} - bool operator!=(const CFormatInfo &o) const {return !operator==(o);} - }; - struct CFormatTag : public CFormatInfo - { - uint Index; - - // compare 2 tags, not a tag and a CFormatInfo - bool sameTag(const CFormatTag &o) const - { - return CFormatInfo::operator==(o) && Index==o.Index; - } - }; - std::vector _FormatTags; - - /// Get the current maxW for multiline, accordgin to parent and _MultiLineOptionMaxW - sint getCurrentMultiLineMaxW() const; - - - - - NL3D::ULetterColors * _LetterColors; - -private: - // A word in a line - class CWord - { - public: - // default ctor - CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {} - ucstring Text; - uint Index; // index of the info for this word - NL3D::UTextContext::CStringInfo Info; - uint NumSpaces; // number of spaces before this word - // The specialized color/format of this word. White if none - CFormatInfo Format; - public: - // build from a string, using the current text context - void build(const ucstring &text, uint numSpaces= 0); - }; - typedef std::vector TWordVect; - - // A line of text (which is made of one word with space, or of several words with no spaces in them) - class CLine : public NLMISC::CRefCount - { - public: - // ctor - CLine(); - // Clear the line & remove text contexts - void clear(); - // Add a new word (and its context) in the line + a number of spaces to append at the end of the line - void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth); - void addWord(const CWord &word, uint fontWidth); - uint getNumWords() const { return (uint)_Words.size(); } - CWord &getWord(uint index) { return _Words[index]; } - float getSpaceWidth() const { return _SpaceWidth; } - void setSpaceWidth(float width) { _SpaceWidth = width; } - // Get the number of chars in the line, not counting the end spaces, but couting the spaces in words - uint getNumChars() const { return _NumChars; } - // Get the total number of spaces between words (not including those in words, but there should not be if text is justified) - uint getNumSpaces() const { return _NumSpaces; } - float getStringLine() const { return _StringLine; } - float getWidthWithoutSpaces() const { return _WidthWithoutSpaces; } - // get total width including spaces, but not including end spaces - float getWidth() const { return _WidthWithoutSpaces + _SpaceWidth * _NumSpaces; } - // Get the number of spaces at the end of the line - void setEndSpaces(uint numSpaces) { _EndSpaces = numSpaces; } - // Set the number of spaces at the end of the line - uint getEndSpaces() const { return _EndSpaces; } - // Test if there's a line feed at the end of the line - bool getLF() const { return _HasLF; } - void setLF(bool lf) { _HasLF = lf; } - void resetTextIndex(); - private: - TWordVect _Words; - uint _NumChars; - uint _NumSpaces; - float _SpaceWidth; // width of a space, in pixels (used with multispace alignment) - float _StringLine; - float _WidthWithoutSpaces; // width without space (see the Field NumSpaces in the CWord class). - // NB : space inserted inside a word are counted, however! - uint _EndSpaces; // spaces at the end of the line - bool _HasLF; // a linefeed is at end of line (no breaking due to line full) - }; - /// NB : we keep pointers on lines (each line contains a vector, that we don't want to be copied, and this occurs as the vector of lines grows..) - - typedef NLMISC::CSmartPtr TLineSPtr; - typedef std::vector TLinePtVect; -private: - /** Data of the updated text for multiline. It is built from the _Text field in the updateTextContext member function, - * and is used to perform the draw - */ - TLinePtVect _Lines; - - /// if true, and if the view text is isSingleLineTextClamped(), then an over will be drawn, with the text - bool _OverExtendViewText : 1; - /// if true and _OverExtendViewText true too, use the parent rectangle to know if must display the over or not - bool _OverExtendViewTextUseParentRect : 1; - /// Letter selection handling - bool _AutoClamp : 1; - bool _ClampRight : 1; - bool _TextSelection : 1; - bool _InvalidTextContext : 1; - bool _Underlined : 1; - bool _ContinuousUpdate : 1; - bool _Setuped : 1; - - uint _TextSelectionStart; - uint _TextSelectionEnd; - - // First line X coordinate - uint _FirstLineX; - - /// Dynamic tooltips - std::vector _Tooltips; - - -private: - void setup (); - void setupDefault (); - - void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd); - -// void pushString(const ucstring &str, bool deleteSpaceAtStart = false); - - /// \from CInterfaceElement - void onInvalidateContent(); - - // may append a new line, and append a word to the last line (no spaces) - void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat); - // Clear all the lines and free their datas - void clearLines(); - // Update in the case of a multiline text - void updateTextContextMultiLine(uint nMaxWidth); - // Update in the case of a multiline text with justification - void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces); - // Recompute font size info - void computeFontSize (); - - // used for "donctClipWord" case in updateTextContextMultiLineJustified(). currLine is reseted - void addDontClipWordLine(std::vector &currLine); - - // FormatTag build. - static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips); - // FormatTag parsing. - bool isFormatTagChange(uint textIndex, uint ctIndex) const; - void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const; -}; - -#endif // NL_VIEW_TEXT_H - -/* End of view_text.h */ diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.h b/code/ryzom/client/src/interface_v3/view_text_formated.h index 4e60e3f1f..0f8c2d4c0 100644 --- a/code/ryzom/client/src/interface_v3/view_text_formated.h +++ b/code/ryzom/client/src/interface_v3/view_text_formated.h @@ -19,7 +19,7 @@ #ifndef VIEW_TEXT_FORMATED_H #define VIEW_TEXT_FORMATED_H -#include "view_text.h" +#include "nel/gui/view_text.h" /** The same as a view text id, but with some display option * The input is a formated string, every character is copied, but subsitution is done for each character preceded by $ diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h index 91d6b5f6e..f976791be 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ b/code/ryzom/client/src/interface_v3/view_text_id.h @@ -20,7 +20,7 @@ #define NL_VIEW_TEXT_ID_H #include "nel/misc/types_nl.h" -#include "view_text.h" +#include "nel/gui/view_text.h" namespace NLMISC{ class CCDBNodeLeaf; diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 0b96b0782..842267e67 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -37,7 +37,7 @@ #include "interface_v3/input_handler_manager.h" #include "interface_v3/group_editbox.h" #include "interface_v3/group_quick_help.h" -#include "interface_v3/view_text.h" +#include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" #include "interface_v3/ctrl_text_button.h" #include "sound_manager.h" From 69068877fcef2d5e40def4049213fa428f93c779 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 17 Jun 2012 21:21:20 +0200 Subject: [PATCH 076/339] CHANGED: #1471 CGroupWheel is now in NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/group_wheel.h | 35 +++++----- code/nel/src/gui/group_wheel.cpp | 69 +++++++++++++++++++ .../client/src/interface_v3/group_wheel.cpp | 69 ------------------- 3 files changed, 88 insertions(+), 85 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/group_wheel.h (61%) create mode 100644 code/nel/src/gui/group_wheel.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_wheel.cpp diff --git a/code/ryzom/client/src/interface_v3/group_wheel.h b/code/nel/include/nel/gui/group_wheel.h similarity index 61% rename from code/ryzom/client/src/interface_v3/group_wheel.h rename to code/nel/include/nel/gui/group_wheel.h index d2f12ca3c..c2c80dd46 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.h +++ b/code/nel/include/nel/gui/group_wheel.h @@ -21,22 +21,25 @@ #include "nel/gui/interface_group.h" - - -// Special group to handle the mouse wheel message -class CInterfaceGroupWheel : public CInterfaceGroup +namespace NLGUI { -public: - /// Constructor - CInterfaceGroupWheel(const TCtorParam ¶m); - /// Coming from CInterfaceElement - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); -private: - IActionHandler *_AHWheelUp; - CStringShared _AHWheelUpParams; - IActionHandler *_AHWheelDown; - CStringShared _AHWheelDownParams; -}; + + // Special group to handle the mouse wheel message + class CInterfaceGroupWheel : public CInterfaceGroup + { + public: + /// Constructor + CInterfaceGroupWheel(const TCtorParam ¶m); + /// Coming from CInterfaceElement + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + private: + IActionHandler *_AHWheelUp; + CStringShared _AHWheelUpParams; + IActionHandler *_AHWheelDown; + CStringShared _AHWheelDownParams; + }; + +} #endif diff --git a/code/nel/src/gui/group_wheel.cpp b/code/nel/src/gui/group_wheel.cpp new file mode 100644 index 000000000..c7d6a57e2 --- /dev/null +++ b/code/nel/src/gui/group_wheel.cpp @@ -0,0 +1,69 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_wheel.h" + + +NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroupWheel, std::string, "group_wheel"); + +namespace NLGUI +{ + + // ***************************************************************************************************************** + CInterfaceGroupWheel::CInterfaceGroupWheel(const TCtorParam ¶m) : CInterfaceGroup(param) + { + _AHWheelUp = NULL; + _AHWheelDown = NULL; + } + + // ***************************************************************************************************************** + bool CInterfaceGroupWheel::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur, parentGroup)) return false; + CAHManager::getInstance()->parseAH(cur, "on_wheel_up", "on_wheel_up_params", _AHWheelUp, _AHWheelUpParams); + CAHManager::getInstance()->parseAH(cur, "on_wheel_down", "on_wheel_down_params", _AHWheelDown, _AHWheelDownParams); + return true; + } + + // ***************************************************************************************************************** + bool CInterfaceGroupWheel::handleEvent(const NLGUI::CEventDescriptor &event) + { + if (CInterfaceGroup::handleEvent(event)) return true; + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + if (eventDesc.getWheel() > 0 && _AHWheelUp) + { + CAHManager::getInstance()->runActionHandler (_AHWheelUp, this, _AHWheelUpParams); + return true; + } + else if (_AHWheelDown) + { + CAHManager::getInstance()->runActionHandler (_AHWheelDown, this, _AHWheelDownParams); + return true; + } + } + } + return false; + } + +} + diff --git a/code/ryzom/client/src/interface_v3/group_wheel.cpp b/code/ryzom/client/src/interface_v3/group_wheel.cpp deleted file mode 100644 index b8b25c70b..000000000 --- a/code/ryzom/client/src/interface_v3/group_wheel.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_wheel.h" -#include "interface_manager.h" - - - -NLMISC_REGISTER_OBJECT(CViewBase, CInterfaceGroupWheel, std::string, "group_wheel"); - -// ***************************************************************************************************************** -CInterfaceGroupWheel::CInterfaceGroupWheel(const TCtorParam ¶m) : CInterfaceGroup(param) -{ - _AHWheelUp = NULL; - _AHWheelDown = NULL; -} - -// ***************************************************************************************************************** -bool CInterfaceGroupWheel::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur, parentGroup)) return false; - CAHManager::getInstance()->parseAH(cur, "on_wheel_up", "on_wheel_up_params", _AHWheelUp, _AHWheelUpParams); - CAHManager::getInstance()->parseAH(cur, "on_wheel_down", "on_wheel_down_params", _AHWheelDown, _AHWheelDownParams); - return true; -} - -// ***************************************************************************************************************** -bool CInterfaceGroupWheel::handleEvent(const NLGUI::CEventDescriptor &event) -{ - if (CInterfaceGroup::handleEvent(event)) return true; - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (eventDesc.getWheel() > 0 && _AHWheelUp) - { - CAHManager::getInstance()->runActionHandler (_AHWheelUp, this, _AHWheelUpParams); - return true; - } - else if (_AHWheelDown) - { - CAHManager::getInstance()->runActionHandler (_AHWheelDown, this, _AHWheelDownParams); - return true; - } - } - } - return false; -} - From b16c0362ef8f558466e1a9f8a01f871b5ac482e0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 06:57:39 +0200 Subject: [PATCH 077/339] CHANGED: #1471 CViewTextID no longer depends on the client string manager. --- .../src/interface_v3/interface_manager.cpp | 23 ++++++++++++++++ .../client/src/interface_v3/view_text_id.cpp | 26 ++++++++----------- .../client/src/interface_v3/view_text_id.h | 16 +++++++++++- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 9624e1074..48d846795 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -50,6 +50,7 @@ #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" +#include "view_text_id.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" @@ -250,6 +251,25 @@ int CInterfaceManager::DebugTrackGroupsGetId( CInterfaceGroup *pIG ) #endif // AJM_DEBUG_TRACK_INTERFACE_GROUPS + +class CStringManagerTextProvider : public CViewTextID::IViewTextProvider +{ + bool getString( uint32 stringId, ucstring &result ) + { + return STRING_MANAGER::CStringManagerClient::instance()->getString( stringId, result ); + } + + bool getDynString( uint32 dynStringId, ucstring &result ) + { + return STRING_MANAGER::CStringManagerClient::instance()->getDynString( dynStringId, result ); + } +}; + +namespace +{ + CStringManagerTextProvider SMTextProvider; +} + // ------------------------------------------------------------------------------------------------ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ) { @@ -261,6 +281,8 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CViewRenderer::hwCursorScale = ClientCfg.HardwareCursorScale; CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::getInstance(); + CViewTextID::setTextProvider( &SMTextProvider ); + _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); @@ -340,6 +362,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext // ------------------------------------------------------------------------------------------------ CInterfaceManager::~CInterfaceManager() { + CViewTextID::setTextProvider( NULL ); reset(); // to flush IDStringWaiters _ParentPositionsMap.clear(); diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp index 041745571..fd37dc6bb 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id.cpp @@ -14,24 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - -#include "stdpch.h" - -#include "interface_manager.h" -#include "../string_manager_client.h" +#include "nel/gui/db_manager.h" #include "view_text_id.h" #include "nel/misc/xml_auto_ptr.h" -#include "../client_cfg.h" #include "nel/misc/algo.h" using namespace std; -using namespace STRING_MANAGER; using NLMISC::CCDBNodeLeaf; NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); +CViewTextID::IViewTextProvider* CViewTextID::textProvider = NULL; + // *************************************************************************** CViewTextID::CViewTextID(const std::string& id,const std::string &/* idDBPath */, sint FontSize /*=12*/,NLMISC::CRGBA Color /*=NLMISC::CRGBA(255,255,255)*/,bool Shadow /*=false*/) : CViewText (id, std::string(""), FontSize, Color, Shadow) @@ -116,13 +110,15 @@ void CViewTextID::checkCoords() { // String result ucstring result; - CStringManagerClient *pSMC = CStringManagerClient::instance(); - // Get the string - if (_DynamicString) - _Initialized = pSMC->getDynString (_TextId, result); - else - _Initialized = pSMC->getString (_TextId, result); + if( textProvider != NULL ) + { + // Get the string + if( _DynamicString ) + _Initialized = textProvider->getDynString( _TextId, result ); + else + _Initialized = textProvider->getString( _TextId, result ); + } // Remove all {break} for(;;) diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h index f976791be..4335846df 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ b/code/ryzom/client/src/interface_v3/view_text_id.h @@ -23,7 +23,7 @@ #include "nel/gui/view_text.h" namespace NLMISC{ -class CCDBNodeLeaf; + class CCDBNodeLeaf; } // *************************************************************************** @@ -45,6 +45,15 @@ public: class CViewTextID : public CViewText { public: + + /// Interface for classes that can provide text to CViewTextId + class IViewTextProvider + { + public: + virtual ~IViewTextProvider(){} + virtual bool getString( uint32 stringId, ucstring &result ) = 0; + virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; + }; CViewTextID(const TCtorParam ¶m) : CViewText(param) { @@ -109,6 +118,8 @@ public: REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); REFLECT_EXPORT_END + static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } + protected: bool _IsDBLink; @@ -130,6 +141,9 @@ protected: std::string _DBPath; #endif +private: + static IViewTextProvider *textProvider; + }; From ed9c2c84ec4cbfe72ce11e2bcd4933eb8bcdcba0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 07:18:25 +0200 Subject: [PATCH 078/339] CHANGED: #1471 CViewTextID is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/view_text_id.h | 156 ++++++++++++ code/nel/src/gui/view_text_id.cpp | 225 ++++++++++++++++++ .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/bot_chat_manager.cpp | 2 +- .../interface_v3/bot_chat_page_mission.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/view_text_id.cpp | 220 ----------------- .../client/src/interface_v3/view_text_id.h | 152 ------------ .../src/interface_v3/view_text_id_formated.h | 2 +- code/ryzom/client/src/net_manager.cpp | 2 +- 19 files changed, 396 insertions(+), 387 deletions(-) create mode 100644 code/nel/include/nel/gui/view_text_id.h create mode 100644 code/nel/src/gui/view_text_id.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id.h diff --git a/code/nel/include/nel/gui/view_text_id.h b/code/nel/include/nel/gui/view_text_id.h new file mode 100644 index 000000000..e293f0d4c --- /dev/null +++ b/code/nel/include/nel/gui/view_text_id.h @@ -0,0 +1,156 @@ +// Ryzom - MMORPG Framework +// 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 NL_VIEW_TEXT_ID_H +#define NL_VIEW_TEXT_ID_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_text.h" + +namespace NLMISC{ + class CCDBNodeLeaf; +} + +namespace NLGUI +{ + + // *************************************************************************** + class IOnReceiveTextId + { + public: + virtual ~IOnReceiveTextId() {} + // the deriver may change the input text + virtual void onReceiveTextId(ucstring &str) =0; + }; + + // *************************************************************************** + /** + * class implementing a text view that take the text from an id + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CViewTextID : public CViewText + { + public: + + /// Interface for classes that can provide text to CViewTextId + class IViewTextProvider + { + public: + virtual ~IViewTextProvider(){} + virtual bool getString( uint32 stringId, ucstring &result ) = 0; + virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; + }; + + CViewTextID(const TCtorParam ¶m) : CViewText(param) + { + _StringModifier= NULL; + _IsDBLink = false; + _TextId = 0xFFFFFFFF; + _Initialized = false; + _DynamicString = false; + _IsTextFormatTaged= false; + } + + // ctor with a text id + CViewTextID (const std::string& id, uint32 nID, sint FontSize=12, + NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) : + CViewText (id, std::string(""), FontSize, Color, Shadow) + { + _StringModifier= NULL; + _IsDBLink = false; + _TextId = nID; + _Initialized = false; + _DynamicString = false; + _IsTextFormatTaged= false; + } + + // ctor with a db path entry + CViewTextID (const std::string& id, + const std::string &idDBPath, + sint FontSize=12, + NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), + bool Shadow=false); + + + ~CViewTextID(); + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + + bool parseTextIdOptions(xmlNodePtr cur); + + uint32 getTextId () const; + void setTextId (uint32 id); + + /** set a text id from a db path + * \return true if the link could be done + */ + bool setDBTextID(const std::string &dbPath); + // set a text from a db leaf + void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf); + + std::string getTextIdDbLink() const; + void setTextIdDbLink(const std::string &link); + + void setDynamicString(bool state) {_DynamicString= state;} + bool getDynamicString() const {return _DynamicString;} + + // modify name when received + void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;} + IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;} + + REFLECT_EXPORT_START(CViewTextID, CViewText) + REFLECT_UINT32("textid", getTextId, setTextId); + REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); + REFLECT_EXPORT_END + + static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } + + protected: + + bool _IsDBLink; + CInterfaceProperty _DBTextId; + uint32 _TextId; + + bool _Initialized; + + // If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString) + bool _DynamicString; + + // If true, setTextFormatted() is used instead of setText() + bool _IsTextFormatTaged; + + // Optional ucstring modifier + IOnReceiveTextId *_StringModifier; + + #if defined(NL_DEBUG) + std::string _DBPath; + #endif + + private: + static IViewTextProvider *textProvider; + + }; + +} + +#endif // NL_VIEW_TEXT_ID_H + +/* End of view_text_id.h */ diff --git a/code/nel/src/gui/view_text_id.cpp b/code/nel/src/gui/view_text_id.cpp new file mode 100644 index 000000000..e487051a3 --- /dev/null +++ b/code/nel/src/gui/view_text_id.cpp @@ -0,0 +1,225 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/db_manager.h" +#include "nel/gui/view_text_id.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/algo.h" + +using namespace std; +using NLMISC::CCDBNodeLeaf; + +NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); + +namespace NLGUI +{ + + CViewTextID::IViewTextProvider* CViewTextID::textProvider = NULL; + + // *************************************************************************** + CViewTextID::CViewTextID(const std::string& id,const std::string &/* idDBPath */, sint FontSize /*=12*/,NLMISC::CRGBA Color /*=NLMISC::CRGBA(255,255,255)*/,bool Shadow /*=false*/) + : CViewText (id, std::string(""), FontSize, Color, Shadow) + { + _StringModifier= NULL; + _IsDBLink = true; + _DBTextId.link(id.c_str()); + _Initialized = false; + _DynamicString = true; + _IsTextFormatTaged= false; + } + + // *************************************************************************** + CViewTextID::~CViewTextID() + { + } + + // *************************************************************************** + bool CViewTextID::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CViewText::parse(cur, parentGroup)) + return false; + + if(!parseTextIdOptions(cur)) + return false; + + return true; + } + + // *************************************************************************** + bool CViewTextID::parseTextIdOptions(xmlNodePtr cur) + { + _Initialized = false; + + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"textid" )); + _IsDBLink = false; + _TextId = 0xFFFFFFFF; + if (prop) + { + if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') + { + NLMISC::fromString((const char*)prop, _TextId); + } + else + { + if (_DBTextId.link(prop)) + { + _TextId = (uint32)_DBTextId.getSInt64(); + _IsDBLink = true; + } + else + { + return false; + } + } + } + + prop= (char*) xmlGetProp( cur, (xmlChar*)"dynamic_string" ); + _DynamicString = true; + if (prop) + _DynamicString = convertBool(prop); + + // format_taged + prop= (char*) xmlGetProp( cur, (xmlChar*)"format_taged" ); + _IsTextFormatTaged= false; + if(prop) + _IsTextFormatTaged= convertBool(prop); + + return true; + } + + // *************************************************************************** + void CViewTextID::checkCoords() + { + if (_IsDBLink) + { + uint32 newId = (uint32)_DBTextId.getSInt64(); + setTextId (newId); + } + + if (!_Initialized) + { + // String result + ucstring result; + + if( textProvider != NULL ) + { + // Get the string + if( _DynamicString ) + _Initialized = textProvider->getDynString( _TextId, result ); + else + _Initialized = textProvider->getString( _TextId, result ); + } + + // Remove all {break} + for(;;) + { + ucstring::size_type index = result.find (ucstring("{break}")); + if (index == ucstring::npos) break; + result = result.substr (0, index) + result.substr(index+7, result.size()); + } + + + // Remove all {ros_exit} + while(NLMISC::strFindReplace(result, "{ros_exit}", "")); + + // Modify the text? + if(_StringModifier) + _StringModifier->onReceiveTextId(result); + + // Set the Text + if(_IsTextFormatTaged) + setTextFormatTaged(result); + else + setText (result); + } + CViewText::checkCoords(); + } + + // *************************************************************************** + uint32 CViewTextID::getTextId () const + { + return _TextId; + } + + // *************************************************************************** + void CViewTextID::setTextId (uint32 newId) + { + if (newId != _TextId) + _Initialized = false; + _TextId = newId; + if (_IsDBLink) + _DBTextId.setSInt64(_TextId); + } + + // *************************************************************************** + bool CViewTextID::setDBTextID(const std::string &dbPath) + { + if (_DBTextId.link(dbPath.c_str())) + { + _TextId = (uint32)_DBTextId.getSInt64(); + _IsDBLink = true; + _Initialized = false; + #ifdef NL_DEBUG + _DBPath =dbPath; + #endif + return true; + } + else + { + _IsDBLink = false; + _Initialized = false; + #ifdef NL_DEBUG + _DBPath="Bad db path : " + dbPath; + #endif + return false; + } + } + + // *************************************************************************** + void CViewTextID::setDBLeaf(CCDBNodeLeaf *leaf) + { + if (!leaf) + { + _IsDBLink = false; + _TextId = 0; + return; + } + _IsDBLink = true; + _DBTextId.setNodePtr(leaf); + } + + // *************************************************************************** + string CViewTextID::getTextIdDbLink() const + { + if (!_IsDBLink) return ""; + if (_DBTextId.getNodePtr() == NULL) return ""; + return _DBTextId.getNodePtr()->getFullName(); + } + + // *************************************************************************** + void CViewTextID::setTextIdDbLink(const string &link) + { + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(link,false); + if (pNL == NULL) + { + nlwarning("cant set textidlink for %s",link.c_str()); + return; + } + setDBLeaf(pNL); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 04bc833e7..4e12abb10 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -29,7 +29,7 @@ #include "group_container.h" #include "group_editbox.h" #include "group_quick_help.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "../user_entity.h" #include "../entities.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index 9e96fb602..a315005dd 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -23,7 +23,7 @@ #include "nel/gui/action_handler.h" #include "../user_entity.h" #include "interface_manager.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "nel/gui/interface_group.h" #include "game_share/prerequisit_infos.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index 6a8f75e8c..4897defa3 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -26,7 +26,7 @@ #include "nel/gui/action_handler.h" #include "group_container.h" #include "dbctrl_sheet.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "../net_manager.h" using namespace std; diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 62a82831b..bdba8c1f0 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -24,7 +24,7 @@ #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index 8bdac6a34..d6d6bf44e 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -20,7 +20,7 @@ #include "encyclopedia_manager.h" #include "interface_manager.h" #include "group_tree.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_bitmap.h" #include "action_handler_misc.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index c1efb9c0d..afd611854 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -28,7 +28,7 @@ #include "../time_client.h" #include "group_editbox.h" #include "view_text_formated.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" #include "group_list.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 603c7f5e5..97777043d 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -30,7 +30,7 @@ #include "../main_loop.h" #include "../bg_downloader_access.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" using namespace std; using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 64fe82706..9315d9024 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -23,7 +23,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index 2ac417734..b3d915235 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -24,7 +24,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 09d3b9283..0b4bb5cd1 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -23,7 +23,7 @@ #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" #include "view_bitmap.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/misc/i_xml.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 48d846795..0219aa87c 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -50,7 +50,7 @@ #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index cec1aeac6..7188c9671 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -41,7 +41,7 @@ #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "view_text_formated.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_text_id_formated.h" #include "view_radar.h" #include "view_pointer.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 299ff3f4b..51bbc1ae6 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -21,7 +21,7 @@ #include "interface_3d_scene.h" #include "nel/gui/view_base.h" #include "nel/gui/view_text.h" -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" #include "view_bitmap.h" #include "view_radar.h" #include "nel/gui/group_submenu_base.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_id.cpp b/code/ryzom/client/src/interface_v3/view_text_id.cpp deleted file mode 100644 index fd37dc6bb..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "nel/gui/db_manager.h" -#include "view_text_id.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/misc/algo.h" - -using namespace std; -using NLMISC::CCDBNodeLeaf; - -NLMISC_REGISTER_OBJECT(CViewBase, CViewTextID, std::string, "text_id"); - -CViewTextID::IViewTextProvider* CViewTextID::textProvider = NULL; - -// *************************************************************************** -CViewTextID::CViewTextID(const std::string& id,const std::string &/* idDBPath */, sint FontSize /*=12*/,NLMISC::CRGBA Color /*=NLMISC::CRGBA(255,255,255)*/,bool Shadow /*=false*/) - : CViewText (id, std::string(""), FontSize, Color, Shadow) -{ - _StringModifier= NULL; - _IsDBLink = true; - _DBTextId.link(id.c_str()); - _Initialized = false; - _DynamicString = true; - _IsTextFormatTaged= false; -} - -// *************************************************************************** -CViewTextID::~CViewTextID() -{ -} - -// *************************************************************************** -bool CViewTextID::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CViewText::parse(cur, parentGroup)) - return false; - - if(!parseTextIdOptions(cur)) - return false; - - return true; -} - -// *************************************************************************** -bool CViewTextID::parseTextIdOptions(xmlNodePtr cur) -{ - _Initialized = false; - - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"textid" )); - _IsDBLink = false; - _TextId = 0xFFFFFFFF; - if (prop) - { - if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') - { - NLMISC::fromString((const char*)prop, _TextId); - } - else - { - if (_DBTextId.link(prop)) - { - _TextId = (uint32)_DBTextId.getSInt64(); - _IsDBLink = true; - } - else - { - return false; - } - } - } - - prop= (char*) xmlGetProp( cur, (xmlChar*)"dynamic_string" ); - _DynamicString = true; - if (prop) - _DynamicString = convertBool(prop); - - // format_taged - prop= (char*) xmlGetProp( cur, (xmlChar*)"format_taged" ); - _IsTextFormatTaged= false; - if(prop) - _IsTextFormatTaged= convertBool(prop); - - return true; -} - -// *************************************************************************** -void CViewTextID::checkCoords() -{ - if (_IsDBLink) - { - uint32 newId = (uint32)_DBTextId.getSInt64(); - setTextId (newId); - } - - if (!_Initialized) - { - // String result - ucstring result; - - if( textProvider != NULL ) - { - // Get the string - if( _DynamicString ) - _Initialized = textProvider->getDynString( _TextId, result ); - else - _Initialized = textProvider->getString( _TextId, result ); - } - - // Remove all {break} - for(;;) - { - ucstring::size_type index = result.find (ucstring("{break}")); - if (index == ucstring::npos) break; - result = result.substr (0, index) + result.substr(index+7, result.size()); - } - - - // Remove all {ros_exit} - while(NLMISC::strFindReplace(result, "{ros_exit}", "")); - - // Modify the text? - if(_StringModifier) - _StringModifier->onReceiveTextId(result); - - // Set the Text - if(_IsTextFormatTaged) - setTextFormatTaged(result); - else - setText (result); - } - CViewText::checkCoords(); -} - -// *************************************************************************** -uint32 CViewTextID::getTextId () const -{ - return _TextId; -} - -// *************************************************************************** -void CViewTextID::setTextId (uint32 newId) -{ - if (newId != _TextId) - _Initialized = false; - _TextId = newId; - if (_IsDBLink) - _DBTextId.setSInt64(_TextId); -} - -// *************************************************************************** -bool CViewTextID::setDBTextID(const std::string &dbPath) -{ - if (_DBTextId.link(dbPath.c_str())) - { - _TextId = (uint32)_DBTextId.getSInt64(); - _IsDBLink = true; - _Initialized = false; - #ifdef NL_DEBUG - _DBPath =dbPath; - #endif - return true; - } - else - { - _IsDBLink = false; - _Initialized = false; - #ifdef NL_DEBUG - _DBPath="Bad db path : " + dbPath; - #endif - return false; - } -} - -// *************************************************************************** -void CViewTextID::setDBLeaf(CCDBNodeLeaf *leaf) -{ - if (!leaf) - { - _IsDBLink = false; - _TextId = 0; - return; - } - _IsDBLink = true; - _DBTextId.setNodePtr(leaf); -} - -// *************************************************************************** -string CViewTextID::getTextIdDbLink() const -{ - if (!_IsDBLink) return ""; - if (_DBTextId.getNodePtr() == NULL) return ""; - return _DBTextId.getNodePtr()->getFullName(); -} - -// *************************************************************************** -void CViewTextID::setTextIdDbLink(const string &link) -{ - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(link,false); - if (pNL == NULL) - { - nlwarning("cant set textidlink for %s",link.c_str()); - return; - } - setDBLeaf(pNL); -} - diff --git a/code/ryzom/client/src/interface_v3/view_text_id.h b/code/ryzom/client/src/interface_v3/view_text_id.h deleted file mode 100644 index 4335846df..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id.h +++ /dev/null @@ -1,152 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_VIEW_TEXT_ID_H -#define NL_VIEW_TEXT_ID_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/view_text.h" - -namespace NLMISC{ - class CCDBNodeLeaf; -} - -// *************************************************************************** -class IOnReceiveTextId -{ -public: - virtual ~IOnReceiveTextId() {} - // the deriver may change the input text - virtual void onReceiveTextId(ucstring &str) =0; -}; - -// *************************************************************************** -/** - * class implementing a text view that take the text from an id - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CViewTextID : public CViewText -{ -public: - - /// Interface for classes that can provide text to CViewTextId - class IViewTextProvider - { - public: - virtual ~IViewTextProvider(){} - virtual bool getString( uint32 stringId, ucstring &result ) = 0; - virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0; - }; - - CViewTextID(const TCtorParam ¶m) : CViewText(param) - { - _StringModifier= NULL; - _IsDBLink = false; - _TextId = 0xFFFFFFFF; - _Initialized = false; - _DynamicString = false; - _IsTextFormatTaged= false; - } - - // ctor with a text id - CViewTextID (const std::string& id, uint32 nID, sint FontSize=12, - NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) : - CViewText (id, std::string(""), FontSize, Color, Shadow) - { - _StringModifier= NULL; - _IsDBLink = false; - _TextId = nID; - _Initialized = false; - _DynamicString = false; - _IsTextFormatTaged= false; - } - - // ctor with a db path entry - CViewTextID (const std::string& id, - const std::string &idDBPath, - sint FontSize=12, - NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), - bool Shadow=false); - - - ~CViewTextID(); - - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - - bool parseTextIdOptions(xmlNodePtr cur); - - uint32 getTextId () const; - void setTextId (uint32 id); - - /** set a text id from a db path - * \return true if the link could be done - */ - bool setDBTextID(const std::string &dbPath); - // set a text from a db leaf - void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf); - - std::string getTextIdDbLink() const; - void setTextIdDbLink(const std::string &link); - - void setDynamicString(bool state) {_DynamicString= state;} - bool getDynamicString() const {return _DynamicString;} - - // modify name when received - void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;} - IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;} - - REFLECT_EXPORT_START(CViewTextID, CViewText) - REFLECT_UINT32("textid", getTextId, setTextId); - REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink); - REFLECT_EXPORT_END - - static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; } - -protected: - - bool _IsDBLink; - CInterfaceProperty _DBTextId; - uint32 _TextId; - - bool _Initialized; - - // If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString) - bool _DynamicString; - - // If true, setTextFormatted() is used instead of setText() - bool _IsTextFormatTaged; - - // Optional ucstring modifier - IOnReceiveTextId *_StringModifier; - - #if defined(NL_DEBUG) - std::string _DBPath; - #endif - -private: - static IViewTextProvider *textProvider; - -}; - - -#endif // NL_VIEW_TEXT_ID_H - -/* End of view_text_id.h */ diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.h b/code/ryzom/client/src/interface_v3/view_text_id_formated.h index c2dec1dbf..d066b2acd 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.h +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.h @@ -19,7 +19,7 @@ #ifndef VIEW_TEXT_ID_FORMATED_H #define VIEW_TEXT_ID_FORMATED_H -#include "view_text_id.h" +#include "nel/gui/view_text_id.h" /** The same as a view text id, but with some display option * The input is a formated string, every character is copied, but subsitution is done for each character preceded by $ diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index f4683d72e..5c1929acd 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -57,7 +57,7 @@ #include "interface_v3/people_interraction.h" #include "interface_v3/bot_chat_manager.h" #include "interface_v3/bot_chat_page_all.h" -#include "interface_v3/view_text_id.h" +#include "nel/gui/view_text_id.h" #include "interface_v3/ctrl_text_button.h" #include "interface_v3/input_handler_manager.h" #include "interface_v3/guild_manager.h" From 462f7c9399288d61e53e9167f8e583fed3424622 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 10:20:43 +0200 Subject: [PATCH 079/339] CHANGED: #1471 CViewTextFormated no longer depends on Ryzom game related code. --- .../src/interface_v3/interface_manager.cpp | 123 ++++++++++++++++- .../src/interface_v3/view_text_formated.cpp | 125 +----------------- .../src/interface_v3/view_text_formated.h | 12 ++ 3 files changed, 140 insertions(+), 120 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 0219aa87c..5f7676853 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -39,6 +39,7 @@ #include "register_interface_elements.h" // Action / Observers #include "nel/gui/action_handler.h" +#include "action_handler_misc.h" #include "interface_observer.h" #include "interface_anim.h" #include "interface_ddx.h" @@ -51,6 +52,7 @@ #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_id.h" +#include "view_text_formated.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" @@ -265,9 +267,127 @@ class CStringManagerTextProvider : public CViewTextID::IViewTextProvider } }; +class CRyzomTextFormatter : public CViewTextFormated::IViewTextFormatter +{ +public: + ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) + { + ucstring formatedResult; + + // Apply the format + for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) + { + if (*it == '$') + { + ++it; + if (it == inputString.end()) + break; + + switch(*it) + { + case 't': // add text ID + formatedResult += paramString; + break; + + case 'P': + case 'p': // add player name + if (ClientCfg.Local) + { + formatedResult += ucstring("player"); + } + else + { + if(UserEntity) + { + ucstring name = UserEntity->getEntityName(); + if (*it == 'P') setCase(name, CaseUpper); + formatedResult += name; + } + } + break; + // + case 's': + case 'b': // add bot name + { + ucstring botName; + bool womanTitle = false; + if (ClientCfg.Local) + { + botName = ucstring("NPC"); + } + else + { + CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; + if(UserEntity) + trader = UserEntity->trader(); + if (trader != CLFECOMMON::INVALID_SLOT) + { + CEntityCL *entity = EntitiesMngr.entity(trader); + if (entity != NULL) + { + uint32 nDBid = entity->getNameId(); + if (nDBid != 0) + { + STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); + pSMC->getString(nDBid, botName); + } + else + { + botName = entity->getDisplayName(); + } + CCharacterCL *pChar = dynamic_cast(entity); + if (pChar != NULL) + womanTitle = pChar->getGender() == GSGENDER::female; + } + } + } + // get the title translated + ucstring sTitleTranslated = botName; + CStringPostProcessRemoveName spprn; + spprn.Woman = womanTitle; + spprn.cbIDStringReceived(sTitleTranslated); + + botName = CEntityCL::removeTitleAndShardFromName(botName); + + // short name (with no title such as 'guard', 'merchant' ...) + if (*it == 's') + { + // But if there is no name, display only the title + if (botName.empty()) + botName = sTitleTranslated; + } + else + { + // Else we want the title ! + if (!botName.empty()) + botName += " "; + botName += sTitleTranslated; + } + + formatedResult += botName; + } + break; + default: + formatedResult += (ucchar) '$'; + break; + } + ++it; + } + else + { + formatedResult += (ucchar) *it; + ++it; + } + } + + return formatedResult; + } +}; + namespace { CStringManagerTextProvider SMTextProvider; + CRyzomTextFormatter RyzomTextFormatter; } // ------------------------------------------------------------------------------------------------ @@ -282,7 +402,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CViewRenderer::hwCursors = &ClientCfg.HardwareCursors; CViewRenderer::getInstance(); CViewTextID::setTextProvider( &SMTextProvider ); - + CViewTextFormated::setFormatter( &RyzomTextFormatter ); _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); @@ -363,6 +483,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CInterfaceManager::~CInterfaceManager() { CViewTextID::setTextProvider( NULL ); + CViewTextFormated::setFormatter( NULL ); reset(); // to flush IDStringWaiters _ParentPositionsMap.clear(); diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_formated.cpp index 6d3513fce..cf8e8264b 100644 --- a/code/ryzom/client/src/interface_v3/view_text_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_formated.cpp @@ -14,26 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" #include "view_text_formated.h" -#include "../user_entity.h" -#include "../entities.h" -#include "../string_manager_client.h" -#include "action_handler_misc.h" -// #include "nel/misc/xml_auto_ptr.h" -// #include "nel/misc/i18n.h" -//////////// -// EXTERN // -//////////// -using namespace STRING_MANAGER; - NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated"); +CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL; + // **************************************************************************** bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) { @@ -70,112 +58,11 @@ void CViewTextFormated::setFormatString(const ucstring &format) ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) { ucstring formatedResult; - // Apply the format - for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) - { - if (*it == '$') - { - ++it; - if (it == inputString.end()) break; - switch(*it) - { - case 't': // add text ID - formatedResult += paramString; - break; - case 'P': - case 'p': // add player name - if (ClientCfg.Local) - { - formatedResult += ucstring("player"); - } - else - { - if(UserEntity) - { - ucstring name = UserEntity->getEntityName(); - if (*it == 'P') setCase(name, CaseUpper); - formatedResult += name; - } - } - break; - // - case 's': - case 'b': // add bot name - { - ucstring botName; - bool womanTitle = false; - if (ClientCfg.Local) - { - botName = ucstring("NPC"); - } - else - { - CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; - if(UserEntity) - trader = UserEntity->trader(); - if (trader != CLFECOMMON::INVALID_SLOT) - { - CEntityCL *entity = EntitiesMngr.entity(trader); - if (entity != NULL) - { - uint32 nDBid = entity->getNameId(); - - if (nDBid != 0) - { - CStringManagerClient *pSMC = CStringManagerClient::instance(); - pSMC->getString(nDBid, botName); - } - else - { - botName = entity->getDisplayName(); - } - - CCharacterCL *pChar = dynamic_cast(entity); - if (pChar != NULL) - womanTitle = pChar->getGender() == GSGENDER::female; - } - } - } - - // get the title translated - ucstring sTitleTranslated = botName; - CStringPostProcessRemoveName spprn; - spprn.Woman = womanTitle; - spprn.cbIDStringReceived(sTitleTranslated); - - botName = CEntityCL::removeTitleAndShardFromName(botName); - - // short name (with no title such as 'guard', 'merchant' ...) - if (*it == 's') - { - // But if there is no name, display only the title - if (botName.empty()) - botName = sTitleTranslated; - } - else - { - // Else we want the title ! - if (!botName.empty()) - botName += " "; - botName += sTitleTranslated; - } - - formatedResult += botName; - } - break; - default: - formatedResult += (ucchar) '$'; - break; - } - ++it; - } - else - { - formatedResult += (ucchar) *it; - ++it; - } - } + if( textFormatter == NULL ) + formatedResult = inputString; + else + formatedResult = CViewTextFormated::textFormatter->formatString( inputString, paramString ); return formatedResult; } diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.h b/code/ryzom/client/src/interface_v3/view_text_formated.h index 0f8c2d4c0..604d16dbc 100644 --- a/code/ryzom/client/src/interface_v3/view_text_formated.h +++ b/code/ryzom/client/src/interface_v3/view_text_formated.h @@ -32,6 +32,14 @@ class CViewTextFormated : public CViewText { public: + + class IViewTextFormatter + { + public: + virtual ~IViewTextFormatter(){} + virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0; + }; + CViewTextFormated (const TCtorParam ¶m) : CViewText(param) {} virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); @@ -40,8 +48,12 @@ public: void setFormatString(const ucstring &format); static ucstring formatString(const ucstring &inputString, const ucstring ¶mString); + + static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } + private: ucstring _FormatString; + static IViewTextFormatter *textFormatter; }; From 9503f2aaae7f3faf39e7e801b77fabe9405010df Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 10:32:46 +0200 Subject: [PATCH 080/339] CHANGED: #1471 CViewTextFormated is now part of NELGUI library, and is under the NLGUI namespace. --- code/nel/include/nel/gui/view_text_formated.h | 67 +++++++++++++++++ code/nel/src/gui/view_text_formated.cpp | 74 +++++++++++++++++++ .../src/interface_v3/group_container.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/view_text_formated.cpp | 68 ----------------- .../src/interface_v3/view_text_formated.h | 64 ---------------- .../interface_v3/view_text_id_formated.cpp | 2 +- 8 files changed, 145 insertions(+), 136 deletions(-) create mode 100644 code/nel/include/nel/gui/view_text_formated.h create mode 100644 code/nel/src/gui/view_text_formated.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_formated.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_formated.h diff --git a/code/nel/include/nel/gui/view_text_formated.h b/code/nel/include/nel/gui/view_text_formated.h new file mode 100644 index 000000000..dd9d1149a --- /dev/null +++ b/code/nel/include/nel/gui/view_text_formated.h @@ -0,0 +1,67 @@ +// Ryzom - MMORPG Framework +// 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 VIEW_TEXT_FORMATED_H +#define VIEW_TEXT_FORMATED_H + +#include "nel/gui/view_text.h" + +namespace NLGUI +{ + + /** The same as a view text id, but with some display option + * The input is a formated string, every character is copied, but subsitution is done for each character preceded by $ + * $p -> expand the player name + * $P -> expand the player name in uppercase + * $b -> expand the current bot name ( bot with which the player is talking) + * $s -> expand the current short bot name (with no specification/title in it) + * if "ui..." replace the format with CI18N + */ + class CViewTextFormated : public CViewText + { + public: + + class IViewTextFormatter + { + public: + virtual ~IViewTextFormatter(){} + virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0; + }; + + CViewTextFormated (const TCtorParam ¶m) : CViewText(param) + {} + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + const ucstring &getFormatString() const { return _FormatString; } + void setFormatString(const ucstring &format); + + static ucstring formatString(const ucstring &inputString, const ucstring ¶mString); + + static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } + + private: + ucstring _FormatString; + static IViewTextFormatter *textFormatter; + }; + + +} + + + +#endif diff --git a/code/nel/src/gui/view_text_formated.cpp b/code/nel/src/gui/view_text_formated.cpp new file mode 100644 index 000000000..2de8f440f --- /dev/null +++ b/code/nel/src/gui/view_text_formated.cpp @@ -0,0 +1,74 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_text_formated.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/i18n.h" + +NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated"); + +namespace NLGUI +{ + + CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL; + + // **************************************************************************** + bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) + { + if (!CViewText::parse(cur, parentGroup)) return false; + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); + if (prop) + setFormatString(ucstring((const char *) prop)); + else + setFormatString(ucstring("$t")); + return true; + } + + // **************************************************************************** + void CViewTextFormated::checkCoords() + { + if (!getActive()) return; + ucstring formatedResult; + formatedResult = formatString(_FormatString, ucstring("")); + + // + setText (formatedResult); + CViewText::checkCoords(); + } + + // **************************************************************************** + void CViewTextFormated::setFormatString(const ucstring &format) + { + _FormatString = format; + if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) + _FormatString = NLMISC::CI18N::get (format.toString()); + } + + // **************************************************************************** + ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) + { + ucstring formatedResult; + + if( textFormatter == NULL ) + formatedResult = inputString; + else + formatedResult = CViewTextFormated::textFormatter->formatString( inputString, paramString ); + + return formatedResult; + } + +} + diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index afd611854..6876c66a8 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -27,7 +27,7 @@ #include "nel/gui/action_handler.h" #include "../time_client.h" #include "group_editbox.h" -#include "view_text_formated.h" +#include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 5f7676853..b9c9a6df0 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -52,7 +52,7 @@ #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_id.h" -#include "view_text_formated.h" +#include "nel/gui/view_text_formated.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 7188c9671..c53c1b322 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -40,7 +40,7 @@ #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" -#include "view_text_formated.h" +#include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" #include "view_text_id_formated.h" #include "view_radar.h" diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_formated.cpp deleted file mode 100644 index cf8e8264b..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_formated.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_text_formated.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/misc/i18n.h" - -NLMISC_REGISTER_OBJECT(CViewBase, CViewTextFormated, std::string, "text_formated"); - -CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL; - -// **************************************************************************** -bool CViewTextFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) -{ - if (!CViewText::parse(cur, parentGroup)) return false; - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); - if (prop) - setFormatString(ucstring((const char *) prop)); - else - setFormatString(ucstring("$t")); - return true; -} - -// **************************************************************************** -void CViewTextFormated::checkCoords() -{ - if (!getActive()) return; - ucstring formatedResult; - formatedResult = formatString(_FormatString, ucstring("")); - - // - setText (formatedResult); - CViewText::checkCoords(); -} - -// **************************************************************************** -void CViewTextFormated::setFormatString(const ucstring &format) -{ - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); -} - -// **************************************************************************** -ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) -{ - ucstring formatedResult; - - if( textFormatter == NULL ) - formatedResult = inputString; - else - formatedResult = CViewTextFormated::textFormatter->formatString( inputString, paramString ); - - return formatedResult; -} diff --git a/code/ryzom/client/src/interface_v3/view_text_formated.h b/code/ryzom/client/src/interface_v3/view_text_formated.h deleted file mode 100644 index 604d16dbc..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_formated.h +++ /dev/null @@ -1,64 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 VIEW_TEXT_FORMATED_H -#define VIEW_TEXT_FORMATED_H - -#include "nel/gui/view_text.h" - -/** The same as a view text id, but with some display option - * The input is a formated string, every character is copied, but subsitution is done for each character preceded by $ - * $p -> expand the player name - * $P -> expand the player name in uppercase - * $b -> expand the current bot name ( bot with which the player is talking) - * $s -> expand the current short bot name (with no specification/title in it) - * if "ui..." replace the format with CI18N - */ -class CViewTextFormated : public CViewText -{ -public: - - class IViewTextFormatter - { - public: - virtual ~IViewTextFormatter(){} - virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0; - }; - - CViewTextFormated (const TCtorParam ¶m) : CViewText(param) - {} - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); - - static ucstring formatString(const ucstring &inputString, const ucstring ¶mString); - - static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; } - -private: - ucstring _FormatString; - static IViewTextFormatter *textFormatter; -}; - - - - - - -#endif diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp index 70bacaa98..1105197b6 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" #include "view_text_id_formated.h" -#include "view_text_formated.h" +#include "nel/gui/view_text_formated.h" #include "../string_manager_client.h" #include "../user_entity.h" #include "../entities.h" From 1594ec45f88b6ee3c95df035b10920edc670267c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 20:21:01 +0200 Subject: [PATCH 081/339] CHANGED: #1471 CViewTextIDFormated no longer depends on Ryzom game related code. --- code/nel/include/nel/gui/view_text_id.h | 2 ++ .../interface_v3/view_text_id_formated.cpp | 24 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/code/nel/include/nel/gui/view_text_id.h b/code/nel/include/nel/gui/view_text_id.h index e293f0d4c..fea01f59c 100644 --- a/code/nel/include/nel/gui/view_text_id.h +++ b/code/nel/include/nel/gui/view_text_id.h @@ -144,6 +144,8 @@ namespace NLGUI std::string _DBPath; #endif + static IViewTextProvider* getTextProvider(){ return textProvider; } + private: static IViewTextProvider *textProvider; diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp index 1105197b6..24dd2c376 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp @@ -16,20 +16,10 @@ -#include "stdpch.h" #include "view_text_id_formated.h" #include "nel/gui/view_text_formated.h" -#include "../string_manager_client.h" -#include "../user_entity.h" -#include "../entities.h" #include "nel/misc/xml_auto_ptr.h" -using namespace STRING_MANAGER; - -//////////// -// EXTERN // -//////////// - NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); // ********************************************************************************* @@ -57,18 +47,18 @@ void CViewTextIDFormated::checkCoords() { ucstring result, formatedResult; bool bValid; - #if defined(NL_DEBUG) - if (ClientCfg.Local) + + if( CViewTextID::getTextProvider() == NULL ) { - if (!_DBPath.empty()) result = ucstring(_DBPath); - else result = ucstring("Text ID = " + NLMISC::toString(_TextId)); + if(!_DBPath.empty()) + result = ucstring(_DBPath); + else + result = ucstring("Text ID = " + NLMISC::toString(_TextId)); bValid = true; } else - #endif { - CStringManagerClient *pSMC = CStringManagerClient::instance(); - bValid = pSMC->getDynString (_TextId, result); + bValid = CViewTextID::getTextProvider()->getDynString (_TextId, result); } formatedResult = CViewTextFormated::formatString(_FormatString, result); // From 80cc60118a41f4f093d2be8ac9cb7fee40597f50 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 20:31:10 +0200 Subject: [PATCH 082/339] CHANGED: #1471 CViewTextIDFormated is now part of the NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/view_text_id_formated.h | 29 +++--- code/nel/src/gui/view_text_id_formated.cpp | 88 +++++++++++++++++++ .../dbgroup_list_sheet_mission.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../interface_v3/view_text_id_formated.cpp | 82 ----------------- 5 files changed, 105 insertions(+), 98 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_text_id_formated.h (74%) create mode 100644 code/nel/src/gui/view_text_id_formated.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_text_id_formated.cpp diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.h b/code/nel/include/nel/gui/view_text_id_formated.h similarity index 74% rename from code/ryzom/client/src/interface_v3/view_text_id_formated.h rename to code/nel/include/nel/gui/view_text_id_formated.h index d066b2acd..11fa19aa3 100644 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.h +++ b/code/nel/include/nel/gui/view_text_id_formated.h @@ -29,22 +29,23 @@ * $b -> expand the current bot name ( bot with which the player is talking) * $s -> expand the current short bot name (with no specification/title in it) */ -class CViewTextIDFormated : public CViewTextID + +namespace NLGUI { -public: - CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param) - {} - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - const ucstring &getFormatString() const { return _FormatString; } - void setFormatString(const ucstring &format); -private: - ucstring _FormatString; -}; - - - + class CViewTextIDFormated : public CViewTextID + { + public: + CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param) + {} + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + const ucstring &getFormatString() const { return _FormatString; } + void setFormatString(const ucstring &format); + private: + ucstring _FormatString; + }; +} #endif diff --git a/code/nel/src/gui/view_text_id_formated.cpp b/code/nel/src/gui/view_text_id_formated.cpp new file mode 100644 index 000000000..991db0344 --- /dev/null +++ b/code/nel/src/gui/view_text_id_formated.cpp @@ -0,0 +1,88 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_text_id_formated.h" +#include "nel/gui/view_text_formated.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/i18n.h" + +NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); + +namespace NLGUI +{ + + // ********************************************************************************* + bool CViewTextIDFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) + { + if (!CViewTextID::parse(cur, parentGroup)) return false; + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); + if (prop) + setFormatString(ucstring((const char *) prop)); + else + setFormatString(ucstring("$t")); + return true; + } + + // ********************************************************************************* + void CViewTextIDFormated::checkCoords() + { + if (_IsDBLink) + { + uint32 newId = (uint32)_DBTextId.getSInt64(); + setTextId (newId); + } + + if (!_Initialized) + { + ucstring result, formatedResult; + bool bValid; + + if( CViewTextID::getTextProvider() == NULL ) + { + if(!_DBPath.empty()) + result = ucstring(_DBPath); + else + result = ucstring("Text ID = " + NLMISC::toString(_TextId)); + bValid = true; + } + else + { + bValid = CViewTextID::getTextProvider()->getDynString (_TextId, result); + } + formatedResult = CViewTextFormated::formatString(_FormatString, result); + // + setText (formatedResult); + // + if (bValid) + { + _Initialized = true; + } + } + CViewText::checkCoords(); + } + + // **************************************************************************** + void CViewTextIDFormated::setFormatString(const ucstring &format) + { + _Initialized = false; + _FormatString = format; + if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) + _FormatString = NLMISC::CI18N::get (format.toString()); + } + +} diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp index fe56bf1d9..ca625340a 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_mission.cpp @@ -19,7 +19,7 @@ #include "game_share/mission_desc.h" #include "dbgroup_list_sheet_mission.h" -#include "view_text_id_formated.h" +#include "nel/gui/view_text_id_formated.h" #include "nel/misc/cdb_leaf.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index c53c1b322..15cab1fd9 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -42,7 +42,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" -#include "view_text_id_formated.h" +#include "nel/gui/view_text_id_formated.h" #include "view_radar.h" #include "view_pointer.h" // DBView (View linked to the database) diff --git a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp b/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp deleted file mode 100644 index 24dd2c376..000000000 --- a/code/ryzom/client/src/interface_v3/view_text_id_formated.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_text_id_formated.h" -#include "nel/gui/view_text_formated.h" -#include "nel/misc/xml_auto_ptr.h" - -NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_formated"); - -// ********************************************************************************* -bool CViewTextIDFormated::parse(xmlNodePtr cur,CInterfaceGroup * parentGroup) -{ - if (!CViewTextID::parse(cur, parentGroup)) return false; - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" )); - if (prop) - setFormatString(ucstring((const char *) prop)); - else - setFormatString(ucstring("$t")); - return true; -} - -// ********************************************************************************* -void CViewTextIDFormated::checkCoords() -{ - if (_IsDBLink) - { - uint32 newId = (uint32)_DBTextId.getSInt64(); - setTextId (newId); - } - - if (!_Initialized) - { - ucstring result, formatedResult; - bool bValid; - - if( CViewTextID::getTextProvider() == NULL ) - { - if(!_DBPath.empty()) - result = ucstring(_DBPath); - else - result = ucstring("Text ID = " + NLMISC::toString(_TextId)); - bValid = true; - } - else - { - bValid = CViewTextID::getTextProvider()->getDynString (_TextId, result); - } - formatedResult = CViewTextFormated::formatString(_FormatString, result); - // - setText (formatedResult); - // - if (bValid) - { - _Initialized = true; - } - } - CViewText::checkCoords(); -} - -// **************************************************************************** -void CViewTextIDFormated::setFormatString(const ucstring &format) -{ - _Initialized = false; - _FormatString = format; - if ( (_FormatString.size()>2) && (_FormatString[0] == 'u') && (_FormatString[1] == 'i')) - _FormatString = NLMISC::CI18N::get (format.toString()); -} From 2b12907293b4f106c5507f879cb38d2b65501c0a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 21:28:13 +0200 Subject: [PATCH 083/339] CHANGED: #1471 CCtrlTextButton no longer depends on CGroupContainer. --- code/nel/include/nel/gui/group_container_base.h | 6 +++++- .../src/interface_v3/ctrl_text_button.cpp | 17 +++-------------- .../client/src/interface_v3/ctrl_text_button.h | 1 - 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index a4c2a0ba6..988050341 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -19,6 +19,7 @@ #define GROUP_CONTAINER_BASE_H #include "nel/gui/interface_group.h" +#include "nel/misc/rgba.h" namespace NLGUI { @@ -76,7 +77,10 @@ namespace NLGUI REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); REFLECT_EXPORT_END - virtual bool isMoving() const{ return false; } + virtual bool isMoving() const{ return false; } + + // Get the header color draw. NB: depends if grayed, and if active. + virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); }; protected: void triggerAlphaSettingsChangedAH(); diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index bdba8c1f0..fff7127f0 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -14,23 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - - -#include "stdpch.h" - #include "ctrl_text_button.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_id.h" -#include "group_container.h" +#include "nel/gui/group_container_base.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" +#include "nel/gui/widget_manager.h" - -// *************************************************************************** using namespace std; using namespace NLMISC; using namespace NL3D; @@ -69,7 +60,6 @@ CCtrlTextButton::CCtrlTextButton(const TCtorParam ¶m) bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { CXMLAutoPtr prop; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); //try to get props that can be inherited from groups @@ -272,7 +262,6 @@ void CCtrlTextButton::draw () CViewRenderer::CTextureId *pTxId = NULL; CRGBA color; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); @@ -392,7 +381,7 @@ void CCtrlTextButton::draw () CInterfaceGroup *pIG= getRootWindow(); if(pIG->isGroupContainer()) { - CGroupContainer *pGC= static_cast(pIG); + CGroupContainerBase *pGC = static_cast(pIG); viewTextColor= pGC->getDrawnHeaderColor(); } } diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h index fd90e2d7e..677690e50 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.h @@ -28,7 +28,6 @@ namespace NLGUI class CEventDescriptor; class CViewText; } -class CInterfaceManager; // *************************************************************************** /** From 1854b8e33aca8d08991243825ccfd11fdb24a693 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 22:20:02 +0200 Subject: [PATCH 084/339] CHANGED: #1471 CCtrlTextButton is now part of NELGUI library, and is under NLGUI namespace. --- code/nel/include/nel/gui/ctrl_text_button.h | 166 ++++++ code/nel/src/gui/ctrl_text_button.cpp | 552 ++++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 +- code/ryzom/client/src/game_context_menu.cpp | 2 +- code/ryzom/client/src/game_context_menu.h | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../src/interface_v3/ctrl_text_button.cpp | 545 ----------------- .../src/interface_v3/ctrl_text_button.h | 165 ------ .../dbgroup_list_sheet_text_share.cpp | 2 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_menu.h | 2 +- .../ryzom/client/src/interface_v3/group_tab.h | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_pointer.h | 3 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../register_interface_elements.cpp | 2 +- code/ryzom/client/src/login.cpp | 2 +- code/ryzom/client/src/net_manager.cpp | 2 +- 19 files changed, 734 insertions(+), 725 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_text_button.h create mode 100644 code/nel/src/gui/ctrl_text_button.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_text_button.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_text_button.h diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h new file mode 100644 index 000000000..a6d43c50f --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -0,0 +1,166 @@ +// Ryzom - MMORPG Framework +// 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 NL_CTRL_TEXT_BUTTON_H +#define NL_CTRL_TEXT_BUTTON_H + +#include "nel/gui/ctrl_base_button.h" +#include "nel/gui/view_renderer.h" + + +namespace NLGUI +{ + class CEventDescriptor; + class CViewText; + + // *************************************************************************** + /** + * Text Button that can be either Push or Toggle button. Localized, auto-resize + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CCtrlTextButton : public CCtrlBaseButton + { + public: + + /// Constructor + CCtrlTextButton(const TCtorParam ¶m); + + // Init part + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + // Display part + virtual void draw(); + + // Hide/Show the text also. + virtual void setActive(bool state); + + // Add also our ViewText + virtual void onAddToGroup(); + + + /// \from CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + // Special Text Colors accessors + // Colors + NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;} + void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;} + NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;} + void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;} + NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;} + void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;} + // Shadow Colors + NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;} + void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;} + NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;} + void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;} + NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;} + void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;} + // Global Modulate Colors + bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;} + void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;} + bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;} + void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;} + bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} + void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} + // Set text (noop if text id) + void setText (const ucstring &text); + ucstring getText () const; + + void setHardText (const std::string &text); + std::string getHardText () const; + + CViewText* getViewText(); + void setViewText(CViewText* text) {_ViewText=text;} + + void setTextX(sint32 x); + sint32 getTextX() const { return _TextX; } + + void setWMargin(sint32 w) { _WMargin = w; } + sint32 getWMargin() const { return _WMargin; } + + sint32 getWMin() const { return _WMin; } + void setWMin( sint32 wmin ) { _WMin = wmin; } + + // Compute Size according to bitmap and Text (Ensure as big as possible button) + sint32 getWMax() const; + + int luaGetViewText(CLuaState &ls); + + REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) + REFLECT_UCSTRING("uc_hardtext", getText, setText); + REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_SINT32("text_x", getTextX, setTextX) + REFLECT_SINT32("wmargin", getWMargin, setWMargin) + REFLECT_SINT32("wmin", getWMin, setWMin) + REFLECT_LUA_METHOD("getViewText", luaGetViewText) + REFLECT_EXPORT_END + + protected: + + enum {NumTexture= 3}; + + CViewRenderer::CTextureId _TextureIdNormal[NumTexture]; + CViewRenderer::CTextureId _TextureIdPushed[NumTexture]; + CViewRenderer::CTextureId _TextureIdOver[NumTexture]; + + // setup + void setup(); + + private: + + CViewText *_ViewText; + + bool _Setuped; + bool _IsViewTextId; + bool _ForceTextOver; // text is displayed over the "over" texture + // Size of Bitmaps + sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH; + // Value to add to TextW to get button W. + sint32 _WMargin; + // Min W Value + sint32 _WMin; + sint32 _TextY; + sint32 _TextX; + THotSpot _TextPosRef; + THotSpot _TextParentPosRef; + // Special Colors for text + NLMISC::CRGBA _TextColorNormal; + NLMISC::CRGBA _TextColorPushed; + NLMISC::CRGBA _TextColorOver; + NLMISC::CRGBA _TextShadowColorNormal; + NLMISC::CRGBA _TextShadowColorPushed; + NLMISC::CRGBA _TextShadowColorOver; + bool _TextModulateGlobalColorNormal; + bool _TextModulateGlobalColorPushed; + bool _TextModulateGlobalColorOver; + bool _TextHeaderColor; + }; + +} + +#endif // NL_CTRL_TEXT_BUTTON_H + +/* End of ctrl_text_button.h */ diff --git a/code/nel/src/gui/ctrl_text_button.cpp b/code/nel/src/gui/ctrl_text_button.cpp new file mode 100644 index 000000000..75964ee36 --- /dev/null +++ b/code/nel/src/gui/ctrl_text_button.cpp @@ -0,0 +1,552 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/ctrl_text_button.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_text.h" +#include "nel/gui/view_text_id.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/i18n.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; + + +NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTextButton, std::string, "text_button"); + +namespace NLGUI +{ + + // *************************************************************************** + CCtrlTextButton::CCtrlTextButton(const TCtorParam ¶m) + : CCtrlBaseButton(param) + { + _BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0; + _WMargin= 0; + _WMin= 0; + _TextX= -2; + _TextY= -2; + _Setuped= false; + _ViewText= NULL; + _IsViewTextId= false; + _TextColorNormal= CRGBA(255, 255, 255, 255); + _TextColorPushed= CRGBA(255, 255, 255, 255); + _TextColorOver= CRGBA(255, 255, 255, 255); + _TextShadowColorNormal= CRGBA(0, 0, 0, 255); + _TextShadowColorPushed= CRGBA(0, 0, 0, 255); + _TextShadowColorOver= CRGBA(0, 0, 0, 255); + _TextModulateGlobalColorNormal= true; + _TextModulateGlobalColorPushed= true; + _TextModulateGlobalColorOver= true; + _TextHeaderColor= false; + _TextPosRef = Hotspot_MM; + _TextParentPosRef = Hotspot_MM; + _ForceTextOver = false; + } + + // *************************************************************************** + bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + CXMLAutoPtr prop; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + if (! CCtrlBaseButton::parse(cur,parentGroup) ) + { + string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + return false; + } + + + // *** Read Textures. + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); + if (prop) + { + string TxName = toLower(std::string((const char *) prop)); + _TextureIdNormal[0].setTexture((TxName+"_l.tga").c_str()); + _TextureIdNormal[1].setTexture((TxName+"_m.tga").c_str()); + _TextureIdNormal[2].setTexture((TxName+"_r.tga").c_str()); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); + if (prop) + { + string TxName = toLower(std::string((const char *) prop)); + _TextureIdPushed[0].setTexture((TxName+"_l.tga").c_str()); + _TextureIdPushed[1].setTexture((TxName+"_m.tga").c_str()); + _TextureIdPushed[2].setTexture((TxName+"_r.tga").c_str()); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); + if (prop) + { + string TxName = toLower(std::string((const char *) prop)); + _TextureIdOver[0].setTexture((TxName+"_l.tga").c_str()); + _TextureIdOver[1].setTexture((TxName+"_m.tga").c_str()); + _TextureIdOver[2].setTexture((TxName+"_r.tga").c_str()); + } + + // Compute Bmp Sizes + nlctassert(NumTexture==3); + rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, _BmpH); + rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, _BmpH); + rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, _BmpH); + + + // *** Create the ViewText for draw, and set text + // ViewTextId or standard view? + CXMLAutoPtr ptr((const char*)xmlGetProp(cur,(xmlChar*)"textid")); + _IsViewTextId= (bool)ptr; + if(_IsViewTextId) + _ViewText= new CViewTextID(CViewBase::TCtorParam()); + else + _ViewText= new CViewText(CViewBase::TCtorParam()); + _ViewText->setId(_Id+"_text"); + _ViewText->parseTextOptions(cur); + _ViewText->setAvoidResizeParent(avoidResizeParent()); + if(_IsViewTextId) + ((CViewTextID*)_ViewText)->parseTextIdOptions(cur); + // Same RenderLayer as us. + _ViewText->setRenderLayer(getRenderLayer()); + // Parse the hardText (if not text id) + if(!_IsViewTextId) + { + prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); + if (prop) + { + const char *propPtr = prop; + ucstring text = ucstring(propPtr); + if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) + text = CI18N::get (propPtr); + _ViewText->setText(text); + } + } + + // wmargin + _WMargin= 0; + prop = (char*) xmlGetProp( cur, (xmlChar*)"wmargin" ); + if (prop) + { + fromString((const char *) prop, _WMargin); + } + + // wmin + _WMin= 0; + prop = (char*) xmlGetProp( cur, (xmlChar*)"wmin" ); + if (prop) + { + fromString((const char *) prop, _WMin); + } + // _WMin is at least the size of All W Bitmaps + _WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW); + + // TextY + _TextY= -2; + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" ); + if (prop) + { + fromString((const char *) prop, _TextY); + } + _TextX = 0; + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_x" ); + if (prop) + { + fromString((const char *) prop, _TextX); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_underlined" ); + if (prop) + { + _ViewText->setUnderlined(convertBool(prop)); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*) "text_posref" ); + _TextParentPosRef = Hotspot_MM; + _TextPosRef = Hotspot_MM; + if (prop) + { + char *seekPtr = prop.getDatas(); + seekPtr = strtok(seekPtr," \t"); + if (seekPtr == NULL) + { + // mean that there s a bad formated posref (missing space or tab) + nlwarning("bad 'text_pos_ref' formatting"); + } + else + { + _TextParentPosRef = convertHotSpot (seekPtr); + seekPtr = strtok (seekPtr+1+strlen(seekPtr)," \t"); + _TextPosRef = convertHotSpot (seekPtr); + } + } + + + // *** Read Text Colors + // get color normal + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_normal" ); + _TextColorNormal = CRGBA(255,255,255,255); + if (prop) + _TextColorNormal = convertColor (prop); + + // Get ColorPushed + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_pushed" ); + _TextColorPushed = CRGBA(255,255,255,255); + if (prop) + _TextColorPushed = convertColor(prop); + + // Get ColorOver + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_over" ); + _TextColorOver = CRGBA(255,255,255,255); + if (prop) + _TextColorOver = convertColor(prop); + + + // *** Read Text Shadow Colors + // get color normal + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_normal" ); + _TextShadowColorNormal = CRGBA(0,0,0,255); + if (prop) + _TextShadowColorNormal = convertColor (prop); + + // Get ColorPushed + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_pushed" ); + _TextShadowColorPushed = CRGBA(0,0,0,255); + if (prop) + _TextShadowColorPushed = convertColor(prop); + + // Get ColorOver + prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_over" ); + _TextShadowColorOver = CRGBA(0,0,0,255); + if (prop) + _TextShadowColorOver = convertColor(prop); + + // *** Read Text Global Color + // Default: take "global_color" param interface_element option. + _TextModulateGlobalColorNormal= _TextModulateGlobalColorPushed= _TextModulateGlobalColorOver= getModulateGlobalColor(); + + // Read special text global_color for each state + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_normal" ); + if (prop) _TextModulateGlobalColorNormal= convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_pushed" ); + if (prop) _TextModulateGlobalColorPushed= convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_over" ); + if (prop) _TextModulateGlobalColorOver= convertBool(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"force_text_over" ); + if (prop) _ForceTextOver= convertBool(prop); + + // read Text header color + prop = (char*) xmlGetProp( cur, (xmlChar*)"text_header_color" ); + if (prop) _TextHeaderColor= convertBool(prop); + + return true; + } + + // *************************************************************************** + void CCtrlTextButton::draw () + { + CViewRenderer::CTextureId *pTxId = NULL; + CRGBA color; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); + + // *** Detect Over + bool lastOver = false; + updateOver(lastOver); + + // *** Choose Button State + switch(_Type) + { + case ToggleButton: + { + if (_Pushed) + { + pTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + pTxId = _TextureIdNormal; + color = getCurrentColorNormal(globalColor); + } + } + break; + case RadioButton: + { + // CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer(); + // Init the radio button + initRBRef(); + + if (*_RBRef == this) + { + // if it is equal to the ref value, then the button must appear pushed + pTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) + { + pTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + pTxId = _TextureIdNormal; + color = getCurrentColorNormal(globalColor); + _Pushed = false; + } + } + } + break; + case PushButton: + { + if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) + { + pTxId = _TextureIdPushed; + color = getCurrentColorPushed(globalColor); + } + else + { + pTxId = _TextureIdNormal; + color = getCurrentColorNormal(globalColor); + _Pushed = false; + } + } + break; + default: + break; + } + + // *** Draw + color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); + + // Fromzen ? + if (getFrozen() && getFrozenHalfTone()) + color.A >>= 2; + + sint32 x= _XReal; + sint32 y= _YReal; + sint32 txw, txh; + txw = _WReal - _BmpLeftW - _BmpRightW; + txh = _HReal; + nlctassert(NumTexture==3); + rVR.drawRotFlipBitmap ( _RenderLayer, x, y, _BmpLeftW, txh, 0, false, pTxId[0], color ); + rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW, y, txw, txh, 0, false, pTxId[1], color ); + rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); + + // *** Draw Over + if (_Over && (_OverWhenPushed || !(_Pushed || CWidgetManager::getInstance()->getCapturePointerLeft() == this))) + { + if ((lastOver == false) && (_AHOnOver != NULL)) + CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); + + // the pointer is over the button. + color= getCurrentColorOver(globalColor); + color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); + + // Fromzen ? + if (getFrozen() && getFrozenHalfTone()) + color.A >>= 2; + + nlctassert(NumTexture==3); + pTxId= _TextureIdOver; + uint layerOffset = _ForceTextOver ? 0 : 1; // Must write Over On Top of the text ? + + rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x, y, _BmpLeftW, txh, 0, false, pTxId[0], color ); + rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x+_BmpLeftW, y, txw, txh, 0, false, pTxId[1], color ); + rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); + } + + // *** Setup ViewText Color according to selected one (should be drawn after because of eltorder) + // update header color? + CRGBA viewTextColor; + if(_TextHeaderColor) + { + CInterfaceGroup *pIG= getRootWindow(); + if(pIG->isGroupContainer()) + { + CGroupContainerBase *pGC = static_cast(pIG); + viewTextColor= pGC->getDrawnHeaderColor(); + } + } + // Setup ViewText color + if ( pTxId==_TextureIdNormal ) + { + if(_TextHeaderColor) viewTextColor.A= _TextColorNormal.A; + else viewTextColor= _TextColorNormal; + _ViewText->setColor(viewTextColor); + _ViewText->setShadowColor(_TextShadowColorNormal); + _ViewText->setModulateGlobalColor(_TextModulateGlobalColorNormal); + } + else if ( pTxId==_TextureIdPushed ) + { + if(_TextHeaderColor) viewTextColor.A= _TextColorPushed.A; + else viewTextColor= _TextColorPushed; + _ViewText->setColor(viewTextColor); + _ViewText->setShadowColor(_TextShadowColorPushed); + _ViewText->setModulateGlobalColor(_TextModulateGlobalColorPushed); + } + else if ( pTxId==_TextureIdOver ) + { + if(_TextHeaderColor) viewTextColor.A= _TextColorOver.A; + else viewTextColor= _TextColorOver; + _ViewText->setColor(viewTextColor); + _ViewText->setShadowColor(_TextShadowColorOver); + _ViewText->setModulateGlobalColor(_TextModulateGlobalColorOver); + } + if(getFrozen() && getFrozenHalfTone()) + _ViewText->setAlpha(_ViewText->getAlpha()>>2); + } + + + // *************************************************************************** + void CCtrlTextButton::updateCoords() + { + // Should have been setuped with addCtrl + nlassert(_Setuped); + + // Compute Size according to bitmap and Text. + if (!(_SizeRef & 1)) + { + _W= _ViewText->getW() + _WMargin + _TextX; + // Ensure as big as possible button + _W= max(_W, _WMin); + } + if (!(_SizeRef & 2)) + { + _H= _BmpH; + } + + CViewBase::updateCoords(); + } + + // *************************************************************************** + sint32 CCtrlTextButton::getWMax() const + { + return max(_ViewText->getW(false) + _WMargin + _TextX, _WMin); + } + + // *************************************************************************** + void CCtrlTextButton::setup() + { + _Setuped= true; + + // setup the viewText and add to parent + _ViewText->setParent (getParent()); + _ViewText->setParentPos (this); + _ViewText->setParentPosRef (_TextParentPosRef); + _ViewText->setPosRef (_TextPosRef); + _ViewText->setActive(_Active); + _ViewText->setX(_TextX); + _ViewText->setY(_TextY); + + getParent()->addView(_ViewText); + } + + // *************************************************************************** + void CCtrlTextButton::setTextX(sint32 x) + { + _TextX = x; + if (_ViewText) _ViewText->setX(_TextX); + } + + // *************************************************************************** + sint32 CCtrlTextButton::getMaxUsedW() const + { + return _W; + } + + // *************************************************************************** + sint32 CCtrlTextButton::getMinUsedW() const + { + return _W; + } + + // *************************************************************************** + void CCtrlTextButton::setActive(bool state) + { + _ViewText->setActive(state); + CCtrlBaseButton::setActive(state); + } + + + // *************************************************************************** + void CCtrlTextButton::onAddToGroup() + { + // Add the view if not done + if(!_Setuped) + setup(); + } + + + // *************************************************************************** + void CCtrlTextButton::setText (const ucstring &text) + { + if (_ViewText && !_IsViewTextId) + _ViewText->setText(text); + } + + // *************************************************************************** + ucstring CCtrlTextButton::getText () const + { + if (_ViewText && !_IsViewTextId) + return _ViewText->getText(); + return ucstring(""); + } + + // *************************************************************************** + void CCtrlTextButton::setHardText (const std::string &text) + { + if (_ViewText && !_IsViewTextId) + _ViewText->setHardText(text); + } + + // *************************************************************************** + string CCtrlTextButton::getHardText () const + { + if (_ViewText && !_IsViewTextId) + return _ViewText->getHardText(); + return string(""); + } + + // *************************************************************************** + + CViewText* CCtrlTextButton::getViewText() + { + return _ViewText; + } + + // *************************************************************************** + + int CCtrlTextButton::luaGetViewText(CLuaState &ls) + { + const char *funcName = "getViewText"; + CLuaIHM::checkArgCount(ls, funcName, 0); + CLuaIHM::pushUIOnStack(ls, getViewText()); + return 1; + } + + // *************************************************************************** + +} + diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 711cb914f..1ebbb53f2 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -33,7 +33,7 @@ #include "interface_v3/group_editbox.h" #include "permanent_ban.h" #include "global.h" -#include "interface_v3/ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "interface_v3/group_tab.h" #include "string_manager_client.h" diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index ec147a3b9..195cf45de 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -24,7 +24,7 @@ // Client. #include "game_context_menu.h" #include "interface_v3/interface_manager.h" -#include "interface_v3/ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "interface_v3/group_menu.h" #include "entities.h" #include "interface_v3/bot_chat_manager.h" diff --git a/code/ryzom/client/src/game_context_menu.h b/code/ryzom/client/src/game_context_menu.h index 0e5dde414..4f325b5c7 100644 --- a/code/ryzom/client/src/game_context_menu.h +++ b/code/ryzom/client/src/game_context_menu.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "main_loop.h" -#include "interface_v3/ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "nel/gui/interface_group.h" #include "interface_v3/interface_pointer.h" #include "game_share/bot_chat_types.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 7085a1c55..70077ab47 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -41,7 +41,7 @@ #include "../string_manager_client.h" #include "group_container.h" #include "dbgroup_list_sheet_text.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "../client_cfg.h" #include "../init_main_loop.h" #include "guild_manager.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp deleted file mode 100644 index fff7127f0..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ /dev/null @@ -1,545 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "ctrl_text_button.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/view_text.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/group_container_base.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/widget_manager.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; - - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTextButton, std::string, "text_button"); - -// *************************************************************************** -CCtrlTextButton::CCtrlTextButton(const TCtorParam ¶m) -: CCtrlBaseButton(param) -{ - _BmpLeftW= _BmpMiddleW= _BmpRightW= _BmpH= 0; - _WMargin= 0; - _WMin= 0; - _TextX= -2; - _TextY= -2; - _Setuped= false; - _ViewText= NULL; - _IsViewTextId= false; - _TextColorNormal= CRGBA(255, 255, 255, 255); - _TextColorPushed= CRGBA(255, 255, 255, 255); - _TextColorOver= CRGBA(255, 255, 255, 255); - _TextShadowColorNormal= CRGBA(0, 0, 0, 255); - _TextShadowColorPushed= CRGBA(0, 0, 0, 255); - _TextShadowColorOver= CRGBA(0, 0, 0, 255); - _TextModulateGlobalColorNormal= true; - _TextModulateGlobalColorPushed= true; - _TextModulateGlobalColorOver= true; - _TextHeaderColor= false; - _TextPosRef = Hotspot_MM; - _TextParentPosRef = Hotspot_MM; - _ForceTextOver = false; -} - -// *************************************************************************** -bool CCtrlTextButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - CXMLAutoPtr prop; - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - if (! CCtrlBaseButton::parse(cur,parentGroup) ) - { - string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - return false; - } - - - // *** Read Textures. - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); - if (prop) - { - string TxName = toLower(std::string((const char *) prop)); - _TextureIdNormal[0].setTexture((TxName+"_l.tga").c_str()); - _TextureIdNormal[1].setTexture((TxName+"_m.tga").c_str()); - _TextureIdNormal[2].setTexture((TxName+"_r.tga").c_str()); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); - if (prop) - { - string TxName = toLower(std::string((const char *) prop)); - _TextureIdPushed[0].setTexture((TxName+"_l.tga").c_str()); - _TextureIdPushed[1].setTexture((TxName+"_m.tga").c_str()); - _TextureIdPushed[2].setTexture((TxName+"_r.tga").c_str()); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); - if (prop) - { - string TxName = toLower(std::string((const char *) prop)); - _TextureIdOver[0].setTexture((TxName+"_l.tga").c_str()); - _TextureIdOver[1].setTexture((TxName+"_m.tga").c_str()); - _TextureIdOver[2].setTexture((TxName+"_r.tga").c_str()); - } - - // Compute Bmp Sizes - nlctassert(NumTexture==3); - rVR.getTextureSizeFromId(_TextureIdNormal[0], _BmpLeftW, _BmpH); - rVR.getTextureSizeFromId(_TextureIdNormal[1], _BmpMiddleW, _BmpH); - rVR.getTextureSizeFromId(_TextureIdNormal[2], _BmpRightW, _BmpH); - - - // *** Create the ViewText for draw, and set text - // ViewTextId or standard view? - CXMLAutoPtr ptr((const char*)xmlGetProp(cur,(xmlChar*)"textid")); - _IsViewTextId= (bool)ptr; - if(_IsViewTextId) - _ViewText= new CViewTextID(CViewBase::TCtorParam()); - else - _ViewText= new CViewText(CViewBase::TCtorParam()); - _ViewText->setId(_Id+"_text"); - _ViewText->parseTextOptions(cur); - _ViewText->setAvoidResizeParent(avoidResizeParent()); - if(_IsViewTextId) - ((CViewTextID*)_ViewText)->parseTextIdOptions(cur); - // Same RenderLayer as us. - _ViewText->setRenderLayer(getRenderLayer()); - // Parse the hardText (if not text id) - if(!_IsViewTextId) - { - prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (prop) - { - const char *propPtr = prop; - ucstring text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - text = CI18N::get (propPtr); - _ViewText->setText(text); - } - } - - // wmargin - _WMargin= 0; - prop = (char*) xmlGetProp( cur, (xmlChar*)"wmargin" ); - if (prop) - { - fromString((const char *) prop, _WMargin); - } - - // wmin - _WMin= 0; - prop = (char*) xmlGetProp( cur, (xmlChar*)"wmin" ); - if (prop) - { - fromString((const char *) prop, _WMin); - } - // _WMin is at least the size of All W Bitmaps - _WMin= max(_WMin, _BmpLeftW + _BmpMiddleW + _BmpRightW); - - // TextY - _TextY= -2; - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_y" ); - if (prop) - { - fromString((const char *) prop, _TextY); - } - _TextX = 0; - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_x" ); - if (prop) - { - fromString((const char *) prop, _TextX); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_underlined" ); - if (prop) - { - _ViewText->setUnderlined(convertBool(prop)); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*) "text_posref" ); - _TextParentPosRef = Hotspot_MM; - _TextPosRef = Hotspot_MM; - if (prop) - { - char *seekPtr = prop.getDatas(); - seekPtr = strtok(seekPtr," \t"); - if (seekPtr == NULL) - { - // mean that there s a bad formated posref (missing space or tab) - nlwarning("bad 'text_pos_ref' formatting"); - } - else - { - _TextParentPosRef = convertHotSpot (seekPtr); - seekPtr = strtok (seekPtr+1+strlen(seekPtr)," \t"); - _TextPosRef = convertHotSpot (seekPtr); - } - } - - - // *** Read Text Colors - // get color normal - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_normal" ); - _TextColorNormal = CRGBA(255,255,255,255); - if (prop) - _TextColorNormal = convertColor (prop); - - // Get ColorPushed - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_pushed" ); - _TextColorPushed = CRGBA(255,255,255,255); - if (prop) - _TextColorPushed = convertColor(prop); - - // Get ColorOver - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_color_over" ); - _TextColorOver = CRGBA(255,255,255,255); - if (prop) - _TextColorOver = convertColor(prop); - - - // *** Read Text Shadow Colors - // get color normal - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_normal" ); - _TextShadowColorNormal = CRGBA(0,0,0,255); - if (prop) - _TextShadowColorNormal = convertColor (prop); - - // Get ColorPushed - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_pushed" ); - _TextShadowColorPushed = CRGBA(0,0,0,255); - if (prop) - _TextShadowColorPushed = convertColor(prop); - - // Get ColorOver - prop= (char*) xmlGetProp( cur, (xmlChar*)"text_shadow_color_over" ); - _TextShadowColorOver = CRGBA(0,0,0,255); - if (prop) - _TextShadowColorOver = convertColor(prop); - - // *** Read Text Global Color - // Default: take "global_color" param interface_element option. - _TextModulateGlobalColorNormal= _TextModulateGlobalColorPushed= _TextModulateGlobalColorOver= getModulateGlobalColor(); - - // Read special text global_color for each state - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_normal" ); - if (prop) _TextModulateGlobalColorNormal= convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_pushed" ); - if (prop) _TextModulateGlobalColorPushed= convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_global_color_over" ); - if (prop) _TextModulateGlobalColorOver= convertBool(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"force_text_over" ); - if (prop) _ForceTextOver= convertBool(prop); - - // read Text header color - prop = (char*) xmlGetProp( cur, (xmlChar*)"text_header_color" ); - if (prop) _TextHeaderColor= convertBool(prop); - - return true; -} - -// *************************************************************************** -void CCtrlTextButton::draw () -{ - CViewRenderer::CTextureId *pTxId = NULL; - CRGBA color; - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent(); - - // *** Detect Over - bool lastOver = false; - updateOver(lastOver); - - // *** Choose Button State - switch(_Type) - { - case ToggleButton: - { - if (_Pushed) - { - pTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); - } - else - { - pTxId = _TextureIdNormal; - color = getCurrentColorNormal(globalColor); - } - } - break; - case RadioButton: - { -// CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer(); - // Init the radio button - initRBRef(); - - if (*_RBRef == this) - { - // if it is equal to the ref value, then the button must appear pushed - pTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); - } - else - { - if ((_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) - { - pTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); - } - else - { - pTxId = _TextureIdNormal; - color = getCurrentColorNormal(globalColor); - _Pushed = false; - } - } - } - break; - case PushButton: - { - if (_Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this)) - { - pTxId = _TextureIdPushed; - color = getCurrentColorPushed(globalColor); - } - else - { - pTxId = _TextureIdNormal; - color = getCurrentColorNormal(globalColor); - _Pushed = false; - } - } - break; - default: - break; - } - - // *** Draw - color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); - - // Fromzen ? - if (getFrozen() && getFrozenHalfTone()) - color.A >>= 2; - - sint32 x= _XReal; - sint32 y= _YReal; - sint32 txw, txh; - txw = _WReal - _BmpLeftW - _BmpRightW; - txh = _HReal; - nlctassert(NumTexture==3); - rVR.drawRotFlipBitmap ( _RenderLayer, x, y, _BmpLeftW, txh, 0, false, pTxId[0], color ); - rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW, y, txw, txh, 0, false, pTxId[1], color ); - rVR.drawRotFlipBitmap ( _RenderLayer, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); - - // *** Draw Over - if (_Over && (_OverWhenPushed || !(_Pushed || CWidgetManager::getInstance()->getCapturePointerLeft() == this))) - { - if ((lastOver == false) && (_AHOnOver != NULL)) - CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams); - - // the pointer is over the button. - color= getCurrentColorOver(globalColor); - color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); - - // Fromzen ? - if (getFrozen() && getFrozenHalfTone()) - color.A >>= 2; - - nlctassert(NumTexture==3); - pTxId= _TextureIdOver; - uint layerOffset = _ForceTextOver ? 0 : 1; // Must write Over On Top of the text ? - - rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x, y, _BmpLeftW, txh, 0, false, pTxId[0], color ); - rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x+_BmpLeftW, y, txw, txh, 0, false, pTxId[1], color ); - rVR.drawRotFlipBitmap ( _RenderLayer+layerOffset, x+_BmpLeftW+txw, y, _BmpRightW, txh, 0, false, pTxId[2], color ); - } - - // *** Setup ViewText Color according to selected one (should be drawn after because of eltorder) - // update header color? - CRGBA viewTextColor; - if(_TextHeaderColor) - { - CInterfaceGroup *pIG= getRootWindow(); - if(pIG->isGroupContainer()) - { - CGroupContainerBase *pGC = static_cast(pIG); - viewTextColor= pGC->getDrawnHeaderColor(); - } - } - // Setup ViewText color - if ( pTxId==_TextureIdNormal ) - { - if(_TextHeaderColor) viewTextColor.A= _TextColorNormal.A; - else viewTextColor= _TextColorNormal; - _ViewText->setColor(viewTextColor); - _ViewText->setShadowColor(_TextShadowColorNormal); - _ViewText->setModulateGlobalColor(_TextModulateGlobalColorNormal); - } - else if ( pTxId==_TextureIdPushed ) - { - if(_TextHeaderColor) viewTextColor.A= _TextColorPushed.A; - else viewTextColor= _TextColorPushed; - _ViewText->setColor(viewTextColor); - _ViewText->setShadowColor(_TextShadowColorPushed); - _ViewText->setModulateGlobalColor(_TextModulateGlobalColorPushed); - } - else if ( pTxId==_TextureIdOver ) - { - if(_TextHeaderColor) viewTextColor.A= _TextColorOver.A; - else viewTextColor= _TextColorOver; - _ViewText->setColor(viewTextColor); - _ViewText->setShadowColor(_TextShadowColorOver); - _ViewText->setModulateGlobalColor(_TextModulateGlobalColorOver); - } - if(getFrozen() && getFrozenHalfTone()) - _ViewText->setAlpha(_ViewText->getAlpha()>>2); -} - - -// *************************************************************************** -void CCtrlTextButton::updateCoords() -{ - // Should have been setuped with addCtrl - nlassert(_Setuped); - - // Compute Size according to bitmap and Text. - if (!(_SizeRef & 1)) - { - _W= _ViewText->getW() + _WMargin + _TextX; - // Ensure as big as possible button - _W= max(_W, _WMin); - } - if (!(_SizeRef & 2)) - { - _H= _BmpH; - } - - CViewBase::updateCoords(); -} - -// *************************************************************************** -sint32 CCtrlTextButton::getWMax() const -{ - return max(_ViewText->getW(false) + _WMargin + _TextX, _WMin); -} - -// *************************************************************************** -void CCtrlTextButton::setup() -{ - _Setuped= true; - - // setup the viewText and add to parent - _ViewText->setParent (getParent()); - _ViewText->setParentPos (this); - _ViewText->setParentPosRef (_TextParentPosRef); - _ViewText->setPosRef (_TextPosRef); - _ViewText->setActive(_Active); - _ViewText->setX(_TextX); - _ViewText->setY(_TextY); - - getParent()->addView(_ViewText); -} - -// *************************************************************************** -void CCtrlTextButton::setTextX(sint32 x) -{ - _TextX = x; - if (_ViewText) _ViewText->setX(_TextX); -} - -// *************************************************************************** -sint32 CCtrlTextButton::getMaxUsedW() const -{ - return _W; -} - -// *************************************************************************** -sint32 CCtrlTextButton::getMinUsedW() const -{ - return _W; -} - -// *************************************************************************** -void CCtrlTextButton::setActive(bool state) -{ - _ViewText->setActive(state); - CCtrlBaseButton::setActive(state); -} - - -// *************************************************************************** -void CCtrlTextButton::onAddToGroup() -{ - // Add the view if not done - if(!_Setuped) - setup(); -} - - -// *************************************************************************** -void CCtrlTextButton::setText (const ucstring &text) -{ - if (_ViewText && !_IsViewTextId) - _ViewText->setText(text); -} - -// *************************************************************************** -ucstring CCtrlTextButton::getText () const -{ - if (_ViewText && !_IsViewTextId) - return _ViewText->getText(); - return ucstring(""); -} - -// *************************************************************************** -void CCtrlTextButton::setHardText (const std::string &text) -{ - if (_ViewText && !_IsViewTextId) - _ViewText->setHardText(text); -} - -// *************************************************************************** -string CCtrlTextButton::getHardText () const -{ - if (_ViewText && !_IsViewTextId) - return _ViewText->getHardText(); - return string(""); -} - -// *************************************************************************** - -CViewText* CCtrlTextButton::getViewText() -{ - return _ViewText; -} - -// *************************************************************************** - -int CCtrlTextButton::luaGetViewText(CLuaState &ls) -{ - const char *funcName = "getViewText"; - CLuaIHM::checkArgCount(ls, funcName, 0); - CLuaIHM::pushUIOnStack(ls, getViewText()); - return 1; -} - -// *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.h b/code/ryzom/client/src/interface_v3/ctrl_text_button.h deleted file mode 100644 index 677690e50..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.h +++ /dev/null @@ -1,165 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_CTRL_TEXT_BUTTON_H -#define NL_CTRL_TEXT_BUTTON_H - -#include "nel/gui/ctrl_base_button.h" -#include "nel/gui/view_renderer.h" - - -namespace NLGUI -{ - class CEventDescriptor; - class CViewText; -} - -// *************************************************************************** -/** - * Text Button that can be either Push or Toggle button. Localized, auto-resize - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CCtrlTextButton : public CCtrlBaseButton -{ -public: - - /// Constructor - CCtrlTextButton(const TCtorParam ¶m); - - // Init part - virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - - virtual void updateCoords(); - - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - // Display part - virtual void draw(); - - // Hide/Show the text also. - virtual void setActive(bool state); - - // Add also our ViewText - virtual void onAddToGroup(); - - - /// \from CInterfaceElement - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - - // Special Text Colors accessors - // Colors - NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;} - void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;} - NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;} - void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;} - NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;} - void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;} - // Shadow Colors - NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;} - void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;} - NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;} - void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;} - NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;} - void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;} - // Global Modulate Colors - bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;} - void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;} - bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;} - void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;} - bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} - void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} - // Set text (noop if text id) - void setText (const ucstring &text); - ucstring getText () const; - - void setHardText (const std::string &text); - std::string getHardText () const; - - CViewText* getViewText(); - void setViewText(CViewText* text) {_ViewText=text;} - - void setTextX(sint32 x); - sint32 getTextX() const { return _TextX; } - - void setWMargin(sint32 w) { _WMargin = w; } - sint32 getWMargin() const { return _WMargin; } - - sint32 getWMin() const { return _WMin; } - void setWMin( sint32 wmin ) { _WMin = wmin; } - - // Compute Size according to bitmap and Text (Ensure as big as possible button) - sint32 getWMax() const; - - int luaGetViewText(CLuaState &ls); - - REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) - REFLECT_UCSTRING("uc_hardtext", getText, setText); - REFLECT_STRING("hardtext", getHardText, setHardText); - REFLECT_SINT32("text_x", getTextX, setTextX) - REFLECT_SINT32("wmargin", getWMargin, setWMargin) - REFLECT_SINT32("wmin", getWMin, setWMin) - REFLECT_LUA_METHOD("getViewText", luaGetViewText) - REFLECT_EXPORT_END - -protected: - - enum {NumTexture= 3}; - - CViewRenderer::CTextureId _TextureIdNormal[NumTexture]; - CViewRenderer::CTextureId _TextureIdPushed[NumTexture]; - CViewRenderer::CTextureId _TextureIdOver[NumTexture]; - - // setup - void setup(); - -private: - - CViewText *_ViewText; - - bool _Setuped; - bool _IsViewTextId; - bool _ForceTextOver; // text is displayed over the "over" texture - // Size of Bitmaps - sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH; - // Value to add to TextW to get button W. - sint32 _WMargin; - // Min W Value - sint32 _WMin; - sint32 _TextY; - sint32 _TextX; - THotSpot _TextPosRef; - THotSpot _TextParentPosRef; - // Special Colors for text - NLMISC::CRGBA _TextColorNormal; - NLMISC::CRGBA _TextColorPushed; - NLMISC::CRGBA _TextColorOver; - NLMISC::CRGBA _TextShadowColorNormal; - NLMISC::CRGBA _TextShadowColorPushed; - NLMISC::CRGBA _TextShadowColorOver; - bool _TextModulateGlobalColorNormal; - bool _TextModulateGlobalColorPushed; - bool _TextModulateGlobalColorOver; - bool _TextHeaderColor; -}; - -#endif // NL_CTRL_TEXT_BUTTON_H - -/* End of ctrl_text_button.h */ diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index d43d8e2f8..18299a803 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -22,7 +22,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "view_bitmap.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "../net_manager.h" #include "../client_sheets/item_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 51b65d236..d3b09c9e5 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -35,7 +35,7 @@ extern "C" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "dbctrl_sheet.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "nel/gui/action_handler.h" #include "group_paragraph.h" #include "group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index 8f87f09a6..bcb24c559 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -23,7 +23,7 @@ #include "nel/gui/group_modal.h" #include "nel/gui/group_submenu_base.h" #include "nel/gui/view_text.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" namespace NLGUI { diff --git a/code/ryzom/client/src/interface_v3/group_tab.h b/code/ryzom/client/src/interface_v3/group_tab.h index 1e8e8c792..46cc241ab 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.h +++ b/code/ryzom/client/src/interface_v3/group_tab.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b9c9a6df0..8b9fc658d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -56,7 +56,7 @@ // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" // DBCtrl #include "dbctrl_sheet.h" // Group diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 15cab1fd9..32d48d7d8 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -56,7 +56,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_col_pick.h" #include "nel/gui/ctrl_tooltip.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "group_paragraph.h" // For CCtrlLink // DBCtrl #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index 62605d6e3..c56a36457 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -28,6 +28,7 @@ namespace NLGUI class CCtrlBaseButton; class CInterfaceGroup; class CViewText; + class CCtrlTextButton; } using namespace NLGUI; @@ -60,7 +61,7 @@ public: // Some pointers typedef CInterfacePtr::TInterfacePtr CInterfaceElementPtr; typedef CInterfacePtr::TInterfacePtr CInterfaceGroupPtr; -typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; +typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; typedef CInterfacePtr::TInterfacePtr CViewTextPtr; typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 81a6cb960..ec9043989 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -32,7 +32,7 @@ #include "../string_manager_client.h" #include "nel/gui/interface_expr.h" #include "nel/gui/ctrl_button.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "filtered_chat_summary.h" #include "input_handler_manager.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 51bbc1ae6..00959b4d2 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -34,7 +34,7 @@ #include "group_list.h" #include "dbgroup_select_number.h" #include "nel/gui/ctrl_button.h" -#include "ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "nel/gui/ctrl_col_pick.h" #include "nel/gui/ctrl_draggable.h" #include "dbctrl_sheet.h" diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 842267e67..eb5008ee2 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -39,7 +39,7 @@ #include "interface_v3/group_quick_help.h" #include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" -#include "interface_v3/ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "sound_manager.h" #include "far_tp.h" diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 5c1929acd..e1e91377f 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -58,7 +58,7 @@ #include "interface_v3/bot_chat_manager.h" #include "interface_v3/bot_chat_page_all.h" #include "nel/gui/view_text_id.h" -#include "interface_v3/ctrl_text_button.h" +#include "nel/gui/ctrl_text_button.h" #include "interface_v3/input_handler_manager.h" #include "interface_v3/guild_manager.h" #include "interface_v3/skill_manager.h" From 0370f774245a023f7acb5469c120ceef351a0455 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 21 Jun 2012 23:05:12 +0200 Subject: [PATCH 085/339] CHANGED: #1471 CViewBitmap no longer depends on CGroupContainer. --- .../nel/include/nel/gui/group_container_base.h | 7 ++++++- code/nel/src/gui/group_container_base.cpp | 2 ++ .../src/interface_v3/group_container.cpp | 2 -- .../client/src/interface_v3/group_container.h | 6 ------ .../client/src/interface_v3/view_bitmap.cpp | 18 ++++-------------- .../client/src/interface_v3/view_bitmap.h | 1 - 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index 988050341..1d228f017 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -81,10 +81,15 @@ namespace NLGUI // Get the header color draw. NB: depends if grayed, and if active. virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); }; + + uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; } + uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; } protected: void triggerAlphaSettingsChangedAH(); - + + uint8 _CurrentContainerAlpha; + uint8 _CurrentContentAlpha; uint8 _ContainerAlpha; uint8 _ContentAlpha; uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it diff --git a/code/nel/src/gui/group_container_base.cpp b/code/nel/src/gui/group_container_base.cpp index 7ef134c8a..315c03862 100644 --- a/code/nel/src/gui/group_container_base.cpp +++ b/code/nel/src/gui/group_container_base.cpp @@ -23,6 +23,8 @@ namespace NLGUI CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam ¶m ) : CInterfaceGroup( param ) { + _CurrentContainerAlpha = 255; + _CurrentContentAlpha = 255; _ContentAlpha = 255; _ContainerAlpha = 255; _RolloverAlphaContainer = 0; diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 6876c66a8..707e85588 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -1201,8 +1201,6 @@ CGroupContainer::CGroupContainer(const TCtorParam ¶m) // faster than a virual call _IsGroupContainer = true; - _CurrentContainerAlpha = 255; - _CurrentContentAlpha = 255; _CurrentRolloverAlphaContainer = 0.f; _CurrentRolloverAlphaContent = 0.f; diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 35c5a851e..731e9bcc7 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -31,7 +31,6 @@ namespace NLGUI class CViewText; } -class CInterfaceList; class COptionsContainerInsertion; class COptionsContainerMove; class CGroupContainer; @@ -366,9 +365,6 @@ public: sint32 getRefW() const { return _RefW; } - uint8 getCurrentContainerAlpha() const { return _CurrentContainerAlpha; } - uint8 getCurrentContentAlpha() const { return _CurrentContentAlpha; } - /** Increase the rollover alpha for the current frame. * Example of use : an edit box that has focus in a group container */ @@ -463,8 +459,6 @@ public: sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } protected: - uint8 _CurrentContainerAlpha; - uint8 _CurrentContentAlpha; uint8 _ICurrentRolloverAlphaContainer; uint8 _HighLightedAlpha; float _CurrentRolloverAlphaContainer; diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp index c2266bb3a..dfbd2c1c7 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap.cpp @@ -16,16 +16,11 @@ -// ---------------------------------------------------------------------------- - -#include "stdpch.h" - #include "view_bitmap.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" -#include "group_container.h" - -// ---------------------------------------------------------------------------- +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" using namespace std; using namespace NLMISC; @@ -144,7 +139,6 @@ bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) // ---------------------------------------------------------------------------- void CViewBitmap::draw () { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA col; @@ -166,7 +160,7 @@ void CViewBitmap::draw () { if (gr->isGroupContainer()) { - CGroupContainer *gc = static_cast(gr); + CGroupContainerBase *gc = static_cast(gr); col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); break; } @@ -208,7 +202,6 @@ void CViewBitmap::updateCoords() { if (!_Scale) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 txw, txh; rVR.getTextureSizeFromId (_TextureId, txw, txh); @@ -230,7 +223,6 @@ void CViewBitmap::setTexture(const std::string & TxName) // ---------------------------------------------------------------------------- std::string CViewBitmap::getTexture () const { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); return rVR.getTextureNameFromId (_TextureId); } @@ -238,7 +230,6 @@ std::string CViewBitmap::getTexture () const // *************************************************************************** void CViewBitmap::fitTexture() { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 w, h; rVR.getTextureSizeFromId(_TextureId, w, h); @@ -286,7 +277,6 @@ NLMISC::CRGBA CViewBitmap::getColorRGBA() const sint32 CViewBitmap::getMaxUsedW() const { sint32 txw, txh; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); rVR.getTextureSizeFromId (_TextureId, txw, txh); return txw; diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.h b/code/ryzom/client/src/interface_v3/view_bitmap.h index 3d63cbfe8..cea94116b 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap.h @@ -133,7 +133,6 @@ protected: sint32 _TxtWidth; // Width of the single texture sint32 _TxtHeight; // Height of the single texture - friend class CInterfaceList; }; From b7dc46ed8bf197e42e00bb0fd4ec7414014e3fc5 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 03:49:43 +0200 Subject: [PATCH 086/339] CHANGED: #1471 CViewBitmap is now part of NELGUI library, and is under NLGUI namespace. --- code/nel/include/nel/gui/view_bitmap.h | 146 ++++++++ code/nel/src/gui/view_bitmap.cpp | 315 ++++++++++++++++++ code/ryzom/client/src/init_main_loop.cpp | 2 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.h | 2 +- .../dbgroup_list_sheet_text_share.cpp | 2 +- .../dbgroup_list_sheet_text_share.h | 5 +- .../interface_v3/dbgroup_select_number.cpp | 2 +- .../src/interface_v3/dbgroup_select_number.h | 4 +- .../client/src/interface_v3/dbview_bar.h | 2 +- .../client/src/interface_v3/dbview_bar3.h | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 2 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_container.h | 2 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../interface_v3/group_in_scene_user_info.cpp | 2 +- .../client/src/interface_v3/group_list.cpp | 2 +- .../ryzom/client/src/interface_v3/group_map.h | 2 +- .../client/src/interface_v3/group_menu.cpp | 2 +- .../client/src/interface_v3/group_menu.h | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../client/src/interface_v3/group_skills.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/group_tree.cpp | 2 +- .../client/src/interface_v3/group_tree.h | 3 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- .../client/src/interface_v3/view_bitmap.cpp | 311 ----------------- .../client/src/interface_v3/view_bitmap.h | 141 -------- .../src/interface_v3/view_bitmap_faber_mp.h | 2 +- .../client/src/r2/displayer_visual_shape.h | 6 +- code/ryzom/client/src/r2/instance_map_deco.h | 2 +- code/ryzom/client/src/r2/prim_render.cpp | 2 +- 40 files changed, 504 insertions(+), 491 deletions(-) create mode 100644 code/nel/include/nel/gui/view_bitmap.h create mode 100644 code/nel/src/gui/view_bitmap.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_bitmap.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_bitmap.h diff --git a/code/nel/include/nel/gui/view_bitmap.h b/code/nel/include/nel/gui/view_bitmap.h new file mode 100644 index 000000000..00030caaa --- /dev/null +++ b/code/nel/include/nel/gui/view_bitmap.h @@ -0,0 +1,146 @@ +// Ryzom - MMORPG Framework +// 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 NL_VIEW_BITMAP_H +#define NL_VIEW_BITMAP_H + +#include "nel/gui/view_base.h" +#include "nel/3d/u_texture.h" +#include "nel/gui/view_renderer.h" + +namespace NLGUI +{ + + /** + * class implementing a bitmap view + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CViewBitmap : public CViewBase + { + public: + DECLARE_UI_CLASS(CViewBitmap) + enum EType { Stretched = 0, Tiled, TypeCount }; + public: + + /// Constructor + CViewBitmap(const TCtorParam ¶m) : CViewBase(param) + { + _Color = NLMISC::CRGBA(255,255,255,255); + _Scale = false; + _Rot = 0; + _Flip = false; + _Tile = false; + _Align = 0; + _Type = Stretched; + _InheritGCAlpha = false; + + // Default parameters for createTexture + _TxtOffsetX = 0; + _TxtOffsetY = 0; + _TxtWidth = -1; + _TxtHeight = -1; + } + + /** + * parse an xml node and initialize the base view mambers. Must call CViewBase::parse + * \param cur : pointer to the xml node to be parsed + * \param parentGroup : the parent group of the view + * \partam id : a refence to the string that will receive the view ID + * \return true if success + */ + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + virtual void updateCoords (); + + /// Draw the view + virtual void draw (); + + bool getScale() const { return _Scale; } + void setScale (bool s) { _Scale = s; } + bool getTile() const { return _Tile; } + void setTile (bool s) { _Tile = s; } + void setColor (const NLMISC::CRGBA &r) { _Color = r; } + + // Reflected + + virtual void setTexture(const std::string & TxName); + virtual std::string getTexture () const; + + /** Force the bitmap to match current texture size + * The 'scale' flag isnot modified + */ + void fitTexture(); + + bool isTextureValid() const { return _TextureId != -1; } + + void setColorAsString(const std::string & col); + std::string getColorAsString() const; + + void setColorAsInt(sint32 col); + sint32 getColorAsInt() const; + + void setColorRGBA(NLMISC::CRGBA col); + NLMISC::CRGBA getColorRGBA() const; + + virtual sint32 getAlpha() const { return _Color.A; } + virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; } + + REFLECT_EXPORT_START(CViewBitmap, CViewBase) + REFLECT_STRING ("color", getColorAsString, setColorAsString); + REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt); + REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); + REFLECT_SINT32 ("alpha", getAlpha, setAlpha); + REFLECT_STRING ("texture", getTexture, setTexture); + REFLECT_BOOL("scale", getScale, setScale); + REFLECT_EXPORT_END + + /// \from CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + virtual void serial(NLMISC::IStream &f); + + protected: + CViewRenderer::CTextureId _TextureId; /// Accelerator + NLMISC::CRGBA _Color; + sint32 _Rot; + sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1) + EType _Type; + bool _Scale : 1; + bool _Flip : 1; + bool _Tile : 1; + bool _InheritGCAlpha : 1; + + // For single texture + + sint32 _TxtOffsetX; // Offset X of the single texture + sint32 _TxtOffsetY; // Offset Y of the single texture + sint32 _TxtWidth; // Width of the single texture + sint32 _TxtHeight; // Height of the single texture + + }; + + +} + +#endif // NL_VIEW_BITMAP_H + +/* End of view_bitmap.h */ diff --git a/code/nel/src/gui/view_bitmap.cpp b/code/nel/src/gui/view_bitmap.cpp new file mode 100644 index 000000000..8643b4162 --- /dev/null +++ b/code/nel/src/gui/view_bitmap.cpp @@ -0,0 +1,315 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_bitmap.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; + + +NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap"); +REGISTER_UI_CLASS(CViewBitmap) + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + + bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + CXMLAutoPtr prop; + + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + if (! CViewBase::parse(cur,parentGroup) ) + { + string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); + nlinfo (tmp.c_str()); + return false; + } + + //try to get the NEEDED specific props + prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _Color = CRGBA(255,255,255,255); + if (prop) + _Color = convertColor (prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsetx" ); + _TxtOffsetX = 0; + if (prop) fromString((const char*)prop, _TxtOffsetX); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsety" ); + _TxtOffsetY = 0; + if (prop) fromString((const char*)prop, _TxtOffsetY); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"txtwidth" ); + _TxtWidth = -1; + if (prop) fromString((const char*)prop, _TxtWidth); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"txtheight" ); + _TxtHeight = -1; + if (prop) fromString((const char*)prop, _TxtHeight); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"texture" ); + if (prop) + { + string TxName = (const char *) prop; + TxName = strlwr (TxName); + setTexture (TxName); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CViewRenderer &rVR = *CViewRenderer::getInstance(); + //_TextureId = rVR.getTextureIdFromName (TxName); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" ); + _Scale = false; + if (prop) + _Scale = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"rot" ); + _Rot = 0; + if (prop) + fromString((const char*)prop, _Rot); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"flip" ); + _Flip = false; + if (prop) + _Flip = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"tile" ); + _Tile = false; + if (prop) + _Tile = convertBool(prop); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); + _Align = 0; + if (prop) + { + const char *seekPtr = prop.getDatas(); + while (*seekPtr != 0) + { + if ((*seekPtr=='l')||(*seekPtr=='L')) + { + _Align &= ~1; + } + if ((*seekPtr=='r')||(*seekPtr=='R')) + { + _Align |= 1; + } + if ((*seekPtr=='b')||(*seekPtr=='B')) + { + _Align &= ~2; + } + if ((*seekPtr=='t')||(*seekPtr=='T')) + { + _Align |= 2; + } + ++seekPtr; + } + } + + _InheritGCAlpha = false; + prop = (char*) xmlGetProp( cur, (xmlChar*)"inherit_gc_alpha" ); + if (prop) + { + _InheritGCAlpha = convertBool(prop); + } + + return true; + } + + // ---------------------------------------------------------------------------- + void CViewBitmap::draw () + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + CRGBA col; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _Color; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + if (_InheritGCAlpha) + { + // search a parent container + CInterfaceGroup *gr = getParent(); + while (gr) + { + if (gr->isGroupContainer()) + { + CGroupContainerBase *gc = static_cast(gr); + col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); + break; + } + gr = gr->getParent(); + } + } + + if (_Scale && !_Tile) + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, + _WReal, _HReal, + (uint8)_Rot, _Flip, + _TextureId, + col ); + } + else + { + if (!_Tile) + { + rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, + (uint8)_Rot, _Flip, + _TextureId, + col); + } + else + { + rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal, + _WReal, _HReal, + (uint8)_Rot, _Flip, + _TextureId, + _Align, + col); + } + } + } + + // ---------------------------------------------------------------------------- + void CViewBitmap::updateCoords() + { + if (!_Scale) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 txw, txh; + rVR.getTextureSizeFromId (_TextureId, txw, txh); + _W = txw; + _H = txh; + } + CViewBase::updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CViewBitmap::setTexture(const std::string & TxName) + { + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + + _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); + } + + // ---------------------------------------------------------------------------- + std::string CViewBitmap::getTexture () const + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + return rVR.getTextureNameFromId (_TextureId); + } + + // *************************************************************************** + void CViewBitmap::fitTexture() + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 w, h; + rVR.getTextureSizeFromId(_TextureId, w, h); + setW(w); + setH(h); + } + + // *************************************************************************** + void CViewBitmap::setColorAsString(const std::string & col) + { + _Color = convertColor (col.c_str()); + } + + // *************************************************************************** + std::string CViewBitmap::getColorAsString() const + { + return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); + } + + // *************************************************************************** + void CViewBitmap::setColorAsInt(sint32 col) + { + _Color.setPacked(col); + } + + // *************************************************************************** + sint32 CViewBitmap::getColorAsInt() const + { + return _Color.getPacked(); + } + + // *************************************************************************** + void CViewBitmap::setColorRGBA(NLMISC::CRGBA col) + { + _Color = col; + } + + // *************************************************************************** + NLMISC::CRGBA CViewBitmap::getColorRGBA() const + { + return _Color; + } + + // *************************************************************************** + sint32 CViewBitmap::getMaxUsedW() const + { + sint32 txw, txh; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.getTextureSizeFromId (_TextureId, txw, txh); + return txw; + } + + // *************************************************************************** + sint32 CViewBitmap::getMinUsedW() const + { + return getMaxUsedW(); + } + + // *************************************************************************** + void CViewBitmap::serial(NLMISC::IStream &f) + { + CViewBase::serial(f); + f.serial(_TextureId); + f.serial(_Color); + f.serial(_Rot); + f.serialEnum(_Align); + f.serialEnum(_Type); + nlSerialBitBool(f, _Scale); + nlSerialBitBool(f, _Flip); + nlSerialBitBool(f, _Tile); + nlSerialBitBool(f, _InheritGCAlpha); + f.serial(_TxtOffsetX); + f.serial(_TxtOffsetY); + f.serial(_TxtWidth); + f.serial(_TxtHeight); + } + +} + +// *************************************************************************** diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index d35d00561..a9e72c2eb 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -53,7 +53,7 @@ #include "interface_v3/interface_manager.h" #include "interface_v3/people_interraction.h" -#include "interface_v3/view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/interface_link.h" #include "cursor_functions.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 9de7ed7c4..486f9b70f 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -46,7 +46,7 @@ #include "interface_ddx.h" #include "group_tree.h" #include "group_map.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "action_handler_tools.h" #include "../connection.h" #include "../client_chat_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index c9d37f5fb..57fb10631 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -42,7 +42,7 @@ #include "nel/gui/ctrl_base_button.h" #include "../connection.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" extern CSheetManager SheetMngr; extern NLMISC::CLog g_log; diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index 70077ab47..aeb455224 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -47,7 +47,7 @@ #include "guild_manager.h" #include "../sheet_manager.h" #include "../user_entity.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/misc/common.h" using namespace std::rel_ops; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index bfe7e06fe..b885a9979 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -22,7 +22,7 @@ #include "sphrase_manager.h" #include "interface_manager.h" #include "dbctrl_sheet.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/ctrl_button.h" #include "group_editbox.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h index 94af94de9..f37ea9134 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h @@ -30,13 +30,13 @@ namespace NLGUI { class CCtrlBaseButton; class CViewText; + class CViewBitmap; } // *************************************************************************** class CDBCtrlSheet; class CSBrickSheet; -class CViewBitmap; class CGroupEditBox; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp index 18299a803..aefc371f8 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.cpp @@ -21,7 +21,7 @@ #include "../client_sheets/sbrick_sheet.h" #include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/ctrl_text_button.h" #include "../net_manager.h" #include "../client_sheets/item_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.h index 272c0cb9d..b94240b8b 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_share.h @@ -22,7 +22,10 @@ #include "nel/misc/types_nl.h" #include "dbgroup_list_sheet_text.h" -class CViewBitmap; +namespace NLGUI +{ + class CViewBitmap; +} // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp index 4889fa367..1b7e7a0e5 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp @@ -22,7 +22,7 @@ #include "dbgroup_select_number.h" #include "nel/gui/view_text.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h index d6446ee33..0b3b1a530 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h @@ -27,12 +27,10 @@ namespace NLGUI { class CCtrlBaseButton; class CViewText; + class CViewBitmap; } -// *************************************************************************** -class CViewBitmap; - // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.h b/code/ryzom/client/src/interface_v3/dbview_bar.h index 79d73fd78..f3ee02129 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.h +++ b/code/ryzom/client/src/interface_v3/dbview_bar.h @@ -20,7 +20,7 @@ #define RZ_DBVIEW_BAR_H #include "nel/misc/types_nl.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" /** * class implementing a bitmap used as the front texture of a progress bar diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.h b/code/ryzom/client/src/interface_v3/dbview_bar3.h index 751b93a1b..f745564c3 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.h +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.h @@ -20,7 +20,7 @@ #define RZ_DBVIEW_BAR3_H #include "nel/misc/types_nl.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" /** * class implementing a 3 Bar widget diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index d6d6bf44e..b3f2abad2 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "group_tree.h" #include "nel/gui/view_text_id.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "action_handler_misc.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 707e85588..8e397bcfc 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -35,7 +35,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/view_text.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 731e9bcc7..26a1b3a45 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -29,13 +29,13 @@ namespace NLGUI class CCtrlButton; class CCtrlScroll; class CViewText; + class CViewBitmap; } class COptionsContainerInsertion; class COptionsContainerMove; class CGroupContainer; class CInterfaceManager; -class CViewBitmap; class COptionsLayer; class CGroupList; diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index d3b09c9e5..77d4c422d 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -40,7 +40,7 @@ extern "C" #include "group_paragraph.h" #include "group_editbox.h" #include "interface_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "../actions.h" #include "dbgroup_combo_box.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp index 16a16393b..d8c5bd4a8 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" #include "interface_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "group_in_scene_user_info.h" #include "nel/gui/action_handler.h" #include "../entities.h" diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 9315d9024..43b109ac1 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" #include "group_container.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.h b/code/ryzom/client/src/interface_v3/group_map.h index 0521ede20..d39a8c1b3 100644 --- a/code/ryzom/client/src/interface_v3/group_map.h +++ b/code/ryzom/client/src/interface_v3/group_map.h @@ -27,7 +27,7 @@ #include "nel/gui/interface_group.h" #include "nel/gui/ctrl_button.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/view_text.h" #include "animal_position_state.h" #include "../continent.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index da2681f53..b0a062049 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -22,7 +22,7 @@ #include "nel/gui/interface_expr.h" #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/action_handler.h" // Just for getAllParams #include "nel/gui/lua_ihm.h" #include "lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index bcb24c559..4b4298ab7 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -28,9 +28,9 @@ namespace NLGUI { class CCtrlScroll; + class CViewBitmap; } -class CViewBitmap; class CGroupMenu; class CGroupList; diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index b3d915235..ae8791c6c 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index d866a8c5a..c73082c1e 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -24,7 +24,7 @@ #include "nel/gui/interface_expr.h" #include "nel/gui/view_text.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "dbview_number.h" #include "dbview_bar.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 0b4bb5cd1..7d9d6239f 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/gui/interface_element.h" #include "../client_chat_manager.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 4c6d48bb6..7a5eafc75 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -21,7 +21,7 @@ #include "group_tree.h" #include "interface_manager.h" #include "nel/gui/interface_element.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/view_text.h" #include "group_container.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/group_tree.h b/code/ryzom/client/src/interface_v3/group_tree.h index 5b158f67b..fcc321a2b 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.h +++ b/code/ryzom/client/src/interface_v3/group_tree.h @@ -26,10 +26,9 @@ namespace NLGUI { class CViewText; + class CViewBitmap; } -class CViewBitmap; - // ---------------------------------------------------------------------------- class CGroupTree : public CInterfaceGroup { diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index a89387a82..bb6f66f38 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -33,7 +33,7 @@ #include "../connection.h" #include "../entity_cl.h" #include "../user_entity.h" // UserEntity -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "../sheet_manager.h" #include "../net_manager.h" #include "../client_sheets/building_sheet.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 8b9fc658d..65e7b6d2d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -46,7 +46,7 @@ #include "action_handler_help.h" #include "action_handler_item.h" // View -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" //#include "view_bitmap_progress.h" #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 32d48d7d8..d593b1000 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -36,7 +36,7 @@ #include "interface_anim.h" #include "interface_3d_scene.h" // View -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "view_bitmap_faber_mp.h" #include "view_bitmap_combo.h" #include "nel/gui/view_text.h" diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index a5ddacdbf..46a08234a 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -20,7 +20,7 @@ #include "people_list.h" #include "group_container.h" #include "group_list.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 00959b4d2..ca2681bdd 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -22,7 +22,7 @@ #include "nel/gui/view_base.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_id.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "view_radar.h" #include "nel/gui/group_submenu_base.h" #include "group_menu.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index d31a4d034..1f849522b 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -28,7 +28,7 @@ #include "nel/gui/action_handler.h" #include "sbrick_manager.h" #include "dbgroup_combo_box.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "../net_manager.h" #include "sbrick_manager.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.cpp b/code/ryzom/client/src/interface_v3/view_bitmap.cpp deleted file mode 100644 index dfbd2c1c7..000000000 --- a/code/ryzom/client/src/interface_v3/view_bitmap.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_bitmap.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_group.h" -#include "nel/gui/group_container_base.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; - - -NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap"); -REGISTER_UI_CLASS(CViewBitmap) - -// ---------------------------------------------------------------------------- - -bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - CXMLAutoPtr prop; - - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - if (! CViewBase::parse(cur,parentGroup) ) - { - string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); - nlinfo (tmp.c_str()); - return false; - } - - //try to get the NEEDED specific props - prop= (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _Color = CRGBA(255,255,255,255); - if (prop) - _Color = convertColor (prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsetx" ); - _TxtOffsetX = 0; - if (prop) fromString((const char*)prop, _TxtOffsetX); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsety" ); - _TxtOffsetY = 0; - if (prop) fromString((const char*)prop, _TxtOffsetY); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"txtwidth" ); - _TxtWidth = -1; - if (prop) fromString((const char*)prop, _TxtWidth); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"txtheight" ); - _TxtHeight = -1; - if (prop) fromString((const char*)prop, _TxtHeight); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"texture" ); - if (prop) - { - string TxName = (const char *) prop; - TxName = strlwr (TxName); - setTexture (TxName); - //CInterfaceManager *pIM = CInterfaceManager::getInstance(); - //CViewRenderer &rVR = *CViewRenderer::getInstance(); - //_TextureId = rVR.getTextureIdFromName (TxName); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" ); - _Scale = false; - if (prop) - _Scale = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"rot" ); - _Rot = 0; - if (prop) - fromString((const char*)prop, _Rot); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"flip" ); - _Flip = false; - if (prop) - _Flip = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"tile" ); - _Tile = false; - if (prop) - _Tile = convertBool(prop); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); - _Align = 0; - if (prop) - { - const char *seekPtr = prop.getDatas(); - while (*seekPtr != 0) - { - if ((*seekPtr=='l')||(*seekPtr=='L')) - { - _Align &= ~1; - } - if ((*seekPtr=='r')||(*seekPtr=='R')) - { - _Align |= 1; - } - if ((*seekPtr=='b')||(*seekPtr=='B')) - { - _Align &= ~2; - } - if ((*seekPtr=='t')||(*seekPtr=='T')) - { - _Align |= 2; - } - ++seekPtr; - } - } - - _InheritGCAlpha = false; - prop = (char*) xmlGetProp( cur, (xmlChar*)"inherit_gc_alpha" ); - if (prop) - { - _InheritGCAlpha = convertBool(prop); - } - - return true; -} - -// ---------------------------------------------------------------------------- -void CViewBitmap::draw () -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - CRGBA col; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _Color; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - if (_InheritGCAlpha) - { - // search a parent container - CInterfaceGroup *gr = getParent(); - while (gr) - { - if (gr->isGroupContainer()) - { - CGroupContainerBase *gc = static_cast(gr); - col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8); - break; - } - gr = gr->getParent(); - } - } - - if (_Scale && !_Tile) - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - (uint8)_Rot, _Flip, - _TextureId, - col ); - } - else - { - if (!_Tile) - { - rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, - (uint8)_Rot, _Flip, - _TextureId, - col); - } - else - { - rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - (uint8)_Rot, _Flip, - _TextureId, - _Align, - col); - } - } -} - -// ---------------------------------------------------------------------------- -void CViewBitmap::updateCoords() -{ - if (!_Scale) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 txw, txh; - rVR.getTextureSizeFromId (_TextureId, txw, txh); - _W = txw; - _H = txh; - } - CViewBase::updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CViewBitmap::setTexture(const std::string & TxName) -{ -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - - _TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false); -} - -// ---------------------------------------------------------------------------- -std::string CViewBitmap::getTexture () const -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - return rVR.getTextureNameFromId (_TextureId); -} - -// *************************************************************************** -void CViewBitmap::fitTexture() -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 w, h; - rVR.getTextureSizeFromId(_TextureId, w, h); - setW(w); - setH(h); -} - -// *************************************************************************** -void CViewBitmap::setColorAsString(const std::string & col) -{ - _Color = convertColor (col.c_str()); -} - -// *************************************************************************** -std::string CViewBitmap::getColorAsString() const -{ - return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A); -} - -// *************************************************************************** -void CViewBitmap::setColorAsInt(sint32 col) -{ - _Color.setPacked(col); -} - -// *************************************************************************** -sint32 CViewBitmap::getColorAsInt() const -{ - return _Color.getPacked(); -} - -// *************************************************************************** -void CViewBitmap::setColorRGBA(NLMISC::CRGBA col) -{ - _Color = col; -} - -// *************************************************************************** -NLMISC::CRGBA CViewBitmap::getColorRGBA() const -{ - return _Color; -} - -// *************************************************************************** -sint32 CViewBitmap::getMaxUsedW() const -{ - sint32 txw, txh; - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.getTextureSizeFromId (_TextureId, txw, txh); - return txw; -} - -// *************************************************************************** -sint32 CViewBitmap::getMinUsedW() const -{ - return getMaxUsedW(); -} - -// *************************************************************************** -void CViewBitmap::serial(NLMISC::IStream &f) -{ - CViewBase::serial(f); - f.serial(_TextureId); - f.serial(_Color); - f.serial(_Rot); - f.serialEnum(_Align); - f.serialEnum(_Type); - nlSerialBitBool(f, _Scale); - nlSerialBitBool(f, _Flip); - nlSerialBitBool(f, _Tile); - nlSerialBitBool(f, _InheritGCAlpha); - f.serial(_TxtOffsetX); - f.serial(_TxtOffsetY); - f.serial(_TxtWidth); - f.serial(_TxtHeight); -} - - -// *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_bitmap.h b/code/ryzom/client/src/interface_v3/view_bitmap.h deleted file mode 100644 index cea94116b..000000000 --- a/code/ryzom/client/src/interface_v3/view_bitmap.h +++ /dev/null @@ -1,141 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_VIEW_BITMAP_H -#define NL_VIEW_BITMAP_H - -#include "nel/gui/view_base.h" -#include "nel/3d/u_texture.h" -#include "nel/gui/view_renderer.h" - -/** - * class implementing a bitmap view - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CViewBitmap : public CViewBase -{ -public: - DECLARE_UI_CLASS(CViewBitmap) - enum EType { Stretched = 0, Tiled, TypeCount }; -public: - - /// Constructor - CViewBitmap(const TCtorParam ¶m) : CViewBase(param) - { - _Color = NLMISC::CRGBA(255,255,255,255); - _Scale = false; - _Rot = 0; - _Flip = false; - _Tile = false; - _Align = 0; - _Type = Stretched; - _InheritGCAlpha = false; - - // Default parameters for createTexture - _TxtOffsetX = 0; - _TxtOffsetY = 0; - _TxtWidth = -1; - _TxtHeight = -1; - } - - /** - * parse an xml node and initialize the base view mambers. Must call CViewBase::parse - * \param cur : pointer to the xml node to be parsed - * \param parentGroup : the parent group of the view - * \partam id : a refence to the string that will receive the view ID - * \return true if success - */ - bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - virtual void updateCoords (); - - /// Draw the view - virtual void draw (); - - bool getScale() const { return _Scale; } - void setScale (bool s) { _Scale = s; } - bool getTile() const { return _Tile; } - void setTile (bool s) { _Tile = s; } - void setColor (const NLMISC::CRGBA &r) { _Color = r; } - - // Reflected - - virtual void setTexture(const std::string & TxName); - virtual std::string getTexture () const; - - /** Force the bitmap to match current texture size - * The 'scale' flag isnot modified - */ - void fitTexture(); - - bool isTextureValid() const { return _TextureId != -1; } - - void setColorAsString(const std::string & col); - std::string getColorAsString() const; - - void setColorAsInt(sint32 col); - sint32 getColorAsInt() const; - - void setColorRGBA(NLMISC::CRGBA col); - NLMISC::CRGBA getColorRGBA() const; - - virtual sint32 getAlpha() const { return _Color.A; } - virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; } - - REFLECT_EXPORT_START(CViewBitmap, CViewBase) - REFLECT_STRING ("color", getColorAsString, setColorAsString); - REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt); - REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA); - REFLECT_SINT32 ("alpha", getAlpha, setAlpha); - REFLECT_STRING ("texture", getTexture, setTexture); - REFLECT_BOOL("scale", getScale, setScale); - REFLECT_EXPORT_END - - /// \from CInterfaceElement - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - - virtual void serial(NLMISC::IStream &f); - -protected: - CViewRenderer::CTextureId _TextureId; /// Accelerator - NLMISC::CRGBA _Color; - sint32 _Rot; - sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1) - EType _Type; - bool _Scale : 1; - bool _Flip : 1; - bool _Tile : 1; - bool _InheritGCAlpha : 1; - - // For single texture - - sint32 _TxtOffsetX; // Offset X of the single texture - sint32 _TxtOffsetY; // Offset Y of the single texture - sint32 _TxtWidth; // Width of the single texture - sint32 _TxtHeight; // Height of the single texture - -}; - - -#endif // NL_VIEW_BITMAP_H - -/* End of view_bitmap.h */ diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h index 22c7b3e0b..02327576c 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h +++ b/code/ryzom/client/src/interface_v3/view_bitmap_faber_mp.h @@ -20,7 +20,7 @@ #define NL_VIEW_BITMAP_MP_FABER_H #include "nel/misc/types_nl.h" -#include "view_bitmap.h" +#include "nel/gui/view_bitmap.h" ///\todo nico : do the real display when item icons are available diff --git a/code/ryzom/client/src/r2/displayer_visual_shape.h b/code/ryzom/client/src/r2/displayer_visual_shape.h index 72ae05e01..dda2a721e 100644 --- a/code/ryzom/client/src/r2/displayer_visual_shape.h +++ b/code/ryzom/client/src/r2/displayer_visual_shape.h @@ -23,7 +23,11 @@ #include "instance_map_deco.h" class CEntityCL; -class CViewBitmap; + +namespace NLGUI +{ + class CViewBitmap; +} namespace NL3D { diff --git a/code/ryzom/client/src/r2/instance_map_deco.h b/code/ryzom/client/src/r2/instance_map_deco.h index 074604dc7..a142602c8 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.h +++ b/code/ryzom/client/src/r2/instance_map_deco.h @@ -24,10 +24,10 @@ namespace NLGUI { class CCtrlQuad; + class CViewBitmap; } class CGroupMap; -class CViewBitmap; namespace R2 { diff --git a/code/ryzom/client/src/r2/prim_render.cpp b/code/ryzom/client/src/r2/prim_render.cpp index e7f881c0a..63a6a5844 100644 --- a/code/ryzom/client/src/r2/prim_render.cpp +++ b/code/ryzom/client/src/r2/prim_render.cpp @@ -22,7 +22,7 @@ #include "nel/misc/vector_2f.h" #include "nel/misc/time_nl.h" // -#include "../interface_v3/view_bitmap.h" +#include "nel/gui/view_bitmap.h" #include "nel/gui/ctrl_quad.h" #include "nel/gui/ctrl_polygon.h" #include "../interface_v3/interface_manager.h" From 547bd65160e5b5b6e183e4ec5a544778ea6bb787 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 04:27:53 +0200 Subject: [PATCH 087/339] CHANGED: #1471 CViewBitmapCombo no longer depends on CViewPointer. --- code/nel/include/nel/gui/view_pointer_base.h | 8 ++++++++ code/nel/src/gui/view_pointer_base.cpp | 3 ++- .../src/interface_v3/view_bitmap_combo.cpp | 17 ++++++++--------- .../client/src/interface_v3/view_pointer.cpp | 3 +-- .../client/src/interface_v3/view_pointer.h | 7 ------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/code/nel/include/nel/gui/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h index bcc38fea4..ab7629a19 100644 --- a/code/nel/include/nel/gui/view_pointer_base.h +++ b/code/nel/include/nel/gui/view_pointer_base.h @@ -18,6 +18,7 @@ #ifndef VIEW_POINTER_BASE_H #define VIEW_POINTER_BASE_H +#include "nel/misc/events.h" #include "nel/gui/view_base.h" namespace NLGUI @@ -52,6 +53,11 @@ namespace NLGUI bool show() const {return _PointerVisible;} void draw(){} + + /// set button state + void setButtonState(NLMISC::TMouseButton state) { _Buttons = state; } + /// get buttons state + NLMISC::TMouseButton getButtonState() const { return _Buttons; } protected: // (x,y) is from the TopLeft corner of the window @@ -66,6 +72,8 @@ namespace NLGUI bool _PointerDrag; // Is the pointer down and we have moved ? bool _PointerVisible; // Is the pointer visible or hidden ? + NLMISC::TMouseButton _Buttons; + private: diff --git a/code/nel/src/gui/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp index 976263eb1..221fffbf4 100644 --- a/code/nel/src/gui/view_pointer_base.cpp +++ b/code/nel/src/gui/view_pointer_base.cpp @@ -21,7 +21,8 @@ namespace NLGUI { CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam ¶m ) : - CViewBase( param ) + CViewBase( param ), + _Buttons( NLMISC::noButton ) { _PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0; _PointerDown = false; diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp index 34aebfaf8..c4f230129 100644 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp @@ -14,13 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "view_bitmap_combo.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/db_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" +#include "nel/gui/interface_group.h" using namespace NLMISC; @@ -275,7 +275,6 @@ void CViewBitmapCombo::draw() if (numRow == 0 || numCol == 0) return; sint32 mx = 0, my = 0; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); const std::vector &rVB = CWidgetManager::getInstance()->getViewsUnderPointer(); if (!CWidgetManager::getInstance()->getPointer()) return; @@ -361,7 +360,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh) { overItem = true; - if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) + if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, texIndex); color = getCol(_ColPushed, texIndex); @@ -416,7 +415,7 @@ void CViewBitmapCombo::draw() // if (_CD.Unrolled.getBool()) { - if (overItem && static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) + if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsId, selectedTexIndex); color = getCol(_Col, selectedTexIndex); @@ -436,7 +435,7 @@ void CViewBitmapCombo::draw() && my < py + (sint32) itemh ) { - if ( static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() )->getButtonState() & NLMISC::leftButton) + if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) { textId = getTexId(_TexsPushedId, selectedTexIndex); color = getCol(_ColPushed, selectedTexIndex); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index a78a4b47f..e1e18248d 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -42,8 +42,7 @@ NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "pointer"); // -------------------------------------------------------------------------------------------------------------------- CViewPointer::CViewPointer (const TCtorParam ¶m) - : CViewPointerBase(param), - _Buttons(NLMISC::noButton) + : CViewPointerBase(param) { _TxIdDefault = -2; _TxIdMoveWindow = -2; diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index 274d07a56..8696ce245 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -63,11 +63,6 @@ public: } // TEMP PATCH - /// set button state - void setButtonState(NLMISC::TMouseButton state) { _Buttons = state; } - /// get buttons state - NLMISC::TMouseButton getButtonState() const { return _Buttons; } - private: /// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead. @@ -120,8 +115,6 @@ private: sint32 _OffsetX; sint32 _OffsetY; - NLMISC::TMouseButton _Buttons; - CGroupContainer *_LastHightLight; // Cursor mode From 2fcef29aa3166e9fea1b540d4d5c5efc047f9f4d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 04:40:34 +0200 Subject: [PATCH 088/339] CHANGED: #1471 CViewBitmapCombo is now part of NELGUI library, and is under NLGUI namespace. --- code/nel/include/nel/gui/view_bitmap_combo.h | 174 ++++++ code/nel/src/gui/view_bitmap_combo.cpp | 585 ++++++++++++++++++ .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/view_bitmap_combo.cpp | 579 ----------------- .../src/interface_v3/view_bitmap_combo.h | 170 ----- 6 files changed, 761 insertions(+), 751 deletions(-) create mode 100644 code/nel/include/nel/gui/view_bitmap_combo.h create mode 100644 code/nel/src/gui/view_bitmap_combo.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_bitmap_combo.h diff --git a/code/nel/include/nel/gui/view_bitmap_combo.h b/code/nel/include/nel/gui/view_bitmap_combo.h new file mode 100644 index 000000000..5a992a588 --- /dev/null +++ b/code/nel/include/nel/gui/view_bitmap_combo.h @@ -0,0 +1,174 @@ +// Ryzom - MMORPG Framework +// 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 NL_VIEW_BITMAP_COMBO_H +#define NL_VIEW_BITMAP_COMBO_H + +#include "nel/misc/cdb.h" +#include "nel/gui/view_base.h" +#include "nel/3d/u_texture.h" +#include +#include + +namespace NLGUI +{ + + /** Description of a combo box, this can be parsed from an xml node + * The bitmap layout is as follow : + * + * I W I W I W + * t G t G t G + * e a e a e a + * m p m p m p + * W S W W + * i e i i + * d l d d + * t e t t + * h c h h + * t + * e + * d + * +----+---+----+---+---+---+---+--... + * |ssss| |****| |***| |***| + * ItemHeight |ssss| |****| |***| |*** + * +----+---+----+---+---+---+---+--... + * | | | | | | | | + * HGapSeleted | | | | | | | | + * +----+---+----+---+---+---+---+--... + * |****| |****| |***| |***| + * ItemHeight |****| |****| |***| |***| + * +----+---+----+---+---+---+---+--... + * | | | | | | | | + * HGap | | | | | | | | + * +----+---+----+---+---+---+---+--... + * |****| |****| |***| |***| + * ItemHeight |****| |****| |***| |***| + * . . . . . . . . + * . . . . . . . . + * s : selected item. . . . . . . + * * : where bitmap are displayed + */ + + + struct CComboBoxDesc + { + bool parse(xmlNodePtr cur, CInterfaceElement *owner); + void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs); + void getGridSize(uint &numRow,uint &numCol) const; + void getDimensions(uint &width, uint &height) const; + CInterfaceProperty NumRow; + CInterfaceProperty NumCol; + CInterfaceProperty CurrSelected; + CInterfaceProperty ItemWidth; + CInterfaceProperty ItemHeight; + CInterfaceProperty Unrolled; + CInterfaceProperty WGapSelected; + CInterfaceProperty WGap; + CInterfaceProperty HGapSelected; + CInterfaceProperty HGap; + CInterfaceProperty NumSel; + CInterfaceProperty Align; + + }; + + + + + /** + * A combo box with several bitmaps in it + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver + { + public: + typedef std::vector TIdArray; + typedef std::vector TStringArray; + typedef std::vector TColorArray; + public: + /// ctor + CViewBitmapCombo(const TCtorParam ¶m); + /** + * parse an xml node and initialize the base view members. Must call CViewBase::parse + * \param cur : pointer to the xml node to be parsed + * \param parentGroup : the parent group of the view + * \partam id : a refence to the string that will receive the view ID + * \return true if success + */ + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + /** + * draw the view + */ + void draw(); + + // access to texture & colors + const TStringArray &getTexs() const { return _Texs; } + const TStringArray &getTexsOver() const { return _TexsOver; } + const TStringArray &getTexsPushed() const { return _TexsPushed; } + // + const TColorArray &getColors() const { return _Col; } + const TColorArray &getColorsOver() const { return _ColOver; } + const TColorArray &getColorsPushed() const { return _ColPushed; } + // + void setTexs(const char * const tex[], uint numTex); + void setTexsOver(const char * const tex[], uint numTex); + void setTexsPushed(const char * const tex[], uint numTex); + // + void setColors(const NLMISC::CRGBA colors[], uint numColors); + void setColorsOver(const NLMISC::CRGBA colors[], uint numColors); + void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors); + + + + + + + + /////////////////////////////////////////////////////////////////////////////////// + private: + // + TStringArray _Texs; + TStringArray _TexsOver; + TStringArray _TexsPushed; + TIdArray _TexsId; + TIdArray _TexsOverId; + TIdArray _TexsPushedId; + TColorArray _Col; + TColorArray _ColOver; + TColorArray _ColPushed; + CComboBoxDesc _CD; + CInterfaceElement *_Owner; + private: + void parseTexList(const std::string &names, TStringArray &dest); + void parseColList(const std::string &names, TColorArray &dest); + void setupSize(); + void getDimensions(uint &numRow, uint &numCol); + // From ICDBNode::IPropertyObserver + void update(NLMISC::ICDBNode *leaf); + // Return a color from the array, or white if it is empty + static NLMISC::CRGBA getCol(const TColorArray &array, uint index); + static const std::string *getTex(const TStringArray &array, uint index); + static sint32 getTexId(const TIdArray &array, uint index); + }; + +} + +#endif diff --git a/code/nel/src/gui/view_bitmap_combo.cpp b/code/nel/src/gui/view_bitmap_combo.cpp new file mode 100644 index 000000000..a13bf9364 --- /dev/null +++ b/code/nel/src/gui/view_bitmap_combo.cpp @@ -0,0 +1,585 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_bitmap_combo.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/db_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" +#include "nel/gui/interface_group.h" + +using namespace NLMISC; + +namespace NLGUI +{ + + //======================================================================================= + bool CComboBoxDesc::parse(xmlNodePtr cur, CInterfaceElement*owner) + { + nlassert(owner); + const std::string &ownerId = owner->getId(); + CXMLAutoPtr prop; + // + prop = xmlGetProp(cur, (const xmlChar *) "selected"); + if (!prop) + { + nlwarning((ownerId + " : Couldn't read 'selected' field").c_str()); + return false; + } + owner->relativeSInt64Read(CurrSelected, "selected", prop, "0"); + // + prop = xmlGetProp(cur, (const xmlChar *) "num_row"); + owner->relativeSInt64Read(NumRow, "num_row", prop, "1"); + // + prop = xmlGetProp(cur, (const xmlChar *) "num_col"); + owner->relativeSInt64Read(NumCol, "num_col", prop, "1"); + // + prop = xmlGetProp(cur, (const xmlChar *) "itemw"); + owner->relativeSInt64Read(ItemWidth, "itemw", prop, "32"); + // + prop = xmlGetProp(cur, (const xmlChar *) "itemh"); + owner->relativeSInt64Read(ItemHeight, "itemh", prop, "32"); + // + prop = xmlGetProp(cur, (const xmlChar *) "unrolled"); + owner->relativeBoolRead(Unrolled, "unrolled", prop, "false"); + // + prop = xmlGetProp(cur, (xmlChar *) "wgap"); + owner->relativeSInt64Read(WGap, "wgap", prop, "0"); + // + prop = xmlGetProp(cur, (xmlChar *) "hgap"); + owner->relativeSInt64Read(HGap, "hgap", prop, "0"); + // + prop = xmlGetProp(cur, (xmlChar *) "wgap_selected"); + owner->relativeSInt64Read(WGapSelected, "wgap_selected", prop, "0"); + // + prop = xmlGetProp(cur, (xmlChar *) "hgap_selected"); + owner->relativeSInt64Read(HGapSelected, "hgap_selected", prop, "0"); + // + // + prop = xmlGetProp(cur, (xmlChar *) "num_sel"); + owner->relativeSInt64Read(NumSel, "num_sel", prop, "1"); + // + prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); + Align.readSInt32 ("0", ownerId + ":align"); + if (prop) + { + const char *seekPtr = prop.getDatas(); + while (*seekPtr != 0) + { + if ((*seekPtr=='l')||(*seekPtr=='L')) + { + Align.setSInt32 (Align.getSInt32()&(~1)); + } + if ((*seekPtr=='r')||(*seekPtr=='R')) + { + Align.setSInt32 (Align.getSInt32()|1); + } + if ((*seekPtr=='b')||(*seekPtr=='B')) + { + Align.setSInt32 (Align.getSInt32()&(~2)); + } + if ((*seekPtr=='t')||(*seekPtr=='T')) + { + Align.setSInt32 (Align.getSInt32()|2); + } + ++seekPtr; + } + } + // + return true; + } + + + //========================================================================================= + void CComboBoxDesc::addObserver(ICDBNode::IPropertyObserver *obs) + { + // Add observers on dimensions + if (NumRow.getNodePtr()) + { + ICDBNode::CTextId textId; + NumRow.getNodePtr()->addObserver(obs, textId); + } + if (NumCol.getNodePtr()) + { + ICDBNode::CTextId textId; + NumCol.getNodePtr()->addObserver(obs, textId); + } + if (ItemWidth.getNodePtr()) + { + ICDBNode::CTextId textId; + ItemWidth.getNodePtr()->addObserver(obs, textId); + } + if (ItemHeight.getNodePtr()) + { + ICDBNode::CTextId textId; + ItemHeight.getNodePtr()->addObserver(obs, textId); + } + if (Unrolled.getNodePtr()) + { + ICDBNode::CTextId textId; + Unrolled.getNodePtr()->addObserver(obs, textId); + } + } + + //======================================================================================= + void CComboBoxDesc::getGridSize(uint &numRow, uint &numCol) const + { + numRow = NumRow.getSInt32(); + numCol = NumCol.getSInt32(); + if (numRow == 0 || numCol == 0) return; + if (!Unrolled.getBool()) + { + numRow = numCol = 1; + } + } + + //======================================================================================= + void CComboBoxDesc::getDimensions(uint &w, uint &h) const + { + uint numRow, numCol; + getGridSize(numRow, numCol); + w = numCol * (ItemWidth.getSInt32() + WGap.getSInt32()); + h = numRow * (ItemHeight.getSInt32() + HGap.getSInt32()); + // + if (numCol == 1) w -= WGap.getSInt32(); + else w += WGapSelected.getSInt32() - WGap.getSInt32(); + // + if (numRow == 1) h -= HGap.getSInt32(); + else h += HGapSelected.getSInt32() - HGap.getSInt32(); + } + + //======================================================================================= + NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmapCombo, std::string, "bitmap_combo"); + + CViewBitmapCombo::CViewBitmapCombo(const TCtorParam ¶m) : CViewBase(param) + { + } + + + //======================================================================================= + bool CViewBitmapCombo::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (! CViewBase::parse(cur, parentGroup) ) + { + parseError(parentGroup); + return false; + } + + CXMLAutoPtr prop; + + std::string texs; + prop = xmlGetProp(cur, (xmlChar *)"tx_normal"); + if (prop) texs = (const char*)prop; + std::string texsOver; + prop = xmlGetProp(cur, (xmlChar *)"tx_over"); + if (prop) texsOver = (const char*)prop; + std::string texsPushed; + prop = xmlGetProp(cur, (xmlChar *)"tx_pushed"); + if (prop) texsPushed = (const char*)prop; + // + // for colors, an empty strings means all colors are white + // + std::string col; + prop = xmlGetProp(cur, (xmlChar *)"col_normal"); + if (prop) col = (const char*)prop; + std::string colOver; + prop = xmlGetProp(cur, (xmlChar *)"col_over"); + if (prop) colOver = (const char*)prop; + std::string colPushed; + prop = xmlGetProp(cur, (xmlChar *)"col_pushed"); + if (prop) colPushed = (const char*)prop; + + /* if (texs.empty() || texsOver.empty() || texsPushed.empty()) + { + parseError(parentGroup, "Cannot read tx_normal, tx_over, or tx_pushed"); + return false; + }*/ + + parseTexList(texs, _Texs); + parseTexList(texsOver, _TexsOver); + parseTexList(texsPushed, _TexsPushed); + + parseColList(col, _Col); + parseColList(colOver, _ColOver); + parseColList(colPushed, _ColPushed); + // + /* if (_Texs.size() != _TexsOver.size() || _TexsOver.size() != _TexsPushed.size()) + { + parseError(parentGroup, "Texture names arrays do not have the same size"); + return false; + } + // + uint numCols = NLMISC::maxof(_Col.size(), _ColOver.size(), _ColPushed.size()); + if (! + ( + (_Col.empty() || _Col.size() == numCols) + && (_ColOver.empty() || _ColOver.size() == numCols) + && (_ColPushed.empty() || _ColPushed.size() == numCols) + ) + ) + { + parseError(parentGroup, "Color names arrays do not have the same size (note an empty array is valid, means all color are 255 255 255"); + return false; + }*/ + // + if (!_CD.parse(cur, this)) + { + return false; + } + // + setupSize(); + // + _CD.addObserver(this); + + return true; + } + + //======================================================================================= + NLMISC::CRGBA CViewBitmapCombo::getCol(const CViewBitmapCombo::TColorArray &array,uint index) + { + if (array.empty()) return CRGBA::White; + return array[index % array.size()]; + } + + //======================================================================================= + const std::string *CViewBitmapCombo::getTex(const TStringArray &array,uint index) + { + if (array.empty()) return NULL; + return &array[index % array.size()]; + } + + //======================================================================================= + sint32 CViewBitmapCombo::getTexId(const TIdArray &array, uint index) + { + if (array.empty()) return -1; + return array[index % array.size()]; + } + + //======================================================================================= + void CViewBitmapCombo::draw() + { + if (_Texs.empty()) return; + uint numRow, numCol; + _CD.getGridSize(numRow, numCol); + if (numRow == 0 || numCol == 0) return; + + sint32 mx = 0, my = 0; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + const std::vector &rVB = CWidgetManager::getInstance()->getViewsUnderPointer(); + if (!CWidgetManager::getInstance()->getPointer()) return; + CWidgetManager::getInstance()->getPointer()->getPointerDispPos(mx, my); + bool over = false; + uint32 i; + for (i = 0; i < rVB.size(); ++i) + { + if (rVB[i] == this) + { + over = true; + break; + } + } + + if (_TexsId.size() == 0) + { + for (i = 0; i < _Texs.size(); ++i) + _TexsId.push_back(rVR.getTextureIdFromName(_Texs[i])); + for (i = 0; i < _TexsOver.size(); ++i) + _TexsOverId.push_back(rVR.getTextureIdFromName(_TexsOver[i])); + for (i = 0; i < _TexsPushed.size(); ++i) + _TexsPushedId.push_back(rVR.getTextureIdFromName(_TexsPushed[i])); + } + + sint32 textId; + CRGBA color; + uint selectedTexIndex = _CD.CurrSelected.getSInt32(); + uint itemw = _CD.ItemWidth.getSInt32() + _CD.WGap.getSInt32(); + uint itemh = _CD.ItemHeight.getSInt32() + _CD.HGap.getSInt32(); + uint counter = 0; + + bool overItem = false; + for(uint x = 0; x < numCol; ++x) + { + for(uint y = 0; y < numRow; ++y) + { + uint texIndex = counter; + if (counter != 0) + { + if (counter == selectedTexIndex) + { + texIndex = 0; + } + sint px; + sint py; + // get the right position depending on alignment + if (_CD.Align.getSInt32() & 1) // right align ? + { + px = _XReal + _WReal - (x + 1) * itemw; + } + else + { + px = _XReal + x * itemw; + } + // top align ? + if (_CD.Align.getSInt32() & 2) + { + py = _YReal + _HReal - (y + 1) * itemh; + } + else + { + py = _YReal + y * itemh; + } + + if (x != 0) + { + if (_CD.Align.getSInt32() & 1) + px -= _CD.WGapSelected.getSInt32() - _CD.WGap.getSInt32(); + else px += _CD.WGapSelected.getSInt32() - _CD.WGap.getSInt32(); + } + if (y != 0) + { + if (_CD.Align.getSInt32() & 2) + py -= _CD.HGapSelected.getSInt32() - _CD.HGap.getSInt32(); + else py += _CD.HGapSelected.getSInt32() - _CD.HGap.getSInt32(); + } + // is the mouse on current item ? + if (over + && mx >= px + && my >= py + && mx < px + (sint32) itemw + && my < py + (sint32) itemh) + { + overItem = true; + if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + { + textId = getTexId(_TexsPushedId, texIndex); + color = getCol(_ColPushed, texIndex); + } + else + { + textId = getTexId(_TexsOverId, texIndex); + color = getCol(_ColOver, texIndex); + } + } + else + { + textId = getTexId(_TexsId, texIndex); + color = getCol(_Col, texIndex); + } + CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, + textId, + color); + } + ++counter; + if ((sint32) counter == _CD.NumSel.getSInt32()) + break; + } + } + + if ((sint32) selectedTexIndex >= _CD.NumSel.getSInt32()) + { + return; + } + + // draw current selection + sint32 px; + sint32 py; + // + if (_CD.Align.getSInt32() & 1) + { + px = _XReal + _WReal - itemw; + } + else + { + px = _XReal; + } + // + if (_CD.Align.getSInt32() & 2) + { + py = _YReal + _HReal - itemh; + } + else + { + py = _YReal; + } + // + if (_CD.Unrolled.getBool()) + { + if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + { + textId = getTexId(_TexsId, selectedTexIndex); + color = getCol(_Col, selectedTexIndex); + } + else + { + textId = getTexId(_TexsPushedId, selectedTexIndex); + color = getCol(_ColPushed, selectedTexIndex); + } + } + else + { + if (over + && mx >= px + && my >= py + && mx < px + (sint32) itemw + && my < py + (sint32) itemh + ) + { + if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) + { + textId = getTexId(_TexsPushedId, selectedTexIndex); + color = getCol(_ColPushed, selectedTexIndex); + } + else + { + textId = getTexId(_TexsOverId, selectedTexIndex); + color = getCol(_ColOver, selectedTexIndex); + } + } + else + { + textId = getTexId(_TexsId, selectedTexIndex); + color = getCol(_Col, selectedTexIndex); + } + } + + CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, + textId, + color); + } + + //======================================================================================= + void CViewBitmapCombo::parseTexList(const std::string &names, TStringArray &dest) + { + static const char sep[] = " ,\t"; + std::string::size_type pos = 0, nextPos; + dest.clear(); + do + { + nextPos = names.find_first_of(sep, pos); + if (pos != nextPos) + { + dest.push_back(names.substr(pos, nextPos - pos)); + } + pos = names.find_first_not_of(sep, nextPos); + } + while (pos != std::string::npos); + } + + //======================================================================================= + void CViewBitmapCombo::parseColList(const std::string &names,TColorArray &dest) + { + static const char sep[] = ",\t"; + std::string::size_type pos = 0, nextPos; + dest.clear(); + std::string col; + do + { + nextPos = names.find_first_of(sep, pos); + if (pos != nextPos) + { + col = names.substr(pos, nextPos - pos); + int r = 0, g = 0, b = 0, a = 255; + sscanf (col.c_str(), "%d %d %d %d", &r, &g, &b, &a); + NLMISC::clamp (r, 0, 255); + NLMISC::clamp (g, 0, 255); + NLMISC::clamp (b, 0, 255); + NLMISC::clamp (a, 0, 255); + dest.push_back(NLMISC::CRGBA((uint8) r, (uint8) g, (uint8) b, (uint8) a)); + } + pos = names.find_first_not_of(sep, nextPos); + } + while (pos != std::string::npos); + } + + //======================================================================================= + void CViewBitmapCombo::setupSize() + { + uint w, h; + _CD.getDimensions(w, h); + setW(w); + setH(h); + invalidateCoords(); + } + + //======================================================================================= + void CViewBitmapCombo::update(ICDBNode * /* leaf */) + { + setupSize(); + } + + + //======================================================================================= + /** copy an array of char * into an array of strings + */ + static void copyStrArrayFromChar(CViewBitmapCombo::TStringArray &dest, const char * const src[], uint numColor) + { + dest.resize(numColor); + for(uint k = 0; k < numColor; ++k) + { + dest[k] = src[k]; + } + } + + + static void copyRGBAVectorFromRGBAArray(CViewBitmapCombo::TColorArray &dest, const NLMISC::CRGBA src[], uint numColor) + { + dest.resize(numColor); + std::copy(src, src + numColor, dest.begin()); + } + + + //======================================================================================= + void CViewBitmapCombo::setTexs(const char * const tex[], uint numTex) + { + copyStrArrayFromChar(_Texs, tex, numTex); + } + + //======================================================================================= + void CViewBitmapCombo::setTexsOver(const char * const tex[], uint numTex) + { + copyStrArrayFromChar(_TexsOver, tex, numTex); + } + + + //======================================================================================= + void CViewBitmapCombo::setTexsPushed(const char * const tex[], uint numTex) + { + copyStrArrayFromChar(_TexsPushed, tex, numTex); + } + + //======================================================================================= + void CViewBitmapCombo::setColors(const NLMISC::CRGBA colors[], uint numColors) + { + copyRGBAVectorFromRGBAArray(_Col, colors, numColors); + } + + + //======================================================================================= + void CViewBitmapCombo::setColorsOver(const NLMISC::CRGBA colors[], uint numColors) + { + copyRGBAVectorFromRGBAArray(_ColOver, colors, numColors); + } + + + //======================================================================================= + void CViewBitmapCombo::setColorsPushed(const NLMISC::CRGBA colors[], uint numColors) + { + copyRGBAVectorFromRGBAArray(_ColPushed, colors, numColors); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 65e7b6d2d..e9fbab649 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -49,7 +49,7 @@ #include "nel/gui/view_bitmap.h" //#include "view_bitmap_progress.h" #include "view_bitmap_faber_mp.h" -#include "view_bitmap_combo.h" +#include "nel/gui/view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_id.h" #include "nel/gui/view_text_formated.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index d593b1000..1203d66b4 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -38,7 +38,7 @@ // View #include "nel/gui/view_bitmap.h" #include "view_bitmap_faber_mp.h" -#include "view_bitmap_combo.h" +#include "nel/gui/view_bitmap_combo.h" #include "nel/gui/view_text.h" #include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp b/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp deleted file mode 100644 index c4f230129..000000000 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.cpp +++ /dev/null @@ -1,579 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_bitmap_combo.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/db_manager.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_pointer_base.h" -#include "nel/gui/interface_group.h" - -using namespace NLMISC; - -//======================================================================================= -bool CComboBoxDesc::parse(xmlNodePtr cur, CInterfaceElement*owner) -{ - nlassert(owner); - const std::string &ownerId = owner->getId(); - CXMLAutoPtr prop; - // - prop = xmlGetProp(cur, (const xmlChar *) "selected"); - if (!prop) - { - nlwarning((ownerId + " : Couldn't read 'selected' field").c_str()); - return false; - } - owner->relativeSInt64Read(CurrSelected, "selected", prop, "0"); - // - prop = xmlGetProp(cur, (const xmlChar *) "num_row"); - owner->relativeSInt64Read(NumRow, "num_row", prop, "1"); - // - prop = xmlGetProp(cur, (const xmlChar *) "num_col"); - owner->relativeSInt64Read(NumCol, "num_col", prop, "1"); - // - prop = xmlGetProp(cur, (const xmlChar *) "itemw"); - owner->relativeSInt64Read(ItemWidth, "itemw", prop, "32"); - // - prop = xmlGetProp(cur, (const xmlChar *) "itemh"); - owner->relativeSInt64Read(ItemHeight, "itemh", prop, "32"); - // - prop = xmlGetProp(cur, (const xmlChar *) "unrolled"); - owner->relativeBoolRead(Unrolled, "unrolled", prop, "false"); - // - prop = xmlGetProp(cur, (xmlChar *) "wgap"); - owner->relativeSInt64Read(WGap, "wgap", prop, "0"); - // - prop = xmlGetProp(cur, (xmlChar *) "hgap"); - owner->relativeSInt64Read(HGap, "hgap", prop, "0"); - // - prop = xmlGetProp(cur, (xmlChar *) "wgap_selected"); - owner->relativeSInt64Read(WGapSelected, "wgap_selected", prop, "0"); - // - prop = xmlGetProp(cur, (xmlChar *) "hgap_selected"); - owner->relativeSInt64Read(HGapSelected, "hgap_selected", prop, "0"); - // - // - prop = xmlGetProp(cur, (xmlChar *) "num_sel"); - owner->relativeSInt64Read(NumSel, "num_sel", prop, "1"); - // - prop = (char*) xmlGetProp (cur, (xmlChar*)"align"); - Align.readSInt32 ("0", ownerId + ":align"); - if (prop) - { - const char *seekPtr = prop.getDatas(); - while (*seekPtr != 0) - { - if ((*seekPtr=='l')||(*seekPtr=='L')) - { - Align.setSInt32 (Align.getSInt32()&(~1)); - } - if ((*seekPtr=='r')||(*seekPtr=='R')) - { - Align.setSInt32 (Align.getSInt32()|1); - } - if ((*seekPtr=='b')||(*seekPtr=='B')) - { - Align.setSInt32 (Align.getSInt32()&(~2)); - } - if ((*seekPtr=='t')||(*seekPtr=='T')) - { - Align.setSInt32 (Align.getSInt32()|2); - } - ++seekPtr; - } - } - // - return true; -} - - -//========================================================================================= -void CComboBoxDesc::addObserver(ICDBNode::IPropertyObserver *obs) -{ - // Add observers on dimensions - if (NumRow.getNodePtr()) - { - ICDBNode::CTextId textId; - NumRow.getNodePtr()->addObserver(obs, textId); - } - if (NumCol.getNodePtr()) - { - ICDBNode::CTextId textId; - NumCol.getNodePtr()->addObserver(obs, textId); - } - if (ItemWidth.getNodePtr()) - { - ICDBNode::CTextId textId; - ItemWidth.getNodePtr()->addObserver(obs, textId); - } - if (ItemHeight.getNodePtr()) - { - ICDBNode::CTextId textId; - ItemHeight.getNodePtr()->addObserver(obs, textId); - } - if (Unrolled.getNodePtr()) - { - ICDBNode::CTextId textId; - Unrolled.getNodePtr()->addObserver(obs, textId); - } -} - -//======================================================================================= -void CComboBoxDesc::getGridSize(uint &numRow, uint &numCol) const -{ - numRow = NumRow.getSInt32(); - numCol = NumCol.getSInt32(); - if (numRow == 0 || numCol == 0) return; - if (!Unrolled.getBool()) - { - numRow = numCol = 1; - } -} - -//======================================================================================= -void CComboBoxDesc::getDimensions(uint &w, uint &h) const -{ - uint numRow, numCol; - getGridSize(numRow, numCol); - w = numCol * (ItemWidth.getSInt32() + WGap.getSInt32()); - h = numRow * (ItemHeight.getSInt32() + HGap.getSInt32()); - // - if (numCol == 1) w -= WGap.getSInt32(); - else w += WGapSelected.getSInt32() - WGap.getSInt32(); - // - if (numRow == 1) h -= HGap.getSInt32(); - else h += HGapSelected.getSInt32() - HGap.getSInt32(); -} - -//======================================================================================= -NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmapCombo, std::string, "bitmap_combo"); - -CViewBitmapCombo::CViewBitmapCombo(const TCtorParam ¶m) : CViewBase(param) -{ -} - - -//======================================================================================= -bool CViewBitmapCombo::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (! CViewBase::parse(cur, parentGroup) ) - { - parseError(parentGroup); - return false; - } - - CXMLAutoPtr prop; - - std::string texs; - prop = xmlGetProp(cur, (xmlChar *)"tx_normal"); - if (prop) texs = (const char*)prop; - std::string texsOver; - prop = xmlGetProp(cur, (xmlChar *)"tx_over"); - if (prop) texsOver = (const char*)prop; - std::string texsPushed; - prop = xmlGetProp(cur, (xmlChar *)"tx_pushed"); - if (prop) texsPushed = (const char*)prop; - // - // for colors, an empty strings means all colors are white - // - std::string col; - prop = xmlGetProp(cur, (xmlChar *)"col_normal"); - if (prop) col = (const char*)prop; - std::string colOver; - prop = xmlGetProp(cur, (xmlChar *)"col_over"); - if (prop) colOver = (const char*)prop; - std::string colPushed; - prop = xmlGetProp(cur, (xmlChar *)"col_pushed"); - if (prop) colPushed = (const char*)prop; - -/* if (texs.empty() || texsOver.empty() || texsPushed.empty()) - { - parseError(parentGroup, "Cannot read tx_normal, tx_over, or tx_pushed"); - return false; - }*/ - - parseTexList(texs, _Texs); - parseTexList(texsOver, _TexsOver); - parseTexList(texsPushed, _TexsPushed); - - parseColList(col, _Col); - parseColList(colOver, _ColOver); - parseColList(colPushed, _ColPushed); - // -/* if (_Texs.size() != _TexsOver.size() || _TexsOver.size() != _TexsPushed.size()) - { - parseError(parentGroup, "Texture names arrays do not have the same size"); - return false; - } - // - uint numCols = NLMISC::maxof(_Col.size(), _ColOver.size(), _ColPushed.size()); - if (! - ( - (_Col.empty() || _Col.size() == numCols) - && (_ColOver.empty() || _ColOver.size() == numCols) - && (_ColPushed.empty() || _ColPushed.size() == numCols) - ) - ) - { - parseError(parentGroup, "Color names arrays do not have the same size (note an empty array is valid, means all color are 255 255 255"); - return false; - }*/ - // - if (!_CD.parse(cur, this)) - { - return false; - } - // - setupSize(); - // - _CD.addObserver(this); - - return true; -} - -//======================================================================================= -NLMISC::CRGBA CViewBitmapCombo::getCol(const CViewBitmapCombo::TColorArray &array,uint index) -{ - if (array.empty()) return CRGBA::White; - return array[index % array.size()]; -} - -//======================================================================================= -const std::string *CViewBitmapCombo::getTex(const TStringArray &array,uint index) -{ - if (array.empty()) return NULL; - return &array[index % array.size()]; -} - -//======================================================================================= -sint32 CViewBitmapCombo::getTexId(const TIdArray &array, uint index) -{ - if (array.empty()) return -1; - return array[index % array.size()]; -} - -//======================================================================================= -void CViewBitmapCombo::draw() -{ - if (_Texs.empty()) return; - uint numRow, numCol; - _CD.getGridSize(numRow, numCol); - if (numRow == 0 || numCol == 0) return; - - sint32 mx = 0, my = 0; - CViewRenderer &rVR = *CViewRenderer::getInstance(); - const std::vector &rVB = CWidgetManager::getInstance()->getViewsUnderPointer(); - if (!CWidgetManager::getInstance()->getPointer()) return; - CWidgetManager::getInstance()->getPointer()->getPointerDispPos(mx, my); - bool over = false; - uint32 i; - for (i = 0; i < rVB.size(); ++i) - { - if (rVB[i] == this) - { - over = true; - break; - } - } - - if (_TexsId.size() == 0) - { - for (i = 0; i < _Texs.size(); ++i) - _TexsId.push_back(rVR.getTextureIdFromName(_Texs[i])); - for (i = 0; i < _TexsOver.size(); ++i) - _TexsOverId.push_back(rVR.getTextureIdFromName(_TexsOver[i])); - for (i = 0; i < _TexsPushed.size(); ++i) - _TexsPushedId.push_back(rVR.getTextureIdFromName(_TexsPushed[i])); - } - - sint32 textId; - CRGBA color; - uint selectedTexIndex = _CD.CurrSelected.getSInt32(); - uint itemw = _CD.ItemWidth.getSInt32() + _CD.WGap.getSInt32(); - uint itemh = _CD.ItemHeight.getSInt32() + _CD.HGap.getSInt32(); - uint counter = 0; - - bool overItem = false; - for(uint x = 0; x < numCol; ++x) - { - for(uint y = 0; y < numRow; ++y) - { - uint texIndex = counter; - if (counter != 0) - { - if (counter == selectedTexIndex) - { - texIndex = 0; - } - sint px; - sint py; - // get the right position depending on alignment - if (_CD.Align.getSInt32() & 1) // right align ? - { - px = _XReal + _WReal - (x + 1) * itemw; - } - else - { - px = _XReal + x * itemw; - } - // top align ? - if (_CD.Align.getSInt32() & 2) - { - py = _YReal + _HReal - (y + 1) * itemh; - } - else - { - py = _YReal + y * itemh; - } - - if (x != 0) - { - if (_CD.Align.getSInt32() & 1) - px -= _CD.WGapSelected.getSInt32() - _CD.WGap.getSInt32(); - else px += _CD.WGapSelected.getSInt32() - _CD.WGap.getSInt32(); - } - if (y != 0) - { - if (_CD.Align.getSInt32() & 2) - py -= _CD.HGapSelected.getSInt32() - _CD.HGap.getSInt32(); - else py += _CD.HGapSelected.getSInt32() - _CD.HGap.getSInt32(); - } - // is the mouse on current item ? - if (over - && mx >= px - && my >= py - && mx < px + (sint32) itemw - && my < py + (sint32) itemh) - { - overItem = true; - if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) - { - textId = getTexId(_TexsPushedId, texIndex); - color = getCol(_ColPushed, texIndex); - } - else - { - textId = getTexId(_TexsOverId, texIndex); - color = getCol(_ColOver, texIndex); - } - } - else - { - textId = getTexId(_TexsId, texIndex); - color = getCol(_Col, texIndex); - } - CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, - textId, - color); - } - ++counter; - if ((sint32) counter == _CD.NumSel.getSInt32()) - break; - } - } - - if ((sint32) selectedTexIndex >= _CD.NumSel.getSInt32()) - { - return; - } - - // draw current selection - sint32 px; - sint32 py; - // - if (_CD.Align.getSInt32() & 1) - { - px = _XReal + _WReal - itemw; - } - else - { - px = _XReal; - } - // - if (_CD.Align.getSInt32() & 2) - { - py = _YReal + _HReal - itemh; - } - else - { - py = _YReal; - } - // - if (_CD.Unrolled.getBool()) - { - if (overItem && CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) - { - textId = getTexId(_TexsId, selectedTexIndex); - color = getCol(_Col, selectedTexIndex); - } - else - { - textId = getTexId(_TexsPushedId, selectedTexIndex); - color = getCol(_ColPushed, selectedTexIndex); - } - } - else - { - if (over - && mx >= px - && my >= py - && mx < px + (sint32) itemw - && my < py + (sint32) itemh - ) - { - if ( CWidgetManager::getInstance()->getPointer()->getButtonState() & NLMISC::leftButton) - { - textId = getTexId(_TexsPushedId, selectedTexIndex); - color = getCol(_ColPushed, selectedTexIndex); - } - else - { - textId = getTexId(_TexsOverId, selectedTexIndex); - color = getCol(_ColOver, selectedTexIndex); - } - } - else - { - textId = getTexId(_TexsId, selectedTexIndex); - color = getCol(_Col, selectedTexIndex); - } - } - - CViewRenderer::getInstance()->drawRotFlipBitmap (_RenderLayer, px, py, itemw, itemh, 0, false, - textId, - color); -} - -//======================================================================================= -void CViewBitmapCombo::parseTexList(const std::string &names, TStringArray &dest) -{ - static const char sep[] = " ,\t"; - std::string::size_type pos = 0, nextPos; - dest.clear(); - do - { - nextPos = names.find_first_of(sep, pos); - if (pos != nextPos) - { - dest.push_back(names.substr(pos, nextPos - pos)); - } - pos = names.find_first_not_of(sep, nextPos); - } - while (pos != std::string::npos); -} - -//======================================================================================= -void CViewBitmapCombo::parseColList(const std::string &names,TColorArray &dest) -{ - static const char sep[] = ",\t"; - std::string::size_type pos = 0, nextPos; - dest.clear(); - std::string col; - do - { - nextPos = names.find_first_of(sep, pos); - if (pos != nextPos) - { - col = names.substr(pos, nextPos - pos); - int r = 0, g = 0, b = 0, a = 255; - sscanf (col.c_str(), "%d %d %d %d", &r, &g, &b, &a); - NLMISC::clamp (r, 0, 255); - NLMISC::clamp (g, 0, 255); - NLMISC::clamp (b, 0, 255); - NLMISC::clamp (a, 0, 255); - dest.push_back(NLMISC::CRGBA((uint8) r, (uint8) g, (uint8) b, (uint8) a)); - } - pos = names.find_first_not_of(sep, nextPos); - } - while (pos != std::string::npos); -} - -//======================================================================================= -void CViewBitmapCombo::setupSize() -{ - uint w, h; - _CD.getDimensions(w, h); - setW(w); - setH(h); - invalidateCoords(); -} - -//======================================================================================= -void CViewBitmapCombo::update(ICDBNode * /* leaf */) -{ - setupSize(); -} - - -//======================================================================================= -/** copy an array of char * into an array of strings - */ -static void copyStrArrayFromChar(CViewBitmapCombo::TStringArray &dest, const char * const src[], uint numColor) -{ - dest.resize(numColor); - for(uint k = 0; k < numColor; ++k) - { - dest[k] = src[k]; - } -} - - -static void copyRGBAVectorFromRGBAArray(CViewBitmapCombo::TColorArray &dest, const NLMISC::CRGBA src[], uint numColor) -{ - dest.resize(numColor); - std::copy(src, src + numColor, dest.begin()); -} - - -//======================================================================================= -void CViewBitmapCombo::setTexs(const char * const tex[], uint numTex) -{ - copyStrArrayFromChar(_Texs, tex, numTex); -} - -//======================================================================================= -void CViewBitmapCombo::setTexsOver(const char * const tex[], uint numTex) -{ - copyStrArrayFromChar(_TexsOver, tex, numTex); -} - - -//======================================================================================= -void CViewBitmapCombo::setTexsPushed(const char * const tex[], uint numTex) -{ - copyStrArrayFromChar(_TexsPushed, tex, numTex); -} - -//======================================================================================= -void CViewBitmapCombo::setColors(const NLMISC::CRGBA colors[], uint numColors) -{ - copyRGBAVectorFromRGBAArray(_Col, colors, numColors); -} - - -//======================================================================================= -void CViewBitmapCombo::setColorsOver(const NLMISC::CRGBA colors[], uint numColors) -{ - copyRGBAVectorFromRGBAArray(_ColOver, colors, numColors); -} - - -//======================================================================================= -void CViewBitmapCombo::setColorsPushed(const NLMISC::CRGBA colors[], uint numColors) -{ - copyRGBAVectorFromRGBAArray(_ColPushed, colors, numColors); -} diff --git a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h b/code/ryzom/client/src/interface_v3/view_bitmap_combo.h deleted file mode 100644 index 1d4c34a0b..000000000 --- a/code/ryzom/client/src/interface_v3/view_bitmap_combo.h +++ /dev/null @@ -1,170 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_VIEW_BITMAP_COMBO_H -#define NL_VIEW_BITMAP_COMBO_H - -#include "nel/misc/cdb.h" -#include "nel/gui/view_base.h" -#include "nel/3d/u_texture.h" -#include -#include - - -/** Description of a combo box, this can be parsed from an xml node - * The bitmap layout is as follow : - * - * I W I W I W - * t G t G t G - * e a e a e a - * m p m p m p - * W S W W - * i e i i - * d l d d - * t e t t - * h c h h - * t - * e - * d - * +----+---+----+---+---+---+---+--... - * |ssss| |****| |***| |***| - * ItemHeight |ssss| |****| |***| |*** - * +----+---+----+---+---+---+---+--... - * | | | | | | | | - * HGapSeleted | | | | | | | | - * +----+---+----+---+---+---+---+--... - * |****| |****| |***| |***| - * ItemHeight |****| |****| |***| |***| - * +----+---+----+---+---+---+---+--... - * | | | | | | | | - * HGap | | | | | | | | - * +----+---+----+---+---+---+---+--... - * |****| |****| |***| |***| - * ItemHeight |****| |****| |***| |***| - * . . . . . . . . - * . . . . . . . . - * s : selected item. . . . . . . - * * : where bitmap are displayed - */ - - -struct CComboBoxDesc -{ - bool parse(xmlNodePtr cur, CInterfaceElement *owner); - void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs); - void getGridSize(uint &numRow,uint &numCol) const; - void getDimensions(uint &width, uint &height) const; - CInterfaceProperty NumRow; - CInterfaceProperty NumCol; - CInterfaceProperty CurrSelected; - CInterfaceProperty ItemWidth; - CInterfaceProperty ItemHeight; - CInterfaceProperty Unrolled; - CInterfaceProperty WGapSelected; - CInterfaceProperty WGap; - CInterfaceProperty HGapSelected; - CInterfaceProperty HGap; - CInterfaceProperty NumSel; - CInterfaceProperty Align; - -}; - - - - -/** - * A combo box with several bitmaps in it - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver -{ -public: - typedef std::vector TIdArray; - typedef std::vector TStringArray; - typedef std::vector TColorArray; -public: - /// ctor - CViewBitmapCombo(const TCtorParam ¶m); - /** - * parse an xml node and initialize the base view members. Must call CViewBase::parse - * \param cur : pointer to the xml node to be parsed - * \param parentGroup : the parent group of the view - * \partam id : a refence to the string that will receive the view ID - * \return true if success - */ - bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - /** - * draw the view - */ - void draw(); - - // access to texture & colors - const TStringArray &getTexs() const { return _Texs; } - const TStringArray &getTexsOver() const { return _TexsOver; } - const TStringArray &getTexsPushed() const { return _TexsPushed; } - // - const TColorArray &getColors() const { return _Col; } - const TColorArray &getColorsOver() const { return _ColOver; } - const TColorArray &getColorsPushed() const { return _ColPushed; } - // - void setTexs(const char * const tex[], uint numTex); - void setTexsOver(const char * const tex[], uint numTex); - void setTexsPushed(const char * const tex[], uint numTex); - // - void setColors(const NLMISC::CRGBA colors[], uint numColors); - void setColorsOver(const NLMISC::CRGBA colors[], uint numColors); - void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors); - - - - - - - -/////////////////////////////////////////////////////////////////////////////////// -private: - // - TStringArray _Texs; - TStringArray _TexsOver; - TStringArray _TexsPushed; - TIdArray _TexsId; - TIdArray _TexsOverId; - TIdArray _TexsPushedId; - TColorArray _Col; - TColorArray _ColOver; - TColorArray _ColPushed; - CComboBoxDesc _CD; - CInterfaceElement *_Owner; -private: - void parseTexList(const std::string &names, TStringArray &dest); - void parseColList(const std::string &names, TColorArray &dest); - void setupSize(); - void getDimensions(uint &numRow, uint &numCol); - // From ICDBNode::IPropertyObserver - void update(NLMISC::ICDBNode *leaf); - // Return a color from the array, or white if it is empty - static NLMISC::CRGBA getCol(const TColorArray &array, uint index); - static const std::string *getTex(const TStringArray &array, uint index); - static sint32 getTexId(const TIdArray &array, uint index); -}; - -#endif From 8c934169092c2d5f9e7cdeb469ef06199fa3a570 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 05:13:05 +0200 Subject: [PATCH 089/339] CHANGED: #1471 CGroupTree no longer depends on CGroupContainer. --- .../include/nel/gui/group_container_base.h | 2 ++ .../client/src/interface_v3/group_tree.cpp | 27 +++++-------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index 1d228f017..1e5313e1b 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -85,6 +85,8 @@ namespace NLGUI uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; } uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; } + virtual bool isGrayed() const{ return false; } + protected: void triggerAlphaSettingsChangedAH(); diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp index 7a5eafc75..735f28421 100644 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ b/code/ryzom/client/src/interface_v3/group_tree.cpp @@ -16,22 +16,19 @@ -#include "stdpch.h" - #include "group_tree.h" -#include "interface_manager.h" #include "nel/gui/interface_element.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text.h" -#include "group_container.h" +#include "nel/gui/group_container_base.h" #include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" - #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" - #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/view_pointer_base.h" using namespace std; using namespace NLMISC; @@ -400,7 +397,6 @@ CGroupTree::~CGroupTree() // ---------------------------------------------------------------------------- bool CGroupTree::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (!CInterfaceGroup::parse(cur, parentGroup)) return false; @@ -521,7 +517,6 @@ void CGroupTree::updateCoords() // ---------------------------------------------------------------------------- void CGroupTree::drawSelection(sint x, sint y, sint w, CRGBA col) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); if(!_RectangleOutlineMode) @@ -556,9 +551,6 @@ CGroupTree::SNode *CGroupTree::getNodeUnderMouse() const // ---------------------------------------------------------------------------- void CGroupTree::draw() { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - // get the clip area sint32 clipx, clipy, clipw, cliph; getClip(clipx, clipy, clipw, cliph); @@ -622,13 +614,13 @@ void CGroupTree::draw() { // Find the first container CInterfaceGroup *pIG = _Parent; - CGroupContainer *pGC = dynamic_cast(pIG); + CGroupContainerBase *pGC = dynamic_cast(pIG); while (pIG != NULL) { pIG = pIG->getParent(); if (pIG == NULL) break; - if (dynamic_cast(pIG) != NULL) - pGC = dynamic_cast(pIG); + if (dynamic_cast(pIG) != NULL) + pGC = dynamic_cast(pIG); } // avoid if window grayed @@ -717,7 +709,6 @@ void CGroupTree::selectLine(uint line, bool runAH /*= true*/) if(line>=_Lines.size()) return; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (!_Lines[line].Node) { // just deleted : must wait next draw to know the new line under mouse @@ -754,7 +745,6 @@ bool CGroupTree::rightButton(uint line) if (line != (uint) _SelectedLine) selectLine(line, false); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHNameRight, this, _Lines[line].Node->AHParamsRight ); @@ -862,7 +852,6 @@ bool CGroupTree::handleEvent (const NLGUI::CEventDescriptor& event) } } - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(changedNode->AHNameClose, this, changedNode->AHParamsClose); } forceRebuild(); @@ -1276,7 +1265,6 @@ CGroupTree::SNode *CGroupTree::selectNodeByIdRecurse(SNode *pNode, const std::s // *************************************************************************** bool CGroupTree::selectNodeById(const std::string &nodeId, bool triggerAH) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); SNode *selNode= NULL; // Avoid infinite recurs @@ -1330,7 +1318,6 @@ class CHandlerTreeReset : public IActionHandler public: void execute (CCtrlBase * /* pCaller */, const std::string &sParams) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CGroupTree *pTree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); if (pTree != NULL) pTree->reset(); From e131c0f837ff75e600ee42a0c4bac4921d02c684 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 05:37:55 +0200 Subject: [PATCH 090/339] CHANGED: #1471 CGroupTree is now part of NELGUI library, and is under NLGUI namespace. --- code/nel/include/nel/gui/group_tree.h | 376 ++++ code/nel/src/gui/group_tree.cpp | 1638 +++++++++++++++++ .../src/interface_v3/action_handler_game.cpp | 2 +- .../interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/encyclopedia_manager.cpp | 2 +- .../client/src/interface_v3/group_html.h | 2 +- .../interface_v3/group_phrase_skill_filter.h | 2 +- .../client/src/interface_v3/group_skills.h | 2 +- .../client/src/interface_v3/group_tree.cpp | 1635 ---------------- .../client/src/interface_v3/group_tree.h | 375 ---- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../register_interface_elements.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 4 +- code/ryzom/client/src/r2/editor.h | 5 +- code/ryzom/client/src/r2/palette_node.h | 2 +- code/ryzom/client/src/r2/tool_choose_pos.cpp | 2 +- 17 files changed, 2031 insertions(+), 2024 deletions(-) create mode 100644 code/nel/include/nel/gui/group_tree.h create mode 100644 code/nel/src/gui/group_tree.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_tree.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_tree.h diff --git a/code/nel/include/nel/gui/group_tree.h b/code/nel/include/nel/gui/group_tree.h new file mode 100644 index 000000000..b6000e779 --- /dev/null +++ b/code/nel/include/nel/gui/group_tree.h @@ -0,0 +1,376 @@ +// Ryzom - MMORPG Framework +// 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 NL_GROUP_TREE_H +#define NL_GROUP_TREE_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/group_frame.h" +#include "nel/misc/smart_ptr.h" + +namespace NLGUI +{ + class CViewText; + class CViewBitmap; + + // ---------------------------------------------------------------------------- + class CGroupTree : public CInterfaceGroup + { + + public: + + struct SNode; + // optional callback that is called when a node has been added + struct INodeAddedCallback + { + /** A node has just been added in the CGroupTree object + * \param node The logic node from which the ui node was built + * \param interfaceElement The ui node that was built + */ + virtual void nodeAdded(SNode *node, CInterfaceElement *interfaceElement) = 0; + }; + + // Logic structure to initialize the group tree (root node is not displayed and is always opened) + struct SNode : public CReflectableRefPtrTarget + { + typedef NLMISC::CRefPtr TRefPtr; + // Common + std::string Id; // If not present auto-generated + bool Opened; + bool DisplayText; // If false instanciate a template + bool Show; // If false, the node is not displayed (true default, Root ignored) + sint32 YDecal; + // Text + ucstring Text; // Internationalized displayed text + sint32 FontSize; // If -1 (default), then take the groupTree one + NLMISC::CRGBA Color; + // Template + NLMISC::CSmartPtr Template; + // Actions Handlers (for left button) + std::string AHName; + std::string AHCond; + std::string AHParams; + // Actions Handlers (for right button) + std::string AHNameRight; + std::string AHParamsRight; + // Actions Handlers (close/open node) + std::string AHNameClose; + std::string AHParamsClose; + // bitmap at this level of hierarchy + std::string Bitmap; // additionnal bitmap + // Hierarchy + std::vector Children; + SNode *Father; + // updated at display + SNode *LastVisibleSon; // filled at build time, meaningfull only if son is shown and opened, undefined otherwise + // Node added callback + INodeAddedCallback *NodeAddedCallback; + // + CGroupTree *ParentTree; + // ---------------------------- + SNode(); + ~SNode(); + void updateLastVisibleSon(); + void detachChild(SNode *pNode); + void deleteChild(SNode *pNode); + void addChild (SNode *pNode); + bool isChild(SNode *pNode) const; + void addChildFront (SNode *pNode); + void addChildAtIndex (SNode *pNode, sint index); + void addChildSorted(SNode *pNode); + void addChildSortedByBitmap(SNode *pNode); + void setParentTree(CGroupTree *parent); + void setFather(SNode *father); + void closeAll(); + void makeOrphan(); + bool parse (xmlNodePtr cur, CGroupTree *parentGroup); + uint getNumBitmap() const { return Bitmap.empty() ? 0 : 1; } + SNode *getNodeFromId(const std::string &id); + + // accessors + void setBitmap(const std::string &bitmap) { Bitmap = bitmap; } + std::string getBitmap() const { return Bitmap; } + void setOpened(bool opened) { Opened = opened; } + bool getOpened() const { return Opened; } + void setText(const ucstring &text) { Text = text; } + const ucstring& getText() const { return Text; } + sint32 getFontSize() const { return FontSize; } + void setFontSize(sint32 value) { FontSize = value; } + sint32 getYDecal() const { return YDecal; } + void setYDecal(sint32 value) { YDecal = value; } + + + std::string getId() const { return Id; } + void setId(const std::string &value) { Id = value; } + bool getShow() const { return Show; } + void setShow(bool value) { Show = value; } + std::string getAHName() const { return AHName; } + void setAHName(const std::string &value) { AHName = value; } + std::string getAHCond() const { return AHCond; } + void setAHCond(const std::string &value) { AHCond = value; } + std::string getAHParams() const { return AHParams; } + void setAHParams(const std::string &value) { AHParams = value; } + std::string getAHNameRight() const { return AHNameRight; } + void setAHNameRight(const std::string &value) { AHNameRight = value; } + std::string getAHParamsRight() const { return AHParamsRight; } + void setAHParamsRight(const std::string &value) { AHParamsRight = value; } + std::string getAHNameClose() const { return AHNameClose; } + void setAHNameClose(const std::string &value) { AHNameClose = value; } + std::string getAHParamsClose() const { return AHParamsClose; } + void setAHParamsClose(const std::string &value) { AHParamsClose = value; } + NLMISC::CRGBA getColor() const { return Color; } + void setColor(NLMISC::CRGBA color) { Color = color; } + // sort branch & sons alphabetically + void sort(); + // sort branch & sons alphabetically & by bitmap name (blank bitmap being the first) + void sortByBitmap(); + + // lua bindings + int luaGetNumChildren(CLuaState &ls); + int luaGetChild(CLuaState &ls); + int luaDetachChild(CLuaState &ls); + int luaDeleteChild(CLuaState &ls); + int luaAddChild(CLuaState &ls); + int luaAddChildSorted(CLuaState &ls); + int luaAddChildSortedByBitmap(CLuaState &ls); + int luaIsChild(CLuaState &ls); + int luaAddChildFront (CLuaState &ls); + int luaAddChildAtIndex (CLuaState &ls); + int luaCloseAll(CLuaState &ls); + int luaGetFather(CLuaState &ls); + int luaSort(CLuaState &ls); + int luaSortByBitmap(CLuaState &ls); + int luaGetNodeFromId(CLuaState &ls); + int luaGetParentTree(CLuaState &ls); + + // get node from first parameter on lua stack and throw necessary exception if not present + static SNode *luaGetNodeOnStack(CLuaState &ls, const char *funcName); + + REFLECT_EXPORT_START(CGroupTree::SNode, CReflectable) + REFLECT_STRING("Id", getId, setId); + REFLECT_STRING("Bitmap", getBitmap, setBitmap); + REFLECT_SINT32("FontSize", getFontSize, setFontSize); + REFLECT_SINT32("YDecal", getYDecal, setYDecal); + REFLECT_STRING("AHName", getAHName, setAHName); + REFLECT_STRING("AHCond", getAHCond, setAHCond); + REFLECT_RGBA("Color", getColor, setColor); + REFLECT_STRING("AHParams", getAHParams, setAHParams); + REFLECT_STRING("AHNameRight", getAHNameRight, setAHNameRight); + REFLECT_STRING("AHParamsRight", getAHParamsRight, setAHParamsRight); + REFLECT_STRING("AHNameClose", getAHNameClose, setAHNameClose); + REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); + REFLECT_BOOL("Opened", getOpened, setOpened); + REFLECT_BOOL("Show", getShow, setShow); + REFLECT_UCSTRING("Text", getText, setText); + // lua + REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); + REFLECT_LUA_METHOD("getChild", luaGetChild); + REFLECT_LUA_METHOD("detachChild", luaDetachChild); + REFLECT_LUA_METHOD("deleteChild", luaDeleteChild); + REFLECT_LUA_METHOD("addChild", luaAddChild); + REFLECT_LUA_METHOD("addChildSorted", luaAddChildSorted); + REFLECT_LUA_METHOD("addChildSortedByBitmap", luaAddChildSortedByBitmap); + REFLECT_LUA_METHOD("addChildFront", luaAddChildFront); + REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex); + REFLECT_LUA_METHOD("isChild", luaIsChild); + REFLECT_LUA_METHOD("closeAll", luaCloseAll); + REFLECT_LUA_METHOD("getFather", luaGetFather); + REFLECT_LUA_METHOD("sort", luaSort); + REFLECT_LUA_METHOD("sortByBitmap", luaSortByBitmap); + REFLECT_LUA_METHOD("getNodeFromId", luaGetNodeFromId); + REFLECT_LUA_METHOD("getParentTree", luaGetParentTree); + REFLECT_EXPORT_END + + + }; + + public: + + ///constructor + CGroupTree(const TCtorParam ¶m); + + // dtor + virtual ~CGroupTree(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + + virtual void checkCoords(); + + virtual void updateCoords(); + + virtual void draw(); + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + void reset(); + + // force rebuild the tree at next updateCoords() + void forceRebuild(); + + // For SNode + sint32 getIdNumber() { _IdGenerator++; return _IdGenerator; } + sint32 getFontSize() { return _FontSize; } + sint32 getYDecal() { return _YDecal; } + + // Set root node and delete the last one the user must not delete all allocated sub node. Nb: selection is reseted + void setRootNode (SNode *); + // Remove all lines bitmaps and templates or texts + void removeAll(); + + // unselect current node in tree + void unselect(); + + // Select a node by its line index (depends on opened nodes). no-op if not possible (AH not here, line>size) + void selectLine(uint line, bool runAH = true); + // simulate right button click on the given line (this also select the line) + bool rightButton(uint line); + + // Get the Selected Node Id. empty if none selected + const std::string &getSelectedNodeId() const; + + // Select by the node Id. return false if not found (selection is not reseted) + // NB: if the node was already selected, no-op (no action handler launched) + bool selectNodeById(const std::string &nodeId, bool triggerAH = true); + + // Get the root node (Opened State represent the current state) + SNode *getRootNode () const {return _RootNode;} + + // get current SNode under the mouse (possibly NULL) + SNode *getNodeUnderMouse() const; + + // Get/Change the NavigateOneBrnahc option. if false, then perform a reset before + bool getNavigateOneBranch() const {return _NavigateOneBranch;} + void changeNavigateOneBranch(bool newState); + + // should be called by action handler when thy want to cancel the selection of the line that triggered them + void cancelNextSelectLine(); + + // Get selected node + SNode * getSelectedNode() { return _SelectedNode;} + + // lua bindings + int luaGetRootNode(CLuaState &ls); + int luaSetRootNode(CLuaState &ls); + int luaForceRebuild(CLuaState &ls); + int luaSelectNodeById(CLuaState &ls); + int luaGetSelectedNodeId(CLuaState &ls); + int luaSelectLine(CLuaState &ls); + int luaUnselect(CLuaState &ls); + int luaGetNodeUnderMouse(CLuaState &ls); + int luaCancelNextSelectLine(CLuaState &ls); + + // Reflection + REFLECT_EXPORT_START(CGroupTree, CInterfaceGroup) + REFLECT_BOOL ("navigate_one_branch", getNavigateOneBranch, changeNavigateOneBranch); + REFLECT_LUA_METHOD("getRootNode", luaGetRootNode); + REFLECT_LUA_METHOD("setRootNode", luaSetRootNode); + REFLECT_LUA_METHOD("forceRebuild", luaForceRebuild); + REFLECT_LUA_METHOD("getSelectedNodeId", luaGetSelectedNodeId); + REFLECT_LUA_METHOD("selectNodeById", luaSelectNodeById); + REFLECT_LUA_METHOD("selectLine", luaSelectLine); + REFLECT_LUA_METHOD("unselect", luaUnselect); + REFLECT_LUA_METHOD("getNodeUnderMouse", luaGetNodeUnderMouse); + REFLECT_LUA_METHOD("cancelNextSelectLine", luaCancelNextSelectLine); + REFLECT_EXPORT_END + + private: + + sint32 _BmpW, _BmpH, _FontSize, _YDecal; + sint32 _XExtend; + + private: + + // Display structure + struct SLine + { + CViewBase *TextOrTemplate; + std::vector Bmps; + SNode::TRefPtr Node; + uint8 Depth; + + SLine() + { + TextOrTemplate = NULL; + } + + ~SLine() + { + Bmps.clear(); + } + uint getNumAdditionnalBitmap() const; + }; + + protected: + + void rebuild(); + void addTextLine (uint8 nDepth, SNode *pNode); + void addHierarchyBitmaps(); + + SNode *selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId); + + SNode *_RootNode; + sint32 _IdGenerator; + bool _MustRebuild; + std::vector _Lines; + sint32 _OverLine; + NLMISC::CRGBA _OverColor; + NLMISC::CRGBA _OverColorBack; + SNode *_SelectedNode; + sint32 _SelectedLine; + NLMISC::CRGBA _SelectedColor; + + // If a node is closed and a son of this node was selected, then this option force the ancestor being the new selection + bool _SelectAncestorOnClose; + bool _NavigateOneBranch; + bool _AvoidSelectNodeByIdIR; + + // when an action handler is run, it can call 'cancelSelectLine' if no selection should be done for real + bool _CancelNextSelectLine; + + + // Bitmap For arbo + std::string _ArboOpenFirst; + std::string _ArboCloseJustOne; + std::string _ArboSonWithoutSon; + std::string _ArboSonLast; + std::string _ArboSon; + std::string _ArboLevel; + std::string _ArboXExtend; + + // Special rectangle + bool _RectangleOutlineMode; + sint32 _RectangleX, _RectangleY; + sint32 _RectangleW, _RectangleH; + sint32 _RectangleDeltaRL; + + sint32 getHrcIconXStart(sint32 depth); + sint32 getHrcIconXEnd(sint32 depth); + + void drawSelection(sint x, sint y, sint w, NLMISC::CRGBA col); + + CViewBitmap *createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture); + }; + +} + + +#endif // NL_GROUP_TREE_H + +/* End of group_tree.h */ + + diff --git a/code/nel/src/gui/group_tree.cpp b/code/nel/src/gui/group_tree.cpp new file mode 100644 index 000000000..cb9372da6 --- /dev/null +++ b/code/nel/src/gui/group_tree.cpp @@ -0,0 +1,1638 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_tree.h" +#include "nel/gui/interface_element.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/view_text.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/lua_ihm.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/i18n.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/view_pointer_base.h" + +using namespace std; +using namespace NLMISC; + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + // SNode + // ---------------------------------------------------------------------------- + // TestYoyo + //uint SNodeCount= 0; + // ---------------------------------------------------------------------------- + CGroupTree::SNode::SNode() + { + Opened = false; + Father = NULL; + FontSize = -1; + YDecal = 0; + DisplayText = true; + Template = NULL; + Show= true; + NodeAddedCallback = NULL; + Color = CRGBA::White; + ParentTree = NULL; + LastVisibleSon = NULL; + // TestYoyo + //nlinfo("SNode(): %8x, c%d", this, SNodeCount++); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::updateLastVisibleSon() + { + LastVisibleSon = NULL; + if (!Show || !Opened) return; + for (sint sonIndex = (sint)Children.size() - 1; sonIndex >= 0; -- sonIndex) + { + if (Children[sonIndex]->Show) + { + LastVisibleSon = Children[sonIndex]; + break; + } + } + for(uint k = 0; k < Children.size(); ++k) + { + Children[k]->updateLastVisibleSon(); + } + } + + // ---------------------------------------------------------------------------- + CGroupTree::SNode::~SNode() + { + makeOrphan(); + // IMPORTANT : must delete in reverse order because "makeOrphan" is called when deleting sons, thus changing vector size... + for (sint i = (sint)Children.size() - 1; i >= 0; --i) + delete Children[i]; + Children.clear(); + // TestYoyo + //nlinfo("~SNode(): %8x, c%d", this, --SNodeCount); + } + + void CGroupTree::SNode::setParentTree(CGroupTree *parent) + { + ParentTree = parent; + for (uint k = 0; k < Children.size(); ++k) + { + Children[k]->setParentTree(parent); + } + } + + void CGroupTree::SNode::setFather(SNode *father) + { + Father = father; + setParentTree(father ? father->ParentTree : NULL); + } + + + CGroupTree::SNode *CGroupTree::SNode::getNodeFromId(const std::string &id) + { + if (Id == id) return this; + // breadth first + for (uint k = 0; k < Children.size(); ++k) + { + if (Children[k]->Id == id) + { + return Children[k]; + } + } + for (uint k = 0; k < Children.size(); ++k) + { + SNode *found = Children[k]->getNodeFromId(id); + if (found) return found; + } + return NULL; + } + + + void CGroupTree::SNode::makeOrphan() + { + if (ParentTree) + { + ParentTree->forceRebuild(); + setParentTree(NULL); + } + // + if (Template != NULL) + { + if (Template->getParent()) + { + // don't delete because may want to keep it. NB: deleted by smartptr at dtor + Template->getParent()->delGroup(Template, true); + } + } + // + if (Father) + { + Father->detachChild(this); + Father = NULL; + } + } + + // ---------------------------------------------------------------------------- + struct CNodeSorter + { + bool operator()(const CGroupTree::SNode *lhs, const CGroupTree::SNode *rhs) const + { + return lhs->Text < rhs->Text; + } + }; + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::sort() + { + std::sort(Children.begin(), Children.end(), CNodeSorter()); + for(uint k = 0; k < Children.size(); ++k) + { + Children[k]->sort(); + } + } + + + // ---------------------------------------------------------------------------- + struct CNodeSorterByBitmap + { + bool operator()(const CGroupTree::SNode *lhs, const CGroupTree::SNode *rhs) const + { + if (lhs->Bitmap != rhs->Bitmap) return lhs->Bitmap < rhs->Bitmap; + return lhs->Text < rhs->Text; + } + }; + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::sortByBitmap() + { + std::sort(Children.begin(), Children.end(), CNodeSorterByBitmap()); + for(uint k = 0; k < Children.size(); ++k) + { + Children[k]->sortByBitmap(); + } + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::addChild (SNode *pNode) + { + if(!pNode) return; + pNode->makeOrphan(); + Children.push_back(pNode); + pNode->setFather(this); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::addChildSorted(SNode *pNode) + { + if (!pNode) return; + pNode->makeOrphan(); + std::vector::iterator it = std::lower_bound(Children.begin(), Children.end(), pNode, CNodeSorter()); + Children.insert(it, pNode); + pNode->setFather(this); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::addChildSortedByBitmap(SNode *pNode) + { + if (!pNode) return; + pNode->makeOrphan(); + std::vector::iterator it = std::lower_bound(Children.begin(), Children.end(), pNode, CNodeSorterByBitmap()); + Children.insert(it, pNode); + pNode->setFather(this); + } + + // ---------------------------------------------------------------------------- + bool CGroupTree::SNode::isChild(SNode *pNode) const + { + return std::find(Children.begin(), Children.end(), pNode) != Children.end(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::detachChild(SNode *pNode) + { + nlassert(pNode); + nlassert(isChild(pNode)); + Children.erase(std::remove(Children.begin(), Children.end(), pNode), Children.end()); + pNode->setFather(NULL); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::deleteChild(SNode *pNode) + { + delete pNode; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::addChildFront (SNode *pNode) + { + if(!pNode) return; + pNode->makeOrphan(); + Children.insert(Children.begin(), pNode); + pNode->setFather(this); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::addChildAtIndex(SNode *pNode, sint index) + { + if(!pNode) return; + if (index < 0 || index > (sint) Children.size()) + { + nlwarning(" bad index %d (%d elements in the vector)", index, Children.size()); + return; + } + pNode->makeOrphan(); + if (pNode->Father) + { + pNode->Father->detachChild(pNode); + } + Children.insert(Children.begin() + index, pNode); + pNode->setFather(this); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::SNode::closeAll() + { + Opened = false; + for (uint i = 0; i < Children.size(); ++i) + Children[i]->closeAll(); + } + + // ---------------------------------------------------------------------------- + bool CGroupTree::SNode::parse (xmlNodePtr cur, CGroupTree * parentGroup) + { + if (stricmp((char*)cur->name, "node") == 0) + { + CXMLAutoPtr id((const char*) xmlGetProp (cur, (xmlChar*)"id")); + if (id) + Id = (const char*)id; + else + Id = toString(parentGroup->getIdNumber()); + + CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); + + if (name) + { + const char *ptrName = (const char*)name; + Text = ucstring(ptrName); + if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) + Text = CI18N::get (ptrName); + } + + CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color")); + if (color) + { + Color = convertColor(color); + } + + CXMLAutoPtr open((const char*) xmlGetProp (cur, (xmlChar*)"opened")); + if (open) Opened = convertBool(open); + + CXMLAutoPtr show((const char*) xmlGetProp (cur, (xmlChar*)"show")); + if (open) Show = convertBool(show); + + CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); + if (ah) AHName = (const char*)ah; + CXMLAutoPtr cond((const char*) xmlGetProp (cur, (xmlChar*)"cond")); + if (cond) AHCond = (const char*)cond; + CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params")); + if (params) AHParams = (const char*)params; + + CXMLAutoPtr ahRight((const char*) xmlGetProp (cur, (xmlChar*)"handler_right")); + if (ahRight) AHNameRight = (const char*)ahRight; + CXMLAutoPtr paramsRight((const char*) xmlGetProp (cur, (xmlChar*)"params_right")); + if (paramsRight) AHParamsRight = (const char*)paramsRight; + + CXMLAutoPtr bitmap((const char*) xmlGetProp (cur, (xmlChar*)"bitmap")); + if (bitmap) Bitmap = (const char*)bitmap; + + FontSize = parentGroup->getFontSize(); + CXMLAutoPtr fs((const char*) xmlGetProp (cur, (xmlChar*)"fontsize")); + if (fs) fromString((const char*)fs, FontSize); + + YDecal = parentGroup->getYDecal(); + CXMLAutoPtr yDecalPtr((const char*) xmlGetProp (cur, (xmlChar*)"y_decal")); + if (yDecalPtr) fromString((const char*)yDecalPtr, YDecal); + + + xmlNodePtr child = cur->children; + + while (child != NULL) + { + SNode *pNode = new SNode; + pNode->parse (child, parentGroup); + addChild(pNode); + child = child->next; + } + } + + return true; + } + + // ---------------------------------------------------------------------------- + // CGroupTree + // ---------------------------------------------------------------------------- + + NLMISC_REGISTER_OBJECT(CViewBase, CGroupTree, std::string, "tree"); + + // ---------------------------------------------------------------------------- + CGroupTree::CGroupTree(const TCtorParam ¶m) + :CInterfaceGroup(param) + { + _IdGenerator = 0; + _XExtend= 0; + _BmpW = 14; + _BmpH = 14; + _FontSize = 12; + _YDecal = 0; + _MustRebuild = true; + _OverColor = CRGBA(255, 255, 255, 128); + _OverColorBack = CRGBA(64, 64, 64, 255); + _SelectedNode = NULL; + _SelectedLine = -1; + _SelectedColor = CRGBA(255, 128, 128, 128); + _RootNode = NULL; + _OverLine = -1; + _SelectAncestorOnClose= false; + _NavigateOneBranch= false; + + _ArboOpenFirst= "arbo_open_first.tga"; + _ArboCloseJustOne= "arbo_close_just_one.tga"; + _ArboSonWithoutSon= "arbo_son_without_son.tga"; + _ArboSonLast= "arbo_son_last.tga"; + _ArboSon= "arbo_son.tga"; + _ArboLevel= "arbo_level.tga"; + + _RectangleOutlineMode= false; + _RectangleX= 0; + _RectangleY= 0; + _RectangleW= 10; + _RectangleH= 10; + _RectangleDeltaRL= 0; + + _AvoidSelectNodeByIdIR= false; + } + + // ---------------------------------------------------------------------------- + CGroupTree::~CGroupTree() + { + removeAll(); + if (_RootNode != NULL) delete _RootNode; + } + + // ---------------------------------------------------------------------------- + bool CGroupTree::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur, parentGroup)) + return false; + + CXMLAutoPtr ptr; + + ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_over"); + if (ptr) _OverColor = convertColor(ptr); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_select"); + if (ptr) _SelectedColor = convertColor(ptr); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_over_back"); + if (ptr) _OverColorBack = convertColor(ptr); + + ptr = (char*) xmlGetProp (cur, (xmlChar*)"fontsize"); + if (ptr) fromString((const char*)ptr, _FontSize); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"select_ancestor_on_close"); + if (ptr) _SelectAncestorOnClose = convertBool(ptr); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"navigate_one_branch"); + if (ptr) _NavigateOneBranch = convertBool(ptr); + + // read optional arbo bmps + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_open_first"); + if (ptr) _ArboOpenFirst= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_close_just_one"); + if (ptr) _ArboCloseJustOne= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son_without_son"); + if (ptr) _ArboSonWithoutSon= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son_last"); + if (ptr) _ArboSonLast= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son"); + if (ptr) _ArboSon= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_level"); + if (ptr) _ArboLevel= (const char*)ptr; + ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_x_extend"); + if (ptr) _ArboXExtend= (const char*)ptr; + + // Rectangle selection style + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_outline"); + if (ptr) _RectangleOutlineMode= convertBool(ptr); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_x"); + if (ptr) fromString((const char*)ptr, _RectangleX); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_y"); + if (ptr) fromString((const char*)ptr, _RectangleY); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_w"); + if (ptr) fromString((const char*)ptr, _RectangleW); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_h"); + if (ptr) fromString((const char*)ptr, _RectangleH); + ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_drl"); + if (ptr) fromString((const char*)ptr, _RectangleDeltaRL); + + + + _RootNode = new SNode; + // bool ok = true; + cur = cur->children; + while (cur) + { + // Check that this is a camera node + if ( stricmp((char*)cur->name, "node") == 0 ) + { + SNode *pNode = new SNode; + if (!pNode->parse(cur, this)) + { + delete pNode; + nlwarning("cannot parse node"); + } + else + { + _RootNode->addChild(pNode); + } + } + cur = cur->next; + } + _RootNode->Opened = true; + _ResizeFromChildW = _ResizeFromChildH = true; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 id = rVR.getTextureIdFromName(_ArboOpenFirst); + if (id != -1) + rVR.getTextureSizeFromId(id, _BmpW, _BmpH); + sint32 dummy; + id = rVR.getTextureIdFromName(_ArboXExtend); + if (id != -1) + rVR.getTextureSizeFromId(id, _XExtend, dummy); + else + // if not found, reset, to avoid errors + _ArboXExtend= ""; + + + return true; + } + + // ---------------------------------------------------------------------------- + sint32 CGroupTree::getHrcIconXStart(sint32 depth) + { + return depth*(_BmpW+_XExtend); + } + + // ---------------------------------------------------------------------------- + sint32 CGroupTree::getHrcIconXEnd(sint32 depth) + { + return depth*(_BmpW+_XExtend) + _BmpW; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::checkCoords() + { + CInterfaceGroup::checkCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::updateCoords() + { + if (_MustRebuild) + rebuild(); + CInterfaceGroup::updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::drawSelection(sint x, sint y, sint w, CRGBA col) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + if(!_RectangleOutlineMode) + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_OffsetX+x, _YReal+_OffsetY+y, + w, _BmpH, 0, false, rVR.getBlankTextureId(), + col ); + } + else + { + // draw the outline + x+= _XReal+_OffsetX+_RectangleX; + y+= _YReal+_OffsetY+_RectangleY; + w= _RectangleW; + sint32 h= _RectangleH; + sint32 rl= _RenderLayer + _RectangleDeltaRL; + + rVR.drawRotFlipBitmap (rl, x, y, 1, h, 0, false, rVR.getBlankTextureId(), col ); + rVR.drawRotFlipBitmap (rl, x+w-1, y, 1, h, 0, false, rVR.getBlankTextureId(), col ); + rVR.drawRotFlipBitmap (rl, x, y, w, 1, 0, false, rVR.getBlankTextureId(), col ); + rVR.drawRotFlipBitmap (rl, x, y+h-1, w, 1, 0, false, rVR.getBlankTextureId(), col ); + } + } + + // ---------------------------------------------------------------------------- + CGroupTree::SNode *CGroupTree::getNodeUnderMouse() const + { + if (_OverLine == -1) return NULL; + return _Lines[_OverLine].Node; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::draw() + { + // get the clip area + sint32 clipx, clipy, clipw, cliph; + getClip(clipx, clipy, clipw, cliph); + + // change the over + bool bDisplayOver = true; + + if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + bDisplayOver = false; + } + else + if (CWidgetManager::getInstance()->getModalWindow() == NULL) + { + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); + + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); + CInterfaceGroup *pParent = this; + bool bFound = false; + while (pParent != NULL) + { + if (pParent == pIG) + { + bFound = true; + break; + } + pParent = pParent->getParent(); + } + + // if the mouse is not in the clipped area + if ((x < clipx) || + (x > (clipx + clipw)) || + (y < clipy) || + (y > (clipy + cliph)) || !bFound) + { + _OverLine = -1; + } + else + { + x = x - _OffsetX; + y = y - _OffsetY; + for (sint32 i = 0; i < (sint32)_Lines.size(); ++i) + { + if ((y >= (_YReal+(sint32)(_Lines.size()-i-1)*_BmpH)) && + (y < (_YReal+(sint32)(_Lines.size()-i)*_BmpH))) + { + _OverLine = i; + } + } + if (_OverLine != -1) + { + if (x < _XReal + getHrcIconXEnd(_Lines[_OverLine].Depth)) + bDisplayOver = false; + } + } + } + + // some over to display? + if ((_OverLine != -1) && bDisplayOver) + { + // Find the first container + CInterfaceGroup *pIG = _Parent; + CGroupContainerBase *pGC = dynamic_cast(pIG); + while (pIG != NULL) + { + pIG = pIG->getParent(); + if (pIG == NULL) break; + if (dynamic_cast(pIG) != NULL) + pGC = dynamic_cast(pIG); + } + + // avoid if window grayed + if (pGC != NULL) + { + if (pGC->isGrayed()) + bDisplayOver = false; + } + + // Has to display the over? + if (bDisplayOver) + { + // !NULL if the text over must displayed across all windows + CViewText *viewTextExtend= NULL; + + // If the line is a simple Text line (not template) + if(_Lines[_OverLine].Node && _Lines[_OverLine].Node->DisplayText) + { + // Get the view text + viewTextExtend= safe_cast(_Lines[_OverLine].TextOrTemplate); + // If this viewText is not too big, no need + if(viewTextExtend->getXReal() + viewTextExtend->getWReal() <= (clipx+clipw) ) + viewTextExtend= NULL; + } + + // draw simple over + if(!viewTextExtend) + { + CRGBA col = _OverColor; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _OverColor; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + drawSelection( getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_OverLine-1)*_BmpH, + _WReal-getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()), col); + } + // Draw extended over + else + { + CRGBA col = _OverColorBack; + // must add the selection color + if(_SelectedLine == _OverLine) + { + // simulate alpha blend of the selection bitmap + CRGBA sel= _SelectedColor; + sel.A= (uint8)((sel.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + col.blendFromuiRGBOnly(col, sel, sel.A); + } + + // will be drawn over all the interface + CWidgetManager::getInstance()->setOverExtendViewText(viewTextExtend, col); + } + } + } + + // some selection to display + if (_SelectedLine != -1) + { + CRGBA col = _SelectedColor; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_SelectedColor, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _SelectedColor; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + + drawSelection( getHrcIconXEnd(_Lines[_SelectedLine].Depth + _Lines[_SelectedLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_SelectedLine-1)*_BmpH, + _WReal-getHrcIconXEnd(_Lines[_SelectedLine].Depth + _Lines[_SelectedLine].getNumAdditionnalBitmap()), col ); + } + + CInterfaceGroup::draw(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::selectLine(uint line, bool runAH /*= true*/) + { + if(line>=_Lines.size()) + return; + + if (!_Lines[line].Node) + { + // just deleted : must wait next draw to know the new line under mouse + return; + } + if (!_Lines[line].Node->AHName.empty() && runAH) + { + _CancelNextSelectLine = false; + /* + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, + this, + _Lines[line].Node->AHParams ); + */ + if (!_CancelNextSelectLine) + { + _SelectedLine = line; + _SelectedNode = _Lines[line].Node; + } + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, + this, + _Lines[line].Node->AHParams ); + _CancelNextSelectLine = false; + } + } + + // ---------------------------------------------------------------------------- + bool CGroupTree::rightButton(uint line) + { + if(line>=_Lines.size()) + return false; + + if (!_Lines[_OverLine].Node || _Lines[_OverLine].Node->AHNameRight.empty()) + return false; + + if (line != (uint) _SelectedLine) selectLine(line, false); + + CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHNameRight, + this, + _Lines[line].Node->AHParamsRight ); + return true; + } + + + + // ---------------------------------------------------------------------------- + const std::string &CGroupTree::getSelectedNodeId() const + { + if(_SelectedLine>=0 && _SelectedLine<(sint)_Lines.size() && _Lines[_SelectedLine].Node) + { + return _Lines[_SelectedLine].Node->Id; + } + else + { + static string empty; + return empty; + } + } + + // ---------------------------------------------------------------------------- + bool CGroupTree::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (!_Active) return false; + if (CInterfaceGroup::handleEvent(event)) return true; + // The line must be over (pre-selected) + if (event.getType() == NLGUI::CEventDescriptor::mouse && _OverLine>=0) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + + if (!isIn(eventDesc.getX(), eventDesc.getY())) + return false; + + sint32 x = eventDesc.getX() - _OffsetX; + // sint32 y = eventDesc.getY() - _OffsetY; + bool bText = false; + if (x >= (_XReal+getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()))) + bText = true; + bool bIcon = false; + if ((x > (_XReal+getHrcIconXStart(_Lines[_OverLine].Depth)-_XExtend)) && + (x < (_XReal+getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap())))) + bIcon = true; + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) + { + if (bText) + { + return rightButton(_OverLine != -1 ? _OverLine : _SelectedLine); + } + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + // line selection + if (bText) + { + selectLine(_OverLine); + } + // close of node + if (bIcon) + { + SNode *changedNode= _Lines[_OverLine].Node; + + if (changedNode) + { + // if "SelectAncestorOnClose" feature wanted, if it was opened before, and if some node selected + if(_SelectAncestorOnClose && changedNode->Opened && _SelectedNode) + { + // check that the selected node is a son of the closing node + SNode *parent= _SelectedNode->Father; + while(parent) + { + if(parent==changedNode) + { + // Then change selection to this parent first + selectLine(_OverLine); + break; + } + parent= parent->Father; + } + } + + // standard hrc + if(!_NavigateOneBranch) + { + // open/close the node + changedNode->Opened = !changedNode->Opened; + } + // else must close all necessary nodes. + else + { + if(changedNode->Opened) + changedNode->closeAll(); + else + { + // must closeAll all his brothers first. + if(changedNode->Father) + { + changedNode->Father->closeAll(); + changedNode->Father->Opened= true; + } + changedNode->Opened= true; + } + } + + CAHManager::getInstance()->runActionHandler(changedNode->AHNameClose, this, changedNode->AHParamsClose); + } + forceRebuild(); + } + return true; + } + } + return false; + } + + + // ---------------------------------------------------------------------------- + void CGroupTree::unselect() + { + _SelectedLine = -1; + _SelectedNode = NULL; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::reset() + { + unselect(); + if (_RootNode) + { + _RootNode->closeAll(); + _RootNode->Opened = true; + } + forceRebuild(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::forceRebuild() + { + _MustRebuild = true; + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::rebuild() + { + // Remove all + removeAll(); + + if (_RootNode) + _RootNode->Opened = true; + + // Rebuild all depending on the logic + if(_RootNode) + addTextLine (0, _RootNode); + + // Reformating + sint32 sizeH = (sint32)_Lines.size()*_BmpH; + for (uint i = 0; i < _Lines.size(); ++i) + _Lines[i].TextOrTemplate->setY (_Lines[i].Node->YDecal + sizeH - ((1+_Lines[i].TextOrTemplate->getY())*_BmpH)); + // Add the hierarchy bitmaps + addHierarchyBitmaps(); + // Find if we can display selection + if (_SelectedNode != NULL) + { + _SelectedLine = -1; + for (uint i = 0; i < _Lines.size(); ++i) + if (_Lines[i].Node == _SelectedNode) + { + _SelectedLine = i; + break; + } + } + + // Ok no more need to rebuild all this + _MustRebuild = false; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::setRootNode (SNode *pNewRoot) + { + // reset selection + _SelectedLine= -1; + _SelectedNode= NULL; + + CRefPtr refPtrNewRoot = pNewRoot; + // clear old + delete _RootNode; + + // If the node was deleted + if (pNewRoot && !refPtrNewRoot) + { + // NB nico : if anyone need that a day, please feel free to modify ... + nlwarning("Trying to set a node that is part of the tree as root node (not supported yet ...)"); + } + + // set new (may be NULL) + _RootNode = pNewRoot; + if(pNewRoot) + pNewRoot->setParentTree(this); + rebuild(); + } + + // ---------------------------------------------------------------------------- + void CGroupTree::removeAll() + { + // Remove (but not delete) the groups template if any + for(uint i=0;i<_Lines.size();i++) + { + if (_Lines[i].Node) + { + if(_Lines[i].Node->Template) + { + delGroup(_Lines[i].Node->Template, true); + } + } + } + + // Clear all lines, but don't delete templates + _Lines.clear(); + + // Delete all BmpViews and/or all text views + clearViews(); + } + + + + // ---------------------------------------------------------------------------- + void CGroupTree::addTextLine (uint8 nDepth, CGroupTree::SNode *pNode) + { + pNode->setParentTree(this); + if (nDepth > 0) + { + SLine line; + line.Depth = nDepth-1; + line.Node = pNode; + if (pNode->DisplayText) + { + CViewText *pVT = new CViewText(TCtorParam()); + line.TextOrTemplate = pVT; + pVT->setId("t"+toString(_Lines.size())); + pVT->setText(pNode->Text); + pVT->setColor(pNode->Color); + if(pNode->FontSize==-1) + pVT->setFontSize(_FontSize); + else + pVT->setFontSize(pNode->FontSize); + } + else + { + line.TextOrTemplate = pNode->Template; + } + line.TextOrTemplate->setPosRef (Hotspot_BL); + line.TextOrTemplate->setParentPosRef (Hotspot_BL); + line.TextOrTemplate->setParent (this); + line.TextOrTemplate->setParentPos (NULL); + line.TextOrTemplate->setX (getHrcIconXEnd(nDepth-1 + line.getNumAdditionnalBitmap())); + line.TextOrTemplate->setY ((sint32)_Lines.size()); + line.TextOrTemplate->setModulateGlobalColor(this->getModulateGlobalColor()); + if (pNode->DisplayText) + addView (line.TextOrTemplate); + else + addGroup ((CInterfaceGroup*)line.TextOrTemplate); + if (pNode->NodeAddedCallback) + { + pNode->NodeAddedCallback->nodeAdded(pNode, line.TextOrTemplate); + } + _Lines.push_back(line); + } + + // recurs + if (pNode->Opened) + { + // **** standard hierarchy display, or if root + if(!_NavigateOneBranch || nDepth==0) + { + for (uint i = 0; i < pNode->Children.size(); ++i) + { + // add the branch only if want to show it + if(pNode->Children[i]->Show) + addTextLine (nDepth+1, pNode->Children[i]); + } + } + // **** display only the branch navigated + else + { + // find the first child opened + sint childOpen= -1; + for (uint i = 0; i < pNode->Children.size(); ++i) + { + // don't take hid ones + if(pNode->Children[i]->Show && pNode->Children[i]->Opened) + { + childOpen= i; + break; + } + } + + // If some chidl opened, add just this line + if(childOpen>=0) + { + addTextLine (nDepth+1, pNode->Children[childOpen]); + } + // else add all closed, but showable lines + else + { + for (uint i = 0; i < pNode->Children.size(); ++i) + { + if(pNode->Children[i]->Show) + addTextLine (nDepth+1, pNode->Children[i]); + } + } + } + } + } + + // ---------------------------------------------------------------------------- + CViewBitmap *CGroupTree::createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture) + { + CViewBitmap *pVB = new CViewBitmap(TCtorParam()); + pVB->setId(idPrefix+toString(_Lines.size())+"_"+toString(_Lines[line].Bmps.size())); + pVB->setParent (this); + pVB->setParentPos (NULL); + pVB->setModulateGlobalColor(this->getModulateGlobalColor()); + pVB->setTexture(texture); + return pVB; + } + + // ---------------------------------------------------------------------------- + void CGroupTree::addHierarchyBitmaps () + { + if (_RootNode) _RootNode->updateLastVisibleSon(); + for (uint nLayer = 0; nLayer < 256; nLayer++) + { + sint32 nCurRootLine = -1; + bool bCurRootLineLast = false; + bool bCurRootLineLastChild = false; + for (uint nLine = 0; nLine < _Lines.size(); nLine++) + if (nLayer <= _Lines[nLine].Depth) + { + // A Bitmap must be created + CViewBitmap *pVB = createViewBitmap(nLine, "t", "blank.tga"); + pVB->setX (getHrcIconXStart(nLayer)); + pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); + + bool bAddBitmap = true; + bool bAddXExtendBitmap = false; + // Choose a bitmap + // Are we on the last depth in the line ? + if (_Lines[nLine].Depth == nLayer) + { + nCurRootLine = nLine; + if (_Lines[nLine].Node == _Lines[nCurRootLine].Node->Father->LastVisibleSon) + bCurRootLineLast = true; + else + bCurRootLineLast = false; + bCurRootLineLastChild = false; + + // do i have some child shown? + bool haveSomeVisibleChild= false; + for(uint k=0;k<_Lines[nLine].Node->Children.size();k++) + { + if(_Lines[nLine].Node->Children[k]->Show) + { + haveSomeVisibleChild= true; + break; + } + } + + // if so + if (haveSomeVisibleChild) + { + // Yes am I opened ? + if (_Lines[nLine].Node->Opened) + { + pVB->setTexture(_ArboOpenFirst); + } + else + { + // No I am closed + pVB->setTexture(_ArboCloseJustOne); + } + } + else + { + /* + // No child + // If there's a bitmap on this line , left an empty bitmap + if (!_Lines[nLine].Node->Bitmap.empty()) + { + pVB->setTexture("blank.tga"); // create a transparent bitmap to have correct "child_resize_w" + pVB->setColor(CRGBA(0, 0, 0, 0)); + } + else + { + pVB->setTexture(_ArboSonWithoutSon); + } + */ + pVB->setTexture(_ArboSonWithoutSon); + } + + // if not the root line, must add Extend Bitmap + if(nLayer) + bAddXExtendBitmap= true; + } + else + { + // No we are before the last depth, Do we have any current root ? + if (nCurRootLine != -1) + { + // Yes, do the current line is child of current root line ? + bool bFound = false; + for (uint i = 0; i < _Lines[nCurRootLine].Node->Children.size(); ++i) + if (_Lines[nLine].Node == _Lines[nCurRootLine].Node->Children[i]) + { + bFound = true; + break; + } + if (bFound) + { + // is it the last child ? + bool lastSonDisplay= _Lines[nLine].Node == _Lines[nCurRootLine].Node->LastVisibleSon; + + + // Special for _NavigateOneBranch mode + if(_NavigateOneBranch) + { + // if node opened, then his brother are hid! => he behaves like a "last son" + if(_Lines[nLine].Node->Opened) + lastSonDisplay= true; + } + + // if must display like last child + if (lastSonDisplay) + { + // Yes this is the last child + pVB->setTexture(_ArboSonLast); + bCurRootLineLastChild = true; + } + else + { + // No so we have brothers + pVB->setTexture(_ArboSon); + } + } + else + { + // Not found, display a line + pVB->setTexture(_ArboLevel); + + // We have to not display a line if we have passed the last child of this root + // We never have to display a line also if we are in _NavigateOneBranch mode + if (bCurRootLineLastChild || _NavigateOneBranch) + bAddBitmap = false; + } + } + } + + // Add the bitmap + if (bAddBitmap) + { + addView (pVB); + _Lines[nLine].Bmps.push_back(pVB); + + // if must add the special extend bitmap, and if exist + if(bAddXExtendBitmap && !_ArboXExtend.empty()) + { + CViewBitmap *pVB = createViewBitmap(nLine, "ext_t", _ArboXExtend); + pVB->setX (getHrcIconXStart(nLayer) - _XExtend); + pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); + addView (pVB); + _Lines[nLine].Bmps.push_back(pVB); + } + } + else + { + delete pVB; + } + } + } + // add additionnal bitmap for each line + for (uint nLine = 0; nLine < _Lines.size(); nLine++) + { + if (!_Lines[nLine].Node->Bitmap.empty()) + { + CViewBitmap *pVB = createViewBitmap(nLine, "custom_bm", _Lines[nLine].Node->Bitmap); + pVB->setX (getHrcIconXStart(_Lines[nLine].Depth + 1)); + pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); + _Lines[nLine].Bmps.push_back(pVB); + addView (pVB); + } + } + } + + // *************************************************************************** + CGroupTree::SNode *CGroupTree::selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId) + { + // select this node? + if(pNode!=_RootNode) + { + if(pNode->Id == nodeId) + return pNode; + } + + // try with sons + for(uint i=0;iChildren.size();i++) + { + SNode *ret= selectNodeByIdRecurse(pNode->Children[i], nodeId); + if(ret) + return ret; + } + + // not found => NULL + return NULL; + } + + // *************************************************************************** + bool CGroupTree::selectNodeById(const std::string &nodeId, bool triggerAH) + { + SNode *selNode= NULL; + + // Avoid infinite recurs + if(_AvoidSelectNodeByIdIR) + return true; + + // first find in the hierarchy + selNode= selectNodeByIdRecurse(_RootNode, nodeId); + + // if found + if(selNode) + { + // Opens the hierarchy + SNode *pFather = selNode->Father; + while(pFather != NULL) + { + pFather->Opened = true; + pFather = pFather->Father; + } + + if (triggerAH) + { + // runAH may infinite recurs (HTML browse...) + _AvoidSelectNodeByIdIR= true; + + // launch the action handler + CAHManager::getInstance()->runActionHandler ( selNode->AHName, + this, + selNode->AHParams ); + } + + // runAH may infinite recurs (HTML browse...) + _AvoidSelectNodeByIdIR= false; + + // mark as selected + _SelectedNode = selNode; + + forceRebuild(); + + return true; + } + else + { + return false; + } + } + + // *************************************************************************** + class CHandlerTreeReset : public IActionHandler + { + public: + void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + { + CGroupTree *pTree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); + if (pTree != NULL) + pTree->reset(); + } + protected: + }; + REGISTER_ACTION_HANDLER( CHandlerTreeReset, "tree_reset"); + + // *************************************************************************** + void CGroupTree::changeNavigateOneBranch(bool newState) + { + if(newState!=_NavigateOneBranch) + { + _NavigateOneBranch= newState; + // if new is true, then must reset both open state and selection + if(_NavigateOneBranch) + { + reset(); + // reselect the first line + selectLine(0); + } + // else just rebuild + else + { + forceRebuild(); + } + } + } + + // *************************************************************************** + void CGroupTree::cancelNextSelectLine() + { + _CancelNextSelectLine = true; + } + + // *************************************************************************** + int CGroupTree::luaGetRootNode(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getRootNode", 0); + CLuaIHM::pushReflectableOnStack(ls, getRootNode()); + return 1; + } + + // *************************************************************************** + int CGroupTree::luaSetRootNode(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "setRootNode", 1); + if (ls.isNil()) + { + setRootNode(NULL); + return 0; + } + setRootNode(SNode::luaGetNodeOnStack(ls, "CGroupTree::setRootNode")); + return 0; + } + + + // *************************************************************************** + int CGroupTree::luaForceRebuild(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "forceRebuild", 0); + forceRebuild(); + return 0; + } + + // *************************************************************************** + CGroupTree::SNode *CGroupTree::SNode::luaGetNodeOnStack(CLuaState &ls, const char * /* funcName */) + { + SNode *node = dynamic_cast(CLuaIHM::getReflectableOnStack(ls, 1)); + CLuaIHM::check(ls, node != NULL, "SNode expected"); + return node; + } + + // *************************************************************************** + int CGroupTree::SNode::luaDetachChild(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaDetachChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + detachChild(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaSort(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaSort"; + CLuaIHM::checkArgCount(ls, funcName, 0); + sort(); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaSortByBitmap(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaSort"; + CLuaIHM::checkArgCount(ls, funcName, 0); + sortByBitmap(); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaDeleteChild(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaDeleteChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + deleteChild(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaAddChild(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaAddChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + addChild(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaAddChildSorted(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaAddChildSorted"; + CLuaIHM::checkArgCount(ls, funcName, 1); + addChildSorted(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaAddChildSortedByBitmap(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaAddChildSortedByBitmap"; + CLuaIHM::checkArgCount(ls, funcName, 1); + addChildSorted(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaGetNodeFromId(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaGetNodeFromId"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + SNode *result = getNodeFromId(ls.toString(1)); + if (result) + { + CLuaIHM::pushReflectableOnStack(ls, result); + } + else + { + ls.pushNil(); + } + return 1; + } + + // *************************************************************************** + int CGroupTree::SNode::luaGetParentTree(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getParentTree", 0); + if (ParentTree) + { + CLuaIHM::pushUIOnStack(ls, ParentTree); + } + else + { + ls.pushNil(); + } + return 1; + } + + // *************************************************************************** + int CGroupTree::luaGetNodeUnderMouse(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getNodeUnderMouse", 0); + SNode *node = getNodeUnderMouse(); + if (node) + { + CLuaIHM::pushReflectableOnStack(ls, node); + } + else + { + ls.pushNil(); + } + return 1; + } + + // *************************************************************************** + int CGroupTree::luaCancelNextSelectLine(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "cancelNextSelectLine", 0); + cancelNextSelectLine(); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaAddChildFront(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaAddChildFront"; + CLuaIHM::checkArgCount(ls, funcName, 1); + addChild(luaGetNodeOnStack(ls, funcName)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaIsChild(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaIsChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + ls.push(isChild(luaGetNodeOnStack(ls, funcName))); + return 1; + } + + // *************************************************************************** + int CGroupTree::SNode::luaAddChildAtIndex(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaAddChildAtIndex"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toNumber(2)); + return 0; + } + + // *************************************************************************** + int CGroupTree::SNode::luaGetFather(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaGetFather"; + CLuaIHM::checkArgCount(ls, funcName, 0); + if(Father) + CLuaIHM::pushReflectableOnStack(ls, Father); + else + ls.pushNil(); + return 1; + } + + // *************************************************************************** + int CGroupTree::SNode::luaGetNumChildren(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaGetNumChildren"; + CLuaIHM::checkArgCount(ls, funcName, 0); + ls.push((double) Children.size()); + return 1; + } + + // *************************************************************************** + int CGroupTree::SNode::luaGetChild(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaGetChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + // + sint index = (sint) ls.toNumber(1); + if (index < 0 || index >= (sint) Children.size()) + { + std::string range = Children.empty() ? "" : toString("[0, %d]", Children.size() - 1); + CLuaIHM::fails(ls, "Bad index of tree node child : %d, range is %s", (int) index, range.c_str()); + } + CLuaIHM::pushReflectableOnStack(ls, Children[index]); + return 1; + } + + // *************************************************************************** + int CGroupTree::SNode::luaCloseAll(CLuaState &ls) + { + const char *funcName = "CGroupTree::SNode::luaGetFather"; + CLuaIHM::checkArgCount(ls, funcName, 0); + closeAll(); + return 0; + } + + // *************************************************************************** + int CGroupTree::luaSelectNodeById(CLuaState &ls) + { + const char *funcName = "selectNodeById"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN); + selectNodeById(ls.toString(1), ls.toBoolean(2)); + return 0; + } + + // *************************************************************************** + int CGroupTree::luaGetSelectedNodeId(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getSelectedNodeId", 0); + ls.push(getSelectedNodeId()); + return 1; + } + + // *************************************************************************** + int CGroupTree::luaSelectLine(CLuaState &ls) + { + CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 1, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 2, LUA_TBOOLEAN); + selectLine((uint) ls.toNumber(1), ls.toBoolean(2)); + return 0; + } + + // *************************************************************************** + int CGroupTree::luaUnselect(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "unselect", 0); + unselect(); + return 0; + } + + + // *************************************************************************** + uint CGroupTree::SLine::getNumAdditionnalBitmap() const + { + if (!Node) return 0; + return Node->getNumBitmap(); + } + +} + + diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 486f9b70f..d764ea90e 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -44,7 +44,7 @@ #include "guild_manager.h" #include "../net_manager.h" #include "interface_ddx.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "group_map.h" #include "nel/gui/view_bitmap.h" #include "action_handler_tools.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 8c60170b2..9a1466479 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -46,7 +46,7 @@ #include "../entities.h" #include "macrocmd_manager.h" #include "group_menu.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" extern CSheetManager SheetMngr; diff --git a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp index b3f2abad2..10f96d306 100644 --- a/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp +++ b/code/ryzom/client/src/interface_v3/encyclopedia_manager.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "encyclopedia_manager.h" #include "interface_manager.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "nel/gui/view_text_id.h" #include "nel/gui/view_bitmap.h" #include "action_handler_misc.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index beca17afd..963c0f07f 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -26,7 +26,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" #include "group_scrolltext.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "nel/gui/ctrl_button.h" #include "group_table.h" diff --git a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h index 8da02ee10..db18813f6 100644 --- a/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h +++ b/code/ryzom/client/src/interface_v3/group_phrase_skill_filter.h @@ -23,7 +23,7 @@ #include "game_share/brick_families.h" #include "game_share/skills.h" #include "nel/gui/interface_group.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_skills.h b/code/ryzom/client/src/interface_v3/group_skills.h index a29af8a03..329734025 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.h +++ b/code/ryzom/client/src/interface_v3/group_skills.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" // *************************************************************************** /** A Group that display all skills by category in a job diff --git a/code/ryzom/client/src/interface_v3/group_tree.cpp b/code/ryzom/client/src/interface_v3/group_tree.cpp deleted file mode 100644 index 735f28421..000000000 --- a/code/ryzom/client/src/interface_v3/group_tree.cpp +++ /dev/null @@ -1,1635 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_tree.h" -#include "nel/gui/interface_element.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_text.h" -#include "nel/gui/group_container_base.h" -#include "nel/gui/action_handler.h" -#include "nel/gui/lua_ihm.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/i18n.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/view_pointer_base.h" - -using namespace std; -using namespace NLMISC; - -// ---------------------------------------------------------------------------- -// SNode -// ---------------------------------------------------------------------------- -// TestYoyo -//uint SNodeCount= 0; -// ---------------------------------------------------------------------------- -CGroupTree::SNode::SNode() -{ - Opened = false; - Father = NULL; - FontSize = -1; - YDecal = 0; - DisplayText = true; - Template = NULL; - Show= true; - NodeAddedCallback = NULL; - Color = CRGBA::White; - ParentTree = NULL; - LastVisibleSon = NULL; - // TestYoyo - //nlinfo("SNode(): %8x, c%d", this, SNodeCount++); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::updateLastVisibleSon() -{ - LastVisibleSon = NULL; - if (!Show || !Opened) return; - for (sint sonIndex = (sint)Children.size() - 1; sonIndex >= 0; -- sonIndex) - { - if (Children[sonIndex]->Show) - { - LastVisibleSon = Children[sonIndex]; - break; - } - } - for(uint k = 0; k < Children.size(); ++k) - { - Children[k]->updateLastVisibleSon(); - } -} - -// ---------------------------------------------------------------------------- -CGroupTree::SNode::~SNode() -{ - makeOrphan(); - // IMPORTANT : must delete in reverse order because "makeOrphan" is called when deleting sons, thus changing vector size... - for (sint i = (sint)Children.size() - 1; i >= 0; --i) - delete Children[i]; - Children.clear(); - // TestYoyo - //nlinfo("~SNode(): %8x, c%d", this, --SNodeCount); -} - -void CGroupTree::SNode::setParentTree(CGroupTree *parent) -{ - ParentTree = parent; - for (uint k = 0; k < Children.size(); ++k) - { - Children[k]->setParentTree(parent); - } -} - -void CGroupTree::SNode::setFather(SNode *father) -{ - Father = father; - setParentTree(father ? father->ParentTree : NULL); -} - - -CGroupTree::SNode *CGroupTree::SNode::getNodeFromId(const std::string &id) -{ - if (Id == id) return this; - // breadth first - for (uint k = 0; k < Children.size(); ++k) - { - if (Children[k]->Id == id) - { - return Children[k]; - } - } - for (uint k = 0; k < Children.size(); ++k) - { - SNode *found = Children[k]->getNodeFromId(id); - if (found) return found; - } - return NULL; -} - - -void CGroupTree::SNode::makeOrphan() -{ - if (ParentTree) - { - ParentTree->forceRebuild(); - setParentTree(NULL); - } - // - if (Template != NULL) - { - if (Template->getParent()) - { - // don't delete because may want to keep it. NB: deleted by smartptr at dtor - Template->getParent()->delGroup(Template, true); - } - } - // - if (Father) - { - Father->detachChild(this); - Father = NULL; - } -} - -// ---------------------------------------------------------------------------- -struct CNodeSorter -{ - bool operator()(const CGroupTree::SNode *lhs, const CGroupTree::SNode *rhs) const - { - return lhs->Text < rhs->Text; - } -}; - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::sort() -{ - std::sort(Children.begin(), Children.end(), CNodeSorter()); - for(uint k = 0; k < Children.size(); ++k) - { - Children[k]->sort(); - } -} - - -// ---------------------------------------------------------------------------- -struct CNodeSorterByBitmap -{ - bool operator()(const CGroupTree::SNode *lhs, const CGroupTree::SNode *rhs) const - { - if (lhs->Bitmap != rhs->Bitmap) return lhs->Bitmap < rhs->Bitmap; - return lhs->Text < rhs->Text; - } -}; - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::sortByBitmap() -{ - std::sort(Children.begin(), Children.end(), CNodeSorterByBitmap()); - for(uint k = 0; k < Children.size(); ++k) - { - Children[k]->sortByBitmap(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::addChild (SNode *pNode) -{ - if(!pNode) return; - pNode->makeOrphan(); - Children.push_back(pNode); - pNode->setFather(this); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::addChildSorted(SNode *pNode) -{ - if (!pNode) return; - pNode->makeOrphan(); - std::vector::iterator it = std::lower_bound(Children.begin(), Children.end(), pNode, CNodeSorter()); - Children.insert(it, pNode); - pNode->setFather(this); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::addChildSortedByBitmap(SNode *pNode) -{ - if (!pNode) return; - pNode->makeOrphan(); - std::vector::iterator it = std::lower_bound(Children.begin(), Children.end(), pNode, CNodeSorterByBitmap()); - Children.insert(it, pNode); - pNode->setFather(this); -} - -// ---------------------------------------------------------------------------- -bool CGroupTree::SNode::isChild(SNode *pNode) const -{ - return std::find(Children.begin(), Children.end(), pNode) != Children.end(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::detachChild(SNode *pNode) -{ - nlassert(pNode); - nlassert(isChild(pNode)); - Children.erase(std::remove(Children.begin(), Children.end(), pNode), Children.end()); - pNode->setFather(NULL); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::deleteChild(SNode *pNode) -{ - delete pNode; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::addChildFront (SNode *pNode) -{ - if(!pNode) return; - pNode->makeOrphan(); - Children.insert(Children.begin(), pNode); - pNode->setFather(this); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::addChildAtIndex(SNode *pNode, sint index) -{ - if(!pNode) return; - if (index < 0 || index > (sint) Children.size()) - { - nlwarning(" bad index %d (%d elements in the vector)", index, Children.size()); - return; - } - pNode->makeOrphan(); - if (pNode->Father) - { - pNode->Father->detachChild(pNode); - } - Children.insert(Children.begin() + index, pNode); - pNode->setFather(this); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::SNode::closeAll() -{ - Opened = false; - for (uint i = 0; i < Children.size(); ++i) - Children[i]->closeAll(); -} - -// ---------------------------------------------------------------------------- -bool CGroupTree::SNode::parse (xmlNodePtr cur, CGroupTree * parentGroup) -{ - if (stricmp((char*)cur->name, "node") == 0) - { - CXMLAutoPtr id((const char*) xmlGetProp (cur, (xmlChar*)"id")); - if (id) - Id = (const char*)id; - else - Id = toString(parentGroup->getIdNumber()); - - CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); - - if (name) - { - const char *ptrName = (const char*)name; - Text = ucstring(ptrName); - if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) - Text = CI18N::get (ptrName); - } - - CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color")); - if (color) - { - Color = convertColor(color); - } - - CXMLAutoPtr open((const char*) xmlGetProp (cur, (xmlChar*)"opened")); - if (open) Opened = convertBool(open); - - CXMLAutoPtr show((const char*) xmlGetProp (cur, (xmlChar*)"show")); - if (open) Show = convertBool(show); - - CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); - if (ah) AHName = (const char*)ah; - CXMLAutoPtr cond((const char*) xmlGetProp (cur, (xmlChar*)"cond")); - if (cond) AHCond = (const char*)cond; - CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params")); - if (params) AHParams = (const char*)params; - - CXMLAutoPtr ahRight((const char*) xmlGetProp (cur, (xmlChar*)"handler_right")); - if (ahRight) AHNameRight = (const char*)ahRight; - CXMLAutoPtr paramsRight((const char*) xmlGetProp (cur, (xmlChar*)"params_right")); - if (paramsRight) AHParamsRight = (const char*)paramsRight; - - CXMLAutoPtr bitmap((const char*) xmlGetProp (cur, (xmlChar*)"bitmap")); - if (bitmap) Bitmap = (const char*)bitmap; - - FontSize = parentGroup->getFontSize(); - CXMLAutoPtr fs((const char*) xmlGetProp (cur, (xmlChar*)"fontsize")); - if (fs) fromString((const char*)fs, FontSize); - - YDecal = parentGroup->getYDecal(); - CXMLAutoPtr yDecalPtr((const char*) xmlGetProp (cur, (xmlChar*)"y_decal")); - if (yDecalPtr) fromString((const char*)yDecalPtr, YDecal); - - - xmlNodePtr child = cur->children; - - while (child != NULL) - { - SNode *pNode = new SNode; - pNode->parse (child, parentGroup); - addChild(pNode); - child = child->next; - } - } - - return true; -} - -// ---------------------------------------------------------------------------- -// CGroupTree -// ---------------------------------------------------------------------------- - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupTree, std::string, "tree"); - -// ---------------------------------------------------------------------------- -CGroupTree::CGroupTree(const TCtorParam ¶m) -:CInterfaceGroup(param) -{ - _IdGenerator = 0; - _XExtend= 0; - _BmpW = 14; - _BmpH = 14; - _FontSize = 12; - _YDecal = 0; - _MustRebuild = true; - _OverColor = CRGBA(255, 255, 255, 128); - _OverColorBack = CRGBA(64, 64, 64, 255); - _SelectedNode = NULL; - _SelectedLine = -1; - _SelectedColor = CRGBA(255, 128, 128, 128); - _RootNode = NULL; - _OverLine = -1; - _SelectAncestorOnClose= false; - _NavigateOneBranch= false; - - _ArboOpenFirst= "arbo_open_first.tga"; - _ArboCloseJustOne= "arbo_close_just_one.tga"; - _ArboSonWithoutSon= "arbo_son_without_son.tga"; - _ArboSonLast= "arbo_son_last.tga"; - _ArboSon= "arbo_son.tga"; - _ArboLevel= "arbo_level.tga"; - - _RectangleOutlineMode= false; - _RectangleX= 0; - _RectangleY= 0; - _RectangleW= 10; - _RectangleH= 10; - _RectangleDeltaRL= 0; - - _AvoidSelectNodeByIdIR= false; -} - -// ---------------------------------------------------------------------------- -CGroupTree::~CGroupTree() -{ - removeAll(); - if (_RootNode != NULL) delete _RootNode; -} - -// ---------------------------------------------------------------------------- -bool CGroupTree::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur, parentGroup)) - return false; - - CXMLAutoPtr ptr; - - ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_over"); - if (ptr) _OverColor = convertColor(ptr); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_select"); - if (ptr) _SelectedColor = convertColor(ptr); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"col_over_back"); - if (ptr) _OverColorBack = convertColor(ptr); - - ptr = (char*) xmlGetProp (cur, (xmlChar*)"fontsize"); - if (ptr) fromString((const char*)ptr, _FontSize); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"select_ancestor_on_close"); - if (ptr) _SelectAncestorOnClose = convertBool(ptr); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"navigate_one_branch"); - if (ptr) _NavigateOneBranch = convertBool(ptr); - - // read optional arbo bmps - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_open_first"); - if (ptr) _ArboOpenFirst= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_close_just_one"); - if (ptr) _ArboCloseJustOne= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son_without_son"); - if (ptr) _ArboSonWithoutSon= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son_last"); - if (ptr) _ArboSonLast= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_son"); - if (ptr) _ArboSon= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_level"); - if (ptr) _ArboLevel= (const char*)ptr; - ptr = (char*) xmlGetProp (cur, (xmlChar*)"arbo_x_extend"); - if (ptr) _ArboXExtend= (const char*)ptr; - - // Rectangle selection style - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_outline"); - if (ptr) _RectangleOutlineMode= convertBool(ptr); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_x"); - if (ptr) fromString((const char*)ptr, _RectangleX); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_y"); - if (ptr) fromString((const char*)ptr, _RectangleY); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_w"); - if (ptr) fromString((const char*)ptr, _RectangleW); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_h"); - if (ptr) fromString((const char*)ptr, _RectangleH); - ptr = (char*) xmlGetProp (cur, (xmlChar*)"rectangle_drl"); - if (ptr) fromString((const char*)ptr, _RectangleDeltaRL); - - - - _RootNode = new SNode; -// bool ok = true; - cur = cur->children; - while (cur) - { - // Check that this is a camera node - if ( stricmp((char*)cur->name, "node") == 0 ) - { - SNode *pNode = new SNode; - if (!pNode->parse(cur, this)) - { - delete pNode; - nlwarning("cannot parse node"); - } - else - { - _RootNode->addChild(pNode); - } - } - cur = cur->next; - } - _RootNode->Opened = true; - _ResizeFromChildW = _ResizeFromChildH = true; - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 id = rVR.getTextureIdFromName(_ArboOpenFirst); - if (id != -1) - rVR.getTextureSizeFromId(id, _BmpW, _BmpH); - sint32 dummy; - id = rVR.getTextureIdFromName(_ArboXExtend); - if (id != -1) - rVR.getTextureSizeFromId(id, _XExtend, dummy); - else - // if not found, reset, to avoid errors - _ArboXExtend= ""; - - - return true; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupTree::getHrcIconXStart(sint32 depth) -{ - return depth*(_BmpW+_XExtend); -} - -// ---------------------------------------------------------------------------- -sint32 CGroupTree::getHrcIconXEnd(sint32 depth) -{ - return depth*(_BmpW+_XExtend) + _BmpW; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::checkCoords() -{ - CInterfaceGroup::checkCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::updateCoords() -{ - if (_MustRebuild) - rebuild(); - CInterfaceGroup::updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::drawSelection(sint x, sint y, sint w, CRGBA col) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if(!_RectangleOutlineMode) - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_OffsetX+x, _YReal+_OffsetY+y, - w, _BmpH, 0, false, rVR.getBlankTextureId(), - col ); - } - else - { - // draw the outline - x+= _XReal+_OffsetX+_RectangleX; - y+= _YReal+_OffsetY+_RectangleY; - w= _RectangleW; - sint32 h= _RectangleH; - sint32 rl= _RenderLayer + _RectangleDeltaRL; - - rVR.drawRotFlipBitmap (rl, x, y, 1, h, 0, false, rVR.getBlankTextureId(), col ); - rVR.drawRotFlipBitmap (rl, x+w-1, y, 1, h, 0, false, rVR.getBlankTextureId(), col ); - rVR.drawRotFlipBitmap (rl, x, y, w, 1, 0, false, rVR.getBlankTextureId(), col ); - rVR.drawRotFlipBitmap (rl, x, y+h-1, w, 1, 0, false, rVR.getBlankTextureId(), col ); - } -} - -// ---------------------------------------------------------------------------- -CGroupTree::SNode *CGroupTree::getNodeUnderMouse() const -{ - if (_OverLine == -1) return NULL; - return _Lines[_OverLine].Node; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::draw() -{ - // get the clip area - sint32 clipx, clipy, clipw, cliph; - getClip(clipx, clipy, clipw, cliph); - - // change the over - bool bDisplayOver = true; - - if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - bDisplayOver = false; - } - else - if (CWidgetManager::getInstance()->getModalWindow() == NULL) - { - sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); - CInterfaceGroup *pParent = this; - bool bFound = false; - while (pParent != NULL) - { - if (pParent == pIG) - { - bFound = true; - break; - } - pParent = pParent->getParent(); - } - - // if the mouse is not in the clipped area - if ((x < clipx) || - (x > (clipx + clipw)) || - (y < clipy) || - (y > (clipy + cliph)) || !bFound) - { - _OverLine = -1; - } - else - { - x = x - _OffsetX; - y = y - _OffsetY; - for (sint32 i = 0; i < (sint32)_Lines.size(); ++i) - { - if ((y >= (_YReal+(sint32)(_Lines.size()-i-1)*_BmpH)) && - (y < (_YReal+(sint32)(_Lines.size()-i)*_BmpH))) - { - _OverLine = i; - } - } - if (_OverLine != -1) - { - if (x < _XReal + getHrcIconXEnd(_Lines[_OverLine].Depth)) - bDisplayOver = false; - } - } - } - - // some over to display? - if ((_OverLine != -1) && bDisplayOver) - { - // Find the first container - CInterfaceGroup *pIG = _Parent; - CGroupContainerBase *pGC = dynamic_cast(pIG); - while (pIG != NULL) - { - pIG = pIG->getParent(); - if (pIG == NULL) break; - if (dynamic_cast(pIG) != NULL) - pGC = dynamic_cast(pIG); - } - - // avoid if window grayed - if (pGC != NULL) - { - if (pGC->isGrayed()) - bDisplayOver = false; - } - - // Has to display the over? - if (bDisplayOver) - { - // !NULL if the text over must displayed across all windows - CViewText *viewTextExtend= NULL; - - // If the line is a simple Text line (not template) - if(_Lines[_OverLine].Node && _Lines[_OverLine].Node->DisplayText) - { - // Get the view text - viewTextExtend= safe_cast(_Lines[_OverLine].TextOrTemplate); - // If this viewText is not too big, no need - if(viewTextExtend->getXReal() + viewTextExtend->getWReal() <= (clipx+clipw) ) - viewTextExtend= NULL; - } - - // draw simple over - if(!viewTextExtend) - { - CRGBA col = _OverColor; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - drawSelection( getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_OverLine-1)*_BmpH, - _WReal-getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()), col); - } - // Draw extended over - else - { - CRGBA col = _OverColorBack; - // must add the selection color - if(_SelectedLine == _OverLine) - { - // simulate alpha blend of the selection bitmap - CRGBA sel= _SelectedColor; - sel.A= (uint8)((sel.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - col.blendFromuiRGBOnly(col, sel, sel.A); - } - - // will be drawn over all the interface - CWidgetManager::getInstance()->setOverExtendViewText(viewTextExtend, col); - } - } - } - - // some selection to display - if (_SelectedLine != -1) - { - CRGBA col = _SelectedColor; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_SelectedColor, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _SelectedColor; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - - drawSelection( getHrcIconXEnd(_Lines[_SelectedLine].Depth + _Lines[_SelectedLine].getNumAdditionnalBitmap()), ((sint)_Lines.size()-_SelectedLine-1)*_BmpH, - _WReal-getHrcIconXEnd(_Lines[_SelectedLine].Depth + _Lines[_SelectedLine].getNumAdditionnalBitmap()), col ); - } - - CInterfaceGroup::draw(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::selectLine(uint line, bool runAH /*= true*/) -{ - if(line>=_Lines.size()) - return; - - if (!_Lines[line].Node) - { - // just deleted : must wait next draw to know the new line under mouse - return; - } - if (!_Lines[line].Node->AHName.empty() && runAH) - { - _CancelNextSelectLine = false; - /* - CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, - this, - _Lines[line].Node->AHParams ); - */ - if (!_CancelNextSelectLine) - { - _SelectedLine = line; - _SelectedNode = _Lines[line].Node; - } - CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHName, - this, - _Lines[line].Node->AHParams ); - _CancelNextSelectLine = false; - } -} - -// ---------------------------------------------------------------------------- -bool CGroupTree::rightButton(uint line) -{ - if(line>=_Lines.size()) - return false; - - if (!_Lines[_OverLine].Node || _Lines[_OverLine].Node->AHNameRight.empty()) - return false; - - if (line != (uint) _SelectedLine) selectLine(line, false); - - CAHManager::getInstance()->runActionHandler ( _Lines[line].Node->AHNameRight, - this, - _Lines[line].Node->AHParamsRight ); - return true; -} - - - -// ---------------------------------------------------------------------------- -const std::string &CGroupTree::getSelectedNodeId() const -{ - if(_SelectedLine>=0 && _SelectedLine<(sint)_Lines.size() && _Lines[_SelectedLine].Node) - { - return _Lines[_SelectedLine].Node->Id; - } - else - { - static string empty; - return empty; - } -} - -// ---------------------------------------------------------------------------- -bool CGroupTree::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active) return false; - if (CInterfaceGroup::handleEvent(event)) return true; - // The line must be over (pre-selected) - if (event.getType() == NLGUI::CEventDescriptor::mouse && _OverLine>=0) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - if (!isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - sint32 x = eventDesc.getX() - _OffsetX; -// sint32 y = eventDesc.getY() - _OffsetY; - bool bText = false; - if (x >= (_XReal+getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap()))) - bText = true; - bool bIcon = false; - if ((x > (_XReal+getHrcIconXStart(_Lines[_OverLine].Depth)-_XExtend)) && - (x < (_XReal+getHrcIconXEnd(_Lines[_OverLine].Depth + _Lines[_OverLine].getNumAdditionnalBitmap())))) - bIcon = true; - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) - { - if (bText) - { - return rightButton(_OverLine != -1 ? _OverLine : _SelectedLine); - } - } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - // line selection - if (bText) - { - selectLine(_OverLine); - } - // close of node - if (bIcon) - { - SNode *changedNode= _Lines[_OverLine].Node; - - if (changedNode) - { - // if "SelectAncestorOnClose" feature wanted, if it was opened before, and if some node selected - if(_SelectAncestorOnClose && changedNode->Opened && _SelectedNode) - { - // check that the selected node is a son of the closing node - SNode *parent= _SelectedNode->Father; - while(parent) - { - if(parent==changedNode) - { - // Then change selection to this parent first - selectLine(_OverLine); - break; - } - parent= parent->Father; - } - } - - // standard hrc - if(!_NavigateOneBranch) - { - // open/close the node - changedNode->Opened = !changedNode->Opened; - } - // else must close all necessary nodes. - else - { - if(changedNode->Opened) - changedNode->closeAll(); - else - { - // must closeAll all his brothers first. - if(changedNode->Father) - { - changedNode->Father->closeAll(); - changedNode->Father->Opened= true; - } - changedNode->Opened= true; - } - } - - CAHManager::getInstance()->runActionHandler(changedNode->AHNameClose, this, changedNode->AHParamsClose); - } - forceRebuild(); - } - return true; - } - } - return false; -} - - -// ---------------------------------------------------------------------------- -void CGroupTree::unselect() -{ - _SelectedLine = -1; - _SelectedNode = NULL; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::reset() -{ - unselect(); - if (_RootNode) - { - _RootNode->closeAll(); - _RootNode->Opened = true; - } - forceRebuild(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::forceRebuild() -{ - _MustRebuild = true; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::rebuild() -{ - // Remove all - removeAll(); - - if (_RootNode) - _RootNode->Opened = true; - - // Rebuild all depending on the logic - if(_RootNode) - addTextLine (0, _RootNode); - - // Reformating - sint32 sizeH = (sint32)_Lines.size()*_BmpH; - for (uint i = 0; i < _Lines.size(); ++i) - _Lines[i].TextOrTemplate->setY (_Lines[i].Node->YDecal + sizeH - ((1+_Lines[i].TextOrTemplate->getY())*_BmpH)); - // Add the hierarchy bitmaps - addHierarchyBitmaps(); - // Find if we can display selection - if (_SelectedNode != NULL) - { - _SelectedLine = -1; - for (uint i = 0; i < _Lines.size(); ++i) - if (_Lines[i].Node == _SelectedNode) - { - _SelectedLine = i; - break; - } - } - - // Ok no more need to rebuild all this - _MustRebuild = false; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::setRootNode (SNode *pNewRoot) -{ - // reset selection - _SelectedLine= -1; - _SelectedNode= NULL; - - CRefPtr refPtrNewRoot = pNewRoot; - // clear old - delete _RootNode; - - // If the node was deleted - if (pNewRoot && !refPtrNewRoot) - { - // NB nico : if anyone need that a day, please feel free to modify ... - nlwarning("Trying to set a node that is part of the tree as root node (not supported yet ...)"); - } - - // set new (may be NULL) - _RootNode = pNewRoot; - if(pNewRoot) - pNewRoot->setParentTree(this); - rebuild(); -} - -// ---------------------------------------------------------------------------- -void CGroupTree::removeAll() -{ - // Remove (but not delete) the groups template if any - for(uint i=0;i<_Lines.size();i++) - { - if (_Lines[i].Node) - { - if(_Lines[i].Node->Template) - { - delGroup(_Lines[i].Node->Template, true); - } - } - } - - // Clear all lines, but don't delete templates - _Lines.clear(); - - // Delete all BmpViews and/or all text views - clearViews(); -} - - - -// ---------------------------------------------------------------------------- -void CGroupTree::addTextLine (uint8 nDepth, CGroupTree::SNode *pNode) -{ - pNode->setParentTree(this); - if (nDepth > 0) - { - SLine line; - line.Depth = nDepth-1; - line.Node = pNode; - if (pNode->DisplayText) - { - CViewText *pVT = new CViewText(TCtorParam()); - line.TextOrTemplate = pVT; - pVT->setId("t"+toString(_Lines.size())); - pVT->setText(pNode->Text); - pVT->setColor(pNode->Color); - if(pNode->FontSize==-1) - pVT->setFontSize(_FontSize); - else - pVT->setFontSize(pNode->FontSize); - } - else - { - line.TextOrTemplate = pNode->Template; - } - line.TextOrTemplate->setPosRef (Hotspot_BL); - line.TextOrTemplate->setParentPosRef (Hotspot_BL); - line.TextOrTemplate->setParent (this); - line.TextOrTemplate->setParentPos (NULL); - line.TextOrTemplate->setX (getHrcIconXEnd(nDepth-1 + line.getNumAdditionnalBitmap())); - line.TextOrTemplate->setY ((sint32)_Lines.size()); - line.TextOrTemplate->setModulateGlobalColor(this->getModulateGlobalColor()); - if (pNode->DisplayText) - addView (line.TextOrTemplate); - else - addGroup ((CInterfaceGroup*)line.TextOrTemplate); - if (pNode->NodeAddedCallback) - { - pNode->NodeAddedCallback->nodeAdded(pNode, line.TextOrTemplate); - } - _Lines.push_back(line); - } - - // recurs - if (pNode->Opened) - { - // **** standard hierarchy display, or if root - if(!_NavigateOneBranch || nDepth==0) - { - for (uint i = 0; i < pNode->Children.size(); ++i) - { - // add the branch only if want to show it - if(pNode->Children[i]->Show) - addTextLine (nDepth+1, pNode->Children[i]); - } - } - // **** display only the branch navigated - else - { - // find the first child opened - sint childOpen= -1; - for (uint i = 0; i < pNode->Children.size(); ++i) - { - // don't take hid ones - if(pNode->Children[i]->Show && pNode->Children[i]->Opened) - { - childOpen= i; - break; - } - } - - // If some chidl opened, add just this line - if(childOpen>=0) - { - addTextLine (nDepth+1, pNode->Children[childOpen]); - } - // else add all closed, but showable lines - else - { - for (uint i = 0; i < pNode->Children.size(); ++i) - { - if(pNode->Children[i]->Show) - addTextLine (nDepth+1, pNode->Children[i]); - } - } - } - } -} - -// ---------------------------------------------------------------------------- -CViewBitmap *CGroupTree::createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture) -{ - CViewBitmap *pVB = new CViewBitmap(TCtorParam()); - pVB->setId(idPrefix+toString(_Lines.size())+"_"+toString(_Lines[line].Bmps.size())); - pVB->setParent (this); - pVB->setParentPos (NULL); - pVB->setModulateGlobalColor(this->getModulateGlobalColor()); - pVB->setTexture(texture); - return pVB; -} - -// ---------------------------------------------------------------------------- -void CGroupTree::addHierarchyBitmaps () -{ - if (_RootNode) _RootNode->updateLastVisibleSon(); - for (uint nLayer = 0; nLayer < 256; nLayer++) - { - sint32 nCurRootLine = -1; - bool bCurRootLineLast = false; - bool bCurRootLineLastChild = false; - for (uint nLine = 0; nLine < _Lines.size(); nLine++) - if (nLayer <= _Lines[nLine].Depth) - { - // A Bitmap must be created - CViewBitmap *pVB = createViewBitmap(nLine, "t", "blank.tga"); - pVB->setX (getHrcIconXStart(nLayer)); - pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); - - bool bAddBitmap = true; - bool bAddXExtendBitmap = false; - // Choose a bitmap - // Are we on the last depth in the line ? - if (_Lines[nLine].Depth == nLayer) - { - nCurRootLine = nLine; - if (_Lines[nLine].Node == _Lines[nCurRootLine].Node->Father->LastVisibleSon) - bCurRootLineLast = true; - else - bCurRootLineLast = false; - bCurRootLineLastChild = false; - - // do i have some child shown? - bool haveSomeVisibleChild= false; - for(uint k=0;k<_Lines[nLine].Node->Children.size();k++) - { - if(_Lines[nLine].Node->Children[k]->Show) - { - haveSomeVisibleChild= true; - break; - } - } - - // if so - if (haveSomeVisibleChild) - { - // Yes am I opened ? - if (_Lines[nLine].Node->Opened) - { - pVB->setTexture(_ArboOpenFirst); - } - else - { - // No I am closed - pVB->setTexture(_ArboCloseJustOne); - } - } - else - { - /* - // No child - // If there's a bitmap on this line , left an empty bitmap - if (!_Lines[nLine].Node->Bitmap.empty()) - { - pVB->setTexture("blank.tga"); // create a transparent bitmap to have correct "child_resize_w" - pVB->setColor(CRGBA(0, 0, 0, 0)); - } - else - { - pVB->setTexture(_ArboSonWithoutSon); - } - */ - pVB->setTexture(_ArboSonWithoutSon); - } - - // if not the root line, must add Extend Bitmap - if(nLayer) - bAddXExtendBitmap= true; - } - else - { - // No we are before the last depth, Do we have any current root ? - if (nCurRootLine != -1) - { - // Yes, do the current line is child of current root line ? - bool bFound = false; - for (uint i = 0; i < _Lines[nCurRootLine].Node->Children.size(); ++i) - if (_Lines[nLine].Node == _Lines[nCurRootLine].Node->Children[i]) - { - bFound = true; - break; - } - if (bFound) - { - // is it the last child ? - bool lastSonDisplay= _Lines[nLine].Node == _Lines[nCurRootLine].Node->LastVisibleSon; - - - // Special for _NavigateOneBranch mode - if(_NavigateOneBranch) - { - // if node opened, then his brother are hid! => he behaves like a "last son" - if(_Lines[nLine].Node->Opened) - lastSonDisplay= true; - } - - // if must display like last child - if (lastSonDisplay) - { - // Yes this is the last child - pVB->setTexture(_ArboSonLast); - bCurRootLineLastChild = true; - } - else - { - // No so we have brothers - pVB->setTexture(_ArboSon); - } - } - else - { - // Not found, display a line - pVB->setTexture(_ArboLevel); - - // We have to not display a line if we have passed the last child of this root - // We never have to display a line also if we are in _NavigateOneBranch mode - if (bCurRootLineLastChild || _NavigateOneBranch) - bAddBitmap = false; - } - } - } - - // Add the bitmap - if (bAddBitmap) - { - addView (pVB); - _Lines[nLine].Bmps.push_back(pVB); - - // if must add the special extend bitmap, and if exist - if(bAddXExtendBitmap && !_ArboXExtend.empty()) - { - CViewBitmap *pVB = createViewBitmap(nLine, "ext_t", _ArboXExtend); - pVB->setX (getHrcIconXStart(nLayer) - _XExtend); - pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); - addView (pVB); - _Lines[nLine].Bmps.push_back(pVB); - } - } - else - { - delete pVB; - } - } - } - // add additionnal bitmap for each line - for (uint nLine = 0; nLine < _Lines.size(); nLine++) - { - if (!_Lines[nLine].Node->Bitmap.empty()) - { - CViewBitmap *pVB = createViewBitmap(nLine, "custom_bm", _Lines[nLine].Node->Bitmap); - pVB->setX (getHrcIconXStart(_Lines[nLine].Depth + 1)); - pVB->setY ((sint32)_Lines.size()*_BmpH - ((1+nLine)*_BmpH)); - _Lines[nLine].Bmps.push_back(pVB); - addView (pVB); - } - } -} - -// *************************************************************************** -CGroupTree::SNode *CGroupTree::selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId) -{ - // select this node? - if(pNode!=_RootNode) - { - if(pNode->Id == nodeId) - return pNode; - } - - // try with sons - for(uint i=0;iChildren.size();i++) - { - SNode *ret= selectNodeByIdRecurse(pNode->Children[i], nodeId); - if(ret) - return ret; - } - - // not found => NULL - return NULL; -} - -// *************************************************************************** -bool CGroupTree::selectNodeById(const std::string &nodeId, bool triggerAH) -{ - SNode *selNode= NULL; - - // Avoid infinite recurs - if(_AvoidSelectNodeByIdIR) - return true; - - // first find in the hierarchy - selNode= selectNodeByIdRecurse(_RootNode, nodeId); - - // if found - if(selNode) - { - // Opens the hierarchy - SNode *pFather = selNode->Father; - while(pFather != NULL) - { - pFather->Opened = true; - pFather = pFather->Father; - } - - if (triggerAH) - { - // runAH may infinite recurs (HTML browse...) - _AvoidSelectNodeByIdIR= true; - - // launch the action handler - CAHManager::getInstance()->runActionHandler ( selNode->AHName, - this, - selNode->AHParams ); - } - - // runAH may infinite recurs (HTML browse...) - _AvoidSelectNodeByIdIR= false; - - // mark as selected - _SelectedNode = selNode; - - forceRebuild(); - - return true; - } - else - { - return false; - } -} - -// *************************************************************************** -class CHandlerTreeReset : public IActionHandler -{ -public: - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) - { - CGroupTree *pTree = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sParams)); - if (pTree != NULL) - pTree->reset(); - } -protected: -}; -REGISTER_ACTION_HANDLER( CHandlerTreeReset, "tree_reset"); - -// *************************************************************************** -void CGroupTree::changeNavigateOneBranch(bool newState) -{ - if(newState!=_NavigateOneBranch) - { - _NavigateOneBranch= newState; - // if new is true, then must reset both open state and selection - if(_NavigateOneBranch) - { - reset(); - // reselect the first line - selectLine(0); - } - // else just rebuild - else - { - forceRebuild(); - } - } -} - -// *************************************************************************** -void CGroupTree::cancelNextSelectLine() -{ - _CancelNextSelectLine = true; -} - -// *************************************************************************** -int CGroupTree::luaGetRootNode(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getRootNode", 0); - CLuaIHM::pushReflectableOnStack(ls, getRootNode()); - return 1; -} - -// *************************************************************************** -int CGroupTree::luaSetRootNode(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "setRootNode", 1); - if (ls.isNil()) - { - setRootNode(NULL); - return 0; - } - setRootNode(SNode::luaGetNodeOnStack(ls, "CGroupTree::setRootNode")); - return 0; -} - - -// *************************************************************************** -int CGroupTree::luaForceRebuild(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "forceRebuild", 0); - forceRebuild(); - return 0; -} - -// *************************************************************************** -CGroupTree::SNode *CGroupTree::SNode::luaGetNodeOnStack(CLuaState &ls, const char * /* funcName */) -{ - SNode *node = dynamic_cast(CLuaIHM::getReflectableOnStack(ls, 1)); - CLuaIHM::check(ls, node != NULL, "SNode expected"); - return node; -} - -// *************************************************************************** -int CGroupTree::SNode::luaDetachChild(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaDetachChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - detachChild(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaSort(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaSort"; - CLuaIHM::checkArgCount(ls, funcName, 0); - sort(); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaSortByBitmap(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaSort"; - CLuaIHM::checkArgCount(ls, funcName, 0); - sortByBitmap(); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaDeleteChild(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaDeleteChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - deleteChild(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaAddChild(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaAddChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - addChild(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaAddChildSorted(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaAddChildSorted"; - CLuaIHM::checkArgCount(ls, funcName, 1); - addChildSorted(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaAddChildSortedByBitmap(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaAddChildSortedByBitmap"; - CLuaIHM::checkArgCount(ls, funcName, 1); - addChildSorted(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaGetNodeFromId(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaGetNodeFromId"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - SNode *result = getNodeFromId(ls.toString(1)); - if (result) - { - CLuaIHM::pushReflectableOnStack(ls, result); - } - else - { - ls.pushNil(); - } - return 1; -} - -// *************************************************************************** -int CGroupTree::SNode::luaGetParentTree(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getParentTree", 0); - if (ParentTree) - { - CLuaIHM::pushUIOnStack(ls, ParentTree); - } - else - { - ls.pushNil(); - } - return 1; -} - -// *************************************************************************** -int CGroupTree::luaGetNodeUnderMouse(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getNodeUnderMouse", 0); - SNode *node = getNodeUnderMouse(); - if (node) - { - CLuaIHM::pushReflectableOnStack(ls, node); - } - else - { - ls.pushNil(); - } - return 1; -} - -// *************************************************************************** -int CGroupTree::luaCancelNextSelectLine(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "cancelNextSelectLine", 0); - cancelNextSelectLine(); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaAddChildFront(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaAddChildFront"; - CLuaIHM::checkArgCount(ls, funcName, 1); - addChild(luaGetNodeOnStack(ls, funcName)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaIsChild(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaIsChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - ls.push(isChild(luaGetNodeOnStack(ls, funcName))); - return 1; -} - -// *************************************************************************** -int CGroupTree::SNode::luaAddChildAtIndex(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaAddChildAtIndex"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - addChildAtIndex(luaGetNodeOnStack(ls, funcName), (sint) ls.toNumber(2)); - return 0; -} - -// *************************************************************************** -int CGroupTree::SNode::luaGetFather(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaGetFather"; - CLuaIHM::checkArgCount(ls, funcName, 0); - if(Father) - CLuaIHM::pushReflectableOnStack(ls, Father); - else - ls.pushNil(); - return 1; -} - -// *************************************************************************** -int CGroupTree::SNode::luaGetNumChildren(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaGetNumChildren"; - CLuaIHM::checkArgCount(ls, funcName, 0); - ls.push((double) Children.size()); - return 1; -} - -// *************************************************************************** -int CGroupTree::SNode::luaGetChild(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaGetChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - // - sint index = (sint) ls.toNumber(1); - if (index < 0 || index >= (sint) Children.size()) - { - std::string range = Children.empty() ? "" : toString("[0, %d]", Children.size() - 1); - CLuaIHM::fails(ls, "Bad index of tree node child : %d, range is %s", (int) index, range.c_str()); - } - CLuaIHM::pushReflectableOnStack(ls, Children[index]); - return 1; -} - -// *************************************************************************** -int CGroupTree::SNode::luaCloseAll(CLuaState &ls) -{ - const char *funcName = "CGroupTree::SNode::luaGetFather"; - CLuaIHM::checkArgCount(ls, funcName, 0); - closeAll(); - return 0; -} - -// *************************************************************************** -int CGroupTree::luaSelectNodeById(CLuaState &ls) -{ - const char *funcName = "selectNodeById"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN); - selectNodeById(ls.toString(1), ls.toBoolean(2)); - return 0; -} - -// *************************************************************************** -int CGroupTree::luaGetSelectedNodeId(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getSelectedNodeId", 0); - ls.push(getSelectedNodeId()); - return 1; -} - -// *************************************************************************** -int CGroupTree::luaSelectLine(CLuaState &ls) -{ - CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 1, LUA_TNUMBER); - CLuaIHM::checkArgType(ls, "CGroupTree::selectLine", 2, LUA_TBOOLEAN); - selectLine((uint) ls.toNumber(1), ls.toBoolean(2)); - return 0; -} - -// *************************************************************************** -int CGroupTree::luaUnselect(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "unselect", 0); - unselect(); - return 0; -} - - -// *************************************************************************** -uint CGroupTree::SLine::getNumAdditionnalBitmap() const -{ - if (!Node) return 0; - return Node->getNumBitmap(); -} - - - - diff --git a/code/ryzom/client/src/interface_v3/group_tree.h b/code/ryzom/client/src/interface_v3/group_tree.h deleted file mode 100644 index fcc321a2b..000000000 --- a/code/ryzom/client/src/interface_v3/group_tree.h +++ /dev/null @@ -1,375 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_GROUP_TREE_H -#define NL_GROUP_TREE_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/group_frame.h" -#include "nel/misc/smart_ptr.h" - -namespace NLGUI -{ - class CViewText; - class CViewBitmap; -} - -// ---------------------------------------------------------------------------- -class CGroupTree : public CInterfaceGroup -{ - -public: - - struct SNode; - // optional callback that is called when a node has been added - struct INodeAddedCallback - { - /** A node has just been added in the CGroupTree object - * \param node The logic node from which the ui node was built - * \param interfaceElement The ui node that was built - */ - virtual void nodeAdded(SNode *node, CInterfaceElement *interfaceElement) = 0; - }; - - // Logic structure to initialize the group tree (root node is not displayed and is always opened) - struct SNode : public CReflectableRefPtrTarget - { - typedef NLMISC::CRefPtr TRefPtr; - // Common - std::string Id; // If not present auto-generated - bool Opened; - bool DisplayText; // If false instanciate a template - bool Show; // If false, the node is not displayed (true default, Root ignored) - sint32 YDecal; - // Text - ucstring Text; // Internationalized displayed text - sint32 FontSize; // If -1 (default), then take the groupTree one - NLMISC::CRGBA Color; - // Template - NLMISC::CSmartPtr Template; - // Actions Handlers (for left button) - std::string AHName; - std::string AHCond; - std::string AHParams; - // Actions Handlers (for right button) - std::string AHNameRight; - std::string AHParamsRight; - // Actions Handlers (close/open node) - std::string AHNameClose; - std::string AHParamsClose; - // bitmap at this level of hierarchy - std::string Bitmap; // additionnal bitmap - // Hierarchy - std::vector Children; - SNode *Father; - // updated at display - SNode *LastVisibleSon; // filled at build time, meaningfull only if son is shown and opened, undefined otherwise - // Node added callback - INodeAddedCallback *NodeAddedCallback; - // - CGroupTree *ParentTree; - // ---------------------------- - SNode(); - ~SNode(); - void updateLastVisibleSon(); - void detachChild(SNode *pNode); - void deleteChild(SNode *pNode); - void addChild (SNode *pNode); - bool isChild(SNode *pNode) const; - void addChildFront (SNode *pNode); - void addChildAtIndex (SNode *pNode, sint index); - void addChildSorted(SNode *pNode); - void addChildSortedByBitmap(SNode *pNode); - void setParentTree(CGroupTree *parent); - void setFather(SNode *father); - void closeAll(); - void makeOrphan(); - bool parse (xmlNodePtr cur, CGroupTree *parentGroup); - uint getNumBitmap() const { return Bitmap.empty() ? 0 : 1; } - SNode *getNodeFromId(const std::string &id); - - // accessors - void setBitmap(const std::string &bitmap) { Bitmap = bitmap; } - std::string getBitmap() const { return Bitmap; } - void setOpened(bool opened) { Opened = opened; } - bool getOpened() const { return Opened; } - void setText(const ucstring &text) { Text = text; } - const ucstring& getText() const { return Text; } - sint32 getFontSize() const { return FontSize; } - void setFontSize(sint32 value) { FontSize = value; } - sint32 getYDecal() const { return YDecal; } - void setYDecal(sint32 value) { YDecal = value; } - - - std::string getId() const { return Id; } - void setId(const std::string &value) { Id = value; } - bool getShow() const { return Show; } - void setShow(bool value) { Show = value; } - std::string getAHName() const { return AHName; } - void setAHName(const std::string &value) { AHName = value; } - std::string getAHCond() const { return AHCond; } - void setAHCond(const std::string &value) { AHCond = value; } - std::string getAHParams() const { return AHParams; } - void setAHParams(const std::string &value) { AHParams = value; } - std::string getAHNameRight() const { return AHNameRight; } - void setAHNameRight(const std::string &value) { AHNameRight = value; } - std::string getAHParamsRight() const { return AHParamsRight; } - void setAHParamsRight(const std::string &value) { AHParamsRight = value; } - std::string getAHNameClose() const { return AHNameClose; } - void setAHNameClose(const std::string &value) { AHNameClose = value; } - std::string getAHParamsClose() const { return AHParamsClose; } - void setAHParamsClose(const std::string &value) { AHParamsClose = value; } - NLMISC::CRGBA getColor() const { return Color; } - void setColor(NLMISC::CRGBA color) { Color = color; } - // sort branch & sons alphabetically - void sort(); - // sort branch & sons alphabetically & by bitmap name (blank bitmap being the first) - void sortByBitmap(); - - // lua bindings - int luaGetNumChildren(CLuaState &ls); - int luaGetChild(CLuaState &ls); - int luaDetachChild(CLuaState &ls); - int luaDeleteChild(CLuaState &ls); - int luaAddChild(CLuaState &ls); - int luaAddChildSorted(CLuaState &ls); - int luaAddChildSortedByBitmap(CLuaState &ls); - int luaIsChild(CLuaState &ls); - int luaAddChildFront (CLuaState &ls); - int luaAddChildAtIndex (CLuaState &ls); - int luaCloseAll(CLuaState &ls); - int luaGetFather(CLuaState &ls); - int luaSort(CLuaState &ls); - int luaSortByBitmap(CLuaState &ls); - int luaGetNodeFromId(CLuaState &ls); - int luaGetParentTree(CLuaState &ls); - - // get node from first parameter on lua stack and throw necessary exception if not present - static SNode *luaGetNodeOnStack(CLuaState &ls, const char *funcName); - - REFLECT_EXPORT_START(CGroupTree::SNode, CReflectable) - REFLECT_STRING("Id", getId, setId); - REFLECT_STRING("Bitmap", getBitmap, setBitmap); - REFLECT_SINT32("FontSize", getFontSize, setFontSize); - REFLECT_SINT32("YDecal", getYDecal, setYDecal); - REFLECT_STRING("AHName", getAHName, setAHName); - REFLECT_STRING("AHCond", getAHCond, setAHCond); - REFLECT_RGBA("Color", getColor, setColor); - REFLECT_STRING("AHParams", getAHParams, setAHParams); - REFLECT_STRING("AHNameRight", getAHNameRight, setAHNameRight); - REFLECT_STRING("AHParamsRight", getAHParamsRight, setAHParamsRight); - REFLECT_STRING("AHNameClose", getAHNameClose, setAHNameClose); - REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose); - REFLECT_BOOL("Opened", getOpened, setOpened); - REFLECT_BOOL("Show", getShow, setShow); - REFLECT_UCSTRING("Text", getText, setText); - // lua - REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren); - REFLECT_LUA_METHOD("getChild", luaGetChild); - REFLECT_LUA_METHOD("detachChild", luaDetachChild); - REFLECT_LUA_METHOD("deleteChild", luaDeleteChild); - REFLECT_LUA_METHOD("addChild", luaAddChild); - REFLECT_LUA_METHOD("addChildSorted", luaAddChildSorted); - REFLECT_LUA_METHOD("addChildSortedByBitmap", luaAddChildSortedByBitmap); - REFLECT_LUA_METHOD("addChildFront", luaAddChildFront); - REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex); - REFLECT_LUA_METHOD("isChild", luaIsChild); - REFLECT_LUA_METHOD("closeAll", luaCloseAll); - REFLECT_LUA_METHOD("getFather", luaGetFather); - REFLECT_LUA_METHOD("sort", luaSort); - REFLECT_LUA_METHOD("sortByBitmap", luaSortByBitmap); - REFLECT_LUA_METHOD("getNodeFromId", luaGetNodeFromId); - REFLECT_LUA_METHOD("getParentTree", luaGetParentTree); - REFLECT_EXPORT_END - - - }; - -public: - - ///constructor - CGroupTree(const TCtorParam ¶m); - - // dtor - virtual ~CGroupTree(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - - virtual void checkCoords(); - - virtual void updateCoords(); - - virtual void draw(); - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - - void reset(); - - // force rebuild the tree at next updateCoords() - void forceRebuild(); - - // For SNode - sint32 getIdNumber() { _IdGenerator++; return _IdGenerator; } - sint32 getFontSize() { return _FontSize; } - sint32 getYDecal() { return _YDecal; } - - // Set root node and delete the last one the user must not delete all allocated sub node. Nb: selection is reseted - void setRootNode (SNode *); - // Remove all lines bitmaps and templates or texts - void removeAll(); - - // unselect current node in tree - void unselect(); - - // Select a node by its line index (depends on opened nodes). no-op if not possible (AH not here, line>size) - void selectLine(uint line, bool runAH = true); - // simulate right button click on the given line (this also select the line) - bool rightButton(uint line); - - // Get the Selected Node Id. empty if none selected - const std::string &getSelectedNodeId() const; - - // Select by the node Id. return false if not found (selection is not reseted) - // NB: if the node was already selected, no-op (no action handler launched) - bool selectNodeById(const std::string &nodeId, bool triggerAH = true); - - // Get the root node (Opened State represent the current state) - SNode *getRootNode () const {return _RootNode;} - - // get current SNode under the mouse (possibly NULL) - SNode *getNodeUnderMouse() const; - - // Get/Change the NavigateOneBrnahc option. if false, then perform a reset before - bool getNavigateOneBranch() const {return _NavigateOneBranch;} - void changeNavigateOneBranch(bool newState); - - // should be called by action handler when thy want to cancel the selection of the line that triggered them - void cancelNextSelectLine(); - - // Get selected node - SNode * getSelectedNode() { return _SelectedNode;} - - // lua bindings - int luaGetRootNode(CLuaState &ls); - int luaSetRootNode(CLuaState &ls); - int luaForceRebuild(CLuaState &ls); - int luaSelectNodeById(CLuaState &ls); - int luaGetSelectedNodeId(CLuaState &ls); - int luaSelectLine(CLuaState &ls); - int luaUnselect(CLuaState &ls); - int luaGetNodeUnderMouse(CLuaState &ls); - int luaCancelNextSelectLine(CLuaState &ls); - - // Reflection - REFLECT_EXPORT_START(CGroupTree, CInterfaceGroup) - REFLECT_BOOL ("navigate_one_branch", getNavigateOneBranch, changeNavigateOneBranch); - REFLECT_LUA_METHOD("getRootNode", luaGetRootNode); - REFLECT_LUA_METHOD("setRootNode", luaSetRootNode); - REFLECT_LUA_METHOD("forceRebuild", luaForceRebuild); - REFLECT_LUA_METHOD("getSelectedNodeId", luaGetSelectedNodeId); - REFLECT_LUA_METHOD("selectNodeById", luaSelectNodeById); - REFLECT_LUA_METHOD("selectLine", luaSelectLine); - REFLECT_LUA_METHOD("unselect", luaUnselect); - REFLECT_LUA_METHOD("getNodeUnderMouse", luaGetNodeUnderMouse); - REFLECT_LUA_METHOD("cancelNextSelectLine", luaCancelNextSelectLine); - REFLECT_EXPORT_END - -private: - - sint32 _BmpW, _BmpH, _FontSize, _YDecal; - sint32 _XExtend; - -private: - - // Display structure - struct SLine - { - CViewBase *TextOrTemplate; - std::vector Bmps; - SNode::TRefPtr Node; - uint8 Depth; - - SLine() - { - TextOrTemplate = NULL; - } - - ~SLine() - { - Bmps.clear(); - } - uint getNumAdditionnalBitmap() const; - }; - -protected: - - void rebuild(); - void addTextLine (uint8 nDepth, SNode *pNode); - void addHierarchyBitmaps(); - - SNode *selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId); - - SNode *_RootNode; - sint32 _IdGenerator; - bool _MustRebuild; - std::vector _Lines; - sint32 _OverLine; - NLMISC::CRGBA _OverColor; - NLMISC::CRGBA _OverColorBack; - SNode *_SelectedNode; - sint32 _SelectedLine; - NLMISC::CRGBA _SelectedColor; - - // If a node is closed and a son of this node was selected, then this option force the ancestor being the new selection - bool _SelectAncestorOnClose; - bool _NavigateOneBranch; - bool _AvoidSelectNodeByIdIR; - - // when an action handler is run, it can call 'cancelSelectLine' if no selection should be done for real - bool _CancelNextSelectLine; - - - // Bitmap For arbo - std::string _ArboOpenFirst; - std::string _ArboCloseJustOne; - std::string _ArboSonWithoutSon; - std::string _ArboSonLast; - std::string _ArboSon; - std::string _ArboLevel; - std::string _ArboXExtend; - - // Special rectangle - bool _RectangleOutlineMode; - sint32 _RectangleX, _RectangleY; - sint32 _RectangleW, _RectangleH; - sint32 _RectangleDeltaRL; - - sint32 getHrcIconXStart(sint32 depth); - sint32 getHrcIconXEnd(sint32 depth); - - void drawSelection(sint x, sint y, sint w, NLMISC::CRGBA col); - - CViewBitmap *createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture); -}; - - -#endif // NL_GROUP_TREE_H - -/* End of group_tree.h */ - - diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 1203d66b4..35df296c3 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -66,7 +66,7 @@ #include "nel/gui/group_modal.h" #include "group_modal_get_key.h" #include "group_list.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "group_menu.h" #include "group_container.h" #include "group_scrolltext.h" diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 3f363258c..cf1a1c2a8 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -51,7 +51,7 @@ #include "nel/gui/interface_group.h" #include "nel/gui/view_text.h" #include "game_share/people_pd.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "nel/gui/interface_link.h" #include "nel/gui/interface_expr.h" #include "people_interraction.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index ca2681bdd..bdde30aa9 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -41,7 +41,7 @@ #include "dbgroup_list_sheet.h" #include "nel/gui/group_editbox_base.h" #include "group_editbox.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "nel/gui/reflect.h" #include "dbview_bar.h" #include "dbview_bar3.h" diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 7ce61fd08..29300c975 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -48,7 +48,7 @@ // #include "nel/gui/lua_helper.h" using namespace NLGUI; -#include "../interface_v3/group_tree.h" +#include "nel/gui/group_tree.h" #include "../interface_v3/interface_manager.h" #include "../contextual_cursor.h" #include "../cursor_functions.h" @@ -56,7 +56,7 @@ using namespace NLGUI; #include "../events_listener.h" #include "../interface_v3/group_list.h" #include "nel/gui/event_descriptor.h" -#include "../interface_v3/group_tree.h" +#include "nel/gui/group_tree.h" #include "../client_cfg.h" #include "nel/gui/lua_ihm.h" #include "../interface_v3/lua_ihm_ryzom.h" diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h index 6219715b2..69711091c 100644 --- a/code/ryzom/client/src/r2/editor.h +++ b/code/ryzom/client/src/r2/editor.h @@ -41,8 +41,11 @@ +namespace NLGUI +{ + class CGroupTree; +} -class CGroupTree; class CEntityCL; namespace NL3D diff --git a/code/ryzom/client/src/r2/palette_node.h b/code/ryzom/client/src/r2/palette_node.h index c4e41fb2e..60c4b143b 100644 --- a/code/ryzom/client/src/r2/palette_node.h +++ b/code/ryzom/client/src/r2/palette_node.h @@ -20,7 +20,7 @@ #if 0 //#include "interface_user_data.h" -#include "group_tree.h" +#include "nel/gui/group_tree.h" #include "nel/gui/lua_object.h" // #include "nel/misc/smart_ptr.h" diff --git a/code/ryzom/client/src/r2/tool_choose_pos.cpp b/code/ryzom/client/src/r2/tool_choose_pos.cpp index 966b54d5a..4d11d0423 100644 --- a/code/ryzom/client/src/r2/tool_choose_pos.cpp +++ b/code/ryzom/client/src/r2/tool_choose_pos.cpp @@ -20,7 +20,7 @@ #include "tool_choose_pos.h" #include "../interface_v3/interface_manager.h" #include "../global.h" -#include "../interface_v3/group_tree.h" +#include "nel/gui/group_tree.h" #include "../interface_v3/group_map.h" #include "../landscape_poly_drawer.h" // From 3bba3af4ab704e062fbe09579dd57a42515b8ace Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 05:44:01 +0200 Subject: [PATCH 091/339] CHANGED: #1471 CGroupList no longer depends on CGroupContainer. --- .../client/src/interface_v3/group_list.cpp | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp index 43b109ac1..3db145367 100644 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ b/code/ryzom/client/src/interface_v3/group_list.cpp @@ -14,27 +14,19 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "group_list.h" -#include "interface_manager.h" #include "nel/gui/interface_element.h" -#include "../client_chat_manager.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" -#include "group_container.h" +#include "nel/gui/group_container_base.h" #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" - #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" using namespace std; using namespace NLMISC; -extern CClientChatManager ChatMngr; - NLMISC_REGISTER_OBJECT(CViewBase, CGroupList, std::string, "list"); // ---------------------------------------------------------------------------- @@ -571,7 +563,6 @@ void CGroupList::draw () //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0, 255, 0, 255) ); if (_Over) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); if (CWidgetManager::getInstance()->getModalWindow() == NULL) @@ -622,13 +613,13 @@ void CGroupList::draw () { // Find the first container CInterfaceGroup *pIG = _Parent; - CGroupContainer *pGC = dynamic_cast(pIG); + CGroupContainerBase *pGC = dynamic_cast(pIG); while (pIG != NULL) { pIG = pIG->_Parent; if (pIG == NULL) break; - if (dynamic_cast(pIG) != NULL) - pGC = dynamic_cast(pIG); + if (dynamic_cast(pIG) != NULL) + pGC = dynamic_cast(pIG); } bool bDisplayOverSelection = true; From ab8b296adc72d7449f52f6c36458138bafe64207 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 06:48:19 +0200 Subject: [PATCH 092/339] CHANGED: #1471 CGroupList is now part of NELGUI library, and is under NLGUI namespace. --- code/nel/include/nel/gui/group_list.h | 262 ++++ code/nel/include/nel/gui/interface_element.h | 5 +- code/nel/src/gui/group_list.cpp | 1158 +++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 +- .../client/src/interface_v3/chat_displayer.h | 2 +- .../client/src/interface_v3/chat_window.h | 3 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_container.h | 2 +- .../client/src/interface_v3/group_header.h | 2 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_html.h | 2 +- .../client/src/interface_v3/group_list.cpp | 1152 ---------------- .../client/src/interface_v3/group_list.h | 258 ---- .../client/src/interface_v3/group_menu.h | 2 +- .../src/interface_v3/group_quick_help.cpp | 2 +- .../src/interface_v3/group_scrolltext.cpp | 2 +- .../src/interface_v3/group_scrolltext.h | 3 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_parser.h | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../register_interface_elements.cpp | 3 +- code/ryzom/client/src/libwww.h | 3 +- code/ryzom/client/src/net_manager.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 2 +- 28 files changed, 1446 insertions(+), 1439 deletions(-) create mode 100644 code/nel/include/nel/gui/group_list.h create mode 100644 code/nel/src/gui/group_list.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_list.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_list.h diff --git a/code/nel/include/nel/gui/group_list.h b/code/nel/include/nel/gui/group_list.h new file mode 100644 index 000000000..f7a2263e2 --- /dev/null +++ b/code/nel/include/nel/gui/group_list.h @@ -0,0 +1,262 @@ +// Ryzom - MMORPG Framework +// 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 NL_GROUP_LIST_H +#define NL_GROUP_LIST_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/group_frame.h" +#include "nel/gui/view_text.h" + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + class CGroupList : public CInterfaceGroup + { + public: + enum EAlign + { + Bottom = 0, + Top, + Left, + Right + }; + + ///constructor + CGroupList(const TCtorParam ¶m); + + // dtor + ~CGroupList(); + /** + * add a child element to the group at the last position + * 'order' of the element is set to the last order + 1 + * \param child : pointer to the child element + */ + void addChild (CViewBase* child, bool deleteOnRemove=true); + + + /** add a child before the element at the given index. + * 'order' of the element is set to 0 + * \return true if there was enough room for that child + */ + bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true); + + /** + * add a text child element to the group, using the text template + * \param line : text to be added + * \param color : text color + */ + void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); + + /** + * add a text child element to the group, using the text template + * \param line : text to be added + */ + void addTextChild (const ucstring& line, bool multiLine = true); + + /// Same as adding a text child but the text will be taken from the string manager + void addTextChildID (uint32 id, bool multiLine = true); + // the same, but with id taken from the database + void addTextChildID (const std::string &dbPath, bool multiLine = true); + + + bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false); + + bool delChild(uint index, bool forceDontDelete = false); + + CViewBase *getChild(uint index) const { return _Elements[index].Element; } + int luaGetChild(CLuaState &ls); + + void deleteAllChildren(); + + void removeHead(); + + // Get the number of children + uint getNumChildren() const { return (uint)_Elements.size(); } + + // Get the number of active children + uint getNumActiveChildren() const; + + /** + * set the template that will be used to add text; + * \templ : a CViewText object. Only its font size, color and shadow are required. + */ + void setTextTemplate(const CViewText& templ); + + /** + * set the template that will be used to add text; + * \templ : a CViewText object. Only its font size, color and shadow are required. + */ + CViewText * getTextTemplatePtr() + { + return &_Templ; + } + + /** + * parse the element and initalize it + * \paral cur : pointer to the node describing this element + * \param parentGroup : the parent group of this element + * \return true if success + */ + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + //virtual uint32 getMemory(); + /** + * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here + */ + virtual void updateCoords(); + + virtual void draw(); + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + virtual void clearViews(); + virtual void clearControls(); + virtual void clearGroups(); + + void setSpace (sint32 s) { _Space = s; } + + virtual CInterfaceElement* getElement (const std::string &id) + { return CInterfaceGroup::getElement (id); } + + sint32 getNbElement() { return (sint32)_Elements.size(); } + sint32 getSpace() { return _Space; } + + void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; } + bool getDynamicDisplaySize() { return _DynamicDisplaySize; } + + void forceSizeW (sint32 newSizeW); + void forceSizeH (sint32 newSizeH); + + void setMinW(sint32 minW); + void setMinH(sint32 minH); + sint32 getMinW() const {return _MinW;} + sint32 getMinH() const {return _MinH;} + + // set the rank for the element at the given index (used to reinsert container after they have been turned into popups) + void setOrder(uint index, uint order) { _Elements[index].Order = order; } + uint getOrder(uint index) const { return _Elements[index].Order; } + + // get element of index or -1 if not found + sint32 getElementIndex(CViewBase* child) const; + int luaGetElementIndex(CLuaState &ls); + + // swap 2 entries in the list (and also their orders) + void swapChildren(uint index1, uint index2); + int luaUpChild(CLuaState &ls); + int luaDownChild(CLuaState &ls); + + // deleteOnRemove flag + void setDelOnRemove(uint index, bool delOnRemove); + bool getDelOnRemove(uint index) const; + + // children number + void setChildrenNb(sint32 /* val */){} + sint32 getChildrenNb() const {return (sint32)_Elements.size();} + + int luaAddChild(CLuaState &ls); + int luaAddChildAtIndex(CLuaState &ls); + int luaDetachChild(CLuaState &ls); + int luaClear(CLuaState &ls); // synonimous for deleteAllChildren + int luaAddTextChild(CLuaState &ls); + int luaAddColoredTextChild(CLuaState &ls); + int luaDelChild(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupList, CInterfaceGroup) + REFLECT_LUA_METHOD("addTextChild", luaAddTextChild) + REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild) + REFLECT_LUA_METHOD("addChild", luaAddChild); + REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex); + REFLECT_LUA_METHOD("detachChild", luaDetachChild); + REFLECT_LUA_METHOD("clear", luaClear); + REFLECT_LUA_METHOD("delChild", luaDelChild); + REFLECT_LUA_METHOD("upChild", luaUpChild); + REFLECT_LUA_METHOD("downChild", luaDownChild); + REFLECT_LUA_METHOD("getChild", luaGetChild); + REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex); + REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb); + REFLECT_EXPORT_END + + + protected: + + //max number of elements + sint32 _MaxElements; + + // Where to add next element + EAlign _AddElt; + + // Where to align the newly added element + EAlign _Align; + + // Space between two elements in pixel + sint32 _Space; + + // Text template + CViewText _Templ; + + // Current id of the view + sint32 _IdCounter; + + // Used for context menu to display the same size as the whole content + bool _DynamicDisplaySize; + + // Do we have a color under the element pointed by the mouse + bool _Over; + + // If over is true so we have a color + NLMISC::CRGBA _OverColor; + + // Current elt over the pointer + sint32 _OverElt; + + struct CElementInfo + { + uint Order; // Used to sort the window by their insertion order. + // This is used to put back a window at the right place if it was turned into a popup. + CViewBase *Element; + bool EltDeleteOnRemove; + }; + friend struct CRemoveViewPred; + friend struct CRemoveCtrlPred; + friend struct CRemoveGroupPred; + + // The list is forced to be at least this size in updateCoords(). + sint32 _MinW; + sint32 _MinH; + + + // To conserve elements in the order they have been added + // (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup + std::vector _Elements; + + private: + + void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); + void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); + + }; + + +} + +#endif // NL_GROUP_LIST_H + +/* End of group_list.h */ + + diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index 380e81b5b..2dcf477f9 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -27,12 +27,11 @@ #include "nel/gui/reflect.h" #include "nel/gui/interface_common.h" -class CGroupList; class CGroupParagraph; namespace NLGUI { - + class CGroupList; class CInterfaceLink; class CInterfaceElement; class CInterfaceGroup; @@ -496,7 +495,7 @@ namespace NLGUI NLMISC::CRefPtr _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it // Friend Class - friend class ::CGroupList; + friend class CGroupList; friend class ::CGroupParagraph; // True if must modulate the global color with the view diff --git a/code/nel/src/gui/group_list.cpp b/code/nel/src/gui/group_list.cpp new file mode 100644 index 000000000..78860c5b6 --- /dev/null +++ b/code/nel/src/gui/group_list.cpp @@ -0,0 +1,1158 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_list.h" +#include "nel/gui/interface_element.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/view_text_id.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/lua_ihm.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" +#include "nel/misc/i18n.h" + +using namespace std; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CGroupList, std::string, "list"); + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + CGroupList::CGroupList(const TCtorParam ¶m) + : CInterfaceGroup(param), + _Templ(TCtorParam()) + { + _IdCounter = 0; + _MaxElements = 1024; + _AddElt = Bottom; + _Align = Left; + _Space = 0; + _DynamicDisplaySize = false; + _MinW= 0; + _MinH= 0; + _Over = false; + _OverColor = CRGBA(255, 255, 255, 32); + _OverElt = -1; + _IsGroupList = true; + } + + // ---------------------------------------------------------------------------- + void CGroupList::addChild (CViewBase* child, bool deleteOnRemove) + { + if (!child) + { + nlwarning(" : tried to add a NULL view"); + return; + } + + // Make sure there's room for the element + if ((sint32)_Elements.size() == _MaxElements) + { + removeHead(); + } + + // add child at last index + addChildAtIndex(child, (uint)_Elements.size(), deleteOnRemove); + if (_Elements.size() >= 2) + { + setOrder((uint)_Elements.size() - 1, getOrder((uint)_Elements.size() - 2) + 1); + } + } + + // ---------------------------------------------------------------------------- + CGroupList::~CGroupList() + { + deleteAllChildren(); + } + + // ---------------------------------------------------------------------------- + // Set Hotspot of the first element in reference to the group + void CGroupList::setHSGroup (CViewBase *child, EAlign addElt, EAlign align) + { + switch (addElt) + { + case Bottom: + if (align == Left) + { + child->_ParentPosRef = Hotspot_TL; + child->_PosRef = Hotspot_TL; + } + else // align == Right + { + child->_ParentPosRef = Hotspot_TR; + child->_PosRef = Hotspot_TR; + } + break; + case Left: + if (align == Top) + { + child->_ParentPosRef = Hotspot_TR; + child->_PosRef = Hotspot_TR; + } + else // align == Bottom + { + child->_ParentPosRef = Hotspot_BR; + child->_PosRef = Hotspot_BR; + } + break; + case Top: + if (align == Left) + { + child->_ParentPosRef = Hotspot_BL; + child->_PosRef = Hotspot_BL; + } + else // align == Right + { + child->_ParentPosRef = Hotspot_BR; + child->_PosRef = Hotspot_BR; + } + break; + case Right: + if (align == Top) + { + child->_ParentPosRef = Hotspot_TL; + child->_PosRef = Hotspot_TL; + } + else // align == Bottom + { + child->_ParentPosRef = Hotspot_BL; + child->_PosRef = Hotspot_BL; + } + break; + default: + nlassert(false); + break; + } + } + + // ---------------------------------------------------------------------------- + /** align an element towards its parent in the group + */ + void CGroupList::setHSParent(CViewBase *view, EAlign addElt, EAlign /* align */, uint space) + { + if ((addElt == Top) || (addElt == Bottom)) + { + if (addElt == Bottom) + { + if (_Align == Left) + view->_ParentPosRef = Hotspot_BL; + else // align == Right + view->_ParentPosRef = Hotspot_BR; + //view->_Y = -abs((sint32)space); + view->_Y = - (sint32)space; + } + else if (addElt == Top) + { + if (_Align == Left) + view->_ParentPosRef = Hotspot_TL; + else // align == Right + view->_ParentPosRef = Hotspot_TR; + // view->_Y = abs((sint32)space); + view->_Y = (sint32)space; + } + } + else + { + if (addElt == Left) + { + if (_Align == Top) + view->_ParentPosRef = Hotspot_TL; + else // align == Bottom + view->_ParentPosRef = Hotspot_BL; + //view->_X = -abs((sint32)space); + view->_X = -(sint32)space; + } + else if (addElt == Right) + { + if (_Align == Top) + view->_ParentPosRef = Hotspot_TR; + else // align == Bottom + view->_ParentPosRef = Hotspot_BR; + //view->_X = abs((sint32)space); + view->_X = (sint32)space; + } + } + } + + // ---------------------------------------------------------------------------- + bool CGroupList::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur, parentGroup)) + return false; + + // Parse location. If these properties are not specified, set them to 0 + + CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"maxelements" )); + _MaxElements = 1024; + if (ptr) + { + if (!fromString((const char*)ptr, _MaxElements)) + { + nlwarning(" Can't parse the 'maxelements' field "); + } + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"addelt" ); + _AddElt = Bottom; + if (ptr) + { + if (stricmp(ptr, "B") == 0) + _AddElt = Bottom; + else if (stricmp(ptr, "T") == 0) + _AddElt = Top; + else if (stricmp(ptr, "L") == 0) + _AddElt = Left; + else if (stricmp(ptr, "R") == 0) + _AddElt = Right; + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); + _Align = Left; + if (ptr) + { + if (stricmp(ptr, "B") == 0) + _Align = Bottom; + else if (stricmp(ptr, "T") == 0) + _Align = Top; + else if (stricmp(ptr, "L") == 0) + _Align = Left; + else if (stricmp(ptr, "R") == 0) + _Align = Right; + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"space" ); + _Space = 0; + if (ptr) + fromString((const char*)ptr, _Space); + + EAlign addElt = _AddElt; + // EAlign align = _Align; + _GroupSizeRef = _SizeRef; + if ((addElt == Top) || (addElt == Bottom)) + { + setMaxW (_W); + setMaxH(_H); + _H = 0; + _SizeRef = _SizeRef&(~2); + } + else + { + setMaxW (_W); + setMaxH (_H); + _W = 0; + _SizeRef = _SizeRef&(~1); + } + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); + _Over = false; + if (ptr) _Over = convertBool(ptr); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"dynamic_display_size" ); + _DynamicDisplaySize = false; + if (ptr) _DynamicDisplaySize = convertBool(ptr); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); + _OverColor = CRGBA(255, 255, 255, 32); + if (ptr) _OverColor = convertColor(ptr); + + + // TEMPLATE TEXT SETUP + + // justification parameters + _Templ.parseTextOptions (cur); + + // initial text + ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); + if (ptr) + { + const char *propPtr = ptr; + ucstring Text = ucstring(propPtr); + if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) + Text = CI18N::get (propPtr); + + addTextChild(Text); + } + else + { + ptr = (char*) xmlGetProp( cur, (xmlChar*)"textid" ); + if (ptr) + { + uint32 textId; + fromString((const char*)ptr, textId); + addTextChildID(textId); + } + } + + return true; + } + + + + // ---------------------------------------------------------------------------- + void CGroupList::addTextChild(const ucstring& line, bool multiLine /*= true*/) + { + const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; + CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); + view->_Parent = this; + view->setMultiLine (multiLine); + view->setTextMode(_Templ.getTextMode()); + if (multiLine) view->setMultiLineSpace (_Space); + view->setText (line); + // Herit global-coloring + view->setModulateGlobalColor(getModulateGlobalColor()); + addChild(view); + invalidateCoords(); + } + + + + // ---------------------------------------------------------------------------- + void CGroupList::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) + { + const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; + CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); + view->_Parent = this; + view->setMultiLine (multiLine); + if (multiLine) view->setMultiLineSpace (_Space); + view->setText (line); + view->setColor (textColor); + // Herit global-coloring + view->setModulateGlobalColor(getModulateGlobalColor()); + addChild(view); + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::addTextChildID (uint32 nID, bool multiLine) + { + const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; + CViewTextID *view= new CViewTextID (elid, nID, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); + view->_Parent = this; + view->setMultiLine (multiLine); + if (multiLine) view->setMultiLineSpace (_Space); + // Herit global-coloring + view->setModulateGlobalColor(getModulateGlobalColor()); + addChild (view); + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::addTextChildID(const std::string &dbPath, bool multiLine /*=true*/) + { + const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; + CViewTextID *view= new CViewTextID (elid, dbPath, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); + view->_Parent = this; + view->setMultiLine (multiLine); + if (multiLine) view->setMultiLineSpace (_Space); + // Herit global-coloring + view->setModulateGlobalColor(getModulateGlobalColor()); + addChild (view); + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + bool CGroupList::delChild (CViewBase* childToDel, bool noWarning, bool forceDontDelete) + { + // Look for child + uint posChildToDel = 0; + for (posChildToDel = 0; posChildToDel < _Elements.size(); ++posChildToDel) + { + CElementInfo rEI = _Elements[posChildToDel]; + if (rEI.Element == childToDel) + break; + } + + if (posChildToDel == _Elements.size()) + { + if (!noWarning) + nlwarning("Can't del child %s, it does not exist in the list", childToDel->getId().c_str()); + return false; + } + return delChild(posChildToDel, forceDontDelete); + } + + // ---------------------------------------------------------------------------- + bool CGroupList::delChild(uint posChildToDel, bool forceDontDelete) + { + if (posChildToDel >= (uint) _Elements.size()) + { + nlwarning(" bad index"); + return false; + } + + CViewBase* childToDel = _Elements[posChildToDel].Element; + + childToDel->_Parent = NULL; + + bool elementMustBeDeleted = _Elements[posChildToDel].EltDeleteOnRemove && !forceDontDelete; + _Elements.erase (_Elements.begin()+posChildToDel); + // Remove from drawing + if (dynamic_cast(childToDel)) delGroup(static_cast(childToDel), !elementMustBeDeleted); + else if (dynamic_cast(childToDel)) delCtrl(static_cast(childToDel), !elementMustBeDeleted); + else delView(childToDel, !elementMustBeDeleted); + + // Bind the new first element + if (posChildToDel < _Elements.size()) + { + CViewBase *pVB = _Elements[posChildToDel].Element; + if (posChildToDel == 0) + { + pVB->_ParentPos = NULL; + setHSGroup (pVB, _AddElt, _Align); + if ((_AddElt == Top) || (_AddElt == Bottom)) + pVB->setY (0); + else + pVB->setX (0); + } + else + pVB->_ParentPos = _Elements[posChildToDel-1].Element; + } + return true; + } + + // ---------------------------------------------------------------------------- + void CGroupList::removeHead () + { + if (_Elements.empty()) + { + nlwarning(" Can't remove head, list is empty"); + return; + } + delChild (_Elements.begin()->Element); + /*CViewBase *pVB = _Elements.begin()->Element; + if ((_AddElt == Top) || (_AddElt == Bottom)) + { + sint32 shift = _H - (pVB->getH() + _Space); + _H = shift; + } + else + { + sint32 shift = _W - (pVB->getW() + _Space); + _W = shift; + } + + bool FirstElementMustBeDeleted = _Elements.begin()->EltDeleteOnRemove; + if (FirstElementMustBeDeleted) + delete pVB; + _Elements.erase (_Elements.begin()); + // Remove from drawing + for (vector::iterator itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) + if(*itg == pVB) + { + _ChildrenGroups.erase (itg); + break; + } + for (vector::iterator itc = _Controls.begin(); itc != _Controls.end(); itc++) + if(*itc == pVB) + { + _Controls.erase (itc); + break; + } + for (vector::iterator itv = _Views.begin(); itv != _Views.end(); itv++) + if(*itv == pVB) + { + _Views.erase (itv); + break; + } + delEltOrder (pVB); + + // Bind the new first element + pVB = _Elements.begin()->Element; + pVB->_ParentPos = NULL; + setHSGroup (pVB, _AddElt, _Align); + if ((_AddElt == Top) || (_AddElt == Bottom)) + pVB->setY (0); + else + pVB->setX (0);*/ + } + + // ---------------------------------------------------------------------------- + void CGroupList::setTextTemplate(const CViewText& templ) + { + _Templ = templ; + } + + + // ---------------------------------------------------------------------------- + void CGroupList::updateCoords() + { + if (!_Active) return; + // Handle if elements are not active + for (sint32 i = 0; i < ((sint32)_Elements.size()-1); ++i) + { + if (_Elements[i].Element->getActive()) + setHSParent(_Elements[i+1].Element, _AddElt, _Align, _Space); + else + setHSParent(_Elements[i+1].Element, _AddElt, _Align, 0); + } + + CInterfaceGroup::updateCoords(); + + sint32 nCurrentX = 0; // Current offset of an element + + EAlign addElt = _AddElt; + if ((addElt == Top) || (addElt == Bottom)) + { + // Calculate size + sint32 newH = 0, newW = 0; + bool bFirst = true; + + for (uint32 i = 0; i < _Elements.size(); ++i) + if (_Elements[i].Element->getActive()) + { + newH += _Elements[i].Element->getH(); + if (!bFirst) + newH += _Space; + bFirst = false; + nCurrentX += _Elements[i].Element->getX(); + newW = max (newW, _Elements[i].Element->getW()+(sint32)abs(nCurrentX)); + } + _W = max(newW, _MinW); + _H = max(newH, _MinH); + if (_DynamicDisplaySize) + { + _MaxW = _W; + _MaxH = _H; + } + if (_H < _MaxH) setOfsY(0); + } + else + { + sint32 newW = 0, newH = 0; + bool bFirst = true; + + for (uint32 i = 0; i < _Elements.size(); ++i) + if (_Elements[i].Element->getActive()) + { + newW += _Elements[i].Element->getW(); + if (!bFirst) + newW += _Space; + bFirst = false; + newH = max (newH, _Elements[i].Element->getH()); + } + _W = max(newW, _MinW); + _H = max(newH, _MinH); + if (_DynamicDisplaySize) + { + _MaxW = _W; + _MaxH = _H; + } + if (_W < _MaxW) setOfsX(0); + } + + CInterfaceElement::updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::draw () + { + // TEMP TEMP + //CViewRenderer &rVR = *CViewRenderer::getInstance(); + //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0, 255, 0, 255) ); + if (_Over) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + if (CWidgetManager::getInstance()->getModalWindow() == NULL) + { + sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); + sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); + + CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); + CInterfaceGroup *pParent = this; + bool bFound = false; + while (pParent != NULL) + { + if (pParent == pIG) + { + bFound = true; + break; + } + pParent = pParent->getParent(); + } + + sint32 clipx, clipy, clipw, cliph; + getClip(clipx, clipy, clipw, cliph); + if ((x < clipx) || + (x > (clipx + clipw)) || + (y < clipy) || + (y > (clipy + cliph)) || !bFound) + { + _OverElt = -1; + } + else + { + for (uint32 i = 0; i < _Elements.size(); ++i) + if (_Elements[i].Element->getActive()) + { + CViewBase *pVB = _Elements[i].Element; + if ((x >= pVB->getXReal()) && + (x < (pVB->getXReal() + pVB->getWReal()))&& + (y >= pVB->getYReal()) && + (y < (pVB->getYReal() + pVB->getHReal()))) + { + _OverElt = i; + } + } + } + } + + if (_OverElt != -1) + { + // Find the first container + CInterfaceGroup *pIG = _Parent; + CGroupContainerBase *pGC = dynamic_cast(pIG); + while (pIG != NULL) + { + pIG = pIG->_Parent; + if (pIG == NULL) break; + if (dynamic_cast(pIG) != NULL) + pGC = dynamic_cast(pIG); + } + + bool bDisplayOverSelection = true; + if (pGC != NULL) + { + if (pGC->isGrayed()) + bDisplayOverSelection = false; + } + + if (bDisplayOverSelection) + { + CViewBase *pVB = _Elements[_OverElt].Element; + CRGBA col = _OverColor; + if(getModulateGlobalColor()) + { + col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); + } + else + { + col= _OverColor; + col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + } + rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), + pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), + col ); + } + + } + } + + CInterfaceGroup::draw (); + } + + // ---------------------------------------------------------------------------- + bool CGroupList::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (!_Active) + return false; + + bool bReturn = CInterfaceGroup::handleEvent(event); + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + + _OverElt = -1; + if (!isIn(eventDesc.getX(), eventDesc.getY())) + return false; + + for (uint32 i = 0; i < _Elements.size(); ++i) + if (_Elements[i].Element->getActive()) + { + CViewBase *pVB = _Elements[i].Element; + if ((eventDesc.getX() >= pVB->getXReal()) && + (eventDesc.getX() < (pVB->getXReal() + pVB->getWReal()))&& + (eventDesc.getY() >= pVB->getYReal()) && + (eventDesc.getY() < (pVB->getYReal() + pVB->getHReal()))) + { + _OverElt = i; + } + } + } + + return bReturn; + } + + + + // predicate to remove a view from the list of element + struct CRemoveViewPred + { + bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } + }; + + // predicate to remove a ctrl from the list of element + struct CRemoveCtrlPred + { + bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } + }; + + // predicate to remove a group from the list of element + struct CRemoveGroupPred + { + bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } + }; + + + // ---------------------------------------------------------------------------- + void CGroupList::clearViews() + { + _IdCounter = 0; + // remove views from the list of elements + _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveViewPred()), _Elements.end()); + CInterfaceGroup::clearViews(); + updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::clearControls() + { + _IdCounter = 0; + // remove views from the list of elements + _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveCtrlPred()), _Elements.end()); + CInterfaceGroup::clearControls(); + updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::clearGroups() + { + _IdCounter = 0; + // remove views from the list of elements + _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveGroupPred()), _Elements.end()); + CInterfaceGroup::clearGroups(); + updateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::forceSizeW (sint32 newSizeW) + { + _W = newSizeW; + for (uint32 i = 0; i < _Elements.size(); ++i) + { + _Elements[i].Element->setW (_W); + _Elements[i].Element->CInterfaceElement::updateCoords(); + } + } + + // ---------------------------------------------------------------------------- + void CGroupList::forceSizeH (sint32 newSizeH) + { + _H = newSizeH; + for (uint32 i = 0; i < _Elements.size(); ++i) + { + _Elements[i].Element->setH (_H); + _Elements[i].Element->CInterfaceElement::updateCoords(); + } + } + + // ---------------------------------------------------------------------------- + void CGroupList::setMinW(sint32 minW) + { + _MinW= minW; + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupList::setMinH(sint32 minH) + { + _MinH= minH; + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + bool CGroupList::addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove /*=true*/) + { + if (!child) + { + nlwarning(" : tried to add a NULL view"); + return false; + } + if (index > _Elements.size()) + { + return false; + } + child->_Parent = this; + child->_ParentPos = NULL; + child->_Active = true; + child->_X = 0; + child->_Y = 0; + child->_RenderLayer = this->_RenderLayer; + // Can't have sizeref on the coordinate corresponding to alignement + switch(_AddElt) + { + case Top: + case Bottom: + child->_SizeRef &= 1; // sizeref on w is permitted + break; + case Left: + case Right: + child->_SizeRef &= 2; // sizeref on h is permitted + break; + default: + nlwarning(" bad align"); + child->_SizeRef = 0; + break; + } + + child->_SizeDivW = 10; + child->_SizeDivH = 10; + + // Position the element according to the list alignement + setHSGroup (child, _AddElt, _Align); + + // update coords of the element (it may use child_resize_h or w) + //child->updateCoords(); + child->invalidateCoords(); + + // Update size + if ((_AddElt == Top) || (_AddElt == Bottom)) + { + // update the list size + sint32 newH = _H + child->getH(); + if (_Elements.size() > 0) + newH += _Space; + _H = newH; + + if ((_SizeRef&1) == 0) // No parent size reference in W + { + sint32 newW = max (_W, child->getW()); + _W = newW; + } + } + else + { + // Update the list coords + sint32 newW = _W + child->getW(); + if (_Elements.size() > 0) + newW += _Space; + _W = newW; + + if ((_SizeRef&2) == 0) // No parent size reference in H + { + sint32 newH = max (_H, child->getH()); + _H = newH; + } + } + + CElementInfo ei; + ei.Element = child; + ei.EltDeleteOnRemove = deleteOnRemove; + ei.Order = 0; + + if (index != 0) + { + // update alignement + setHSParent(child, _AddElt, _Align, _Space); + child->_ParentPos = _Elements[index - 1].Element; + } + _Elements.insert(_Elements.begin() + index, ei); + // link next element to this one + if (index < _Elements.size() - 1) + { + _Elements[index + 1].Element->_ParentPos = child; + setHSParent(_Elements[index + 1].Element, _AddElt, _Align, _Space); + } + + // Add this element for drawing + { + CInterfaceGroup *pIG = dynamic_cast(child); + if (pIG != NULL) + { + addGroup (pIG, (sint) index); + return true; + } + CCtrlBase *pCB = dynamic_cast(child); + if (pCB != NULL) + { + addCtrl (pCB, (sint) index); + return true; + } + CViewBase *pVB = dynamic_cast(child); + if (pVB != NULL) + { + addView (pVB, (sint) index); + return true; + } + nlstop; + return false; + } + return false; + } + + // ---------------------------------------------------------------------------- + sint32 CGroupList::getElementIndex(CViewBase* child) const + { + for(uint k = 0; k < _Elements.size(); ++k) + { + if (_Elements[k].Element == child) return k; + } + return -1; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaGetElementIndex(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getElementIndex", 1); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + ls.push((double) getElementIndex(viewBase)); + return 1; + } + + // ---------------------------------------------------------------------------- + void CGroupList::swapChildren(uint index1, uint index2) + { + if (index1 >= _Elements.size() + || index2 >= _Elements.size()) + { + nlwarning(" bad indexes"); + return; + } + // prevent elements from being deleted + bool oldMustDelete1 = _Elements[index1].EltDeleteOnRemove; + bool oldMustDelete2 = _Elements[index2].EltDeleteOnRemove; + + uint order1 = _Elements[index1].Order; + uint order2 = _Elements[index2].Order; + + _Elements[index1].EltDeleteOnRemove = false; + _Elements[index2].EltDeleteOnRemove = false; + + CViewBase *v1 = _Elements[index1].Element; + CViewBase *v2 = _Elements[index2].Element; + + + if (index1 < index2) + { + delChild(index2); + delChild(index1); + addChildAtIndex(v2, index1, oldMustDelete2); + setOrder(index1, order2); + addChildAtIndex(v1, index2, oldMustDelete1); + setOrder(index2, order1); + } + else + { + delChild(index1); + delChild(index2); + addChildAtIndex(v1, index2, oldMustDelete1); + setOrder(index2, order1); + addChildAtIndex(v2, index1, oldMustDelete2); + setOrder(index1, order2); + } + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaUpChild(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "upChild", 1); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + sint32 indexUpChild = getElementIndex(viewBase); + if(indexUpChild > 0) + { + swapChildren(indexUpChild, indexUpChild-1); + } + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaDownChild(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "downChild", 1); + CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + sint32 indexDownChild = getElementIndex(viewBase); + if(indexDownChild < (sint32) (_Elements.size()-1)) + { + swapChildren(indexDownChild, indexDownChild+1); + } + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaGetChild(CLuaState &ls) + { + const char *funcName = "getChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + sint index = (sint) ls.toNumber(1); + if(index < 0 || index >= (sint) _Elements.size()) + { + CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements", + index, getId().c_str(), (int) _Elements.size()); + } + CLuaIHM::pushUIOnStack(ls, getChild((uint) index)); + return 1; + } + + // ---------------------------------------------------------------------------- + void CGroupList::deleteAllChildren() + { + uint numChildren = getNbElement(); + for(uint k = 0; k < numChildren; ++k) + { + delChild(numChildren - 1 - k); // delete in reverse order to avoid unnecessary vector copies + } + } + + // ---------------------------------------------------------------------------- + uint CGroupList::getNumActiveChildren() const + { + uint numChildren = 0; + for(uint k = 0; k < _Elements.size(); ++k) + { + if (_Elements[k].Element->getActive()) ++numChildren; + } + return numChildren; + } + + // ---------------------------------------------------------------------------- + void CGroupList::setDelOnRemove(uint index, bool delOnRemove) + { + if (index >= _Elements.size()) + { + nlwarning("bad index"); + return; + } + _Elements[index].EltDeleteOnRemove = delOnRemove; + } + + // ---------------------------------------------------------------------------- + bool CGroupList::getDelOnRemove(uint index) const + { + if (index >= _Elements.size()) + { + nlwarning("bad index"); + return false; + } + return _Elements[index].EltDeleteOnRemove; + } + + + // ---------------------------------------------------------------------------- + int CGroupList::luaAddTextChild(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "addTextChild", 1); + ucstring text; + if(CLuaIHM::pop(ls, text)) + { + addTextChild(text); + } + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaAddColoredTextChild(CLuaState &ls) + { + const char *funcName = "addColoredTextChild"; + CLuaIHM::checkArgCount(ls, funcName, 5); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TNUMBER); + string text = ls.toString(1); + ucstring ucText; + ucText.fromUtf8(text); + + uint r = (uint) ls.toNumber(2); + uint g = (uint) ls.toNumber(3); + uint b = (uint) ls.toNumber(4); + uint a = (uint) ls.toNumber(5); + + addTextChild(ucText, CRGBA(r, g, b, a)); + + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaAddChild(CLuaState &ls) + { + const char *funcName = "addChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (!vb) + { + CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); + } + else + { + addChild(vb); + } + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaAddChildAtIndex(CLuaState &ls) + { + const char *funcName = "addChildAtIndex"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (!vb) + { + CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); + } + else + { + addChildAtIndex(vb, (uint) ls.toNumber(2)); + } + return 0; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaDetachChild(CLuaState &ls) + { + const char *funcName = "detachChild"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (!vb) + { + nlwarning("%s requires a view, group or control", funcName); + ls.push(false); + } + else + { + ls.push(delChild(vb, false, true)); + } + return 1; + } + + // ---------------------------------------------------------------------------- + int CGroupList::luaDelChild(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CGroupList::delChild", 1); + CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (vb) delChild(vb); + updateCoords(); + return 0; + } + + + + // ---------------------------------------------------------------------------- + int CGroupList::luaClear(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "clear", 0); + deleteAllChildren(); + return 0; + } + +} + diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 1ebbb53f2..85038deea 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -23,7 +23,7 @@ #include "client_chat_manager.h" #include "net_manager.h" -#include "interface_v3/group_list.h" +#include "nel/gui/group_list.h" #include "interface_v3/interface_manager.h" #include "interface_v3/people_interraction.h" #include "string_manager_client.h" diff --git a/code/ryzom/client/src/interface_v3/chat_displayer.h b/code/ryzom/client/src/interface_v3/chat_displayer.h index 9c8120223..fc87ba9cb 100644 --- a/code/ryzom/client/src/interface_v3/chat_displayer.h +++ b/code/ryzom/client/src/interface_v3/chat_displayer.h @@ -20,7 +20,7 @@ #define NL_CHAT_DISPLAYER_H #include "nel/misc/displayer.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "interface_manager.h" #include "nel/misc/mutex.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index 285116998..da6179fd8 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -29,6 +29,7 @@ namespace NLGUI { class CCtrlBase; class CViewText; + class CGroupList; } class CChatWindow; @@ -206,7 +207,7 @@ protected: std::vector _FreeTellers; - void getAssociatedSubWindow(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, class CGroupList *&gl, class CCtrlTabButton *&tab); + void getAssociatedSubWindow(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, NLGUI::CGroupList *&gl, class CCtrlTabButton *&tab); void updateFreeTellerHeader(CGroupContainer &ft); private: diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 8e397bcfc..0b103d511 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -31,7 +31,7 @@ #include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/view_text.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 26a1b3a45..aa1ac8018 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -30,6 +30,7 @@ namespace NLGUI class CCtrlScroll; class CViewText; class CViewBitmap; + class CGroupList; } class COptionsContainerInsertion; @@ -37,7 +38,6 @@ class COptionsContainerMove; class CGroupContainer; class CInterfaceManager; class COptionsLayer; -class CGroupList; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/group_header.h b/code/ryzom/client/src/interface_v3/group_header.h index 248c9585a..113130d1d 100644 --- a/code/ryzom/client/src/interface_v3/group_header.h +++ b/code/ryzom/client/src/interface_v3/group_header.h @@ -18,7 +18,7 @@ #define CL_GROUP_HEADER_H -#include "group_list.h" +#include "nel/gui/group_list.h" class CGroupHeaderEntry; diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 77d4c422d..3f10224c5 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -29,7 +29,7 @@ extern "C" #include "../libwww.h" #include "group_html.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "group_container.h" #include "view_link.h" #include "nel/gui/ctrl_scroll.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 963c0f07f..a0a4b7d7d 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -41,9 +41,9 @@ namespace NLGUI { class CCtrlButton; class CCtrlScroll; + class CGroupList; } -class CGroupList; class CDBGroupComboBox; class CGroupParagraph; diff --git a/code/ryzom/client/src/interface_v3/group_list.cpp b/code/ryzom/client/src/interface_v3/group_list.cpp deleted file mode 100644 index 3db145367..000000000 --- a/code/ryzom/client/src/interface_v3/group_list.cpp +++ /dev/null @@ -1,1152 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_list.h" -#include "nel/gui/interface_element.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/group_container_base.h" -#include "nel/gui/lua_ihm.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_pointer_base.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupList, std::string, "list"); - -// ---------------------------------------------------------------------------- -CGroupList::CGroupList(const TCtorParam ¶m) -: CInterfaceGroup(param), - _Templ(TCtorParam()) -{ - _IdCounter = 0; - _MaxElements = 1024; - _AddElt = Bottom; - _Align = Left; - _Space = 0; - _DynamicDisplaySize = false; - _MinW= 0; - _MinH= 0; - _Over = false; - _OverColor = CRGBA(255, 255, 255, 32); - _OverElt = -1; - _IsGroupList = true; -} - -// ---------------------------------------------------------------------------- -void CGroupList::addChild (CViewBase* child, bool deleteOnRemove) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return; - } - - // Make sure there's room for the element - if ((sint32)_Elements.size() == _MaxElements) - { - removeHead(); - } - - // add child at last index - addChildAtIndex(child, (uint)_Elements.size(), deleteOnRemove); - if (_Elements.size() >= 2) - { - setOrder((uint)_Elements.size() - 1, getOrder((uint)_Elements.size() - 2) + 1); - } -} - -// ---------------------------------------------------------------------------- -CGroupList::~CGroupList() -{ - deleteAllChildren(); -} - -// ---------------------------------------------------------------------------- -// Set Hotspot of the first element in reference to the group -void CGroupList::setHSGroup (CViewBase *child, EAlign addElt, EAlign align) -{ - switch (addElt) - { - case Bottom: - if (align == Left) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - break; - case Left: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Top: - if (align == Left) - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Right: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - break; - default: - nlassert(false); - break; - } -} - -// ---------------------------------------------------------------------------- -/** align an element towards its parent in the group - */ -void CGroupList::setHSParent(CViewBase *view, EAlign addElt, EAlign /* align */, uint space) -{ - if ((addElt == Top) || (addElt == Bottom)) - { - if (addElt == Bottom) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_BL; - else // align == Right - view->_ParentPosRef = Hotspot_BR; - //view->_Y = -abs((sint32)space); - view->_Y = - (sint32)space; - } - else if (addElt == Top) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_TL; - else // align == Right - view->_ParentPosRef = Hotspot_TR; - // view->_Y = abs((sint32)space); - view->_Y = (sint32)space; - } - } - else - { - if (addElt == Left) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TL; - else // align == Bottom - view->_ParentPosRef = Hotspot_BL; - //view->_X = -abs((sint32)space); - view->_X = -(sint32)space; - } - else if (addElt == Right) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TR; - else // align == Bottom - view->_ParentPosRef = Hotspot_BR; - //view->_X = abs((sint32)space); - view->_X = (sint32)space; - } - } -} - -// ---------------------------------------------------------------------------- -bool CGroupList::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur, parentGroup)) - return false; - - // Parse location. If these properties are not specified, set them to 0 - - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"maxelements" )); - _MaxElements = 1024; - if (ptr) - { - if (!fromString((const char*)ptr, _MaxElements)) - { - nlwarning(" Can't parse the 'maxelements' field "); - } - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"addelt" ); - _AddElt = Bottom; - if (ptr) - { - if (stricmp(ptr, "B") == 0) - _AddElt = Bottom; - else if (stricmp(ptr, "T") == 0) - _AddElt = Top; - else if (stricmp(ptr, "L") == 0) - _AddElt = Left; - else if (stricmp(ptr, "R") == 0) - _AddElt = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); - _Align = Left; - if (ptr) - { - if (stricmp(ptr, "B") == 0) - _Align = Bottom; - else if (stricmp(ptr, "T") == 0) - _Align = Top; - else if (stricmp(ptr, "L") == 0) - _Align = Left; - else if (stricmp(ptr, "R") == 0) - _Align = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"space" ); - _Space = 0; - if (ptr) - fromString((const char*)ptr, _Space); - - EAlign addElt = _AddElt; -// EAlign align = _Align; - _GroupSizeRef = _SizeRef; - if ((addElt == Top) || (addElt == Bottom)) - { - setMaxW (_W); - setMaxH(_H); - _H = 0; - _SizeRef = _SizeRef&(~2); - } - else - { - setMaxW (_W); - setMaxH (_H); - _W = 0; - _SizeRef = _SizeRef&(~1); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); - _Over = false; - if (ptr) _Over = convertBool(ptr); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"dynamic_display_size" ); - _DynamicDisplaySize = false; - if (ptr) _DynamicDisplaySize = convertBool(ptr); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); - _OverColor = CRGBA(255, 255, 255, 32); - if (ptr) _OverColor = convertColor(ptr); - - - // TEMPLATE TEXT SETUP - - // justification parameters - _Templ.parseTextOptions (cur); - - // initial text - ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (ptr) - { - const char *propPtr = ptr; - ucstring Text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - - addTextChild(Text); - } - else - { - ptr = (char*) xmlGetProp( cur, (xmlChar*)"textid" ); - if (ptr) - { - uint32 textId; - fromString((const char*)ptr, textId); - addTextChildID(textId); - } - } - - return true; -} - - - -// ---------------------------------------------------------------------------- -void CGroupList::addTextChild(const ucstring& line, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - view->setTextMode(_Templ.getTextMode()); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild(view); - invalidateCoords(); -} - - - -// ---------------------------------------------------------------------------- -void CGroupList::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - view->setColor (textColor); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild(view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::addTextChildID (uint32 nID, bool multiLine) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, nID, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::addTextChildID(const std::string &dbPath, bool multiLine /*=true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, dbPath, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -bool CGroupList::delChild (CViewBase* childToDel, bool noWarning, bool forceDontDelete) -{ - // Look for child - uint posChildToDel = 0; - for (posChildToDel = 0; posChildToDel < _Elements.size(); ++posChildToDel) - { - CElementInfo rEI = _Elements[posChildToDel]; - if (rEI.Element == childToDel) - break; - } - - if (posChildToDel == _Elements.size()) - { - if (!noWarning) - nlwarning("Can't del child %s, it does not exist in the list", childToDel->getId().c_str()); - return false; - } - return delChild(posChildToDel, forceDontDelete); -} - -// ---------------------------------------------------------------------------- -bool CGroupList::delChild(uint posChildToDel, bool forceDontDelete) -{ - if (posChildToDel >= (uint) _Elements.size()) - { - nlwarning(" bad index"); - return false; - } - - CViewBase* childToDel = _Elements[posChildToDel].Element; - - childToDel->_Parent = NULL; - - bool elementMustBeDeleted = _Elements[posChildToDel].EltDeleteOnRemove && !forceDontDelete; - _Elements.erase (_Elements.begin()+posChildToDel); - // Remove from drawing - if (dynamic_cast(childToDel)) delGroup(static_cast(childToDel), !elementMustBeDeleted); - else if (dynamic_cast(childToDel)) delCtrl(static_cast(childToDel), !elementMustBeDeleted); - else delView(childToDel, !elementMustBeDeleted); - - // Bind the new first element - if (posChildToDel < _Elements.size()) - { - CViewBase *pVB = _Elements[posChildToDel].Element; - if (posChildToDel == 0) - { - pVB->_ParentPos = NULL; - setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0); - } - else - pVB->_ParentPos = _Elements[posChildToDel-1].Element; - } - return true; -} - -// ---------------------------------------------------------------------------- -void CGroupList::removeHead () -{ - if (_Elements.empty()) - { - nlwarning(" Can't remove head, list is empty"); - return; - } - delChild (_Elements.begin()->Element); - /*CViewBase *pVB = _Elements.begin()->Element; - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - sint32 shift = _H - (pVB->getH() + _Space); - _H = shift; - } - else - { - sint32 shift = _W - (pVB->getW() + _Space); - _W = shift; - } - - bool FirstElementMustBeDeleted = _Elements.begin()->EltDeleteOnRemove; - if (FirstElementMustBeDeleted) - delete pVB; - _Elements.erase (_Elements.begin()); - // Remove from drawing - for (vector::iterator itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - if(*itg == pVB) - { - _ChildrenGroups.erase (itg); - break; - } - for (vector::iterator itc = _Controls.begin(); itc != _Controls.end(); itc++) - if(*itc == pVB) - { - _Controls.erase (itc); - break; - } - for (vector::iterator itv = _Views.begin(); itv != _Views.end(); itv++) - if(*itv == pVB) - { - _Views.erase (itv); - break; - } - delEltOrder (pVB); - - // Bind the new first element - pVB = _Elements.begin()->Element; - pVB->_ParentPos = NULL; - setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0);*/ -} - -// ---------------------------------------------------------------------------- -void CGroupList::setTextTemplate(const CViewText& templ) -{ - _Templ = templ; -} - - -// ---------------------------------------------------------------------------- -void CGroupList::updateCoords() -{ - if (!_Active) return; - // Handle if elements are not active - for (sint32 i = 0; i < ((sint32)_Elements.size()-1); ++i) - { - if (_Elements[i].Element->getActive()) - setHSParent(_Elements[i+1].Element, _AddElt, _Align, _Space); - else - setHSParent(_Elements[i+1].Element, _AddElt, _Align, 0); - } - - CInterfaceGroup::updateCoords(); - - sint32 nCurrentX = 0; // Current offset of an element - - EAlign addElt = _AddElt; - if ((addElt == Top) || (addElt == Bottom)) - { - // Calculate size - sint32 newH = 0, newW = 0; - bool bFirst = true; - - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - newH += _Elements[i].Element->getH(); - if (!bFirst) - newH += _Space; - bFirst = false; - nCurrentX += _Elements[i].Element->getX(); - newW = max (newW, _Elements[i].Element->getW()+(sint32)abs(nCurrentX)); - } - _W = max(newW, _MinW); - _H = max(newH, _MinH); - if (_DynamicDisplaySize) - { - _MaxW = _W; - _MaxH = _H; - } - if (_H < _MaxH) setOfsY(0); - } - else - { - sint32 newW = 0, newH = 0; - bool bFirst = true; - - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - newW += _Elements[i].Element->getW(); - if (!bFirst) - newW += _Space; - bFirst = false; - newH = max (newH, _Elements[i].Element->getH()); - } - _W = max(newW, _MinW); - _H = max(newH, _MinH); - if (_DynamicDisplaySize) - { - _MaxW = _W; - _MaxH = _H; - } - if (_W < _MaxW) setOfsX(0); - } - - CInterfaceElement::updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::draw () -{ - // TEMP TEMP - //CViewRenderer &rVR = *CViewRenderer::getInstance(); - //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0, 255, 0, 255) ); - if (_Over) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if (CWidgetManager::getInstance()->getModalWindow() == NULL) - { - sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x, y); - CInterfaceGroup *pParent = this; - bool bFound = false; - while (pParent != NULL) - { - if (pParent == pIG) - { - bFound = true; - break; - } - pParent = pParent->getParent(); - } - - sint32 clipx, clipy, clipw, cliph; - getClip(clipx, clipy, clipw, cliph); - if ((x < clipx) || - (x > (clipx + clipw)) || - (y < clipy) || - (y > (clipy + cliph)) || !bFound) - { - _OverElt = -1; - } - else - { - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((x >= pVB->getXReal()) && - (x < (pVB->getXReal() + pVB->getWReal()))&& - (y >= pVB->getYReal()) && - (y < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - } - - if (_OverElt != -1) - { - // Find the first container - CInterfaceGroup *pIG = _Parent; - CGroupContainerBase *pGC = dynamic_cast(pIG); - while (pIG != NULL) - { - pIG = pIG->_Parent; - if (pIG == NULL) break; - if (dynamic_cast(pIG) != NULL) - pGC = dynamic_cast(pIG); - } - - bool bDisplayOverSelection = true; - if (pGC != NULL) - { - if (pGC->isGrayed()) - bDisplayOverSelection = false; - } - - if (bDisplayOverSelection) - { - CViewBase *pVB = _Elements[_OverElt].Element; - CRGBA col = _OverColor; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), - pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), - col ); - } - - } - } - - CInterfaceGroup::draw (); -} - -// ---------------------------------------------------------------------------- -bool CGroupList::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active) - return false; - - bool bReturn = CInterfaceGroup::handleEvent(event); - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - _OverElt = -1; - if (!isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((eventDesc.getX() >= pVB->getXReal()) && - (eventDesc.getX() < (pVB->getXReal() + pVB->getWReal()))&& - (eventDesc.getY() >= pVB->getYReal()) && - (eventDesc.getY() < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - - return bReturn; -} - - - -// predicate to remove a view from the list of element -struct CRemoveViewPred -{ - bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a ctrl from the list of element -struct CRemoveCtrlPred -{ - bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a group from the list of element -struct CRemoveGroupPred -{ - bool operator()(const CGroupList::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - - -// ---------------------------------------------------------------------------- -void CGroupList::clearViews() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveViewPred()), _Elements.end()); - CInterfaceGroup::clearViews(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::clearControls() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveCtrlPred()), _Elements.end()); - CInterfaceGroup::clearControls(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::clearGroups() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveGroupPred()), _Elements.end()); - CInterfaceGroup::clearGroups(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::forceSizeW (sint32 newSizeW) -{ - _W = newSizeW; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setW (_W); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupList::forceSizeH (sint32 newSizeH) -{ - _H = newSizeH; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setH (_H); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupList::setMinW(sint32 minW) -{ - _MinW= minW; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupList::setMinH(sint32 minH) -{ - _MinH= minH; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -bool CGroupList::addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove /*=true*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return false; - } - if (index > _Elements.size()) - { - return false; - } - child->_Parent = this; - child->_ParentPos = NULL; - child->_Active = true; - child->_X = 0; - child->_Y = 0; - child->_RenderLayer = this->_RenderLayer; - // Can't have sizeref on the coordinate corresponding to alignement - switch(_AddElt) - { - case Top: - case Bottom: - child->_SizeRef &= 1; // sizeref on w is permitted - break; - case Left: - case Right: - child->_SizeRef &= 2; // sizeref on h is permitted - break; - default: - nlwarning(" bad align"); - child->_SizeRef = 0; - break; - } - - child->_SizeDivW = 10; - child->_SizeDivH = 10; - - // Position the element according to the list alignement - setHSGroup (child, _AddElt, _Align); - - // update coords of the element (it may use child_resize_h or w) - //child->updateCoords(); - child->invalidateCoords(); - - // Update size - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - // update the list size - sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) - newH += _Space; - _H = newH; - - if ((_SizeRef&1) == 0) // No parent size reference in W - { - sint32 newW = max (_W, child->getW()); - _W = newW; - } - } - else - { - // Update the list coords - sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) - newW += _Space; - _W = newW; - - if ((_SizeRef&2) == 0) // No parent size reference in H - { - sint32 newH = max (_H, child->getH()); - _H = newH; - } - } - - CElementInfo ei; - ei.Element = child; - ei.EltDeleteOnRemove = deleteOnRemove; - ei.Order = 0; - - if (index != 0) - { - // update alignement - setHSParent(child, _AddElt, _Align, _Space); - child->_ParentPos = _Elements[index - 1].Element; - } - _Elements.insert(_Elements.begin() + index, ei); - // link next element to this one - if (index < _Elements.size() - 1) - { - _Elements[index + 1].Element->_ParentPos = child; - setHSParent(_Elements[index + 1].Element, _AddElt, _Align, _Space); - } - - // Add this element for drawing - { - CInterfaceGroup *pIG = dynamic_cast(child); - if (pIG != NULL) - { - addGroup (pIG, (sint) index); - return true; - } - CCtrlBase *pCB = dynamic_cast(child); - if (pCB != NULL) - { - addCtrl (pCB, (sint) index); - return true; - } - CViewBase *pVB = dynamic_cast(child); - if (pVB != NULL) - { - addView (pVB, (sint) index); - return true; - } - nlstop; - return false; - } - return false; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupList::getElementIndex(CViewBase* child) const -{ - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element == child) return k; - } - return -1; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaGetElementIndex(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getElementIndex", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - ls.push((double) getElementIndex(viewBase)); - return 1; -} - -// ---------------------------------------------------------------------------- -void CGroupList::swapChildren(uint index1, uint index2) -{ - if (index1 >= _Elements.size() - || index2 >= _Elements.size()) - { - nlwarning(" bad indexes"); - return; - } - // prevent elements from being deleted - bool oldMustDelete1 = _Elements[index1].EltDeleteOnRemove; - bool oldMustDelete2 = _Elements[index2].EltDeleteOnRemove; - - uint order1 = _Elements[index1].Order; - uint order2 = _Elements[index2].Order; - - _Elements[index1].EltDeleteOnRemove = false; - _Elements[index2].EltDeleteOnRemove = false; - - CViewBase *v1 = _Elements[index1].Element; - CViewBase *v2 = _Elements[index2].Element; - - - if (index1 < index2) - { - delChild(index2); - delChild(index1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - } - else - { - delChild(index1); - delChild(index2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - } -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaUpChild(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "upChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - sint32 indexUpChild = getElementIndex(viewBase); - if(indexUpChild > 0) - { - swapChildren(indexUpChild, indexUpChild-1); - } - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaDownChild(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "downChild", 1); - CViewBase * viewBase = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - sint32 indexDownChild = getElementIndex(viewBase); - if(indexDownChild < (sint32) (_Elements.size()-1)) - { - swapChildren(indexDownChild, indexDownChild+1); - } - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaGetChild(CLuaState &ls) -{ - const char *funcName = "getChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - sint index = (sint) ls.toNumber(1); - if(index < 0 || index >= (sint) _Elements.size()) - { - CLuaIHM::fails(ls, "getChild : trying to access element %d in list '%s', which has %d elements", - index, getId().c_str(), (int) _Elements.size()); - } - CLuaIHM::pushUIOnStack(ls, getChild((uint) index)); - return 1; -} - -// ---------------------------------------------------------------------------- -void CGroupList::deleteAllChildren() -{ - uint numChildren = getNbElement(); - for(uint k = 0; k < numChildren; ++k) - { - delChild(numChildren - 1 - k); // delete in reverse order to avoid unnecessary vector copies - } -} - -// ---------------------------------------------------------------------------- -uint CGroupList::getNumActiveChildren() const -{ - uint numChildren = 0; - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element->getActive()) ++numChildren; - } - return numChildren; -} - -// ---------------------------------------------------------------------------- -void CGroupList::setDelOnRemove(uint index, bool delOnRemove) -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return; - } - _Elements[index].EltDeleteOnRemove = delOnRemove; -} - -// ---------------------------------------------------------------------------- -bool CGroupList::getDelOnRemove(uint index) const -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return false; - } - return _Elements[index].EltDeleteOnRemove; -} - - -// ---------------------------------------------------------------------------- -int CGroupList::luaAddTextChild(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "addTextChild", 1); - ucstring text; - if(CLuaIHM::pop(ls, text)) - { - addTextChild(text); - } - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaAddColoredTextChild(CLuaState &ls) -{ - const char *funcName = "addColoredTextChild"; - CLuaIHM::checkArgCount(ls, funcName, 5); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TNUMBER); - CLuaIHM::checkArgType(ls, funcName, 4, LUA_TNUMBER); - CLuaIHM::checkArgType(ls, funcName, 5, LUA_TNUMBER); - string text = ls.toString(1); - ucstring ucText; - ucText.fromUtf8(text); - - uint r = (uint) ls.toNumber(2); - uint g = (uint) ls.toNumber(3); - uint b = (uint) ls.toNumber(4); - uint a = (uint) ls.toNumber(5); - - addTextChild(ucText, CRGBA(r, g, b, a)); - - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaAddChild(CLuaState &ls) -{ - const char *funcName = "addChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (!vb) - { - CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); - } - else - { - addChild(vb); - } - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaAddChildAtIndex(CLuaState &ls) -{ - const char *funcName = "addChildAtIndex"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (!vb) - { - CLuaIHM::fails(ls, "%s requires a view, group or control", funcName); - } - else - { - addChildAtIndex(vb, (uint) ls.toNumber(2)); - } - return 0; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaDetachChild(CLuaState &ls) -{ - const char *funcName = "detachChild"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (!vb) - { - nlwarning("%s requires a view, group or control", funcName); - ls.push(false); - } - else - { - ls.push(delChild(vb, false, true)); - } - return 1; -} - -// ---------------------------------------------------------------------------- -int CGroupList::luaDelChild(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CGroupList::delChild", 1); - CViewBase *vb = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (vb) delChild(vb); - updateCoords(); - return 0; -} - - - -// ---------------------------------------------------------------------------- -int CGroupList::luaClear(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "clear", 0); - deleteAllChildren(); - return 0; -} - diff --git a/code/ryzom/client/src/interface_v3/group_list.h b/code/ryzom/client/src/interface_v3/group_list.h deleted file mode 100644 index 94b5d5b7f..000000000 --- a/code/ryzom/client/src/interface_v3/group_list.h +++ /dev/null @@ -1,258 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_GROUP_LIST_H -#define NL_GROUP_LIST_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/group_frame.h" -#include "nel/gui/view_text.h" - - -// ---------------------------------------------------------------------------- -class CGroupList : public CInterfaceGroup -{ -public: - enum EAlign - { - Bottom = 0, - Top, - Left, - Right - }; - - ///constructor - CGroupList(const TCtorParam ¶m); - - // dtor - ~CGroupList(); - /** - * add a child element to the group at the last position - * 'order' of the element is set to the last order + 1 - * \param child : pointer to the child element - */ - void addChild (CViewBase* child, bool deleteOnRemove=true); - - - /** add a child before the element at the given index. - * 'order' of the element is set to 0 - * \return true if there was enough room for that child - */ - bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - * \param color : text color - */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - */ - void addTextChild (const ucstring& line, bool multiLine = true); - - /// Same as adding a text child but the text will be taken from the string manager - void addTextChildID (uint32 id, bool multiLine = true); - // the same, but with id taken from the database - void addTextChildID (const std::string &dbPath, bool multiLine = true); - - - bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false); - - bool delChild(uint index, bool forceDontDelete = false); - - CViewBase *getChild(uint index) const { return _Elements[index].Element; } - int luaGetChild(CLuaState &ls); - - void deleteAllChildren(); - - void removeHead(); - - // Get the number of children - uint getNumChildren() const { return (uint)_Elements.size(); } - - // Get the number of active children - uint getNumActiveChildren() const; - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - void setTextTemplate(const CViewText& templ); - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - CViewText * getTextTemplatePtr() - { - return &_Templ; - } - - /** - * parse the element and initalize it - * \paral cur : pointer to the node describing this element - * \param parentGroup : the parent group of this element - * \return true if success - */ - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - //virtual uint32 getMemory(); - /** - * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here - */ - virtual void updateCoords(); - - virtual void draw(); - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - - virtual void clearViews(); - virtual void clearControls(); - virtual void clearGroups(); - - void setSpace (sint32 s) { _Space = s; } - - virtual CInterfaceElement* getElement (const std::string &id) - { return CInterfaceGroup::getElement (id); } - - sint32 getNbElement() { return (sint32)_Elements.size(); } - sint32 getSpace() { return _Space; } - - void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; } - bool getDynamicDisplaySize() { return _DynamicDisplaySize; } - - void forceSizeW (sint32 newSizeW); - void forceSizeH (sint32 newSizeH); - - void setMinW(sint32 minW); - void setMinH(sint32 minH); - sint32 getMinW() const {return _MinW;} - sint32 getMinH() const {return _MinH;} - - // set the rank for the element at the given index (used to reinsert container after they have been turned into popups) - void setOrder(uint index, uint order) { _Elements[index].Order = order; } - uint getOrder(uint index) const { return _Elements[index].Order; } - - // get element of index or -1 if not found - sint32 getElementIndex(CViewBase* child) const; - int luaGetElementIndex(CLuaState &ls); - - // swap 2 entries in the list (and also their orders) - void swapChildren(uint index1, uint index2); - int luaUpChild(CLuaState &ls); - int luaDownChild(CLuaState &ls); - - // deleteOnRemove flag - void setDelOnRemove(uint index, bool delOnRemove); - bool getDelOnRemove(uint index) const; - - // children number - void setChildrenNb(sint32 /* val */){} - sint32 getChildrenNb() const {return (sint32)_Elements.size();} - - int luaAddChild(CLuaState &ls); - int luaAddChildAtIndex(CLuaState &ls); - int luaDetachChild(CLuaState &ls); - int luaClear(CLuaState &ls); // synonimous for deleteAllChildren - int luaAddTextChild(CLuaState &ls); - int luaAddColoredTextChild(CLuaState &ls); - int luaDelChild(CLuaState &ls); - - REFLECT_EXPORT_START(CGroupList, CInterfaceGroup) - REFLECT_LUA_METHOD("addTextChild", luaAddTextChild) - REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild) - REFLECT_LUA_METHOD("addChild", luaAddChild); - REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex); - REFLECT_LUA_METHOD("detachChild", luaDetachChild); - REFLECT_LUA_METHOD("clear", luaClear); - REFLECT_LUA_METHOD("delChild", luaDelChild); - REFLECT_LUA_METHOD("upChild", luaUpChild); - REFLECT_LUA_METHOD("downChild", luaDownChild); - REFLECT_LUA_METHOD("getChild", luaGetChild); - REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex); - REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb); - REFLECT_EXPORT_END - - -protected: - - //max number of elements - sint32 _MaxElements; - - // Where to add next element - EAlign _AddElt; - - // Where to align the newly added element - EAlign _Align; - - // Space between two elements in pixel - sint32 _Space; - - // Text template - CViewText _Templ; - - // Current id of the view - sint32 _IdCounter; - - // Used for context menu to display the same size as the whole content - bool _DynamicDisplaySize; - - // Do we have a color under the element pointed by the mouse - bool _Over; - - // If over is true so we have a color - NLMISC::CRGBA _OverColor; - - // Current elt over the pointer - sint32 _OverElt; - - struct CElementInfo - { - uint Order; // Used to sort the window by their insertion order. - // This is used to put back a window at the right place if it was turned into a popup. - CViewBase *Element; - bool EltDeleteOnRemove; - }; - friend struct CRemoveViewPred; - friend struct CRemoveCtrlPred; - friend struct CRemoveGroupPred; - - // The list is forced to be at least this size in updateCoords(). - sint32 _MinW; - sint32 _MinH; - - - // To conserve elements in the order they have been added - // (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup - std::vector _Elements; - -private: - - void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); - void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); - -}; - - -#endif // NL_GROUP_LIST_H - -/* End of group_list.h */ - - diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h index 4b4298ab7..8ab8708e3 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ b/code/ryzom/client/src/interface_v3/group_menu.h @@ -29,10 +29,10 @@ namespace NLGUI { class CCtrlScroll; class CViewBitmap; + class CGroupList; } class CGroupMenu; -class CGroupList; /** diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 108d07a9b..1419a203a 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -22,7 +22,7 @@ #include "stdpch.h" #include "group_quick_help.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "group_paragraph.h" #include "../libwww.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index ea8409475..b58569313 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -21,7 +21,7 @@ #include "stdpch.h" #include "group_scrolltext.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/view_text.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h index cfedb76bc..88fc2c6cb 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.h @@ -27,10 +27,9 @@ namespace NLGUI { class CCtrlBaseButton; class CCtrlScroll; + class CGroupList; } -class CGroupList; - // Can be used to build a chat window or anything that displays sequences of strings /** * Widget to have a resizable scrolltext and its scrollbar diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index e9fbab649..ab028fc3e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -60,7 +60,7 @@ // DBCtrl #include "dbctrl_sheet.h" // Group -#include "group_list.h" +#include "nel/gui/group_list.h" #include "group_menu.h" #include "group_container.h" #include "nel/gui/group_modal.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 46e0d9cac..f0099a46b 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -25,7 +25,7 @@ #include "nel/3d/u_text_context.h" #include "nel/gui/interface_group.h" #include "nel/gui/interface_link.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/view_base.h" #include "view_pointer.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 35df296c3..62a38eace 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -65,7 +65,7 @@ #include "group_career.h" #include "nel/gui/group_modal.h" #include "group_modal_get_key.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/group_tree.h" #include "group_menu.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 0e74c503b..91f23427c 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -36,10 +36,10 @@ namespace NLGUI class CInterfaceOptions; class CInterfaceLink; class CCtrlBase; + class CGroupList; } class CGroupContainer; -class CGroupList; class CInterfaceAnim; class CViewPointer; class CBrickJob; diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 7ffe97d27..1bec84943 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -26,7 +26,7 @@ #include "nel/gui/action_handler.h" #include "nel/gui/ctrl_button.h" #include "group_editbox.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" #include "group_container.h" #include "group_modal_get_key.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index e66fc16d7..96a5145d0 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -27,7 +27,7 @@ #include "dbctrl_sheet.h" #include "nel/gui/ctrl_button.h" #include "group_editbox.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" #include "group_container.h" #include "group_modal_get_key.h" diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 46a08234a..1d2be1faa 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" #include "people_list.h" #include "group_container.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/view_bitmap.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index bdde30aa9..3a2d7f7b1 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -31,7 +31,7 @@ #include "nel/gui/group_frame.h" #include "nel/gui/group_container_base.h" #include "group_container.h" -#include "group_list.h" +#include "nel/gui/group_list.h" #include "dbgroup_select_number.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_text_button.h" @@ -45,7 +45,6 @@ #include "nel/gui/reflect.h" #include "dbview_bar.h" #include "dbview_bar3.h" -#include "group_list.h" #include "nel/gui/ctrl_scroll_base.h" #include "nel/gui/ctrl_scroll.h" #include "dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/libwww.h b/code/ryzom/client/src/libwww.h index b82a75534..aa3f6b424 100644 --- a/code/ryzom/client/src/libwww.h +++ b/code/ryzom/client/src/libwww.h @@ -29,10 +29,9 @@ namespace NLGUI { class CCtrlBaseButton; class CCtrlScroll; + class CGroupList; } -class CGroupList; - // *************************************************************************** // Init the libwww diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index e1e91377f..03a10aec4 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -39,7 +39,7 @@ #include "game_share/combat_flying_text.h" #include "game_share/shard_names.h" // Client. -#include "interface_v3/group_list.h" +#include "nel/gui/group_list.h" #include "interface_v3/interface_manager.h" #include "net_manager.h" #include "client_cfg.h" diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 29300c975..54b498858 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -54,7 +54,7 @@ using namespace NLGUI; #include "../cursor_functions.h" #include "../entities.h" #include "../events_listener.h" -#include "../interface_v3/group_list.h" +#include "nel/gui/group_list.h" #include "nel/gui/event_descriptor.h" #include "nel/gui/group_tree.h" #include "../client_cfg.h" From 2da27bdc2d441763d2b07ed0f7b6593a7f46ed1e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 22 Jun 2012 23:17:55 +0200 Subject: [PATCH 093/339] CHANGED: #1471 CGroupEditBox no longer depends on CGroupContainer, and CInputHandlerManager. --- .../include/nel/gui/group_container_base.h | 3 ++ .../client/src/interface_v3/group_editbox.cpp | 51 +++++-------------- .../client/src/interface_v3/group_editbox.h | 16 +++++- .../interface_v3/input_handler_manager.cpp | 2 + .../src/interface_v3/input_handler_manager.h | 3 +- 5 files changed, 36 insertions(+), 39 deletions(-) diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h index 1e5313e1b..b961f5da3 100644 --- a/code/nel/include/nel/gui/group_container_base.h +++ b/code/nel/include/nel/gui/group_container_base.h @@ -86,6 +86,9 @@ namespace NLGUI uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; } virtual bool isGrayed() const{ return false; } + virtual bool getTouchFlag(bool clearFlag) const{ return false; } + virtual void backupPosition(){} + virtual void restorePosition(){} protected: void triggerAlphaSettingsChangedAH(); diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index 529642288..1fd5c37cf 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -14,21 +14,17 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "group_editbox.h" -#include "interface_manager.h" -#include "input_handler_manager.h" #include "nel/misc/command.h" #include "nel/gui/view_text.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/interface_options.h" -#include "dbctrl_sheet.h" -#include "group_container.h" -#include "../time_client.h" +#include "nel/gui/ctrl_draggable.h" +#include "nel/gui/group_container_base.h" #include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/db_manager.h" using namespace std; using namespace NLMISC; @@ -41,6 +37,7 @@ using namespace NL3D; sint32 CGroupEditBox::_SelectCursorPos = 0; CGroupEditBox *CGroupEditBox::_MenuFather = NULL; +CGroupEditBox::IComboKeyHandler* CGroupEditBox::comboKeyHandler = NULL; // ---------------------------------------------------------------------------- @@ -93,7 +90,6 @@ CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : CGroupEditBox::~CGroupEditBox() { if (this == _CurrSelection) _CurrSelection = NULL; - CInterfaceManager *im = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) { CWidgetManager::getInstance()->resetCaptureKeyboard(); @@ -106,8 +102,6 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) if(!CInterfaceGroup::parse(cur, parentGroup)) return false; CXMLAutoPtr prop; -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); if (! CInterfaceGroup::parse(cur,parentGroup) ) { @@ -216,7 +210,6 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) void CGroupEditBox::draw () { // - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); // /*CRGBA col; @@ -296,7 +289,7 @@ void CGroupEditBox::draw () // Display the cursor if needed if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) { - _BlinkTime += DT; + _BlinkTime += 0.0025f; if (_BlinkTime > 0.25f) { _BlinkTime = fmodf(_BlinkTime, 0.25f); @@ -566,7 +559,6 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) break; // OTHER default: - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) { // update historic. @@ -583,7 +575,6 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) _CursorPos = 0; // loose the keyboard focus - CInterfaceManager *im = CInterfaceManager::getInstance(); if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) { if(_LooseFocusOnEnter) @@ -717,7 +708,6 @@ void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK) // ---------------------------------------------------------------------------- bool CGroupEditBox::undo() { - CInterfaceManager *im = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanUndo) return false; _ModifiedInputString = _InputString; @@ -732,7 +722,6 @@ bool CGroupEditBox::undo() // ---------------------------------------------------------------------------- bool CGroupEditBox::redo() { - CInterfaceManager *im = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (!_CanRedo) return false; setInputString(_ModifiedInputString); @@ -748,11 +737,10 @@ void CGroupEditBox::triggerOnChangeAH() { _CanUndo = true; _CanRedo = false; + if (!_AHOnChange.empty()) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } + } // ---------------------------------------------------------------------------- @@ -856,8 +844,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) else { // Look into the input handler Manager if the key combo has to be considered as handled - CInputHandlerManager *pIH= CInputHandlerManager::getInstance(); - if( pIH->isComboKeyChat(rEDK) ) + if( ( CGroupEditBox::comboKeyHandler != NULL ) && comboKeyHandler->isComboKeyChat(rEDK) ) return true; else return false; @@ -871,8 +858,6 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) ///////////////// const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) { if (CWidgetManager::getInstance()->getCapturePointerRight() == this) @@ -880,7 +865,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) CWidgetManager::getInstance()->setCapturePointerRight(NULL); if (!_ListMenuRight.empty()) { - if (CDBCtrlSheet::getDraggedSheet() == NULL) + if (CCtrlDraggable::getDraggedSheet() == NULL) { _MenuFather = this; CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); @@ -1069,7 +1054,7 @@ void CGroupEditBox::updateCoords() if (_BackupFatherContainerPos) { - CGroupContainer *gc = static_cast< CGroupContainer* >( getEnclosingContainer() ); + CGroupContainerBase *gc = static_cast< CGroupContainerBase* >( getEnclosingContainer() ); if (gc && !gc->getTouchFlag(true)) { @@ -1301,12 +1286,9 @@ void CGroupEditBox::setCommand(const ucstring &command, bool execute) // *************************************************************************** void CGroupEditBox::makeTopWindow() { - CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceGroup *root = getRootWindow(); - if (root) - { + if(root) CWidgetManager::getInstance()->setTopWindow(root); - } } // *************************************************************************** @@ -1405,10 +1387,8 @@ void CGroupEditBox::elementCaptured(CCtrlBase *capturedElement) void CGroupEditBox::onKeyboardCaptureLost() { if (!_AHOnFocusLost.empty()) - { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); - } + } // *************************************************************************** @@ -1428,7 +1408,6 @@ void CGroupEditBox::setFocusOnText() return; // else set the focus - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->setCaptureKeyboard (this); _CurrSelection = this; @@ -1454,7 +1433,6 @@ int CGroupEditBox::luaCancelFocusOnText(CLuaState &ls) const char *funcName = "cancelFocusOnText"; CLuaIHM::checkArgCount(ls, funcName, 0); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this) CWidgetManager::getInstance()->resetCaptureKeyboard(); @@ -1490,7 +1468,6 @@ void CGroupEditBox::setFrozen (bool state) // if frozen, loose the focus if(_Frozen) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); // stop capture and selection CWidgetManager::getInstance()->setCaptureKeyboard (NULL); if(_CurrSelection==this) _CurrSelection = NULL; diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index 1c0a02e68..2df561ff8 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -33,8 +33,16 @@ namespace NLGUI class CGroupEditBox : public CGroupEditBoxBase { public: + + class IComboKeyHandler + { + public: + virtual ~IComboKeyHandler(){} + virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0; + }; + enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with -public: + DECLARE_UI_CLASS( CGroupEditBox ) /// Constructor CGroupEditBox(const TCtorParam ¶m); @@ -341,6 +349,12 @@ private: } return false; } + + static IComboKeyHandler *comboKeyHandler; + +public: + static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; } + }; diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp index da2fddea9..7622cc737 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.cpp +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.cpp @@ -67,11 +67,13 @@ CInputHandlerManager::CInputHandlerManager() _RecoverFocusLost = false; inputHandler.setListener( CInterfaceManager::getInstance() ); + CGroupEditBox::setComboKeyHandler( this ); } // *************************************************************************** CInputHandlerManager::~CInputHandlerManager() { + CGroupEditBox::setComboKeyHandler( NULL ); } // ******************************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.h b/code/ryzom/client/src/interface_v3/input_handler_manager.h index 085806122..aa5903b72 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.h @@ -26,6 +26,7 @@ #include #include "nel/gui/event_descriptor.h" #include "nel/gui/input_handler.h" +#include "group_editbox.h" /** @@ -40,7 +41,7 @@ */ -class CInputHandlerManager : public NLMISC::IEventListener +class CInputHandlerManager : public NLMISC::IEventListener, public CGroupEditBox::IComboKeyHandler { public: /// The EventServer Filled with Filtered Messages the InterfaceManager didn't cactch From 02227edb5816513aca4e5ece55f8c9135beccb0e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 03:27:49 +0200 Subject: [PATCH 094/339] CHANGED: #1471 CGroupEditBox is now in the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/group_editbox.h | 364 ++++ code/nel/src/gui/group_editbox.cpp | 1486 +++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 +- code/ryzom/client/src/commands.cpp | 2 +- code/ryzom/client/src/connection.cpp | 2 +- code/ryzom/client/src/init_main_loop.cpp | 2 +- .../src/interface_v3/action_handler_base.cpp | 2 +- .../src/interface_v3/action_handler_edit.cpp | 2 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/action_handler_misc.cpp | 2 +- .../src/interface_v3/action_handler_ui.cpp | 2 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../bot_chat_page_create_guild.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../client/src/interface_v3/chat_window.h | 6 +- .../src/interface_v3/dbgroup_build_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_build_phrase.h | 3 +- .../src/interface_v3/group_container.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 1481 ---------------- .../client/src/interface_v3/group_editbox.h | 363 ---- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../src/interface_v3/input_handler_manager.h | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../register_interface_elements.cpp | 2 +- code/ryzom/client/src/login.cpp | 2 +- code/ryzom/client/src/r2/editor.cpp | 2 +- 36 files changed, 1884 insertions(+), 1879 deletions(-) create mode 100644 code/nel/include/nel/gui/group_editbox.h create mode 100644 code/nel/src/gui/group_editbox.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_editbox.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_editbox.h diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h new file mode 100644 index 000000000..38d362589 --- /dev/null +++ b/code/nel/include/nel/gui/group_editbox.h @@ -0,0 +1,364 @@ +// Ryzom - MMORPG Framework +// 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 RZ_CTRL_EDITBOX_H +#define RZ_CTRL_EDITBOX_H + +#include "nel/gui/interface_group.h" +#include "nel/gui/group_editbox_base.h" +#include "nel/3d/u_texture.h" + +namespace NLGUI +{ + class CEventDescriptor; + class CViewText; + + // ---------------------------------------------------------------------------- + class CGroupEditBox : public CGroupEditBoxBase + { + public: + + class IComboKeyHandler + { + public: + virtual ~IComboKeyHandler(){} + virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0; + }; + + enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with + + DECLARE_UI_CLASS( CGroupEditBox ) + /// Constructor + CGroupEditBox(const TCtorParam ¶m); + /// Dtor + ~CGroupEditBox(); + + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + virtual void draw(); + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + /// Accessors + ucstring getInputString() const { return _InputString; } + const ucstring &getInputStringRef() const { return _InputString; } + const ucstring &getPrompt() const { return _Prompt; } + + /** Set the prompt + * NB : line returns are encoded as '\n', not '\r\n' + */ + void setPrompt(const ucstring &s) { _Prompt = s; } + void setInputString(const ucstring &str); + void setInputStringRef(const ucstring &str) {_InputString = str; }; + void setInputStringAsInt(sint32 val); + sint32 getInputStringAsInt() const; + void setInputStringAsInt64(sint64 val); + sint64 getInputStringAsInt64() const; + void setInputStringAsFloat(float val); + float getInputStringAsFloat() const; + void setInputStringAsStdString(const std::string &str); + std::string getInputStringAsStdString() const; + void setInputStringAsUtf8(const std::string &str); + std::string getInputStringAsUtf8() const; + void setColor(NLMISC::CRGBA col); + + + /// force the selection of all the text + void setSelectionAll(); + + virtual void checkCoords(); + virtual void updateCoords(); + virtual void clearViews (); + + virtual void setActive (bool state); + + static CGroupEditBox *getMenuFather() { return _MenuFather; } + + void setCommand(const ucstring &command, bool execute); + + // Stop parent from blinking + void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } + + // Get / set cursor position + sint32 getCursorPos () const {return _CursorPos;} + void setCursorPos (sint32 pos) {_CursorPos=pos;} + + // Get / set cursor at previous line end + bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;} + void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;} + + // Get / set current selection position + static sint32 getSelectCursorPos () {return _SelectCursorPos;} + static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;} + + // Get the view text + const CViewText *getViewText () const {return _ViewText;} + + // Get the historic information + sint32 getMaxHistoric() const {return _MaxHistoric;} + sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} + void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} + const ucstring &getHistoric(uint32 index) const {return _Historic[index];} + uint32 getNumHistoric() const {return (uint32)_Historic.size ();} + + // Get on change action handler + const std::string &getAHOnChange() const {return _AHOnChange;} + const std::string &getParamsOnChange() const {return _ParamsOnChange;} + + void cutSelection(); + + /// From CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + // Copy the selection into buffer + void copy(); + // Paste the selection into buffer + void paste(); + // Write the string into buffer + void writeString(const ucstring &str, bool replace = true, bool atEnd = true); + + // Expand the expression (true if there was a '/' at the start of the line) + bool expand(); + + // Back space + void back(); + + // ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant) + void bypassNextKey() { _BypassNextKey = true; } + + // True if the editBox loose the focus on enter + bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;} + // + virtual void clearAllEditBox(); + // From CInterfaceElement + virtual bool wantSerialConfig() const; + // From CInterfaceElement + virtual void serialConfig(NLMISC::IStream &f); + // From CInterfaceElement + virtual void onQuit(); + // From CInterfaceElement + virtual void onLoadConfig(); + + // from CCtrlBase + virtual void elementCaptured(CCtrlBase *capturedElement); + + // from CCtrlBase + virtual void onKeyboardCaptureLost(); + + // set the input string as "default". will be reseted at first click (used for user information) + void setDefaultInputString(const ucstring &str); + + // For Interger and PositiveInteger, can specify min and max values + void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} + void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;} + void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;} + void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;} + + void setFocusOnText(); + + int luaSetSelectionAll(CLuaState &ls); + int luaSetupDisplayText(CLuaState &ls); + int luaSetFocusOnText(CLuaState &ls); + int luaCancelFocusOnText(CLuaState &ls); + REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase) + REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText); + REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); + REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); + REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); + REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); + REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); + REFLECT_EXPORT_END + + /** Restore the original value of the edit box. + * This value is captured when the edit box get focus + * (return true if no undo was available) + * Will always fails ifthe edito box do not have the focus + */ + bool undo(); + + /** Cancel last undo operation + * Return true if redo operation is available + */ + bool redo(); + + /// freeze the control (loose focus, and cannot edit) + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + protected: + + // Cursor infos + float _BlinkTime; + sint32 _CursorPos; + uint32 _MaxNumChar; + uint32 _MaxNumReturn; + uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only + sint32 _MaxCharsSize; + sint32 _FirstVisibleChar; + sint32 _LastVisibleChar; + + // Text selection + static sint32 _SelectCursorPos; + bool _SelectingText; + NLMISC::CRGBA _TextSelectColor; + NLMISC::CRGBA _BackSelectColor; + + // Text info + ucstring _Prompt; + ucstring _InputString; + CViewText *_ViewText; + + // undo / redo + ucstring _StartInputString; // value of the input string when focus was acuired first + ucstring _ModifiedInputString; + + + // Historic info + typedef std::deque THistoric; + THistoric _Historic; + uint32 _MaxHistoric; + sint32 _CurrentHistoricIndex; + sint32 _PrevNumLine; + + // Action Handler + std::string _AHOnChange; + std::string _ParamsOnChange; + std::string _ListMenuRight; + + std::string _AHOnFocusLost; + std::string _AHOnFocusLostParams; + + // entry type + TEntryType _EntryType; + + + bool _Setupped : 1; // setup + bool _BypassNextKey : 1; + bool _BlinkState : 1; + bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines) + bool _LooseFocusOnEnter : 1; + bool _ResetFocusOnHide : 1; + bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed. + // If the edit box is at the bottom of the screen and if it expands on y + // because of multiline, thz parent container will be moved to top + // The good position can be restored by a press on enter then + bool _WantReturn : 1; // Want return char, don't call the enter action handler + bool _Savable : 1; // should content be saved ? + bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited) + bool _Frozen : 1; // is the control frozen? (cannot edit in it) + + bool _CanRedo : 1; + bool _CanUndo : 1; + + std::vector _NegativeFilter; + + sint _CursorTexID; + sint32 _CursorWidth; + + sint32 _IntegerMinValue; + sint32 _IntegerMaxValue; + uint32 _PositiveIntegerMinValue; + uint32 _PositiveIntegerMaxValue; + + sint32 _ViewTextDeltaX; + + private: + void setupDisplayText(); + void makeTopWindow(); + void handleEventChar(const NLGUI::CEventDescriptorKey &event); + void handleEventString(const NLGUI::CEventDescriptorKey &event); + void setup(); + void triggerOnChangeAH(); + void appendStringFromClipboard(const ucstring &str); + + ucstring getSelection(); + + static CGroupEditBox *_MenuFather; + + static bool isValidAlphaNumSpace(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= '0' && ac <= '9') || + (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z') || + ac==' '; + } + + static bool isValidAlphaNum(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= '0' && ac <= '9') || + (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z'); + } + + static bool isValidAlpha(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z'); + } + + static bool isValidPlayerNameChar(ucchar c) + { + // valid player name (with possible shard prefix / suffix format + return isValidAlpha(c) || c=='.' || c=='(' || c==')'; + } + + static bool isValidFilenameChar(ucchar c) + { + if (c == '\\' || + c == '/' || + c == ':' || + c == '*' || + c == '?' || + c == '\"' || + c == '<' || + c == '>' || + c == '|') return false; + return true; + } + // + bool isFiltered(ucchar c) + { + uint length = (uint)_NegativeFilter.size(); + for (uint k = 0; k < length; ++k) + { + if ((ucchar) _NegativeFilter[k] == c) return true; + } + return false; + } + + static IComboKeyHandler *comboKeyHandler; + + public: + static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; } + + }; + + +} + +#endif // RZ_CTRL_EDITBOX_H + +/* End of ctrl_editbox.h */ diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp new file mode 100644 index 000000000..062981568 --- /dev/null +++ b/code/nel/src/gui/group_editbox.cpp @@ -0,0 +1,1486 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_editbox.h" +#include "nel/misc/command.h" +#include "nel/gui/view_text.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/interface_options.h" +#include "nel/gui/ctrl_draggable.h" +#include "nel/gui/group_container_base.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/db_manager.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; + + +namespace NLGUI +{ + + + ///////////// + // STATICS // + ///////////// + + sint32 CGroupEditBox::_SelectCursorPos = 0; + CGroupEditBox *CGroupEditBox::_MenuFather = NULL; + CGroupEditBox::IComboKeyHandler* CGroupEditBox::comboKeyHandler = NULL; + + + // ---------------------------------------------------------------------------- + NLMISC_REGISTER_OBJECT(CViewBase, CGroupEditBox, std::string, "edit_box"); + + CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : + CGroupEditBoxBase(param), + _BlinkTime(0.f), + _CursorPos(0), + _MaxNumChar(std::numeric_limits::max()), + _MaxNumReturn(std::numeric_limits::max()), + _MaxFloatPrec(20), + _MaxCharsSize(32768), + _FirstVisibleChar(0), + _LastVisibleChar(0), + _SelectingText(false), + _ViewText(NULL), + _MaxHistoric(0), + _CurrentHistoricIndex(-1), + _PrevNumLine(1), + _EntryType(Text), + _Setupped(false), + _BypassNextKey(false), + _BlinkState(false), + _CursorAtPreviousLineEnd(false), + _LooseFocusOnEnter(true), + _ResetFocusOnHide(false), + _BackupFatherContainerPos(false), + _WantReturn(false), + _Savable(true), + _DefaultInputString(false), + _Frozen(false), + _CanRedo(false), + _CanUndo(false), + _CursorTexID(-1), + _CursorWidth(0), + _IntegerMinValue(INT_MIN), + _IntegerMaxValue(INT_MAX), + _PositiveIntegerMinValue(0), + _PositiveIntegerMaxValue(UINT_MAX), + _ViewTextDeltaX(0) + + { + _Prompt = ">"; + _BackSelectColor= CRGBA::White; + _TextSelectColor= CRGBA::Black; + } + + // ---------------------------------------------------------------------------- + CGroupEditBox::~CGroupEditBox() + { + if (this == _CurrSelection) _CurrSelection = NULL; + if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) + { + CWidgetManager::getInstance()->resetCaptureKeyboard(); + } + } + + // ---------------------------------------------------------------------------- + bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CInterfaceGroup::parse(cur, parentGroup)) + return false; + CXMLAutoPtr prop; + + if (! CInterfaceGroup::parse(cur,parentGroup) ) + { + string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + return false; + } + + // NB: use InterfaceGroup "OnEnter" data. Different script params for an historic reason + CAHManager::getInstance()->parseAH(cur, "onenter", "params", _AHOnEnter, _AHOnEnterParams); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange" ); + if (prop) _AHOnChange = (const char *) prop; + prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange_params" ); + if (prop) _ParamsOnChange = (const char *) prop; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_lost" ); + if (prop) _AHOnFocusLost = (const char *) prop; + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_lost_params" ); + if (prop) _AHOnFocusLostParams = (const char *) prop; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus" ); + if (prop) _AHOnFocus = (const char *) prop; + prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_params" ); + if (prop) _AHOnFocusParams = (const char *) prop; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_chars" ); + if (prop) fromString((const char*)prop, _MaxNumChar); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_return" ); + if (prop) fromString((const char*)prop, _MaxNumReturn); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_chars_size" ); + if (prop) fromString((const char*)prop, _MaxCharsSize); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"enter_loose_focus" ); + if (prop) _LooseFocusOnEnter = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"enter_recover_focus" ); + if (prop) _RecoverFocusOnEnter = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"reset_focus_on_hide" ); + if (prop) _ResetFocusOnHide = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" ); + if (prop) _Prompt = (const char*)prop; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" ); + _EntryType = Text; + if (prop) + { + if (stricmp(prop, "text") == 0) _EntryType = Text; + else if (stricmp(prop, "integer") == 0) _EntryType = Integer; + else if (stricmp(prop, "positive_integer") == 0) _EntryType = PositiveInteger; + else if (stricmp(prop, "float") == 0) _EntryType = Float; + else if (stricmp(prop, "positive_float") == 0) _EntryType = PositiveFloat; + else if (stricmp(prop, "alpha") == 0) _EntryType = Alpha; + else if (stricmp(prop, "alpha_num") == 0) _EntryType = AlphaNum; + else if (stricmp(prop, "alpha_num_space") == 0) _EntryType = AlphaNumSpace; + else if (stricmp(prop, "password") == 0) _EntryType = Password; + else if (stricmp(prop, "filename") == 0) _EntryType = Filename; + else if (stricmp(prop, "playername") == 0) _EntryType = PlayerName; + else nlwarning(" Unknown entry type %s", (const char *) prop); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); + if (prop) + { + string tmp = (const char *) prop; + _ListMenuRight = strlwr(tmp); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" ); + if (prop) fromString((const char*)prop, _MaxHistoric); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"backup_father_container_pos" ); + if (prop) _BackupFatherContainerPos = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"want_return" ); + if (prop) _WantReturn = convertBool(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"savable" ); + if (prop) _Savable = convertBool(prop); + + // For float conversion only + prop = (char*) xmlGetProp( cur, (xmlChar*)"max_float_prec" ); + if (prop) + { + fromString((const char*)prop, _MaxFloatPrec); + _MaxFloatPrec = min((uint32)20, _MaxFloatPrec); + } + + // negative characters filter + prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" ); + if (prop) + { + uint length = (uint)strlen(prop); + _NegativeFilter.resize(length); + std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin()); + } + + return true; + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::draw () + { + // + CViewRenderer &rVR = *CViewRenderer::getInstance(); + // + /*CRGBA col; + col.modulateFromColor(CRGBA(64,64,64,255), pIM->getGlobalColorForContent()); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), col ); + */ + + // Frozen? display text in "grayed" + CRGBA bkupTextColor; + if(_Frozen && _ViewText) + { + bkupTextColor= _ViewText->getColor(); + CRGBA grayed= bkupTextColor; + grayed.A>>=2; + _ViewText->setColor(grayed); + } + + // draw the group and thus the text + CInterfaceGroup::draw(); + + // restore the text color if changed + if(_Frozen && _ViewText) + _ViewText->setColor(bkupTextColor); + + // no text setuped? abort + if (!_ViewText) return; + + // Display the selection if needed + if (_CurrSelection == this && _SelectCursorPos!=_CursorPos) + { + sint32 blankTextId= rVR.getBlankTextureId(); + CRGBA col= _BackSelectColor; + col.A= CWidgetManager::getInstance()->getGlobalColorForContent().A; + sint32 minPos= min(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); + sint32 maxPos= max(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); + + // get its position on screen + sint cxMinPos, cyMinPos; + sint cxMaxPos, cyMaxPos; + sint height; + _ViewText->getCharacterPositionFromIndex(minPos, false, cxMinPos, cyMinPos, height); + _ViewText->getCharacterPositionFromIndex(maxPos, false, cxMaxPos, cyMaxPos, height); + + // Multiline selection if cy different! + if(cyMinPos!=cyMaxPos) + { + nlassert(cyMaxPosgetXReal() + cxMinPos, _ViewText->getYReal() + cyMinPos, _ViewText->getW()-cxMinPos, height, 0, 0, blankTextId, col); + + // Draw One quad for all lines into the big selection (if any) + sint32 cyBigQuad= cyMaxPos+height; + if(cyBigQuadgetXReal(), _ViewText->getYReal() + cyBigQuad, _ViewText->getW(), cyMinPos-cyBigQuad, 0, 0, blankTextId, col); + } + + // draw the 3rd quad from the last line from start of line to max pos + rVR.drawRotFlipBitmap(_RenderLayer, _ViewText->getXReal(), _ViewText->getYReal() + cyMaxPos, cxMaxPos, height, 0, 0, blankTextId, col); + } + else + { + rVR.drawRotFlipBitmap(_RenderLayer, _ViewText->getXReal() + cxMinPos, _ViewText->getYReal() + cyMinPos, cxMaxPos-cxMinPos, height, 0, 0, blankTextId, col); + } + + // Draw The Selection String in black + CRGBA bkup= _ViewText->getColor(); + _ViewText->setColor(_TextSelectColor); + _ViewText->enableStringSelection(minPos, maxPos); + // redraw just this string,clipped by the group + CInterfaceGroup::drawElement(_ViewText); + // bkup + _ViewText->setColor(bkup); + _ViewText->disableStringSelection(); + } + + // Display the cursor if needed + if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) + { + _BlinkTime += 0.0025f; + if (_BlinkTime > 0.25f) + { + _BlinkTime = fmodf(_BlinkTime, 0.25f); + _BlinkState = !_BlinkState; + } + if (_BlinkState) // is the cursor shown ? + { + // get its position on screen + sint cx, cy; + sint height; + _ViewText->getCharacterPositionFromIndex(_CursorPos + (sint)_Prompt.length(), _CursorAtPreviousLineEnd, cx, cy, height); + // display the cursor + // get the texture for the cursor + if (_CursorTexID == -1) + { + _CursorTexID = rVR.getTextureIdFromName("text_cursor.tga"); + sint32 dummyCursorHeight; + rVR.getTextureSizeFromId(_CursorTexID, _CursorWidth, dummyCursorHeight); + } + // draw in a layer after to be on TOP of the text + sint32 cursorx = std::max((sint) 0, (sint)(cx - (_CursorWidth >> 1))); + rVR.drawRotFlipBitmap(_RenderLayer+1, _ViewText->getXReal() + cursorx, _ViewText->getYReal() + cy, 3, height, 0, 0, _CursorTexID); + } + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::copy() + { + if (_CurrSelection != this) + { + nlwarning("Selection can only be on focus"); + } + stopParentBlink(); + + // get the selection and copy it + if (CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(getSelection())) + nlinfo ("Chat input was copied in the clipboard"); + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::paste() + { + if(_CurrSelection != NULL) + { + if (_CurrSelection != this) + { + nlwarning("Selection can only be on focus"); + } + cutSelection(); + } + + ucstring sString; + + if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString)) + { + // append string now + appendStringFromClipboard(sString); + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::appendStringFromClipboard(const ucstring &str) + { + stopParentBlink(); + makeTopWindow(); + + writeString(str, true, false); + nlinfo ("Chat input was pasted from the clipboard"); + + triggerOnChangeAH(); + + _CursorAtPreviousLineEnd = false; + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd) + { + sint length = (sint)str.length(); + + ucstring toAppend; + // filter character depending on the entry type + switch (_EntryType) + { + case Text: + case Password: + { + if (_NegativeFilter.empty()) + { + toAppend = str; + } + else + { + for (sint k = 0; k < length; ++k) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + // remove '\r' characters + toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); + + } + break; + case PositiveInteger: + case PositiveFloat: + { + for (sint k = 0; k < length; ++k) + { + if (isdigit(str[k]) || str[k]== ' ' || + (_EntryType==PositiveFloat && str[k]=='.') ) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Integer: + case Float: + { + for (sint k = 0; k < length; ++k) + { + if (isdigit(str[k]) || str[k]== ' ' || str[k]== '-' || + (_EntryType==Float && str[k]=='.') ) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case AlphaNumSpace: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlphaNumSpace(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case AlphaNum: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlphaNum(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Alpha: + { + for (sint k = 0; k < length; ++k) + { + if (isValidAlpha(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case Filename: + { + for (sint k = 0; k < length; ++k) + { + if (isValidFilenameChar(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + break; + case PlayerName: + { + for (sint k = 0; k < length; ++k) + { + if (isValidPlayerNameChar(str[k])) + { + if (!isFiltered(str[k])) + { + toAppend += str[k]; + } + } + } + } + } + length = (sint)toAppend.size(); + if ((uint) (_InputString.length() + length) > _MaxNumChar) + { + length = _MaxNumChar - (sint)_InputString.length(); + } + ucstring toAdd = toAppend.substr(0, length); + sint32 minPos; + sint32 maxPos; + if (_CurrSelection == this) + { + minPos = min(_CursorPos, _SelectCursorPos); + maxPos = max(_CursorPos, _SelectCursorPos); + } + else + { + minPos = _CursorPos; + maxPos = _CursorPos; + } + + nlinfo("%d, %d", minPos, maxPos); + if (replace) + { + _InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(maxPos); + _CursorPos = minPos+(sint32)toAdd.length(); + } + else + { + if (atEnd) + { + _InputString = _InputString.substr(0, maxPos) + toAdd + _InputString.substr(maxPos); + _CursorPos = maxPos; + _SelectCursorPos = _CursorPos; + + } + else + { + _InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(minPos); + _CursorPos = minPos+(sint32)toAdd.length(); + _SelectCursorPos = maxPos+(sint32)toAdd.length(); + } + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) + { + stopParentBlink(); + switch(rEDK.getChar()) + { + case KeyESCAPE: + _CurrentHistoricIndex= -1; + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); + // stop selection + _CurrSelection = NULL; + _CursorAtPreviousLineEnd = false; + break; + case KeyTAB: + makeTopWindow(); + break; + // OTHER + default: + if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) + { + // update historic. + if(_MaxHistoric) + { + if( !_InputString.empty() ) + { + _Historic.push_front(_InputString); + if(_Historic.size()>_MaxHistoric) + _Historic.pop_back(); + } + _CurrentHistoricIndex= -1; + } + + _CursorPos = 0; + // loose the keyboard focus + if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) + { + if(_LooseFocusOnEnter) + CWidgetManager::getInstance()->setCaptureKeyboard(NULL); + } + // stop selection + _CurrSelection = NULL; + _CursorAtPreviousLineEnd = false; + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + } + else + { + // If the char is not alphanumeric -> return. + // if(!isalnum(ec.Char)) + // return + if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) ) + { + if (rEDK.getChar() == KeyRETURN) + { + ucstring copyStr= _InputString; + if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) + break; + } + + // if selection is activated, then cut the selection + if(_CurrSelection != NULL) + { + if (_CurrSelection != this) + { + nlwarning("Selection can only be on focus"); + } + cutSelection(); + } + + ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar(); + if (isFiltered(c)) return; + switch(_EntryType) + { + case Integer: + if (c > 255 || !(c =='-' || c==' ' || isdigit((int) c))) + return; + break; + case PositiveInteger: + if (c > 255 || !(c == ' ' || isdigit((int) c))) + return; + break; + case Float: + if (c > 255 || !(c =='-' || c==' ' || c=='.' || isdigit((int) c))) + return; + break; + case PositiveFloat: + if (c > 255 || !(c == ' ' || c=='.' || isdigit((int) c))) + return; + break; + case AlphaNumSpace: + if (!isValidAlphaNumSpace(c)) + return; + break; + case AlphaNum: + if (!isValidAlphaNum(c)) + return; + break; + case Alpha: + if (!isValidAlpha(c)) + return; + break; + case Filename: + if (!isValidFilenameChar(c)) + return; + break; + case PlayerName: + if (!isValidPlayerNameChar(c)) + return; + break; + default: + break; + } + // verify integer bounds + if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) + { + // estimate new string + ucstring copyStr= _InputString; + ucstring::iterator it = copyStr.begin() + _CursorPos; + copyStr.insert(it, c); + sint32 value; + fromString(copyStr.toString(), value); + // if out of bounds, abort char + if(value<_IntegerMinValue || value>_IntegerMaxValue) + return; + } + // verify integer bounds + if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) + { + // estimate new string + ucstring copyStr= _InputString; + ucstring::iterator it = copyStr.begin() + _CursorPos; + copyStr.insert(it, c); + // \todo yoyo: this doesn't really work i think.... + uint32 value; + fromString(copyStr.toString(), value); + // if out of bounds, abort char + if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue) + return; + } + // verify max num char + if ((uint) _InputString.length() < _MaxNumChar) + { + makeTopWindow(); + ucstring::iterator it = _InputString.begin() + _CursorPos; + _InputString.insert(it, c); + ++ _CursorPos; + triggerOnChangeAH(); + } + if (rEDK.getChar() == KeyRETURN) + { + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + } + } + _CursorAtPreviousLineEnd = false; + } + break; + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK) + { + appendStringFromClipboard(rEDK.getString()); + } + + // ---------------------------------------------------------------------------- + bool CGroupEditBox::undo() + { + if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; + if (!_CanUndo) return false; + _ModifiedInputString = _InputString; + setInputString(_StartInputString); + _CanUndo = false; + _CanRedo = true; + setCursorPos((sint32)_InputString.length()); + setSelectionAll(); + return true; + } + + // ---------------------------------------------------------------------------- + bool CGroupEditBox::redo() + { + if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; + if (!_CanRedo) return false; + setInputString(_ModifiedInputString); + _CanUndo = true; + _CanRedo = false; + setCursorPos((sint32)_InputString.length()); + setSelectionAll(); + return true; + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::triggerOnChangeAH() + { + _CanUndo = true; + _CanRedo = false; + + if (!_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + + } + + // ---------------------------------------------------------------------------- + bool CGroupEditBox::expand() + { + if ((_EntryType == Integer) || + (_EntryType == PositiveInteger) || + (_EntryType == Float) || + (_EntryType == PositiveFloat) || + (_EntryType == AlphaNumSpace) || + (_EntryType == AlphaNum) || + (_EntryType == Alpha) || + (_EntryType == Filename) || + (_EntryType == PlayerName) + ) + return false; + + if(!_InputString.empty()) + { + if (_InputString[0] == '/') + { + makeTopWindow(); + // for french, deutsch and russian, be aware of unicode + std::string command = ucstring(_InputString.substr(1)).toUtf8(); + ICommand::expand(command); + // then back to ucstring + _InputString.fromUtf8(command); + _InputString = '/' + _InputString; + _CursorPos = (sint32)_InputString.length(); + _CursorAtPreviousLineEnd = false; + triggerOnChangeAH(); + return true; + } + } + return false; + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::back() + { + makeTopWindow(); + // if selection is activated and not same cursors pos, then cut the selection + if(_CurrSelection != NULL && _CursorPos != _SelectCursorPos) + { + if (_CurrSelection != this) + { + nlwarning("Selection can only be on focus"); + } + cutSelection(); + _CursorAtPreviousLineEnd = false; + } + // else delete last character + else if(_InputString.size () > 0 && _CursorPos != 0) + { + ucstring::iterator it = _InputString.begin() + (_CursorPos - 1); + _InputString.erase(it); + -- _CursorPos; + _CursorAtPreviousLineEnd = false; + triggerOnChangeAH(); + } + // must stop selection in all case + if (_CurrSelection) + { + if (_CurrSelection != this) + { + nlwarning("Selection can only be on focus"); + } + _CurrSelection = NULL; + } + } + + // ---------------------------------------------------------------------------- + bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (!_Active || !_ViewText) + return false; + if (event.getType() == NLGUI::CEventDescriptor::key) + { + if (_BypassNextKey) + { + _BypassNextKey = false; + return true; + } + /////////////// + // KEY EVENT // + /////////////// + const NLGUI::CEventDescriptorKey &rEDK = (const NLGUI::CEventDescriptorKey&)event; + switch(rEDK.getKeyEventType()) + { + case NLGUI::CEventDescriptorKey::keychar: handleEventChar(rEDK); break; + case NLGUI::CEventDescriptorKey::keystring: handleEventString(rEDK); break; + default: break; + } + // update the text + setInputString(_InputString); + + // if event of type char or string, consider handle all of them + if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) + return true; + // Else filter the EventKeyDown AND EventKeyUp. + else + { + // Look into the input handler Manager if the key combo has to be considered as handled + if( ( CGroupEditBox::comboKeyHandler != NULL ) && comboKeyHandler->isComboKeyChat(rEDK) ) + return true; + else + return false; + } + } + else + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + ///////////////// + // MOUSE EVENT // + ///////////////// + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) + { + if (CWidgetManager::getInstance()->getCapturePointerRight() == this) + { + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + if (!_ListMenuRight.empty()) + { + if (CCtrlDraggable::getDraggedSheet() == NULL) + { + _MenuFather = this; + CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); + stopParentBlink(); + } + } + return true; + } + else + { + return false; + } + } + + if (!isIn(eventDesc.getX(), eventDesc.getY())) + return false; + + // if click, and not frozen, then get the focus + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) + { + _SelectingText = true; + stopParentBlink(); + CWidgetManager::getInstance()->setCaptureKeyboard (this); + // set the right cursor position + uint newCurPos; + bool cursorAtPreviousLineEnd; + _ViewText->getCharacterIndexFromPosition(eventDesc.getX() - _ViewText->getXReal(), eventDesc.getY() - _ViewText->getYReal(), newCurPos, cursorAtPreviousLineEnd); + _CursorAtPreviousLineEnd = cursorAtPreviousLineEnd; + _CursorPos = newCurPos; + _CursorPos -= (sint32)_Prompt.length(); + _CursorPos = std::max(_CursorPos, sint32(0)); + _SelectCursorPos = _CursorPos; + _CurrSelection = NULL; + + return true; + } + // if click, and not frozen, then get the focus + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove && !_Frozen && _SelectingText) + { + // set the right cursor position + uint newCurPos; + bool cursorAtPreviousLineEnd; + _CurrSelection = this; + _ViewText->getCharacterIndexFromPosition(eventDesc.getX() - _ViewText->getXReal(), eventDesc.getY() - _ViewText->getYReal(), newCurPos, cursorAtPreviousLineEnd); + _SelectCursorPos = newCurPos; + _SelectCursorPos -= (sint32)_Prompt.length(); + _SelectCursorPos = std::max(_SelectCursorPos, sint32(0)); + return true; + } + + // if click, and not frozen, then get the focus + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && !_Frozen) + { + _SelectingText = false; + if (_SelectCursorPos == _CursorPos) + _CurrSelection = NULL; + + return true; + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) + { + CWidgetManager::getInstance()->setCapturePointerRight(this); + return true; + } + } + else + { + ////////////////// + // SYSTEM EVENT // + ////////////////// + const NLGUI::CEventDescriptorSystem &eventDesc = (const NLGUI::CEventDescriptorSystem &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) + { + NLGUI::CEventDescriptorActiveCalledOnParent &activeEvent = (NLGUI::CEventDescriptorActiveCalledOnParent &) eventDesc; + if (activeEvent.getActive() == false && _ResetFocusOnHide) + { + CWidgetManager::getInstance()->resetCaptureKeyboard(); + // If a selection was shown, reset it + if (_CurrSelection == this) _CurrSelection = NULL; + } + CInterfaceGroup::handleEvent(activeEvent); + } + + } + return false; + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::setupDisplayText() + { + if (_ViewText) + { + ucstring usTmp; + if (_EntryType == Password) + { + usTmp = _Prompt; + for (uint32 i = 0; i < _InputString.size(); ++i) + usTmp += "*"; + } + else + { + usTmp = _Prompt + _InputString; + } + _ViewText->setText (usTmp); + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::checkCoords() + { + setupDisplayText(); + + CInterfaceGroup::checkCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::updateCoords() + { + if (!_Setupped) + { + setup(); + _Setupped = true; + } + CInterfaceGroup::updateCoords(); + + if (_ViewText) + { + bool bRecalc = false; + + // if the length of the view text exceed the max w we allow, cut it + while (_ViewText->getWReal() > _MaxCharsSize) + { + // Suppr last char + _InputString = _InputString.substr(0, _InputString.size()-1); + + setupDisplayText(); + + _ViewText->updateCoords(); + bRecalc = true; + } + + // if the length of the view text exceed our real size, ensure the Cursor position is at least visible + sint32 viewTextNewX = _ViewText->getX(); + if (_ViewText->getWReal() > _WReal) + { + // Check if cursor visible + sint xCursVT, xCurs, yTmp, hTmp; + // Get the cursor pos from the BL of the viewtext + _ViewText->getCharacterPositionFromIndex(_CursorPos+(sint)_Prompt.size(), false, xCursVT, yTmp, hTmp); + // Get the cursor pos from the BL of the edit box + xCurs = xCursVT - (_XReal - _ViewText->getXReal()); + // If the cursor is outside the edit box move the view text to show the cursor + if (xCurs > _WReal) + { + viewTextNewX = _ViewTextDeltaX - (xCursVT - _WReal); + } + if (xCurs < 0) + { + if ((xCursVT + xCurs) < 0) + viewTextNewX = _ViewTextDeltaX; + else + viewTextNewX = _ViewTextDeltaX - (xCursVT + xCurs); + } + if (_CursorPos == 0) + { + viewTextNewX = _ViewTextDeltaX; + } + } + else + { + viewTextNewX = _ViewTextDeltaX; + } + + // if X position changed, must recompute + if (viewTextNewX != _ViewText->getX()) + { + _ViewText->setX(viewTextNewX); + bRecalc = true; + } + + // recompute position + if (bRecalc) + CInterfaceGroup::updateCoords(); + } + + if (_BackupFatherContainerPos) + { + CGroupContainerBase *gc = static_cast< CGroupContainerBase* >( getEnclosingContainer() ); + + if (gc && !gc->getTouchFlag(true)) + { + + if (_ViewText && _ViewText->getNumLine() <= 1) + { + if (_PrevNumLine > 1) + { + gc->restorePosition(); + CInterfaceGroup::updateCoords(); + } + } + else + { + if (_PrevNumLine <= 1) + { + gc->backupPosition(); + } + } + _PrevNumLine = _ViewText->getNumLine(); + } + else + { + gc->backupPosition(); + } + } + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::clearViews() + { + CInterfaceGroup::clearViews(); + } + + // ---------------------------------------------------------------------------- + void CGroupEditBox::setup() + { + // bind to the controls + _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); + + if(_ViewText == NULL) + nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); + + // For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens) + if(_ViewText) + _ViewText->setMultiLineClipEndSpace(true); + + // Bakcup the delta X of this view text + if(_ViewText) + _ViewTextDeltaX= _ViewText->getX(); + else + _ViewTextDeltaX= 0; + + // read options + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("text_selection"); + if (pIO != NULL) + { + _BackSelectColor= pIO->getValColor("back_select_color"); + _TextSelectColor= pIO->getValColor("text_select_color"); + } + } + + + // ---------------------------------------------------------------------------- + void CGroupEditBox::setInputString(const ucstring &str) + { + _InputString = str; + if (_CursorPos > (sint32) str.length()) + { + _CursorPos = (sint32)str.length(); + _CursorAtPreviousLineEnd = false; + } + if (!_ViewText) return; + setupDisplayText(); + + invalidateCoords(); + } + + + // *************************************************************************** + void CGroupEditBox::setDefaultInputString(const ucstring &str) + { + _DefaultInputString= true; + setInputString(str); + } + + + // *************************************************************************** + sint32 CGroupEditBox::getInputStringAsInt() const + { + sint32 value; + fromString(_InputString.toString(), value); + return value; + } + + // *************************************************************************** + void CGroupEditBox::setInputStringAsInt(sint32 val) + { + setInputString(NLMISC::toString(val)); + } + + // *************************************************************************** + sint64 CGroupEditBox::getInputStringAsInt64() const + { + sint64 value; + fromString(_InputString.toString(), value); + return value; + } + + // *************************************************************************** + void CGroupEditBox::setInputStringAsInt64(sint64 val) + { + setInputString(NLMISC::toString(val)); + } + + // *************************************************************************** + float CGroupEditBox::getInputStringAsFloat() const + { + float value; + fromString(_InputString.toString(), value); + return value; + } + + // *************************************************************************** + void CGroupEditBox::setInputStringAsFloat(float val) + { + string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f"; + setInputString(NLMISC::toString(fmt.c_str(), val)); + } + + // *************************************************************************** + void CGroupEditBox::cutSelection() + { + sint32 minPos= min(_CursorPos, _SelectCursorPos); + sint32 maxPos= max(_CursorPos, _SelectCursorPos); + // cut the selection + if(!_InputString.empty()) + { + _InputString= _InputString.substr(0, minPos) + _InputString.substr(maxPos); + } + _CurrSelection = NULL; + _CursorPos= minPos; + triggerOnChangeAH(); + } + + // *************************************************************************** + ucstring CGroupEditBox::getSelection() + { + sint32 minPos= min(_CursorPos, _SelectCursorPos); + sint32 maxPos= max(_CursorPos, _SelectCursorPos); + // get the selection + return _InputString.substr(minPos, maxPos-minPos); + } + + + + // *************************************************************************** + void CGroupEditBox::setSelectionAll() + { + if(!_InputString.empty()) + { + _CurrSelection = this; + _SelectCursorPos= 0; + _CursorPos= (sint32)_InputString.size(); + _CursorAtPreviousLineEnd = false; + } + } + + // *************************************************************************** + void CGroupEditBox::setActive(bool active) + { + if (!active && _ResetFocusOnHide) + CWidgetManager::getInstance()->resetCaptureKeyboard(); + + CInterfaceGroup::setActive(active); + } + + // *************************************************************************** + void CGroupEditBox::setInputStringAsStdString(const std::string &str) + { + setInputString(ucstring(str)); + } + + // *************************************************************************** + std::string CGroupEditBox::getInputStringAsStdString() const + { + std::string result; + _InputString.toString(result); + return result; + } + + // *************************************************************************** + void CGroupEditBox::setInputStringAsUtf8(const std::string &str) + { + ucstring tmp; + tmp.fromUtf8(str); + setInputString(tmp); + } + + // *************************************************************************** + std::string CGroupEditBox::getInputStringAsUtf8() const + { + return _InputString.toUtf8(); + } + + // *************************************************************************** + void CGroupEditBox::setCommand(const ucstring &command, bool execute) + { + // do nothing if frozen + if(_Frozen) + return; + + // set the string and maybe execute + setInputString((ucchar) '/' + command); + if (execute) + { + // stop selection + _CurrSelection = NULL; + _CursorAtPreviousLineEnd = false; + CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); + } + else + { + CWidgetManager::getInstance()->setCaptureKeyboard (this); + _CursorPos = (sint32)_InputString.length(); + } + } + + // *************************************************************************** + void CGroupEditBox::makeTopWindow() + { + CInterfaceGroup *root = getRootWindow(); + if(root) + CWidgetManager::getInstance()->setTopWindow(root); + } + + // *************************************************************************** + void CGroupEditBox::clearAllEditBox() + { + _InputString = ""; + _CursorPos = 0; + _CursorAtPreviousLineEnd = false; + if (!_ViewText) return; + setupDisplayText(); + invalidateCoords(); + } + + // *************************************************************************** + sint32 CGroupEditBox::getMaxUsedW() const + { + return _W; + } + + // *************************************************************************** + sint32 CGroupEditBox::getMinUsedW() const + { + return _W; + } + + // *************************************************************************** + bool CGroupEditBox::wantSerialConfig() const + { + return _Savable && !_InputString.empty(); + } + + // *************************************************************************** + void CGroupEditBox::serialConfig(NLMISC::IStream &f) + { + f.serialVersion(0); + if(_DefaultInputString) // Don't want to save the default input + { + _DefaultInputString= false; + _InputString.clear(); + } + f.serial(_InputString); + f.serial(_CursorPos); + f.serial(_PrevNumLine); + if (f.isReading()) + { + setInputString(_InputString); + + } + // serial selection + bool isSelected = (_CurrSelection == this); + f.serial(isSelected); + if (isSelected) + { + _CurrSelection = this; + f.serial(_SelectCursorPos); + } + } + + // *************************************************************************** + void CGroupEditBox::onQuit() + { + // clear the text and restore backup pos before final save + setInputString(ucstring("")); + _CurrSelection = NULL; + } + + // *************************************************************************** + void CGroupEditBox::onLoadConfig() + { + // config is not saved when there's an empty string, so restore that default state. + setInputString(ucstring("")); + _CurrSelection = NULL; + _PrevNumLine = 1; + } + + + // *************************************************************************** + void CGroupEditBox::elementCaptured(CCtrlBase *capturedElement) + { + // If the input string is the default one, then reset it + if(capturedElement == this) + { + if (_DefaultInputString) + { + _DefaultInputString= false; + setInputString(ucstring()); + } + _CanRedo = false; + _CanUndo = false; + _StartInputString = _ModifiedInputString = _InputString; + } + CInterfaceGroup::elementCaptured(capturedElement); + } + + // *************************************************************************** + void CGroupEditBox::onKeyboardCaptureLost() + { + if (!_AHOnFocusLost.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); + + } + + // *************************************************************************** + int CGroupEditBox::luaSetSelectionAll(CLuaState &ls) + { + const char *funcName = "setSelectionAll"; + CLuaIHM::checkArgCount(ls, funcName, 0); + setSelectionAll(); + return 0; + } + + // *************************************************************************** + void CGroupEditBox::setFocusOnText() + { + // do nothing if frozen + if(_Frozen) + return; + + // else set the focus + CWidgetManager::getInstance()->setCaptureKeyboard (this); + + _CurrSelection = this; + _SelectCursorPos= (sint32)_InputString.size(); + _CursorPos= (sint32)_InputString.size(); + _CursorAtPreviousLineEnd = false; + } + + // *************************************************************************** + int CGroupEditBox::luaSetFocusOnText(CLuaState &ls) + { + const char *funcName = "setFocusOnText"; + CLuaIHM::checkArgCount(ls, funcName, 0); + + setFocusOnText(); + + return 0; + } + + // *************************************************************************** + int CGroupEditBox::luaCancelFocusOnText(CLuaState &ls) + { + const char *funcName = "cancelFocusOnText"; + CLuaIHM::checkArgCount(ls, funcName, 0); + + if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this) + CWidgetManager::getInstance()->resetCaptureKeyboard(); + + _CurrSelection = NULL; + _SelectCursorPos= 0; + _CursorPos= 0; + _CursorAtPreviousLineEnd = false; + + return 0; + } + + // *************************************************************************** + int CGroupEditBox::luaSetupDisplayText(CLuaState &ls) + { + const char *funcName = "setupDisplayText"; + CLuaIHM::checkArgCount(ls, funcName, 0); + setupDisplayText(); + return 0; + } + + // *************************************************************************** + void CGroupEditBox::setColor(NLMISC::CRGBA col) + { + if (_ViewText) + _ViewText->setColor(col); + } + + // *************************************************************************** + void CGroupEditBox::setFrozen (bool state) + { + _Frozen= state; + + // if frozen, loose the focus + if(_Frozen) + { + // stop capture and selection + CWidgetManager::getInstance()->setCaptureKeyboard (NULL); + if(_CurrSelection==this) _CurrSelection = NULL; + // do not allow to recover focus + if (CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) + { + CWidgetManager::getInstance()->resetCaptureKeyboard(); + } + } + } +} + diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 85038deea..bbb52e524 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -30,7 +30,7 @@ #include "entity_cl.h" #include "nel/gui/action_handler.h" #include "entities.h" -#include "interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "permanent_ban.h" #include "global.h" #include "nel/gui/ctrl_text_button.h" diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index e3e43b55e..a5b732c60 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -63,7 +63,7 @@ #include "init_main_loop.h" #include "sheet_manager.h" #include "sound_manager.h" -#include "interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "debug_client.h" #include "user_entity.h" #include "time_client.h" diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index f5e393aac..9ef633596 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -66,7 +66,7 @@ #include "interface_v3/character_3d.h" #include "nel/gui/ctrl_button.h" #include "interface_v3/input_handler_manager.h" -#include "interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/interface_expr.h" #include "init_main_loop.h" #include "continent_manager.h" diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index a9e72c2eb..c64c0a9ea 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -71,7 +71,7 @@ #include "continent_manager.h" #include "continent.h" #include "sky_render.h" -#include "interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "interface_v3/inventory_manager.h" #include "interface_v3/bot_chat_page_all.h" #include "main_loop.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_base.cpp b/code/ryzom/client/src/interface_v3/action_handler_base.cpp index cfb6c6549..e9f413322 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_base.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_base.cpp @@ -21,7 +21,7 @@ #include "interface_manager.h" #include "group_container.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "dbctrl_sheet.h" #include "interface_3d_scene.h" #include "character_3d.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index 72931f511..f65784aa8 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace NLMISC; #include "nel/gui/action_handler.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "interface_manager.h" #include "../client_chat_manager.h" #include "people_interraction.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index d764ea90e..a38912556 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -39,7 +39,7 @@ #include "nel/gui/interface_expr.h" #include "group_menu.h" #include "group_container.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "inventory_manager.h" #include "guild_manager.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 4e12abb10..a610b26fe 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -27,7 +27,7 @@ #include "dbctrl_sheet.h" #include "nel/gui/interface_expr.h" #include "group_container.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_quick_help.h" #include "nel/gui/view_text_id.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index 57fb10631..cfe18adb4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -24,7 +24,7 @@ #include "../sheet_manager.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/interface_expr.h" #include "player_trade.h" #include "../user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index dfbbeafc3..c36bbdfa7 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -19,7 +19,7 @@ #include "interface_manager.h" #include "nel/gui/ctrl_button.h" #include "group_container.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "people_interraction.h" #include "nel/misc/algo.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index fd5d58329..b3ea4d6ff 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -27,7 +27,7 @@ #include "macrocmd_manager.h" #include "chat_window.h" #include "people_interraction.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_html.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 92d4f4897..48e611348 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -30,7 +30,7 @@ #include "../net_manager.h" #include "sbrick_manager.h" #include "sphrase_manager.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "dbview_bar.h" #include "skill_manager.h" #include "game_share/bot_chat_types.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp index ec3ff4d64..9dc8f1a13 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp @@ -22,7 +22,7 @@ #include "guild_manager.h" #include "nel/gui/interface_group.h" #include "nel/gui/action_handler.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "dbctrl_sheet.h" #include "bot_chat_manager.h" #include "bot_chat_page_all.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index aeb455224..e98019b25 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -34,7 +34,7 @@ #include "bot_chat_page_all.h" #include "bot_chat_manager.h" #include "dbctrl_sheet.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_tab.h" #include "group_container.h" #include "action_handler_help.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index d1f376b17..9592697a3 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -31,7 +31,7 @@ #include "../connection.h" // #include "group_container.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_tab.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index da6179fd8..d63871ba2 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -30,11 +30,11 @@ namespace NLGUI class CCtrlBase; class CViewText; class CGroupList; + class CGroupEditBox; } class CChatWindow; class CGroupContainer; -class CGroupEditBox; /** Interface to react to a chat box entry * Derivers should define the msgEntered member function to handle entry event. @@ -122,7 +122,7 @@ public: */ CGroupContainer *getContainer() const { return _Chat; } // - CGroupEditBox *getEditBox() const; + NLGUI::CGroupEditBox *getEditBox() const; /** try to rename the chat window * \return true if success */ @@ -163,7 +163,7 @@ protected: protected: IChatWindowListener *_Listener; NLMISC::CRefPtr _Chat; - CGroupEditBox *_EB; + NLGUI::CGroupEditBox *_EB; bool _ParentBlink; static CChatWindow *_ChatWindowLaunchingCommand; std::vector _Observers; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp index b885a9979..4c3c0ae9d 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp @@ -24,7 +24,7 @@ #include "dbctrl_sheet.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/ctrl_button.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "../client_cfg.h" #include "nel/gui/view_text.h" #include "skill_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h index f37ea9134..c41f0dd83 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_build_phrase.h @@ -31,14 +31,13 @@ namespace NLGUI class CCtrlBaseButton; class CViewText; class CViewBitmap; + class CGroupEditBox; } // *************************************************************************** class CDBCtrlSheet; class CSBrickSheet; -class CGroupEditBox; - // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index 0b103d511..ecf2ba5b9 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -26,7 +26,7 @@ #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/action_handler.h" #include "../time_client.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp deleted file mode 100644 index 1fd5c37cf..000000000 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ /dev/null @@ -1,1481 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_editbox.h" -#include "nel/misc/command.h" -#include "nel/gui/view_text.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/interface_options.h" -#include "nel/gui/ctrl_draggable.h" -#include "nel/gui/group_container_base.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/db_manager.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; - - -///////////// -// STATICS // -///////////// - -sint32 CGroupEditBox::_SelectCursorPos = 0; -CGroupEditBox *CGroupEditBox::_MenuFather = NULL; -CGroupEditBox::IComboKeyHandler* CGroupEditBox::comboKeyHandler = NULL; - - -// ---------------------------------------------------------------------------- -NLMISC_REGISTER_OBJECT(CViewBase, CGroupEditBox, std::string, "edit_box"); - -CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : - CGroupEditBoxBase(param), - _BlinkTime(0.f), - _CursorPos(0), - _MaxNumChar(std::numeric_limits::max()), - _MaxNumReturn(std::numeric_limits::max()), - _MaxFloatPrec(20), - _MaxCharsSize(32768), - _FirstVisibleChar(0), - _LastVisibleChar(0), - _SelectingText(false), - _ViewText(NULL), - _MaxHistoric(0), - _CurrentHistoricIndex(-1), - _PrevNumLine(1), - _EntryType(Text), - _Setupped(false), - _BypassNextKey(false), - _BlinkState(false), - _CursorAtPreviousLineEnd(false), - _LooseFocusOnEnter(true), - _ResetFocusOnHide(false), - _BackupFatherContainerPos(false), - _WantReturn(false), - _Savable(true), - _DefaultInputString(false), - _Frozen(false), - _CanRedo(false), - _CanUndo(false), - _CursorTexID(-1), - _CursorWidth(0), - _IntegerMinValue(INT_MIN), - _IntegerMaxValue(INT_MAX), - _PositiveIntegerMinValue(0), - _PositiveIntegerMaxValue(UINT_MAX), - _ViewTextDeltaX(0) - -{ - _Prompt = ">"; - _BackSelectColor= CRGBA::White; - _TextSelectColor= CRGBA::Black; -} - -// ---------------------------------------------------------------------------- -CGroupEditBox::~CGroupEditBox() -{ - if (this == _CurrSelection) _CurrSelection = NULL; - if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) - { - CWidgetManager::getInstance()->resetCaptureKeyboard(); - } -} - -// ---------------------------------------------------------------------------- -bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CInterfaceGroup::parse(cur, parentGroup)) - return false; - CXMLAutoPtr prop; - - if (! CInterfaceGroup::parse(cur,parentGroup) ) - { - string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - return false; - } - - // NB: use InterfaceGroup "OnEnter" data. Different script params for an historic reason - CAHManager::getInstance()->parseAH(cur, "onenter", "params", _AHOnEnter, _AHOnEnterParams); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange" ); - if (prop) _AHOnChange = (const char *) prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange_params" ); - if (prop) _ParamsOnChange = (const char *) prop; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_lost" ); - if (prop) _AHOnFocusLost = (const char *) prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_lost_params" ); - if (prop) _AHOnFocusLostParams = (const char *) prop; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus" ); - if (prop) _AHOnFocus = (const char *) prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"on_focus_params" ); - if (prop) _AHOnFocusParams = (const char *) prop; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_chars" ); - if (prop) fromString((const char*)prop, _MaxNumChar); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"max_num_return" ); - if (prop) fromString((const char*)prop, _MaxNumReturn); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"max_chars_size" ); - if (prop) fromString((const char*)prop, _MaxCharsSize); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"enter_loose_focus" ); - if (prop) _LooseFocusOnEnter = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"enter_recover_focus" ); - if (prop) _RecoverFocusOnEnter = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"reset_focus_on_hide" ); - if (prop) _ResetFocusOnHide = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" ); - if (prop) _Prompt = (const char*)prop; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" ); - _EntryType = Text; - if (prop) - { - if (stricmp(prop, "text") == 0) _EntryType = Text; - else if (stricmp(prop, "integer") == 0) _EntryType = Integer; - else if (stricmp(prop, "positive_integer") == 0) _EntryType = PositiveInteger; - else if (stricmp(prop, "float") == 0) _EntryType = Float; - else if (stricmp(prop, "positive_float") == 0) _EntryType = PositiveFloat; - else if (stricmp(prop, "alpha") == 0) _EntryType = Alpha; - else if (stricmp(prop, "alpha_num") == 0) _EntryType = AlphaNum; - else if (stricmp(prop, "alpha_num_space") == 0) _EntryType = AlphaNumSpace; - else if (stricmp(prop, "password") == 0) _EntryType = Password; - else if (stricmp(prop, "filename") == 0) _EntryType = Filename; - else if (stricmp(prop, "playername") == 0) _EntryType = PlayerName; - else nlwarning(" Unknown entry type %s", (const char *) prop); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); - if (prop) - { - string tmp = (const char *) prop; - _ListMenuRight = strlwr(tmp); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" ); - if (prop) fromString((const char*)prop, _MaxHistoric); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"backup_father_container_pos" ); - if (prop) _BackupFatherContainerPos = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"want_return" ); - if (prop) _WantReturn = convertBool(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"savable" ); - if (prop) _Savable = convertBool(prop); - - // For float conversion only - prop = (char*) xmlGetProp( cur, (xmlChar*)"max_float_prec" ); - if (prop) - { - fromString((const char*)prop, _MaxFloatPrec); - _MaxFloatPrec = min((uint32)20, _MaxFloatPrec); - } - - // negative characters filter - prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" ); - if (prop) - { - uint length = (uint)strlen(prop); - _NegativeFilter.resize(length); - std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin()); - } - - return true; -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::draw () -{ - // - CViewRenderer &rVR = *CViewRenderer::getInstance(); - // - /*CRGBA col; - col.modulateFromColor(CRGBA(64,64,64,255), pIM->getGlobalColorForContent()); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), col ); - */ - - // Frozen? display text in "grayed" - CRGBA bkupTextColor; - if(_Frozen && _ViewText) - { - bkupTextColor= _ViewText->getColor(); - CRGBA grayed= bkupTextColor; - grayed.A>>=2; - _ViewText->setColor(grayed); - } - - // draw the group and thus the text - CInterfaceGroup::draw(); - - // restore the text color if changed - if(_Frozen && _ViewText) - _ViewText->setColor(bkupTextColor); - - // no text setuped? abort - if (!_ViewText) return; - - // Display the selection if needed - if (_CurrSelection == this && _SelectCursorPos!=_CursorPos) - { - sint32 blankTextId= rVR.getBlankTextureId(); - CRGBA col= _BackSelectColor; - col.A= CWidgetManager::getInstance()->getGlobalColorForContent().A; - sint32 minPos= min(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); - sint32 maxPos= max(_CursorPos, _SelectCursorPos) + (sint32)_Prompt.length(); - - // get its position on screen - sint cxMinPos, cyMinPos; - sint cxMaxPos, cyMaxPos; - sint height; - _ViewText->getCharacterPositionFromIndex(minPos, false, cxMinPos, cyMinPos, height); - _ViewText->getCharacterPositionFromIndex(maxPos, false, cxMaxPos, cyMaxPos, height); - - // Multiline selection if cy different! - if(cyMinPos!=cyMaxPos) - { - nlassert(cyMaxPosgetXReal() + cxMinPos, _ViewText->getYReal() + cyMinPos, _ViewText->getW()-cxMinPos, height, 0, 0, blankTextId, col); - - // Draw One quad for all lines into the big selection (if any) - sint32 cyBigQuad= cyMaxPos+height; - if(cyBigQuadgetXReal(), _ViewText->getYReal() + cyBigQuad, _ViewText->getW(), cyMinPos-cyBigQuad, 0, 0, blankTextId, col); - } - - // draw the 3rd quad from the last line from start of line to max pos - rVR.drawRotFlipBitmap(_RenderLayer, _ViewText->getXReal(), _ViewText->getYReal() + cyMaxPos, cxMaxPos, height, 0, 0, blankTextId, col); - } - else - { - rVR.drawRotFlipBitmap(_RenderLayer, _ViewText->getXReal() + cxMinPos, _ViewText->getYReal() + cyMinPos, cxMaxPos-cxMinPos, height, 0, 0, blankTextId, col); - } - - // Draw The Selection String in black - CRGBA bkup= _ViewText->getColor(); - _ViewText->setColor(_TextSelectColor); - _ViewText->enableStringSelection(minPos, maxPos); - // redraw just this string,clipped by the group - CInterfaceGroup::drawElement(_ViewText); - // bkup - _ViewText->setColor(bkup); - _ViewText->disableStringSelection(); - } - - // Display the cursor if needed - if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) - { - _BlinkTime += 0.0025f; - if (_BlinkTime > 0.25f) - { - _BlinkTime = fmodf(_BlinkTime, 0.25f); - _BlinkState = !_BlinkState; - } - if (_BlinkState) // is the cursor shown ? - { - // get its position on screen - sint cx, cy; - sint height; - _ViewText->getCharacterPositionFromIndex(_CursorPos + (sint)_Prompt.length(), _CursorAtPreviousLineEnd, cx, cy, height); - // display the cursor - // get the texture for the cursor - if (_CursorTexID == -1) - { - _CursorTexID = rVR.getTextureIdFromName("text_cursor.tga"); - sint32 dummyCursorHeight; - rVR.getTextureSizeFromId(_CursorTexID, _CursorWidth, dummyCursorHeight); - } - // draw in a layer after to be on TOP of the text - sint32 cursorx = std::max((sint) 0, (sint)(cx - (_CursorWidth >> 1))); - rVR.drawRotFlipBitmap(_RenderLayer+1, _ViewText->getXReal() + cursorx, _ViewText->getYReal() + cy, 3, height, 0, 0, _CursorTexID); - } - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::copy() -{ - if (_CurrSelection != this) - { - nlwarning("Selection can only be on focus"); - } - stopParentBlink(); - - // get the selection and copy it - if (CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(getSelection())) - nlinfo ("Chat input was copied in the clipboard"); -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::paste() -{ - if(_CurrSelection != NULL) - { - if (_CurrSelection != this) - { - nlwarning("Selection can only be on focus"); - } - cutSelection(); - } - - ucstring sString; - - if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString)) - { - // append string now - appendStringFromClipboard(sString); - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::appendStringFromClipboard(const ucstring &str) -{ - stopParentBlink(); - makeTopWindow(); - - writeString(str, true, false); - nlinfo ("Chat input was pasted from the clipboard"); - - triggerOnChangeAH(); - - _CursorAtPreviousLineEnd = false; -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd) -{ - sint length = (sint)str.length(); - - ucstring toAppend; - // filter character depending on the entry type - switch (_EntryType) - { - case Text: - case Password: - { - if (_NegativeFilter.empty()) - { - toAppend = str; - } - else - { - for (sint k = 0; k < length; ++k) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - // remove '\r' characters - toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end()); - - } - break; - case PositiveInteger: - case PositiveFloat: - { - for (sint k = 0; k < length; ++k) - { - if (isdigit(str[k]) || str[k]== ' ' || - (_EntryType==PositiveFloat && str[k]=='.') ) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case Integer: - case Float: - { - for (sint k = 0; k < length; ++k) - { - if (isdigit(str[k]) || str[k]== ' ' || str[k]== '-' || - (_EntryType==Float && str[k]=='.') ) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case AlphaNumSpace: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlphaNumSpace(str[k])) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case AlphaNum: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlphaNum(str[k])) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case Alpha: - { - for (sint k = 0; k < length; ++k) - { - if (isValidAlpha(str[k])) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case Filename: - { - for (sint k = 0; k < length; ++k) - { - if (isValidFilenameChar(str[k])) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - break; - case PlayerName: - { - for (sint k = 0; k < length; ++k) - { - if (isValidPlayerNameChar(str[k])) - { - if (!isFiltered(str[k])) - { - toAppend += str[k]; - } - } - } - } - } - length = (sint)toAppend.size(); - if ((uint) (_InputString.length() + length) > _MaxNumChar) - { - length = _MaxNumChar - (sint)_InputString.length(); - } - ucstring toAdd = toAppend.substr(0, length); - sint32 minPos; - sint32 maxPos; - if (_CurrSelection == this) - { - minPos = min(_CursorPos, _SelectCursorPos); - maxPos = max(_CursorPos, _SelectCursorPos); - } - else - { - minPos = _CursorPos; - maxPos = _CursorPos; - } - - nlinfo("%d, %d", minPos, maxPos); - if (replace) - { - _InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(maxPos); - _CursorPos = minPos+(sint32)toAdd.length(); - } - else - { - if (atEnd) - { - _InputString = _InputString.substr(0, maxPos) + toAdd + _InputString.substr(maxPos); - _CursorPos = maxPos; - _SelectCursorPos = _CursorPos; - - } - else - { - _InputString = _InputString.substr(0, minPos) + toAdd + _InputString.substr(minPos); - _CursorPos = minPos+(sint32)toAdd.length(); - _SelectCursorPos = maxPos+(sint32)toAdd.length(); - } - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK) -{ - stopParentBlink(); - switch(rEDK.getChar()) - { - case KeyESCAPE: - _CurrentHistoricIndex= -1; - CWidgetManager::getInstance()->setCaptureKeyboard(NULL); - // stop selection - _CurrSelection = NULL; - _CursorAtPreviousLineEnd = false; - break; - case KeyTAB: - makeTopWindow(); - break; - // OTHER - default: - if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) - { - // update historic. - if(_MaxHistoric) - { - if( !_InputString.empty() ) - { - _Historic.push_front(_InputString); - if(_Historic.size()>_MaxHistoric) - _Historic.pop_back(); - } - _CurrentHistoricIndex= -1; - } - - _CursorPos = 0; - // loose the keyboard focus - if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) - { - if(_LooseFocusOnEnter) - CWidgetManager::getInstance()->setCaptureKeyboard(NULL); - } - // stop selection - _CurrSelection = NULL; - _CursorAtPreviousLineEnd = false; - CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); - } - else - { - // If the char is not alphanumeric -> return. - // if(!isalnum(ec.Char)) - // return - if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) ) - { - if (rEDK.getChar() == KeyRETURN) - { - ucstring copyStr= _InputString; - if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn) - break; - } - - // if selection is activated, then cut the selection - if(_CurrSelection != NULL) - { - if (_CurrSelection != this) - { - nlwarning("Selection can only be on focus"); - } - cutSelection(); - } - - ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar(); - if (isFiltered(c)) return; - switch(_EntryType) - { - case Integer: - if (c > 255 || !(c =='-' || c==' ' || isdigit((int) c))) - return; - break; - case PositiveInteger: - if (c > 255 || !(c == ' ' || isdigit((int) c))) - return; - break; - case Float: - if (c > 255 || !(c =='-' || c==' ' || c=='.' || isdigit((int) c))) - return; - break; - case PositiveFloat: - if (c > 255 || !(c == ' ' || c=='.' || isdigit((int) c))) - return; - break; - case AlphaNumSpace: - if (!isValidAlphaNumSpace(c)) - return; - break; - case AlphaNum: - if (!isValidAlphaNum(c)) - return; - break; - case Alpha: - if (!isValidAlpha(c)) - return; - break; - case Filename: - if (!isValidFilenameChar(c)) - return; - break; - case PlayerName: - if (!isValidPlayerNameChar(c)) - return; - break; - default: - break; - } - // verify integer bounds - if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX)) - { - // estimate new string - ucstring copyStr= _InputString; - ucstring::iterator it = copyStr.begin() + _CursorPos; - copyStr.insert(it, c); - sint32 value; - fromString(copyStr.toString(), value); - // if out of bounds, abort char - if(value<_IntegerMinValue || value>_IntegerMaxValue) - return; - } - // verify integer bounds - if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX)) - { - // estimate new string - ucstring copyStr= _InputString; - ucstring::iterator it = copyStr.begin() + _CursorPos; - copyStr.insert(it, c); - // \todo yoyo: this doesn't really work i think.... - uint32 value; - fromString(copyStr.toString(), value); - // if out of bounds, abort char - if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue) - return; - } - // verify max num char - if ((uint) _InputString.length() < _MaxNumChar) - { - makeTopWindow(); - ucstring::iterator it = _InputString.begin() + _CursorPos; - _InputString.insert(it, c); - ++ _CursorPos; - triggerOnChangeAH(); - } - if (rEDK.getChar() == KeyRETURN) - { - CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); - } - } - _CursorAtPreviousLineEnd = false; - } - break; - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK) -{ - appendStringFromClipboard(rEDK.getString()); -} - -// ---------------------------------------------------------------------------- -bool CGroupEditBox::undo() -{ - if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; - if (!_CanUndo) return false; - _ModifiedInputString = _InputString; - setInputString(_StartInputString); - _CanUndo = false; - _CanRedo = true; - setCursorPos((sint32)_InputString.length()); - setSelectionAll(); - return true; -} - -// ---------------------------------------------------------------------------- -bool CGroupEditBox::redo() -{ - if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; - if (!_CanRedo) return false; - setInputString(_ModifiedInputString); - _CanUndo = true; - _CanRedo = false; - setCursorPos((sint32)_InputString.length()); - setSelectionAll(); - return true; -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::triggerOnChangeAH() -{ - _CanUndo = true; - _CanRedo = false; - - if (!_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - -} - -// ---------------------------------------------------------------------------- -bool CGroupEditBox::expand() -{ - if ((_EntryType == Integer) || - (_EntryType == PositiveInteger) || - (_EntryType == Float) || - (_EntryType == PositiveFloat) || - (_EntryType == AlphaNumSpace) || - (_EntryType == AlphaNum) || - (_EntryType == Alpha) || - (_EntryType == Filename) || - (_EntryType == PlayerName) - ) - return false; - - if(!_InputString.empty()) - { - if (_InputString[0] == '/') - { - makeTopWindow(); - // for french, deutsch and russian, be aware of unicode - std::string command = ucstring(_InputString.substr(1)).toUtf8(); - ICommand::expand(command); - // then back to ucstring - _InputString.fromUtf8(command); - _InputString = '/' + _InputString; - _CursorPos = (sint32)_InputString.length(); - _CursorAtPreviousLineEnd = false; - triggerOnChangeAH(); - return true; - } - } - return false; -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::back() -{ - makeTopWindow(); - // if selection is activated and not same cursors pos, then cut the selection - if(_CurrSelection != NULL && _CursorPos != _SelectCursorPos) - { - if (_CurrSelection != this) - { - nlwarning("Selection can only be on focus"); - } - cutSelection(); - _CursorAtPreviousLineEnd = false; - } - // else delete last character - else if(_InputString.size () > 0 && _CursorPos != 0) - { - ucstring::iterator it = _InputString.begin() + (_CursorPos - 1); - _InputString.erase(it); - -- _CursorPos; - _CursorAtPreviousLineEnd = false; - triggerOnChangeAH(); - } - // must stop selection in all case - if (_CurrSelection) - { - if (_CurrSelection != this) - { - nlwarning("Selection can only be on focus"); - } - _CurrSelection = NULL; - } -} - -// ---------------------------------------------------------------------------- -bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active || !_ViewText) - return false; - if (event.getType() == NLGUI::CEventDescriptor::key) - { - if (_BypassNextKey) - { - _BypassNextKey = false; - return true; - } - /////////////// - // KEY EVENT // - /////////////// - const NLGUI::CEventDescriptorKey &rEDK = (const NLGUI::CEventDescriptorKey&)event; - switch(rEDK.getKeyEventType()) - { - case NLGUI::CEventDescriptorKey::keychar: handleEventChar(rEDK); break; - case NLGUI::CEventDescriptorKey::keystring: handleEventString(rEDK); break; - default: break; - } - // update the text - setInputString(_InputString); - - // if event of type char or string, consider handle all of them - if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring ) - return true; - // Else filter the EventKeyDown AND EventKeyUp. - else - { - // Look into the input handler Manager if the key combo has to be considered as handled - if( ( CGroupEditBox::comboKeyHandler != NULL ) && comboKeyHandler->isComboKeyChat(rEDK) ) - return true; - else - return false; - } - } - else - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - ///////////////// - // MOUSE EVENT // - ///////////////// - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) - { - if (CWidgetManager::getInstance()->getCapturePointerRight() == this) - { - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - if (!_ListMenuRight.empty()) - { - if (CCtrlDraggable::getDraggedSheet() == NULL) - { - _MenuFather = this; - CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); - stopParentBlink(); - } - } - return true; - } - else - { - return false; - } - } - - if (!isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && !_Frozen) - { - _SelectingText = true; - stopParentBlink(); - CWidgetManager::getInstance()->setCaptureKeyboard (this); - // set the right cursor position - uint newCurPos; - bool cursorAtPreviousLineEnd; - _ViewText->getCharacterIndexFromPosition(eventDesc.getX() - _ViewText->getXReal(), eventDesc.getY() - _ViewText->getYReal(), newCurPos, cursorAtPreviousLineEnd); - _CursorAtPreviousLineEnd = cursorAtPreviousLineEnd; - _CursorPos = newCurPos; - _CursorPos -= (sint32)_Prompt.length(); - _CursorPos = std::max(_CursorPos, sint32(0)); - _SelectCursorPos = _CursorPos; - _CurrSelection = NULL; - - return true; - } - // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove && !_Frozen && _SelectingText) - { - // set the right cursor position - uint newCurPos; - bool cursorAtPreviousLineEnd; - _CurrSelection = this; - _ViewText->getCharacterIndexFromPosition(eventDesc.getX() - _ViewText->getXReal(), eventDesc.getY() - _ViewText->getYReal(), newCurPos, cursorAtPreviousLineEnd); - _SelectCursorPos = newCurPos; - _SelectCursorPos -= (sint32)_Prompt.length(); - _SelectCursorPos = std::max(_SelectCursorPos, sint32(0)); - return true; - } - - // if click, and not frozen, then get the focus - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup && !_Frozen) - { - _SelectingText = false; - if (_SelectCursorPos == _CursorPos) - _CurrSelection = NULL; - - return true; - } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown) - { - CWidgetManager::getInstance()->setCapturePointerRight(this); - return true; - } - } - else - { - ////////////////// - // SYSTEM EVENT // - ////////////////// - const NLGUI::CEventDescriptorSystem &eventDesc = (const NLGUI::CEventDescriptorSystem &)event; - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent) - { - NLGUI::CEventDescriptorActiveCalledOnParent &activeEvent = (NLGUI::CEventDescriptorActiveCalledOnParent &) eventDesc; - if (activeEvent.getActive() == false && _ResetFocusOnHide) - { - CWidgetManager::getInstance()->resetCaptureKeyboard(); - // If a selection was shown, reset it - if (_CurrSelection == this) _CurrSelection = NULL; - } - CInterfaceGroup::handleEvent(activeEvent); - } - - } - return false; -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::setupDisplayText() -{ - if (_ViewText) - { - ucstring usTmp; - if (_EntryType == Password) - { - usTmp = _Prompt; - for (uint32 i = 0; i < _InputString.size(); ++i) - usTmp += "*"; - } - else - { - usTmp = _Prompt + _InputString; - } - _ViewText->setText (usTmp); - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::checkCoords() -{ - setupDisplayText(); - - CInterfaceGroup::checkCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::updateCoords() -{ - if (!_Setupped) - { - setup(); - _Setupped = true; - } - CInterfaceGroup::updateCoords(); - - if (_ViewText) - { - bool bRecalc = false; - - // if the length of the view text exceed the max w we allow, cut it - while (_ViewText->getWReal() > _MaxCharsSize) - { - // Suppr last char - _InputString = _InputString.substr(0, _InputString.size()-1); - - setupDisplayText(); - - _ViewText->updateCoords(); - bRecalc = true; - } - - // if the length of the view text exceed our real size, ensure the Cursor position is at least visible - sint32 viewTextNewX = _ViewText->getX(); - if (_ViewText->getWReal() > _WReal) - { - // Check if cursor visible - sint xCursVT, xCurs, yTmp, hTmp; - // Get the cursor pos from the BL of the viewtext - _ViewText->getCharacterPositionFromIndex(_CursorPos+(sint)_Prompt.size(), false, xCursVT, yTmp, hTmp); - // Get the cursor pos from the BL of the edit box - xCurs = xCursVT - (_XReal - _ViewText->getXReal()); - // If the cursor is outside the edit box move the view text to show the cursor - if (xCurs > _WReal) - { - viewTextNewX = _ViewTextDeltaX - (xCursVT - _WReal); - } - if (xCurs < 0) - { - if ((xCursVT + xCurs) < 0) - viewTextNewX = _ViewTextDeltaX; - else - viewTextNewX = _ViewTextDeltaX - (xCursVT + xCurs); - } - if (_CursorPos == 0) - { - viewTextNewX = _ViewTextDeltaX; - } - } - else - { - viewTextNewX = _ViewTextDeltaX; - } - - // if X position changed, must recompute - if (viewTextNewX != _ViewText->getX()) - { - _ViewText->setX(viewTextNewX); - bRecalc = true; - } - - // recompute position - if (bRecalc) - CInterfaceGroup::updateCoords(); - } - - if (_BackupFatherContainerPos) - { - CGroupContainerBase *gc = static_cast< CGroupContainerBase* >( getEnclosingContainer() ); - - if (gc && !gc->getTouchFlag(true)) - { - - if (_ViewText && _ViewText->getNumLine() <= 1) - { - if (_PrevNumLine > 1) - { - gc->restorePosition(); - CInterfaceGroup::updateCoords(); - } - } - else - { - if (_PrevNumLine <= 1) - { - gc->backupPosition(); - } - } - _PrevNumLine = _ViewText->getNumLine(); - } - else - { - gc->backupPosition(); - } - } -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::clearViews() -{ - CInterfaceGroup::clearViews(); -} - -// ---------------------------------------------------------------------------- -void CGroupEditBox::setup() -{ - // bind to the controls - _ViewText = dynamic_cast(CInterfaceGroup::getView("edit_text")); - - if(_ViewText == NULL) - nlwarning("Interface: CGroupEditBox: text 'edit_text' missing or bad type"); - - // For MultiLine editbox, clip the end space, else weird when edit space at end of line (nothing happens) - if(_ViewText) - _ViewText->setMultiLineClipEndSpace(true); - - // Bakcup the delta X of this view text - if(_ViewText) - _ViewTextDeltaX= _ViewText->getX(); - else - _ViewTextDeltaX= 0; - - // read options - CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("text_selection"); - if (pIO != NULL) - { - _BackSelectColor= pIO->getValColor("back_select_color"); - _TextSelectColor= pIO->getValColor("text_select_color"); - } -} - - -// ---------------------------------------------------------------------------- -void CGroupEditBox::setInputString(const ucstring &str) -{ - _InputString = str; - if (_CursorPos > (sint32) str.length()) - { - _CursorPos = (sint32)str.length(); - _CursorAtPreviousLineEnd = false; - } - if (!_ViewText) return; - setupDisplayText(); - - invalidateCoords(); -} - - -// *************************************************************************** -void CGroupEditBox::setDefaultInputString(const ucstring &str) -{ - _DefaultInputString= true; - setInputString(str); -} - - -// *************************************************************************** -sint32 CGroupEditBox::getInputStringAsInt() const -{ - sint32 value; - fromString(_InputString.toString(), value); - return value; -} - -// *************************************************************************** -void CGroupEditBox::setInputStringAsInt(sint32 val) -{ - setInputString(NLMISC::toString(val)); -} - -// *************************************************************************** -sint64 CGroupEditBox::getInputStringAsInt64() const -{ - sint64 value; - fromString(_InputString.toString(), value); - return value; -} - -// *************************************************************************** -void CGroupEditBox::setInputStringAsInt64(sint64 val) -{ - setInputString(NLMISC::toString(val)); -} - -// *************************************************************************** -float CGroupEditBox::getInputStringAsFloat() const -{ - float value; - fromString(_InputString.toString(), value); - return value; -} - -// *************************************************************************** -void CGroupEditBox::setInputStringAsFloat(float val) -{ - string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f"; - setInputString(NLMISC::toString(fmt.c_str(), val)); -} - -// *************************************************************************** -void CGroupEditBox::cutSelection() -{ - sint32 minPos= min(_CursorPos, _SelectCursorPos); - sint32 maxPos= max(_CursorPos, _SelectCursorPos); - // cut the selection - if(!_InputString.empty()) - { - _InputString= _InputString.substr(0, minPos) + _InputString.substr(maxPos); - } - _CurrSelection = NULL; - _CursorPos= minPos; - triggerOnChangeAH(); -} - -// *************************************************************************** -ucstring CGroupEditBox::getSelection() -{ - sint32 minPos= min(_CursorPos, _SelectCursorPos); - sint32 maxPos= max(_CursorPos, _SelectCursorPos); - // get the selection - return _InputString.substr(minPos, maxPos-minPos); -} - - - -// *************************************************************************** -void CGroupEditBox::setSelectionAll() -{ - if(!_InputString.empty()) - { - _CurrSelection = this; - _SelectCursorPos= 0; - _CursorPos= (sint32)_InputString.size(); - _CursorAtPreviousLineEnd = false; - } -} - -// *************************************************************************** -void CGroupEditBox::setActive(bool active) -{ - if (!active && _ResetFocusOnHide) - CWidgetManager::getInstance()->resetCaptureKeyboard(); - - CInterfaceGroup::setActive(active); -} - -// *************************************************************************** -void CGroupEditBox::setInputStringAsStdString(const std::string &str) -{ - setInputString(ucstring(str)); -} - -// *************************************************************************** -std::string CGroupEditBox::getInputStringAsStdString() const -{ - std::string result; - _InputString.toString(result); - return result; -} - -// *************************************************************************** -void CGroupEditBox::setInputStringAsUtf8(const std::string &str) -{ - ucstring tmp; - tmp.fromUtf8(str); - setInputString(tmp); -} - -// *************************************************************************** -std::string CGroupEditBox::getInputStringAsUtf8() const -{ - return _InputString.toUtf8(); -} - -// *************************************************************************** -void CGroupEditBox::setCommand(const ucstring &command, bool execute) -{ - // do nothing if frozen - if(_Frozen) - return; - - // set the string and maybe execute - setInputString((ucchar) '/' + command); - if (execute) - { - // stop selection - _CurrSelection = NULL; - _CursorAtPreviousLineEnd = false; - CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams); - } - else - { - CWidgetManager::getInstance()->setCaptureKeyboard (this); - _CursorPos = (sint32)_InputString.length(); - } -} - -// *************************************************************************** -void CGroupEditBox::makeTopWindow() -{ - CInterfaceGroup *root = getRootWindow(); - if(root) - CWidgetManager::getInstance()->setTopWindow(root); -} - -// *************************************************************************** -void CGroupEditBox::clearAllEditBox() -{ - _InputString = ""; - _CursorPos = 0; - _CursorAtPreviousLineEnd = false; - if (!_ViewText) return; - setupDisplayText(); - invalidateCoords(); -} - -// *************************************************************************** -sint32 CGroupEditBox::getMaxUsedW() const -{ - return _W; -} - -// *************************************************************************** -sint32 CGroupEditBox::getMinUsedW() const -{ - return _W; -} - -// *************************************************************************** -bool CGroupEditBox::wantSerialConfig() const -{ - return _Savable && !_InputString.empty(); -} - -// *************************************************************************** -void CGroupEditBox::serialConfig(NLMISC::IStream &f) -{ - f.serialVersion(0); - if(_DefaultInputString) // Don't want to save the default input - { - _DefaultInputString= false; - _InputString.clear(); - } - f.serial(_InputString); - f.serial(_CursorPos); - f.serial(_PrevNumLine); - if (f.isReading()) - { - setInputString(_InputString); - - } - // serial selection - bool isSelected = (_CurrSelection == this); - f.serial(isSelected); - if (isSelected) - { - _CurrSelection = this; - f.serial(_SelectCursorPos); - } -} - -// *************************************************************************** -void CGroupEditBox::onQuit() -{ - // clear the text and restore backup pos before final save - setInputString(ucstring("")); - _CurrSelection = NULL; -} - -// *************************************************************************** -void CGroupEditBox::onLoadConfig() -{ - // config is not saved when there's an empty string, so restore that default state. - setInputString(ucstring("")); - _CurrSelection = NULL; - _PrevNumLine = 1; -} - - -// *************************************************************************** -void CGroupEditBox::elementCaptured(CCtrlBase *capturedElement) -{ - // If the input string is the default one, then reset it - if(capturedElement == this) - { - if (_DefaultInputString) - { - _DefaultInputString= false; - setInputString(ucstring()); - } - _CanRedo = false; - _CanUndo = false; - _StartInputString = _ModifiedInputString = _InputString; - } - CInterfaceGroup::elementCaptured(capturedElement); -} - -// *************************************************************************** -void CGroupEditBox::onKeyboardCaptureLost() -{ - if (!_AHOnFocusLost.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); - -} - -// *************************************************************************** -int CGroupEditBox::luaSetSelectionAll(CLuaState &ls) -{ - const char *funcName = "setSelectionAll"; - CLuaIHM::checkArgCount(ls, funcName, 0); - setSelectionAll(); - return 0; -} - -// *************************************************************************** -void CGroupEditBox::setFocusOnText() -{ - // do nothing if frozen - if(_Frozen) - return; - - // else set the focus - CWidgetManager::getInstance()->setCaptureKeyboard (this); - - _CurrSelection = this; - _SelectCursorPos= (sint32)_InputString.size(); - _CursorPos= (sint32)_InputString.size(); - _CursorAtPreviousLineEnd = false; -} - -// *************************************************************************** -int CGroupEditBox::luaSetFocusOnText(CLuaState &ls) -{ - const char *funcName = "setFocusOnText"; - CLuaIHM::checkArgCount(ls, funcName, 0); - - setFocusOnText(); - - return 0; -} - -// *************************************************************************** -int CGroupEditBox::luaCancelFocusOnText(CLuaState &ls) -{ - const char *funcName = "cancelFocusOnText"; - CLuaIHM::checkArgCount(ls, funcName, 0); - - if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this) - CWidgetManager::getInstance()->resetCaptureKeyboard(); - - _CurrSelection = NULL; - _SelectCursorPos= 0; - _CursorPos= 0; - _CursorAtPreviousLineEnd = false; - - return 0; -} - -// *************************************************************************** -int CGroupEditBox::luaSetupDisplayText(CLuaState &ls) -{ - const char *funcName = "setupDisplayText"; - CLuaIHM::checkArgCount(ls, funcName, 0); - setupDisplayText(); - return 0; -} - -// *************************************************************************** -void CGroupEditBox::setColor(NLMISC::CRGBA col) -{ - if (_ViewText) - _ViewText->setColor(col); -} - -// *************************************************************************** -void CGroupEditBox::setFrozen (bool state) -{ - _Frozen= state; - - // if frozen, loose the focus - if(_Frozen) - { - // stop capture and selection - CWidgetManager::getInstance()->setCaptureKeyboard (NULL); - if(_CurrSelection==this) _CurrSelection = NULL; - // do not allow to recover focus - if (CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) - { - CWidgetManager::getInstance()->resetCaptureKeyboard(); - } - } -} - diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h deleted file mode 100644 index 2df561ff8..000000000 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ /dev/null @@ -1,363 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_CTRL_EDITBOX_H -#define RZ_CTRL_EDITBOX_H - -#include "nel/gui/interface_group.h" -#include "nel/gui/group_editbox_base.h" -#include "nel/3d/u_texture.h" - -namespace NLGUI -{ - class CEventDescriptor; - class CViewText; -} - -// ---------------------------------------------------------------------------- -class CGroupEditBox : public CGroupEditBoxBase -{ -public: - - class IComboKeyHandler - { - public: - virtual ~IComboKeyHandler(){} - virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0; - }; - - enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with - - DECLARE_UI_CLASS( CGroupEditBox ) - /// Constructor - CGroupEditBox(const TCtorParam ¶m); - /// Dtor - ~CGroupEditBox(); - - bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - - virtual void draw(); - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - - /// Accessors - ucstring getInputString() const { return _InputString; } - const ucstring &getInputStringRef() const { return _InputString; } - const ucstring &getPrompt() const { return _Prompt; } - - /** Set the prompt - * NB : line returns are encoded as '\n', not '\r\n' - */ - void setPrompt(const ucstring &s) { _Prompt = s; } - void setInputString(const ucstring &str); - void setInputStringRef(const ucstring &str) {_InputString = str; }; - void setInputStringAsInt(sint32 val); - sint32 getInputStringAsInt() const; - void setInputStringAsInt64(sint64 val); - sint64 getInputStringAsInt64() const; - void setInputStringAsFloat(float val); - float getInputStringAsFloat() const; - void setInputStringAsStdString(const std::string &str); - std::string getInputStringAsStdString() const; - void setInputStringAsUtf8(const std::string &str); - std::string getInputStringAsUtf8() const; - void setColor(NLMISC::CRGBA col); - - - /// force the selection of all the text - void setSelectionAll(); - - virtual void checkCoords(); - virtual void updateCoords(); - virtual void clearViews (); - - virtual void setActive (bool state); - - static CGroupEditBox *getMenuFather() { return _MenuFather; } - - void setCommand(const ucstring &command, bool execute); - - // Stop parent from blinking - void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } - - // Get / set cursor position - sint32 getCursorPos () const {return _CursorPos;} - void setCursorPos (sint32 pos) {_CursorPos=pos;} - - // Get / set cursor at previous line end - bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;} - void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;} - - // Get / set current selection position - static sint32 getSelectCursorPos () {return _SelectCursorPos;} - static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;} - - // Get the view text - const CViewText *getViewText () const {return _ViewText;} - - // Get the historic information - sint32 getMaxHistoric() const {return _MaxHistoric;} - sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} - void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} - const ucstring &getHistoric(uint32 index) const {return _Historic[index];} - uint32 getNumHistoric() const {return (uint32)_Historic.size ();} - - // Get on change action handler - const std::string &getAHOnChange() const {return _AHOnChange;} - const std::string &getParamsOnChange() const {return _ParamsOnChange;} - - void cutSelection(); - - /// From CInterfaceElement - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - - // Copy the selection into buffer - void copy(); - // Paste the selection into buffer - void paste(); - // Write the string into buffer - void writeString(const ucstring &str, bool replace = true, bool atEnd = true); - - // Expand the expression (true if there was a '/' at the start of the line) - bool expand(); - - // Back space - void back(); - - // ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant) - void bypassNextKey() { _BypassNextKey = true; } - - // True if the editBox loose the focus on enter - bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;} - // - virtual void clearAllEditBox(); - // From CInterfaceElement - virtual bool wantSerialConfig() const; - // From CInterfaceElement - virtual void serialConfig(NLMISC::IStream &f); - // From CInterfaceElement - virtual void onQuit(); - // From CInterfaceElement - virtual void onLoadConfig(); - - // from CCtrlBase - virtual void elementCaptured(CCtrlBase *capturedElement); - - // from CCtrlBase - virtual void onKeyboardCaptureLost(); - - // set the input string as "default". will be reseted at first click (used for user information) - void setDefaultInputString(const ucstring &str); - - // For Interger and PositiveInteger, can specify min and max values - void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} - void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;} - void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;} - void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;} - - void setFocusOnText(); - - int luaSetSelectionAll(CLuaState &ls); - int luaSetupDisplayText(CLuaState &ls); - int luaSetFocusOnText(CLuaState &ls); - int luaCancelFocusOnText(CLuaState &ls); - REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase) - REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText); - REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); - REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); - REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); - REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); - REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); - REFLECT_EXPORT_END - - /** Restore the original value of the edit box. - * This value is captured when the edit box get focus - * (return true if no undo was available) - * Will always fails ifthe edito box do not have the focus - */ - bool undo(); - - /** Cancel last undo operation - * Return true if redo operation is available - */ - bool redo(); - - /// freeze the control (loose focus, and cannot edit) - void setFrozen (bool state); - bool getFrozen () const { return _Frozen; } - -protected: - - // Cursor infos - float _BlinkTime; - sint32 _CursorPos; - uint32 _MaxNumChar; - uint32 _MaxNumReturn; - uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only - sint32 _MaxCharsSize; - sint32 _FirstVisibleChar; - sint32 _LastVisibleChar; - - // Text selection - static sint32 _SelectCursorPos; - bool _SelectingText; - NLMISC::CRGBA _TextSelectColor; - NLMISC::CRGBA _BackSelectColor; - - // Text info - ucstring _Prompt; - ucstring _InputString; - CViewText *_ViewText; - - // undo / redo - ucstring _StartInputString; // value of the input string when focus was acuired first - ucstring _ModifiedInputString; - - - // Historic info - typedef std::deque THistoric; - THistoric _Historic; - uint32 _MaxHistoric; - sint32 _CurrentHistoricIndex; - sint32 _PrevNumLine; - - // Action Handler - std::string _AHOnChange; - std::string _ParamsOnChange; - std::string _ListMenuRight; - - std::string _AHOnFocusLost; - std::string _AHOnFocusLostParams; - - // entry type - TEntryType _EntryType; - - - bool _Setupped : 1; // setup - bool _BypassNextKey : 1; - bool _BlinkState : 1; - bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines) - bool _LooseFocusOnEnter : 1; - bool _ResetFocusOnHide : 1; - bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed. - // If the edit box is at the bottom of the screen and if it expands on y - // because of multiline, thz parent container will be moved to top - // The good position can be restored by a press on enter then - bool _WantReturn : 1; // Want return char, don't call the enter action handler - bool _Savable : 1; // should content be saved ? - bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited) - bool _Frozen : 1; // is the control frozen? (cannot edit in it) - - bool _CanRedo : 1; - bool _CanUndo : 1; - - std::vector _NegativeFilter; - - sint _CursorTexID; - sint32 _CursorWidth; - - sint32 _IntegerMinValue; - sint32 _IntegerMaxValue; - uint32 _PositiveIntegerMinValue; - uint32 _PositiveIntegerMaxValue; - - sint32 _ViewTextDeltaX; - -private: - void setupDisplayText(); - void makeTopWindow(); - void handleEventChar(const NLGUI::CEventDescriptorKey &event); - void handleEventString(const NLGUI::CEventDescriptorKey &event); - void setup(); - void triggerOnChangeAH(); - void appendStringFromClipboard(const ucstring &str); - - ucstring getSelection(); - - static CGroupEditBox *_MenuFather; - - static bool isValidAlphaNumSpace(ucchar c) - { - if (c > 255) return false; - char ac = (char) c; - return (ac >= '0' && ac <= '9') || - (ac >= 'a' && ac <= 'z') || - (ac >= 'A' && ac <= 'Z') || - ac==' '; - } - - static bool isValidAlphaNum(ucchar c) - { - if (c > 255) return false; - char ac = (char) c; - return (ac >= '0' && ac <= '9') || - (ac >= 'a' && ac <= 'z') || - (ac >= 'A' && ac <= 'Z'); - } - - static bool isValidAlpha(ucchar c) - { - if (c > 255) return false; - char ac = (char) c; - return (ac >= 'a' && ac <= 'z') || - (ac >= 'A' && ac <= 'Z'); - } - - static bool isValidPlayerNameChar(ucchar c) - { - // valid player name (with possible shard prefix / suffix format - return isValidAlpha(c) || c=='.' || c=='(' || c==')'; - } - - static bool isValidFilenameChar(ucchar c) - { - if (c == '\\' || - c == '/' || - c == ':' || - c == '*' || - c == '?' || - c == '\"' || - c == '<' || - c == '>' || - c == '|') return false; - return true; - } - // - bool isFiltered(ucchar c) - { - uint length = (uint)_NegativeFilter.size(); - for (uint k = 0; k < length; ++k) - { - if ((ucchar) _NegativeFilter[k] == c) return true; - } - return false; - } - - static IComboKeyHandler *comboKeyHandler; - -public: - static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; } - -}; - - -#endif // RZ_CTRL_EDITBOX_H - -/* End of ctrl_editbox.h */ diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 3f10224c5..422af5755 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -38,7 +38,7 @@ extern "C" #include "nel/gui/ctrl_text_button.h" #include "nel/gui/action_handler.h" #include "group_paragraph.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "interface_manager.h" #include "nel/gui/view_bitmap.h" #include "../actions.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 68341375f..7593780b7 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -25,7 +25,7 @@ #include "../zone_util.h" #include "../user_entity.h" #include "nel/gui/ctrl_button.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "../string_manager_client.h" #include "group_container.h" #include "nel/gui/action_handler.h" diff --git a/code/ryzom/client/src/interface_v3/input_handler_manager.h b/code/ryzom/client/src/interface_v3/input_handler_manager.h index aa5903b72..8491bd53a 100644 --- a/code/ryzom/client/src/interface_v3/input_handler_manager.h +++ b/code/ryzom/client/src/interface_v3/input_handler_manager.h @@ -26,7 +26,7 @@ #include #include "nel/gui/event_descriptor.h" #include "nel/gui/input_handler.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" /** diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index ab028fc3e..a3535a109 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -64,7 +64,7 @@ #include "group_menu.h" #include "group_container.h" #include "nel/gui/group_modal.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_in_scene_bubble.h" #include "group_skills.h" #include "group_compas.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 62a38eace..ec5a22938 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -70,7 +70,7 @@ #include "group_menu.h" #include "group_container.h" #include "group_scrolltext.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_skills.h" #include "group_html_forum.h" #include "group_html_mail.h" diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index cf1a1c2a8..54892a61a 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -76,7 +76,7 @@ #include "../motion/user_controls.h" #include "group_html_cs.h" #include "bonus_malus.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "../entities.h" #include "../sheet_manager.h" // for emotes #include "../global.h" // for emotes diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 1bec84943..d4d2d87ad 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -25,7 +25,7 @@ #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "nel/gui/ctrl_button.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 96a5145d0..099b6f364 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -26,7 +26,7 @@ #include "nel/gui/action_handler.h" #include "dbctrl_sheet.h" #include "nel/gui/ctrl_button.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" #include "group_container.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index ec9043989..1a7593031 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -26,7 +26,7 @@ #include "action_handler_misc.h" #include "chat_window.h" #include "../entity_animation_manager.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "group_menu.h" #include "../client_chat_manager.h" #include "../string_manager_client.h" diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 1d2be1faa..3eb1c500f 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -23,7 +23,7 @@ #include "nel/gui/view_bitmap.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "../client_chat_manager.h" #include "chat_text_manager.h" #include "people_interraction.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 3a2d7f7b1..2df8c0dda 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -40,7 +40,7 @@ #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" #include "nel/gui/group_editbox_base.h" -#include "group_editbox.h" +#include "nel/gui/group_editbox.h" #include "nel/gui/group_tree.h" #include "nel/gui/reflect.h" #include "dbview_bar.h" diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index eb5008ee2..5d37d7c54 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -35,7 +35,7 @@ #include "interface_v3/interface_manager.h" #include "interface_v3/input_handler_manager.h" -#include "interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "interface_v3/group_quick_help.h" #include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 54b498858..f740cdf81 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -81,7 +81,7 @@ using namespace NLGUI; #include "../interface_v3/input_handler_manager.h" #include "../connection.h" #include "../init_main_loop.h" -#include "../interface_v3/group_editbox.h" +#include "nel/gui/group_editbox.h" #include "../landscape_poly_drawer.h" #include "../input.h" #include "../motion/user_controls.h" From d7ea450e204d0c9805cfedd16f0be9867cb7cc3b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 04:23:52 +0200 Subject: [PATCH 095/339] CHANGED: #1471 Moved some code from interface_options_ryzom to interface_options ( needed for CGroupContainer ) --- code/nel/include/nel/gui/interface_options.h | 110 +++++++++ code/nel/src/gui/interface_options.cpp | 210 ++++++++++++++++++ .../src/interface_v3/group_container.cpp | 1 - .../client/src/interface_v3/group_container.h | 6 +- .../interface_v3/interface_options_ryzom.cpp | 209 ----------------- .../interface_v3/interface_options_ryzom.h | 107 --------- 6 files changed, 323 insertions(+), 320 deletions(-) diff --git a/code/nel/include/nel/gui/interface_options.h b/code/nel/include/nel/gui/interface_options.h index 6fcd6c18d..0ef9b0d6d 100644 --- a/code/nel/include/nel/gui/interface_options.h +++ b/code/nel/include/nel/gui/interface_options.h @@ -96,6 +96,116 @@ namespace NLGUI }; + + + // *************************************************************************** + class COptionsLayer : public CInterfaceOptions + { + + public: + COptionsLayer(); + ~COptionsLayer(); + virtual bool parse (xmlNodePtr cur); + + // Container optimizer + + sint32 Tile_Blank; + sint32 Tile_M_Header, Tile_M_Scrollbar; + sint32 Tile_T, Tile_B, Tile_L, Tile_R; + sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open; + + sint32 Scrollbar_Offset_X; + sint32 Scrollbar_W; + sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar; + sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar; + sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar; + + sint32 TxId_L_Header, W_L_Header, H_L_Header; + sint32 TxId_M_Header, W_M_Header, H_M_Header; + sint32 TxId_R_Header, W_R_Header, H_R_Header; + + sint32 TxId_TL, W_TL, H_TL; + sint32 TxId_T, W_T, H_T; + sint32 TxId_TR, W_TR, H_TR; + sint32 TxId_L, W_L, H_L; + sint32 TxId_R, W_R, H_R; + sint32 TxId_Blank, W_Blank, H_Blank; + sint32 TxId_BL, W_BL, H_BL; + sint32 TxId_B, W_B, H_B; + sint32 TxId_BR, W_BR, H_BR; + + sint32 TxId_BL_Open, W_BL_Open, H_BL_Open; + sint32 TxId_B_Open, W_B_Open, H_B_Open; + sint32 TxId_BR_Open, W_BR_Open, H_BR_Open; + sint32 TxId_EL_Open, W_EL_Open, H_EL_Open; + sint32 TxId_EM_Open, W_EM_Open, H_EM_Open; + sint32 TxId_ER_Open, W_ER_Open, H_ER_Open; + sint32 TxId_E_Open, W_E_Open, H_E_Open; + sint32 TxId_M_Open, W_M_Open, H_M_Open; + + sint32 TxId_TL_HighLight; + sint32 TxId_T_HighLight; + sint32 TxId_TR_HighLight; + sint32 TxId_L_HighLight; + sint32 TxId_R_HighLight; + sint32 TxId_BL_HighLight; + sint32 TxId_B_HighLight; + sint32 TxId_BR_HighLight; + + sint32 HeaderH; + }; + + // *************************************************************************** + class COptionsContainerInsertion : public CInterfaceOptions + { + public: + COptionsContainerInsertion(); + virtual bool parse (xmlNodePtr cur); + + sint32 TxId_R_Arrow; + sint32 TxId_L_Arrow; + sint32 TxId_T_Arrow; + sint32 TxId_B_Arrow; + sint32 TxId_InsertionBar; + }; + + // *************************************************************************** + class COptionsContainerMove : public CInterfaceOptions + { + public: + COptionsContainerMove(); + virtual bool parse (xmlNodePtr cur); + + sint32 TrackW; + sint32 TrackH; + sint32 TrackY; + sint32 TrackYWithTopResizer; + sint32 TrackHWithTopResizer; + sint32 ResizerSize; + }; + + + + // *************************************************************************** + /** + * read a list of with no name. id auto incremented + */ + class COptionsList : public CInterfaceOptions + { + public: + COptionsList(); + virtual bool parse (xmlNodePtr cur); + + uint getNumParams() const {return _NumParams;} + + // get a value by its index (from 0 to numParams) + const CInterfaceOptionValue &getValue(uint paramId) const; + + private: + uint _NumParams; + }; + + } #endif // NL_INTERFACE_LAYER_H diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index c4cd33f2c..28c1edafb 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -18,6 +18,7 @@ #include "nel/gui/interface_element.h" #include "nel/gui/interface_options.h" +#include "nel/gui/view_renderer.h" using namespace std; using namespace NLMISC; @@ -124,4 +125,213 @@ namespace NLGUI return getValue(sParamName).getValBool(); } + + + // ---------------------------------------------------------------------------- + // CInterfaceLayer + // ---------------------------------------------------------------------------- + + // ---------------------------------------------------------------------------- + COptionsLayer::COptionsLayer() + { + TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2; + TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2; + Tile_Blank = 0; + Tile_M_Header = Tile_M_Scrollbar = 0; + Tile_T = Tile_B = Tile_L = Tile_R = 0; + Tile_B_Open = Tile_EM_Open = Tile_M_Open = 0; + Scrollbar_Offset_X = 4; + Scrollbar_W = 8; + } + + // ---------------------------------------------------------------------------- + COptionsLayer::~COptionsLayer() + { + } + + // ---------------------------------------------------------------------------- + bool COptionsLayer::parse (xmlNodePtr cur) + { + if (!CInterfaceOptions::parse (cur)) + return false; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + Tile_Blank = getValSInt32("tile_blank"); + Tile_M_Header = getValSInt32("tile_m_header"); + Tile_M_Scrollbar = getValSInt32("tile_m_scrollbar"); + Tile_T = getValSInt32("tile_t"); + Tile_B = getValSInt32("tile_b"); + Tile_L = getValSInt32("tile_l"); + Tile_R = getValSInt32("tile_r"); + Tile_B_Open = getValSInt32("tile_b_open"); + Tile_EM_Open = getValSInt32("tile_em_open"); + Tile_M_Open = getValSInt32("tile_m_open"); + + Scrollbar_Offset_X = getValSInt32("scrollbar_offset_x"); + Scrollbar_W = getValSInt32("scrollbar_size_w"); + TxId_B_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_b")); + rVR.getTextureSizeFromId(TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar); + TxId_M_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_m")); + rVR.getTextureSizeFromId(TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar); + TxId_T_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_t")); + rVR.getTextureSizeFromId(TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar); + + TxId_L_Header = rVR.getTextureIdFromName (getValStr("tx_l_header")); + rVR.getTextureSizeFromId(TxId_L_Header, W_L_Header, H_L_Header); + TxId_M_Header = rVR.getTextureIdFromName (getValStr("tx_m_header")); + rVR.getTextureSizeFromId(TxId_M_Header, W_M_Header, H_M_Header); + TxId_R_Header = rVR.getTextureIdFromName (getValStr("tx_r_header")); + rVR.getTextureSizeFromId(TxId_R_Header, W_R_Header, H_R_Header); + + TxId_TL = rVR.getTextureIdFromName (getValStr("tx_tl")); + rVR.getTextureSizeFromId(TxId_TL, W_TL, H_TL); + TxId_T = rVR.getTextureIdFromName (getValStr("tx_t")); + rVR.getTextureSizeFromId(TxId_T, W_T, H_T); + TxId_TR = rVR.getTextureIdFromName (getValStr("tx_tr")); + rVR.getTextureSizeFromId(TxId_TR, W_TR, H_TR); + TxId_L = rVR.getTextureIdFromName (getValStr("tx_l")); + rVR.getTextureSizeFromId(TxId_L, W_L, H_L); + TxId_R = rVR.getTextureIdFromName (getValStr("tx_r")); + rVR.getTextureSizeFromId(TxId_R, W_R, H_R); + TxId_Blank = rVR.getTextureIdFromName (getValStr("tx_blank")); + rVR.getTextureSizeFromId(TxId_Blank, W_Blank, H_Blank); + TxId_BL = rVR.getTextureIdFromName (getValStr("tx_bl")); + rVR.getTextureSizeFromId(TxId_BL, W_BL, H_BL); + TxId_B = rVR.getTextureIdFromName (getValStr("tx_b")); + rVR.getTextureSizeFromId(TxId_B, W_B, H_B); + TxId_BR = rVR.getTextureIdFromName (getValStr("tx_br")); + rVR.getTextureSizeFromId(TxId_BR, W_BR, H_BR); + // + TxId_BL_Open = rVR.getTextureIdFromName (getValStr("tx_bl_open")); + rVR.getTextureSizeFromId(TxId_BL_Open, W_BL_Open, H_BL_Open); + TxId_B_Open = rVR.getTextureIdFromName (getValStr("tx_b_open")); + rVR.getTextureSizeFromId(TxId_B_Open, W_B_Open, H_B_Open); + TxId_BR_Open = rVR.getTextureIdFromName (getValStr("tx_br_open")); + rVR.getTextureSizeFromId(TxId_BR_Open, W_BR_Open, H_BR_Open); + TxId_EL_Open = rVR.getTextureIdFromName (getValStr("tx_el_open")); + rVR.getTextureSizeFromId(TxId_EL_Open, W_EL_Open, H_EL_Open); + TxId_EM_Open = rVR.getTextureIdFromName (getValStr("tx_em_open")); + rVR.getTextureSizeFromId(TxId_EM_Open, W_EM_Open, H_EM_Open); + TxId_ER_Open = rVR.getTextureIdFromName (getValStr("tx_er_open")); + rVR.getTextureSizeFromId(TxId_ER_Open, W_ER_Open, H_ER_Open); + TxId_M_Open = rVR.getTextureIdFromName (getValStr("tx_m_open")); + rVR.getTextureSizeFromId(TxId_M_Open, W_M_Open, H_M_Open); + TxId_E_Open = rVR.getTextureIdFromName (getValStr("tx_e_open")); + rVR.getTextureSizeFromId(TxId_E_Open, W_E_Open, H_E_Open); + // + + TxId_TL_HighLight = rVR.getTextureIdFromName (getValStr("tx_tl_highlight")); + TxId_T_HighLight = rVR.getTextureIdFromName (getValStr("tx_t_highlight")); + TxId_TR_HighLight = rVR.getTextureIdFromName (getValStr("tx_tr_highlight")); + TxId_L_HighLight = rVR.getTextureIdFromName (getValStr("tx_l_highlight")); + TxId_R_HighLight = rVR.getTextureIdFromName (getValStr("tx_r_highlight")); + TxId_BL_HighLight = rVR.getTextureIdFromName (getValStr("tx_bl_highlight")); + TxId_B_HighLight = rVR.getTextureIdFromName (getValStr("tx_b_highlight")); + TxId_BR_HighLight = rVR.getTextureIdFromName (getValStr("tx_br_highlight")); + + // + HeaderH = getValSInt32("header_h"); + + return true; + } + + // ---------------------------------------------------------------------------- + COptionsContainerInsertion::COptionsContainerInsertion() + { + TxId_R_Arrow = -2; + TxId_L_Arrow = -2; + TxId_T_Arrow = -2; + TxId_B_Arrow = -2; + TxId_InsertionBar = -2; + } + + // ---------------------------------------------------------------------------- + bool COptionsContainerInsertion::parse(xmlNodePtr cur) + { + if (!CInterfaceOptions::parse (cur)) + return false; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + TxId_T_Arrow = rVR.getTextureIdFromName (getValStr("arrow_top")); + TxId_B_Arrow = rVR.getTextureIdFromName (getValStr("arrow_down")); + TxId_L_Arrow = rVR.getTextureIdFromName (getValStr("arrow_left")); + TxId_R_Arrow = rVR.getTextureIdFromName (getValStr("arrow_right")); + TxId_InsertionBar = rVR.getTextureIdFromName (getValStr("insertion_bar")); + + return true; + } + + + // *************************************************************************** + COptionsContainerMove::COptionsContainerMove() + { + TrackW = -8; + TrackH = 22; + TrackY = -4; + TrackYWithTopResizer = -8; + TrackHWithTopResizer = 18; + ResizerSize = 8; + } + + // *************************************************************************** + bool COptionsContainerMove::parse(xmlNodePtr cur) + { + if (!CInterfaceOptions::parse (cur)) + return false; + fromString(getValStr("track_w"), TrackW); + fromString(getValStr("track_h"), TrackH); + fromString(getValStr("track_y"), TrackY); + fromString(getValStr("track_y_with_top_resizer"), TrackYWithTopResizer); + fromString(getValStr("track_h_with_top_resizer"), TrackHWithTopResizer); + fromString(getValStr("resizer_size"), ResizerSize); + return true; + } + + // *************************************************************************** + COptionsList::COptionsList() + { + _NumParams= 0; + } + + // *************************************************************************** + bool COptionsList::parse (xmlNodePtr cur) + { + cur = cur->children; + bool ok = true; + uint id= 0; + while (cur) + { + if ( !stricmp((char*)cur->name,"param") ) + { + CXMLAutoPtr ptr, val; + val = xmlGetProp (cur, (xmlChar*)"value"); + if (!val) + { + nlinfo("param with no name or no value"); + ok = false; + } + else + { + string value = (string((const char*)val)); + _ParamValue[toString(id)].init(value); + id++; + } + } + cur = cur->next; + } + + _NumParams= id; + + return ok; + } + + + // *************************************************************************** + const CInterfaceOptionValue &COptionsList::getValue(uint paramId) const + { + return CInterfaceOptions::getValue(toString(paramId)); + } + + } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index ecf2ba5b9..f787a4f9a 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -22,7 +22,6 @@ #include "group_container.h" #include "interface_manager.h" #include "nel/gui/interface_options.h" -#include "interface_options_ryzom.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/action_handler.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index aa1ac8018..07e2f95ec 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -31,13 +31,13 @@ namespace NLGUI class CViewText; class CViewBitmap; class CGroupList; + class COptionsContainerInsertion; + class COptionsContainerMove; + class COptionsLayer; } -class COptionsContainerInsertion; -class COptionsContainerMove; class CGroupContainer; class CInterfaceManager; -class COptionsLayer; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp index 8e29004fa..11cdc1a91 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp @@ -39,215 +39,6 @@ using namespace NLMISC; extern CEntityAnimationManager *EAM; -// ---------------------------------------------------------------------------- -// CInterfaceLayer -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -COptionsLayer::COptionsLayer() -{ - TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2; - TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2; - Tile_Blank = 0; - Tile_M_Header = Tile_M_Scrollbar = 0; - Tile_T = Tile_B = Tile_L = Tile_R = 0; - Tile_B_Open = Tile_EM_Open = Tile_M_Open = 0; - Scrollbar_Offset_X = 4; - Scrollbar_W = 8; -} - -// ---------------------------------------------------------------------------- -COptionsLayer::~COptionsLayer() -{ -} - -// ---------------------------------------------------------------------------- -bool COptionsLayer::parse (xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - Tile_Blank = getValSInt32("tile_blank"); - Tile_M_Header = getValSInt32("tile_m_header"); - Tile_M_Scrollbar = getValSInt32("tile_m_scrollbar"); - Tile_T = getValSInt32("tile_t"); - Tile_B = getValSInt32("tile_b"); - Tile_L = getValSInt32("tile_l"); - Tile_R = getValSInt32("tile_r"); - Tile_B_Open = getValSInt32("tile_b_open"); - Tile_EM_Open = getValSInt32("tile_em_open"); - Tile_M_Open = getValSInt32("tile_m_open"); - - Scrollbar_Offset_X = getValSInt32("scrollbar_offset_x"); - Scrollbar_W = getValSInt32("scrollbar_size_w"); - TxId_B_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_b")); - rVR.getTextureSizeFromId(TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar); - TxId_M_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_m")); - rVR.getTextureSizeFromId(TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar); - TxId_T_Scrollbar = rVR.getTextureIdFromName (getValStr("scrollbar_tx_t")); - rVR.getTextureSizeFromId(TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar); - - TxId_L_Header = rVR.getTextureIdFromName (getValStr("tx_l_header")); - rVR.getTextureSizeFromId(TxId_L_Header, W_L_Header, H_L_Header); - TxId_M_Header = rVR.getTextureIdFromName (getValStr("tx_m_header")); - rVR.getTextureSizeFromId(TxId_M_Header, W_M_Header, H_M_Header); - TxId_R_Header = rVR.getTextureIdFromName (getValStr("tx_r_header")); - rVR.getTextureSizeFromId(TxId_R_Header, W_R_Header, H_R_Header); - - TxId_TL = rVR.getTextureIdFromName (getValStr("tx_tl")); - rVR.getTextureSizeFromId(TxId_TL, W_TL, H_TL); - TxId_T = rVR.getTextureIdFromName (getValStr("tx_t")); - rVR.getTextureSizeFromId(TxId_T, W_T, H_T); - TxId_TR = rVR.getTextureIdFromName (getValStr("tx_tr")); - rVR.getTextureSizeFromId(TxId_TR, W_TR, H_TR); - TxId_L = rVR.getTextureIdFromName (getValStr("tx_l")); - rVR.getTextureSizeFromId(TxId_L, W_L, H_L); - TxId_R = rVR.getTextureIdFromName (getValStr("tx_r")); - rVR.getTextureSizeFromId(TxId_R, W_R, H_R); - TxId_Blank = rVR.getTextureIdFromName (getValStr("tx_blank")); - rVR.getTextureSizeFromId(TxId_Blank, W_Blank, H_Blank); - TxId_BL = rVR.getTextureIdFromName (getValStr("tx_bl")); - rVR.getTextureSizeFromId(TxId_BL, W_BL, H_BL); - TxId_B = rVR.getTextureIdFromName (getValStr("tx_b")); - rVR.getTextureSizeFromId(TxId_B, W_B, H_B); - TxId_BR = rVR.getTextureIdFromName (getValStr("tx_br")); - rVR.getTextureSizeFromId(TxId_BR, W_BR, H_BR); - // - TxId_BL_Open = rVR.getTextureIdFromName (getValStr("tx_bl_open")); - rVR.getTextureSizeFromId(TxId_BL_Open, W_BL_Open, H_BL_Open); - TxId_B_Open = rVR.getTextureIdFromName (getValStr("tx_b_open")); - rVR.getTextureSizeFromId(TxId_B_Open, W_B_Open, H_B_Open); - TxId_BR_Open = rVR.getTextureIdFromName (getValStr("tx_br_open")); - rVR.getTextureSizeFromId(TxId_BR_Open, W_BR_Open, H_BR_Open); - TxId_EL_Open = rVR.getTextureIdFromName (getValStr("tx_el_open")); - rVR.getTextureSizeFromId(TxId_EL_Open, W_EL_Open, H_EL_Open); - TxId_EM_Open = rVR.getTextureIdFromName (getValStr("tx_em_open")); - rVR.getTextureSizeFromId(TxId_EM_Open, W_EM_Open, H_EM_Open); - TxId_ER_Open = rVR.getTextureIdFromName (getValStr("tx_er_open")); - rVR.getTextureSizeFromId(TxId_ER_Open, W_ER_Open, H_ER_Open); - TxId_M_Open = rVR.getTextureIdFromName (getValStr("tx_m_open")); - rVR.getTextureSizeFromId(TxId_M_Open, W_M_Open, H_M_Open); - TxId_E_Open = rVR.getTextureIdFromName (getValStr("tx_e_open")); - rVR.getTextureSizeFromId(TxId_E_Open, W_E_Open, H_E_Open); - // - - TxId_TL_HighLight = rVR.getTextureIdFromName (getValStr("tx_tl_highlight")); - TxId_T_HighLight = rVR.getTextureIdFromName (getValStr("tx_t_highlight")); - TxId_TR_HighLight = rVR.getTextureIdFromName (getValStr("tx_tr_highlight")); - TxId_L_HighLight = rVR.getTextureIdFromName (getValStr("tx_l_highlight")); - TxId_R_HighLight = rVR.getTextureIdFromName (getValStr("tx_r_highlight")); - TxId_BL_HighLight = rVR.getTextureIdFromName (getValStr("tx_bl_highlight")); - TxId_B_HighLight = rVR.getTextureIdFromName (getValStr("tx_b_highlight")); - TxId_BR_HighLight = rVR.getTextureIdFromName (getValStr("tx_br_highlight")); - - // - HeaderH = getValSInt32("header_h"); - - return true; -} - -// ---------------------------------------------------------------------------- -COptionsContainerInsertion::COptionsContainerInsertion() -{ - TxId_R_Arrow = -2; - TxId_L_Arrow = -2; - TxId_T_Arrow = -2; - TxId_B_Arrow = -2; - TxId_InsertionBar = -2; -} - -// ---------------------------------------------------------------------------- -bool COptionsContainerInsertion::parse(xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - TxId_T_Arrow = rVR.getTextureIdFromName (getValStr("arrow_top")); - TxId_B_Arrow = rVR.getTextureIdFromName (getValStr("arrow_down")); - TxId_L_Arrow = rVR.getTextureIdFromName (getValStr("arrow_left")); - TxId_R_Arrow = rVR.getTextureIdFromName (getValStr("arrow_right")); - TxId_InsertionBar = rVR.getTextureIdFromName (getValStr("insertion_bar")); - - return true; -} - - -// *************************************************************************** -COptionsContainerMove::COptionsContainerMove() -{ - TrackW = -8; - TrackH = 22; - TrackY = -4; - TrackYWithTopResizer = -8; - TrackHWithTopResizer = 18; - ResizerSize = 8; -} - -// *************************************************************************** -bool COptionsContainerMove::parse(xmlNodePtr cur) -{ - if (!CInterfaceOptions::parse (cur)) - return false; - fromString(getValStr("track_w"), TrackW); - fromString(getValStr("track_h"), TrackH); - fromString(getValStr("track_y"), TrackY); - fromString(getValStr("track_y_with_top_resizer"), TrackYWithTopResizer); - fromString(getValStr("track_h_with_top_resizer"), TrackHWithTopResizer); - fromString(getValStr("resizer_size"), ResizerSize); - return true; -} - -// *************************************************************************** -COptionsList::COptionsList() -{ - _NumParams= 0; -} - -// *************************************************************************** -bool COptionsList::parse (xmlNodePtr cur) -{ - cur = cur->children; - bool ok = true; - uint id= 0; - while (cur) - { - if ( !stricmp((char*)cur->name,"param") ) - { - CXMLAutoPtr ptr, val; - val = xmlGetProp (cur, (xmlChar*)"value"); - if (!val) - { - nlinfo("param with no name or no value"); - ok = false; - } - else - { - string value = (string((const char*)val)); - _ParamValue[toString(id)].init(value); - id++; - } - } - cur = cur->next; - } - - _NumParams= id; - - return ok; -} - - -// *************************************************************************** -const CInterfaceOptionValue &COptionsList::getValue(uint paramId) const -{ - return CInterfaceOptions::getValue(toString(paramId)); -} - - // *************************************************************************** bool CMissionIconList::parse(xmlNodePtr cur) { diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h index 14a623e28..24d3b7524 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h @@ -22,113 +22,6 @@ using namespace NLGUI; -// *************************************************************************** -class COptionsLayer : public CInterfaceOptions -{ - -public: - COptionsLayer(); - ~COptionsLayer(); - virtual bool parse (xmlNodePtr cur); - - // Container optimizer - - sint32 Tile_Blank; - sint32 Tile_M_Header, Tile_M_Scrollbar; - sint32 Tile_T, Tile_B, Tile_L, Tile_R; - sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open; - - sint32 Scrollbar_Offset_X; - sint32 Scrollbar_W; - sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar; - sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar; - sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar; - - sint32 TxId_L_Header, W_L_Header, H_L_Header; - sint32 TxId_M_Header, W_M_Header, H_M_Header; - sint32 TxId_R_Header, W_R_Header, H_R_Header; - - sint32 TxId_TL, W_TL, H_TL; - sint32 TxId_T, W_T, H_T; - sint32 TxId_TR, W_TR, H_TR; - sint32 TxId_L, W_L, H_L; - sint32 TxId_R, W_R, H_R; - sint32 TxId_Blank, W_Blank, H_Blank; - sint32 TxId_BL, W_BL, H_BL; - sint32 TxId_B, W_B, H_B; - sint32 TxId_BR, W_BR, H_BR; - - sint32 TxId_BL_Open, W_BL_Open, H_BL_Open; - sint32 TxId_B_Open, W_B_Open, H_B_Open; - sint32 TxId_BR_Open, W_BR_Open, H_BR_Open; - sint32 TxId_EL_Open, W_EL_Open, H_EL_Open; - sint32 TxId_EM_Open, W_EM_Open, H_EM_Open; - sint32 TxId_ER_Open, W_ER_Open, H_ER_Open; - sint32 TxId_E_Open, W_E_Open, H_E_Open; - sint32 TxId_M_Open, W_M_Open, H_M_Open; - - sint32 TxId_TL_HighLight; - sint32 TxId_T_HighLight; - sint32 TxId_TR_HighLight; - sint32 TxId_L_HighLight; - sint32 TxId_R_HighLight; - sint32 TxId_BL_HighLight; - sint32 TxId_B_HighLight; - sint32 TxId_BR_HighLight; - - sint32 HeaderH; -}; - -// *************************************************************************** -class COptionsContainerInsertion : public CInterfaceOptions -{ -public: - COptionsContainerInsertion(); - virtual bool parse (xmlNodePtr cur); - - sint32 TxId_R_Arrow; - sint32 TxId_L_Arrow; - sint32 TxId_T_Arrow; - sint32 TxId_B_Arrow; - sint32 TxId_InsertionBar; -}; - -// *************************************************************************** -class COptionsContainerMove : public CInterfaceOptions -{ -public: - COptionsContainerMove(); - virtual bool parse (xmlNodePtr cur); - - sint32 TrackW; - sint32 TrackH; - sint32 TrackY; - sint32 TrackYWithTopResizer; - sint32 TrackHWithTopResizer; - sint32 ResizerSize; -}; - - - -// *************************************************************************** -/** - * read a list of with no name. id auto incremented - */ -class COptionsList : public CInterfaceOptions -{ -public: - COptionsList(); - virtual bool parse (xmlNodePtr cur); - - uint getNumParams() const {return _NumParams;} - - // get a value by its index (from 0 to numParams) - const CInterfaceOptionValue &getValue(uint paramId) const; - -private: - uint _NumParams; -}; - // *************************************************************************** class CMissionIconList : public CInterfaceOptions { From 2b4298b269ac03d5f3b237140201ae6ad0ccca5a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 06:24:09 +0200 Subject: [PATCH 096/339] CHANGED: #1471 CGroupContainer no longer depends on CInterfaceManager, CViewPointer and the Ryzom game client time values. --- code/nel/include/nel/gui/widget_manager.h | 39 +++++++ code/nel/src/gui/group_editbox.cpp | 4 +- code/nel/src/gui/widget_manager.cpp | 41 +++++++ .../src/interface_v3/group_container.cpp | 109 ++++++++---------- .../client/src/interface_v3/group_container.h | 7 +- .../src/interface_v3/interface_manager.cpp | 28 +---- .../src/interface_v3/interface_manager.h | 29 ----- code/ryzom/client/src/time_client.cpp | 8 ++ 8 files changed, 144 insertions(+), 121 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 8188a68cb..9f6f685c9 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -55,6 +55,21 @@ namespace NLGUI class CWidgetManager{ public: + struct SInterfaceTimes + { + public: + sint64 lastFrameMs; + sint64 thisFrameMs; + sint64 frameDiffMs; + + SInterfaceTimes() + { + lastFrameMs = 0; + thisFrameMs = 0; + frameDiffMs = 0; + } + }; + // Master groups encapsulate all windows struct SMasterGroup { @@ -341,6 +356,21 @@ namespace NLGUI _OverExtendViewText = vt; _OverExtendViewTextBackColor = backGround; } + + float getAlphaRolloverSpeed(); + void resetAlphaRolloverSpeed(); + + void setContainerAlpha( uint8 alpha ); + uint8 getContainerAlpha() const { return _ContainerAlpha; } + uint8 getGlobalContentAlpha() const { return _GlobalContentAlpha; } + uint8 getGlobalContainerAlpha() const { return _GlobalContainerAlpha; } + uint8 getGlobalRolloverFactorContent() const { return _GlobalRolloverFactorContent; } + uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } + + void updateGlobalAlphas(); + + const SInterfaceTimes& getInterfaceTimes() const{ return interfaceTimes; } + void updateInterfaceTimes( const SInterfaceTimes × ){ interfaceTimes = times; } static IParser *parser; @@ -383,6 +413,13 @@ namespace NLGUI NLMISC::CCDBNodeLeaf *_GProp; NLMISC::CCDBNodeLeaf *_BProp; NLMISC::CCDBNodeLeaf *_AProp; + NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; + + uint8 _ContainerAlpha; + uint8 _GlobalContentAlpha; + uint8 _GlobalContainerAlpha; + uint8 _GlobalRolloverFactorContent; + uint8 _GlobalRolloverFactorContainer; bool _MouseHandlingEnabled; @@ -392,6 +429,8 @@ namespace NLGUI // The next ViewText to draw for Over NLMISC::CRefPtr< CInterfaceElement > _OverExtendViewText; NLMISC::CRGBA _OverExtendViewTextBackColor; + + SInterfaceTimes interfaceTimes; }; } diff --git a/code/nel/src/gui/group_editbox.cpp b/code/nel/src/gui/group_editbox.cpp index 062981568..e24649f3c 100644 --- a/code/nel/src/gui/group_editbox.cpp +++ b/code/nel/src/gui/group_editbox.cpp @@ -293,7 +293,9 @@ namespace NLGUI // Display the cursor if needed if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) { - _BlinkTime += 0.0025f; + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + _BlinkTime += ( static_cast< float >( times.frameDiffMs ) / 1000.0f ); if (_BlinkTime > 0.25f) { _BlinkTime = fmodf(_BlinkTime, 0.25f); diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 483df5887..f60349a69 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -29,6 +29,8 @@ namespace { const uint DOUBLE_CLICK_MIN = 50; const uint DOUBLE_CLICK_MAX = 750; + const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; + const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; } namespace NLGUI @@ -960,6 +962,8 @@ namespace NLGUI setCapturePointerRight(NULL); resetColorProps(); + + _AlphaRolloverSpeedDB = NULL; } @@ -1445,6 +1449,37 @@ namespace NLGUI } } + + // Get the alpha roll over speed + float CWidgetManager::getAlphaRolloverSpeed() + { + if( _AlphaRolloverSpeedDB == NULL ) + _AlphaRolloverSpeedDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ALPHA_ROLLOVER_SPEED"); + float fTmp = ROLLOVER_MIN_DELTA_PER_MS + (ROLLOVER_MAX_DELTA_PER_MS - ROLLOVER_MIN_DELTA_PER_MS) * 0.01f * (100 - _AlphaRolloverSpeedDB->getValue32()); + return fTmp*fTmp*fTmp; + } + + void CWidgetManager::resetAlphaRolloverSpeed() + { + _AlphaRolloverSpeedDB = NULL; + } + + void CWidgetManager::setContainerAlpha(uint8 alpha) + { + _ContainerAlpha = alpha; + // update alpha of global color + NLMISC::CRGBA c = getGlobalColor(); + c.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContainerAlpha) >> 8); */ + setGlobalColor( c ); + } + + void CWidgetManager::updateGlobalAlphas() + { + _GlobalContentAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); + _GlobalContainerAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); + _GlobalRolloverFactorContent = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); + _GlobalRolloverFactorContainer = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); + } CWidgetManager::CWidgetManager() { @@ -1456,6 +1491,12 @@ namespace NLGUI _GlobalColor = NLMISC::CRGBA(255,255,255,255); _GlobalColorForContent = _GlobalColor; _ContentAlpha = 255; + _ContainerAlpha = 255; + _GlobalContentAlpha = 255; + _GlobalContainerAlpha = 255; + _GlobalRolloverFactorContent = 255; + _GlobalRolloverFactorContainer = 255; + _AlphaRolloverSpeedDB = NULL; _MouseHandlingEnabled = true; } diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp index f787a4f9a..d101e968b 100644 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ b/code/ryzom/client/src/interface_v3/group_container.cpp @@ -14,28 +14,22 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -// *************************************************************************** -#include "stdpch.h" - #include "group_container.h" -#include "interface_manager.h" #include "nel/gui/interface_options.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/action_handler.h" -#include "../time_client.h" #include "nel/gui/group_editbox.h" #include "nel/gui/view_text_formated.h" #include "nel/gui/view_text_id.h" #include "nel/gui/lua_ihm.h" - #include "nel/gui/group_list.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/view_text.h" #include "nel/gui/view_bitmap.h" -#include "../time_client.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" // *************************************************************************** @@ -330,7 +324,6 @@ bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) // call resize handler of parent container if any if (gc && gc->getAHOnResizePtr() != NULL) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(gc->getAHOnResize(), gc, gc->getAHOnResizeParams()); } } @@ -469,7 +462,6 @@ COptionsContainerInsertion *CCtrlMover::getInsertionOptions() { static NLMISC::CRefPtr insertionOptions; if (insertionOptions) return insertionOptions; - CInterfaceManager *im = CInterfaceManager::getInstance(); insertionOptions = (COptionsContainerInsertion *) CWidgetManager::getInstance()->getOptions("container_insertion_opt"); return insertionOptions; } @@ -483,7 +475,6 @@ void CCtrlMover::draw () #endif // No Op if window is minimized - CInterfaceManager *pIM= CInterfaceManager::getInstance(); if(CViewRenderer::getInstance()->isMinimized()) return; @@ -498,7 +489,6 @@ void CCtrlMover::draw () uint32 sw, sh; rVR.getScreenSize(sw, sh); rVR.setClipWindow (0, 0, (sint32) sw, (sint32) sh); - CInterfaceManager *im = CInterfaceManager::getInstance(); CViewRenderer &vr = *CViewRenderer::getInstance(); // CGroupContainer *gc = dynamic_cast(_Parent); @@ -567,7 +557,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (!_Active) return false; - CInterfaceManager *pIM= CInterfaceManager::getInstance(); + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); if (event.getType() == NLGUI::CEventDescriptor::system) { @@ -577,7 +567,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; if (edsf.hasFocus() == false && _Moving) { - stopMove(pIM); + stopMove(); return true; } } @@ -664,7 +654,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) gc->setHighLighted(false); if (_HasMoved || _MovingInParentList) { - stopMove(pIM); + stopMove(); return true; } if (isIn(eventDesc.getX(), eventDesc.getY())) @@ -674,7 +664,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { _WaitToOpenClose = true; CWidgetManager::getInstance()->registerClockMsgTarget(this); - _WaitToOpenCloseDate = T1; + _WaitToOpenCloseDate = times.thisFrameMs; } else { @@ -716,7 +706,6 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) CWidgetManager::getInstance()->setTopWindow(_Parent); if (gc->getAHOnBeginMovePtr()) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(gc->getAHOnBeginMove(), gc, gc->getAHOnBeginMoveParams()); } return true; @@ -728,7 +717,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) // Leave Moving? if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup ) { - stopMove(pIM); + stopMove(); return true; } // Move @@ -753,7 +742,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) CGroupList *parentList = dynamic_cast(gc->getParent()); if (!parentList) return false; if (parentList->getNbElement() == 1) return false; - setMovingInParent(gc, x, y, pIM, eventDesc); + setMovingInParent(gc, x, y, eventDesc); updateInsertionIndex(parentList, eventDesc.getY()); return true; } @@ -765,7 +754,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) { if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP || abs(y - _Parent->getY()) > DELTA_BEFORE_POPUP) { - setPoped(gc, x, y, pIM, eventDesc); + setPoped(gc, x, y, eventDesc); return true; } } @@ -777,7 +766,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) CGroupList *parentList = dynamic_cast(gc->getParent()); if (!parentList) return false; if (parentList->getNbElement() == 1) return false; - setMovingInParent(gc, x, y, pIM, eventDesc); + setMovingInParent(gc, x, y, eventDesc); updateInsertionIndex(parentList, eventDesc.getY()); return true; } @@ -785,7 +774,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) //if (_Parent->getX() - x > DELTA_BEFORE_POPUP || x - (_Parent->getX() + _Parent->getWReal()) > DELTA_BEFORE_POPUP) if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP) { - setPoped(gc, x, y, pIM, eventDesc); + setPoped(gc, x, y, eventDesc); return true; } } @@ -920,7 +909,7 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) if (_WaitToOpenClose) { uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); - if ((T1 - _WaitToOpenCloseDate) > dbclickDelay) + if ((times.thisFrameMs - _WaitToOpenCloseDate) > dbclickDelay) { CGroupContainer *gc = dynamic_cast(_Parent); if (!gc) return false; @@ -951,18 +940,20 @@ bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) void CCtrlMover::handleScrolling() { const uint pixPerMS = 7; // the number of millisecond to move of one pixel in the parent scrollbar - CInterfaceManager *im = CInterfaceManager::getInstance(); CGroupContainer *gc = dynamic_cast(_Parent); if (!gc) return; CGroupList *gl = gc->getPreviousParentList(); if (!gl) return; + + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + if (_ParentScrollingUp) { sint32 topPosY = gl->getChild(0)->getYReal(); // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar if (gc->getYReal() < topPosY) { - _ScrollTime += DT64; + _ScrollTime += times.frameDiffMs; sint32 deltaY = (sint32) (_ScrollTime / pixPerMS); if (deltaY != 0) { @@ -996,7 +987,7 @@ void CCtrlMover::handleScrolling() sint32 bottomPosY = gl->getChild(gl->getNumChildren() - 1)->getYReal() - gl->getChild(gl->getNumChildren() - 1)->getHReal(); if (gc->getYReal() - gc->getHReal() > bottomPosY) { - _ScrollTime += DT64; + _ScrollTime += times.frameDiffMs; sint32 deltaY = - (sint32) (_ScrollTime / pixPerMS); if (deltaY != 0) { @@ -1030,7 +1021,6 @@ bool CCtrlMover::runTitleActionHandler() { CGroupContainer *gc = dynamic_cast(_Parent); if (!gc) return false; - CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceGroup *gr = gc->isOpen() ? gc->getHeaderOpened() : gc->getHeaderClosed(); if (gr && !gr->getLeftClickHandler().empty()) { @@ -1047,7 +1037,7 @@ bool CCtrlMover::runTitleActionHandler() } // *************************************************************************** -void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc) +void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) { gc->setHighLighted(false); sint32 deltaX = x - _Parent->getX(); @@ -1089,7 +1079,7 @@ void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceMan } // *************************************************************************** -void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc) +void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) { if (!gc) return; sint32 deltaY = y - gc->getY(); @@ -1134,7 +1124,6 @@ void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y _MovingInParentList = true; // register to get time events -// CInterfaceManager *im = CInterfaceManager::getInstance(); } // *************************************************************************** @@ -1162,7 +1151,7 @@ void CCtrlMover::updateInsertionIndex(const CGroupList *gl, sint32 posY) } // *************************************************************************** -void CCtrlMover::stopMove(CInterfaceManager *pIM) +void CCtrlMover::stopMove() { _ParentScrollingUp = false; _ParentScrollingDown = false; @@ -1788,8 +1777,8 @@ void CGroupContainer::draw () if (_LayerSetup == -1) return; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - float speed = pIM->getAlphaRolloverSpeed(); + float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); CRGBA oldGlobalColor = CWidgetManager::getInstance()->getGlobalColor(); CRGBA oldGColForGrayed = CWidgetManager::getInstance()->getGlobalColor(); @@ -1826,7 +1815,7 @@ void CGroupContainer::draw () } _BlinkState = false; } - _BlinkDT += std::min((uint) DT64, blinkDuration); + _BlinkDT += std::min((uint) times.frameDiffMs, blinkDuration); } CGroupContainer *parentGC = NULL; @@ -1870,7 +1859,7 @@ void CGroupContainer::draw () } else { - _CurrentContainerAlpha = _UseGlobalAlpha ? pIM->getGlobalContainerAlpha() : _ContainerAlpha; + _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; } // modulate by container alpha color col.A = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) col.A) >> 8); @@ -1883,9 +1872,9 @@ void CGroupContainer::draw () } else { - uint8 rolloverFactorContent = _UseGlobalAlpha ? (255 - pIM->getGlobalRolloverFactorContent()) : _RolloverAlphaContent; + uint8 rolloverFactorContent = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContent()) : _RolloverAlphaContent; _ICurrentRolloverAlphaContent = (uint8) (255 - rolloverFactorContent + rolloverFactorContent * _CurrentRolloverAlphaContent); - uint8 rolloverFactorContainer = _UseGlobalAlpha ? (255 - pIM->getGlobalRolloverFactorContainer()) : _RolloverAlphaContainer; + uint8 rolloverFactorContainer = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContainer()) : _RolloverAlphaContainer; _ICurrentRolloverAlphaContainer = (uint8) (255 - rolloverFactorContainer + rolloverFactorContainer * _CurrentRolloverAlphaContainer); } // Modulate alpha by rollover alpha @@ -2120,8 +2109,8 @@ void CGroupContainer::draw () } else { - _CurrentContentAlpha = _UseGlobalAlpha ? pIM->getGlobalContentAlpha() : _ContentAlpha; - _CurrentContainerAlpha = _UseGlobalAlpha ? pIM->getGlobalContainerAlpha() : _ContainerAlpha; + _CurrentContentAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContentAlpha() : _ContentAlpha; + _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; } // set content alpha multiplied by rollover alpha CWidgetManager::getInstance()->setContentAlpha((uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8)); @@ -2187,7 +2176,7 @@ void CGroupContainer::draw () // manage rollover - CViewPointer *mousePointer = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); + CViewPointerBase *mousePointer = CWidgetManager::getInstance()->getPointer(); if (mousePointer) { bool dontFade = false; @@ -2227,18 +2216,18 @@ void CGroupContainer::draw () } if (dontFade || isOver) { - _CurrentRolloverAlphaContent += (float) (speed * DT64); + _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); - _CurrentRolloverAlphaContainer += (float) (speed * DT64); + _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); } else { - _CurrentRolloverAlphaContent -= (float) (speed * DT64); + _CurrentRolloverAlphaContent -= (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContent = std::max(0.f, _CurrentRolloverAlphaContent); - _CurrentRolloverAlphaContainer -= (float) (speed * DT64); + _CurrentRolloverAlphaContainer -= (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContainer = std::max(0.f, _CurrentRolloverAlphaContainer); } } @@ -2322,7 +2311,6 @@ void CGroupContainer::open() // call action handler if any if (_AHOnOpen != NULL) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnOpen, this, _AHOnOpenParams); } @@ -2350,7 +2338,6 @@ void CGroupContainer::close() // call action handler if any if (_AHOnClose != NULL) { - CInterfaceManager *im = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnClose, this, _AHOnCloseParams); } } @@ -3193,7 +3180,6 @@ void CGroupContainer::launch () // *************************************************************************** void CGroupContainer::setActive (bool state) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if(state != getActive() && getLayer()==0) { if (state) @@ -3281,7 +3267,6 @@ void CGroupContainer::popupCurrentPos() _Parent = parent; _ParentPos = parent; - CInterfaceManager *im = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->makeWindow(this); CWidgetManager::getInstance()->setTopWindow(this); CWidgetManager::getInstance()->clearViewUnders(); @@ -3338,7 +3323,6 @@ void CGroupContainer::popin(sint32 insertPos /* = -1 */, bool putBackInFatherCon _List->setOfsY(0); _MovingInParentList = false; - CInterfaceManager *im = CInterfaceManager::getInstance(); CWidgetManager::getInstance()->unMakeWindow(this); CWidgetManager::getInstance()->clearViewUnders(); CWidgetManager::getInstance()->clearCtrlsUnders(); @@ -3437,7 +3421,6 @@ COptionsContainerMove *CGroupContainer::getMoveOptions() { static NLMISC::CRefPtr moveOptions; if (moveOptions) return moveOptions; - CInterfaceManager *im = CInterfaceManager::getInstance(); moveOptions = (COptionsContainerMove *) CWidgetManager::getInstance()->getOptions("container_move_opt"); return moveOptions; } @@ -3489,8 +3472,6 @@ public: if (pIC == NULL) return; if (pIC->isLocked()) return; - CInterfaceManager *im = CInterfaceManager::getInstance(); - // check if the window can be really closed CGroupContainer::_ValidateCanDeactivate = true; if (!pIC->getAHOnDeactiveCheck().empty()) @@ -3526,7 +3507,7 @@ public: // pIC->popup(); // - CInterfaceManager *im = CInterfaceManager::getInstance(); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); CWidgetManager::getInstance()->setCapturePointerRight(NULL); } @@ -3551,7 +3532,7 @@ public: pIC->setPopupH(pIC->getH()); // pIC->popin(); - CInterfaceManager *im = CInterfaceManager::getInstance(); + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); CWidgetManager::getInstance()->setCapturePointerRight(NULL); } @@ -3587,7 +3568,7 @@ class CICHelp : public IActionHandler const std::string &helpPage= pIC->getHelpPage(); if(!helpPage.empty()) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); + // open the web browser, and point to the page CAHManager::getInstance()->runActionHandler("launch_help", NULL, "url=" + helpPage); } @@ -3633,15 +3614,17 @@ void CGroupContainer::setOpenable(bool openable) // *************************************************************************** void CGroupContainer::rollOverAlphaUp() { - CInterfaceManager *im = CInterfaceManager::getInstance(); - CViewPointer *vp = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() ); - float speed = im->getAlphaRolloverSpeed(); + + CViewPointerBase *vp = CWidgetManager::getInstance()->getPointer(); + float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); if (!isIn(vp->getX(), vp->getY())) { - _CurrentRolloverAlphaContainer += (float) (speed * DT64); + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); - _CurrentRolloverAlphaContent += (float) (speed * DT64); + _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); } } @@ -3656,7 +3639,7 @@ void CGroupContainer::forceRolloverAlpha() // *************************************************************************** bool CGroupContainer::hasKeyboardFocus() const { - CInterfaceManager *im = CInterfaceManager::getInstance(); + if (CWidgetManager::getInstance()->getCaptureKeyboard() != NULL) { const CGroupEditBox *geb = dynamic_cast(CWidgetManager::getInstance()->getCaptureKeyboard()); @@ -3725,7 +3708,6 @@ void CGroupContainer::setTitleColorAsString(const std::string &col) // *************************************************************************** void CGroupContainer::setModalParentList (const std::string &name) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); _ModalParentNames = name; // can have multiple parent @@ -3933,7 +3915,6 @@ int CGroupContainer::luaSetHeaderColor(CLuaState &ls) // *************************************************************************** CRGBA CGroupContainer::getDrawnHeaderColor () const { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CRGBA c = CRGBA(255,255,255,255); // Display the header in white if we are the last clicked window diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h index 07e2f95ec..fd966aadf 100644 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ b/code/ryzom/client/src/interface_v3/group_container.h @@ -37,7 +37,6 @@ namespace NLGUI } class CGroupContainer; -class CInterfaceManager; // *************************************************************************** /** @@ -136,10 +135,10 @@ private: // static COptionsContainerInsertion *getInsertionOptions(); private: - void setPoped(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc); - void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, CInterfaceManager *pIM, const NLGUI::CEventDescriptorMouse &eventDesc); + void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); + void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); void updateInsertionIndex(const CGroupList *gl, sint32 posY); - void stopMove(CInterfaceManager *pIM); + void stopMove(); bool runTitleActionHandler(); void handleScrolling(); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index a3535a109..b7b7e0958 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -410,17 +410,11 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _ScreenW = _ScreenH = 0; _LastInGameScreenW = _LastInGameScreenH = 0; _DescTextTarget = NULL; - _ContainerAlpha = 255; - _GlobalContentAlpha = 255; - _GlobalContainerAlpha = 255; - _GlobalRolloverFactorContent = 255; - _GlobalRolloverFactorContainer = 255; _MouseOverWindow= false; _ConfigLoaded = false; _LogState = false; _KeysLoaded = false; CWidgetManager::getInstance()->resetColorProps(); - _AlphaRolloverSpeedDB = NULL; _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; @@ -522,7 +516,7 @@ void CInterfaceManager::reset() _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; - _AlphaRolloverSpeedDB = NULL; + } // ------------------------------------------------------------------------------------------------ @@ -1326,7 +1320,7 @@ void CInterfaceManager::uninitInGame1 () _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; - _AlphaRolloverSpeedDB = NULL; + CWidgetManager::getInstance()->resetAlphaRolloverSpeed(); CWidgetManager::getInstance()->resetColorProps(); #ifdef AJM_DEBUG_TRACK_INTERFACE_GROUPS @@ -1942,12 +1936,10 @@ void CInterfaceManager::drawViews(NL3D::UCamera camera) c.B = gc.B; c.A = (uint8) (( (uint16) c.A * (uint16) CWidgetManager::getInstance()->getContentAlpha() ) >> 8); CWidgetManager::getInstance()->setGlobalColorForContent( c ); - + // Update global alphaS from database - _GlobalContentAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ALPHA")->getValue32(); - _GlobalContainerAlpha = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ALPHA")->getValue32(); - _GlobalRolloverFactorContent = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTENT_ROLLOVER_FACTOR")->getValue32(); - _GlobalRolloverFactorContainer = (uint8)NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTAINER_ROLLOVER_FACTOR")->getValue32(); + CWidgetManager::getInstance()->updateGlobalAlphas(); + // Update Player characteristics (for Item carac requirement Redifying) nlctassert(CHARACTERISTICS::NUM_CHARACTERISTICS==8); @@ -3724,16 +3716,6 @@ void CInterfaceManager::launchContextMenuInGame (const std::string &nameOfCM) } } -// *************************************************************************** -void CInterfaceManager::setContainerAlpha(uint8 alpha) -{ - _ContainerAlpha = alpha; - // update alpha of global color - CRGBA c = CWidgetManager::getInstance()->getGlobalColor(); - c.A = alpha;/*(uint8) (( (uint16) _GlobalColor.A * (uint16) _ContainerAlpha) >> 8); */ - CWidgetManager::getInstance()->setGlobalColor( c ); -} - // *************************************************************************** void CInterfaceManager::updateGroupContainerImage(CGroupContainer &gc, uint8 mode) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index f0099a46b..507bcb855 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -51,9 +51,6 @@ #include "../ingame_database_manager.h" -static const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; -static const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; - //the network database node extern CCDBSynchronised IngameDbMngr; @@ -295,15 +292,6 @@ public: void drawContextHelp (); //void drawContextMenu (); - void setContainerAlpha(uint8 alpha); - uint8 getContainerAlpha() const { return _ContainerAlpha; } - - // these values are updated from the DB - uint8 getGlobalContentAlpha() const { return _GlobalContentAlpha; } - uint8 getGlobalContainerAlpha() const { return _GlobalContainerAlpha; } - uint8 getGlobalRolloverFactorContent() const { return _GlobalRolloverFactorContent; } - uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; } - /// Update all the elements void updateAllLocalisedElements (); @@ -453,15 +441,6 @@ public: // @} - // Get the alpha roll over speed - float getAlphaRolloverSpeed() - { - if (!_AlphaRolloverSpeedDB) - _AlphaRolloverSpeedDB = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:ALPHA_ROLLOVER_SPEED"); - float fTmp = ROLLOVER_MIN_DELTA_PER_MS + (ROLLOVER_MAX_DELTA_PER_MS - ROLLOVER_MIN_DELTA_PER_MS) * 0.01f * (100 - _AlphaRolloverSpeedDB->getValue32()); - return fTmp*fTmp*fTmp; - } - // Item Carac Test, get the value bool isItemCaracRequirementMet(CHARACTERISTICS::TCharacteristics type, sint32 value) { @@ -649,13 +628,6 @@ private: uint8 _LocalSyncActionCounterMask; - uint8 _ContainerAlpha; - // - uint8 _GlobalContentAlpha; - uint8 _GlobalContainerAlpha; - uint8 _GlobalRolloverFactorContent; - uint8 _GlobalRolloverFactorContainer; - /// Constructor CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext *textcontext ); @@ -719,7 +691,6 @@ private: NLMISC::CCDBNodeLeaf *_NeutralColor; NLMISC::CCDBNodeLeaf *_WarningColor; NLMISC::CCDBNodeLeaf *_ErrorColor; - NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB; void drawOverExtendViewText(); diff --git a/code/ryzom/client/src/time_client.cpp b/code/ryzom/client/src/time_client.cpp index f07bfbf49..710edf78a 100644 --- a/code/ryzom/client/src/time_client.cpp +++ b/code/ryzom/client/src/time_client.cpp @@ -381,6 +381,14 @@ void updateClientTime() if(NetMngr.isReplayStarting()) NetMngr.startReplay(); #endif + + CWidgetManager::SInterfaceTimes times; + times.lastFrameMs = T0; + times.thisFrameMs = T1; + times.frameDiffMs = DT64; + + CWidgetManager::getInstance()->updateInterfaceTimes( times ); + }// updateClientTime // From bdf9c2b7ba52dbb2fc3fcc103bcdd62f8af5d632 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 07:21:32 +0200 Subject: [PATCH 097/339] CHANGED: #1471 CGroupContainer is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/group_container.h | 656 +++ code/nel/src/gui/group_container.cpp | 4005 +++++++++++++++++ code/ryzom/client/src/cursor_functions.cpp | 2 +- code/ryzom/client/src/entity_cl.cpp | 2 +- .../src/interface_v3/action_handler_base.cpp | 4 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/action_handler_misc.cpp | 2 +- .../interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/action_handler_ui.cpp | 2 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../interface_v3/bot_chat_page_mission.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 4 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../client/src/interface_v3/chat_window.h | 12 +- .../src/interface_v3/dbgroup_list_sheet.cpp | 2 +- .../src/interface_v3/dbgroup_list_sheet.h | 4 +- .../interface_v3/dbgroup_list_sheet_text.cpp | 2 +- .../interface_v3/dbgroup_list_sheet_text.h | 2 +- .../client/src/interface_v3/group_career.h | 2 +- .../client/src/interface_v3/group_compas.h | 2 +- .../src/interface_v3/group_container.cpp | 4003 ---------------- .../client/src/interface_v3/group_container.h | 655 --- .../client/src/interface_v3/group_header.cpp | 2 +- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_in_scene.h | 2 +- .../client/src/interface_v3/group_map.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 2 +- .../client/src/interface_v3/group_table.cpp | 2 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_config.cpp | 2 +- .../src/interface_v3/interface_config.h | 14 +- .../interface_expr_user_fct_game.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_parser.h | 2 +- .../src/interface_v3/interface_pointer.h | 3 +- .../src/interface_v3/inventory_manager.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.h | 7 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../client/src/interface_v3/music_player.h | 2 +- .../client/src/interface_v3/people_list.cpp | 2 +- .../client/src/interface_v3/people_list.h | 2 +- .../register_interface_elements.cpp | 2 +- .../src/interface_v3/task_bar_manager.cpp | 2 +- .../src/interface_v3/task_bar_manager.h | 2 +- .../client/src/interface_v3/view_pointer.cpp | 2 +- .../client/src/interface_v3/view_pointer.h | 3 +- .../client/src/interface_v3/view_radar.cpp | 2 +- code/ryzom/client/src/outpost_manager.cpp | 2 +- .../ryzom/client/src/r2/instance_map_deco.cpp | 2 +- code/ryzom/client/src/r2/npc_editor.cpp | 2 +- code/ryzom/client/src/r2/npc_editor.h | 8 +- code/ryzom/client/src/r2/tool.h | 2 +- 56 files changed, 4738 insertions(+), 4726 deletions(-) create mode 100644 code/nel/include/nel/gui/group_container.h create mode 100644 code/nel/src/gui/group_container.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_container.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_container.h diff --git a/code/nel/include/nel/gui/group_container.h b/code/nel/include/nel/gui/group_container.h new file mode 100644 index 000000000..79abcbccf --- /dev/null +++ b/code/nel/include/nel/gui/group_container.h @@ -0,0 +1,656 @@ +// Ryzom - MMORPG Framework +// 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 RZ_GROUP_CONTAINER_H +#define RZ_GROUP_CONTAINER_H + +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" +#include "nel/misc/smart_ptr.h" + +namespace NLGUI +{ + class CEventDescriptorLocalised; + class CCtrlButton; + class CCtrlScroll; + class CViewText; + class CViewBitmap; + class CGroupList; + class COptionsContainerInsertion; + class COptionsContainerMove; + class COptionsLayer; + class CGroupContainer; + + + + // *************************************************************************** + /** + * class describing a resizer for the container + * \author Matthieu 'TrapII' Besson + * \date 2003 + */ + class CCtrlResizer : public CCtrlBase + { + + public: + + CCtrlResizer(const TCtorParam ¶m); + virtual void draw (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + // Add a big delta so when the user is over the Resizer, always take it whatever other controls under + virtual uint getDeltaDepth() const { return 100; } + + // get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded + // if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded + THotSpot getRealResizerPos() const; + THotSpot getResizerPos() const { return _ResizerPos; } + void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; } + + bool IsMaxH; // Do this resizer is a MaxH resizer ? + + // Max sizes for the parent + sint32 WMin, WMax; + sint32 HMin, HMax; + + // from CCtrlBase + virtual bool canChangeVirtualDesktop() const { return !_MouseDown; } + + private: + + sint32 resizeW (sint32 dx); + sint32 resizeH (sint32 dy); + + private: + THotSpot _ResizerPos; // how the resizer should resize its parent + bool _MouseDown; + sint32 _MouseDownX; + sint32 _MouseDownY; + sint32 _XBias; + sint32 _YBias; + }; + + + // *************************************************************************** + /** + * Class describing a Mover for the container + * Clicking on it can also open the container + * This can be used to move a container if it is movable. + * If the container is popable, it will first pull it of the hierarchy, then it becomes movable. + * It can also be used to change the position of a group container that is inserted in the list of another container. + * \author Lionel Berenguier + * \date 2003 + */ + class CCtrlMover : public CCtrlBase + { + public: + + CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen); + ~CCtrlMover(); + virtual void draw (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + bool canMove() { return _CanMove; } + + bool isMoving() const {return _Moving;} + bool isMovingInParentList() const { return _MovingInParentList; } + + // from CCtrlBase + virtual bool canChangeVirtualDesktop() const { return !_Moving; } + + private: + sint32 _MoveStartX, _MoveStartY; + sint32 _MoveDeltaXReal, _MoveDeltaYReal; + sint64 _ScrollTime; + sint32 _StartIndex; + sint32 _InsertionIndex; + // clip window from parent list + sint32 _ParentListTop; + sint32 _ParentListBottom; + // + sint64 _WaitToOpenCloseDate; + // + bool _CanMove : 1; + bool _CanOpen : 1; + bool _Moving : 1; + bool _MovingInParentList : 1; + bool _HasMoved : 1; + bool _ParentScrollingUp : 1; + bool _ParentScrollingDown : 1; + bool _StopScrolling : 1; // stop scrolling at next draw + bool _WaitToOpenClose : 1; + // + static COptionsContainerInsertion *getInsertionOptions(); + private: + void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); + void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); + void updateInsertionIndex(const CGroupList *gl, sint32 posY); + void stopMove(); + bool runTitleActionHandler(); + void handleScrolling(); + + }; + + + // *************************************************************************** + /** + * class describing a group of views controls and other groups + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CGroupContainer : public CGroupContainerBase + { + public: + enum { NumResizers = 8 }; + public: + // observer to know when children have moved. This can be used to keep external datas in sync + struct IChildrenObs + { + virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0; + }; + public: + CGroupContainer(const TCtorParam ¶m); + ~CGroupContainer(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + virtual void updateCoords (); + + virtual void draw (); + + virtual void clearViews (); + + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + virtual void launch (); + + virtual void setActive (bool state); + + virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group + + virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); + + void open(); + + void close(); + + void setup(); // Create the container + + /** If insertion order is -1, pIC is added at the end of the container + * otherwise it is inserted after containers of a lower order + */ + void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1); + // Insert a container at the given index. + bool attachContainerAtIndex(CGroupContainer *pIC, uint index); + + // Before a container is detached from parent, it should be pop in + void detachContainer (CGroupContainer *pIC); + void removeAllContainers(); + + void setOpen(bool opened) + { + if (opened) + { + open(); + } + else + { + close(); + } + } + bool isOpen() const { return _Opened; } + + // Force Open for container setActive and open() + virtual void forceOpen(); + + /// Set the title open and close + virtual bool isMovable() const {return _Movable;} + void setMovable(bool b); + + void setContent (CInterfaceGroup *pC); + + std::string getTitle () const; + void setTitle (const std::string &title); + std::string getTitleOpened () const; + void setTitleOpened (const std::string &title); + std::string getTitleClosed () const; + void setTitleClosed (const std::string &title); + std::string getTitleColorAsString() const; + void setTitleColorAsString(const std::string &col); + + void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); } + + // Get the header color draw. NB: depends if grayed, and if active. + NLMISC::CRGBA getDrawnHeaderColor () const; + + ucstring getUCTitleOpened () const; + void setUCTitleOpened (const ucstring &title); + ucstring getUCTitleClosed () const; + void setUCTitleClosed (const ucstring &title); + ucstring getUCTitle () const; + void setUCTitle (const ucstring &title); + + void setPopable(bool popable) { _Popable = popable; } + bool isPopable() const { return _Popable; } + bool isPopuped() const { return _Poped; } + + + void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; } + bool isMovableInParentList() const { return _MovableInParentList; } + + // high light the border of the container + void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; } + bool isHighLighted() const { return _HighLighted; } + + // y offset for content of container + sint32 getContentYOffset() const { return (sint32) _ContentYOffset; } + void setContentYOffset(sint32 value); + + // Window requires attention + void requireAttention(); + + // Lua exports + int luaBlink(CLuaState &ls); + int luaSetHeaderColor(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase) + REFLECT_LUA_METHOD("blink", luaBlink); + REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor); + REFLECT_STRING("title", getTitle, setTitle); + REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); + REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); + REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); + REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); + REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); + REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); + REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); + REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); + REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW); + REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW); + REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW); + REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset); + REFLECT_BOOL("openable", isOpenable, setOpenable); + REFLECT_BOOL("opened", isOpen, setOpen); + REFLECT_BOOL("lockable", isLockable, setLockable); + REFLECT_BOOL("locked", isLocked, setLocked); + + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); + REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); + REFLECT_EXPORT_END + + sint32 getLayerSetup() const { return _LayerSetup; } + + // if this window is popable, pop it at its actual position + void popupCurrentPos(); + // Popup at previous memorized position + void popup(); + /** Popin the window and possibly put it back in its father container, using the order defined in the list of the container. + * \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL) + * \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list + */ + void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true); + + // get the mover control associated with that control, or NULL if none + CCtrlMover *getCtrlMover() const { return _Mover; } + + // true if there is a mover and if the window is being moved + bool isMoving() const { return _Mover && _Mover->isMoving(); } + + /** Force the container to blink (to tell the user that an event has happened). + * This uses the global color, so the container must use it + * This state is automatically disabled if the container is opened + * \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise + */ + virtual void enableBlink(uint numBlinks = 0); + virtual void disableBlink(); + virtual bool isBlinking() const { return _Blinking; } + + CGroupList *getList() const { return _List; } + + CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; } + CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; } + CInterfaceGroup *getContent() const { return _Content; } + + void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; } + IChildrenObs *getChildrenObs() const { return _ChildrenObs; } + + // Get current father container (if any). + CGroupContainer *getFatherContainer() const; + // Get current father container (if any). If the container is popup, it gives the proprietary container + CGroupContainer *getProprietaryContainer() const; + + + bool isOpenable() const { return _Openable; } + void setOpenable(bool openable); + + bool getHeaderActive() const { return _HeaderActive; } + void setHeaderActive(bool active) { _HeaderActive = active; } + + bool getRightButtonEnabled() const { return _EnabledRightButton; } + void setRightButtonEnabled(bool enabled); + + CCtrlScroll *getScroll() const { return _ScrollBar; } + + bool isSavable() const { return _Savable; } + void setSavable(bool savable) { _Savable = savable; } + bool isActiveSavable() const { return _ActiveSavable; } + + bool isLocalize() const { return _Localize; } + void setLocalize(bool localize) { _Localize = localize; } + + void setPopupX(sint32 x) { _PopupX = x; } + void setPopupY(sint32 y) { _PopupY = y; } + void setPopupW(sint32 w) { _PopupW = w; } + void setPopupH(sint32 h) { _PopupH = h; } + + sint32 getPopupX() const { return _PopupX; } + sint32 getPopupY() const { return _PopupY; } + sint32 getPopupW() const { return _PopupW; } + sint32 getPopupH() const { return _PopupH; } + + sint32 getRefW() const { return _RefW; } + + /** Increase the rollover alpha for the current frame. + * Example of use : an edit box that has focus in a group container + */ + void rollOverAlphaUp(); + // force the rollover alpha to its max value, depending on there's keyboard focus or not + void forceRolloverAlpha(); + + bool isOpenWhenPopup() const { return _OpenWhenPopup; } + + /// Locking of window (prevent it from being moved) + void setLockable(bool lockable); + bool isLockable() const { return _Lockable; } + void setLocked(bool locked); + + // to be called by the 'deactive check' handler + static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } + const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); } + const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; } + // + const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); } + const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; } + // + IActionHandler *getAHOnMovePtr() const { return _AHOnMove; } + const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); } + const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; } + // + IActionHandler *getAHOnResizePtr() const { return _AHOnResize; } + const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); } + const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } + // + IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; } + const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); } + const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; } + + // + void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } + void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } + + void setModalParentList (const std::string &name); + bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) + bool isGrayed() const; + bool blinkAllSons(); + + // true if the resizer is enabled. + bool getEnabledResizer() const {return _EnabledResizer;} + + sint32 getPopupMinW() const {return _PopupMinW;} + sint32 getPopupMaxW() const {return _PopupMaxW;} + sint32 getPopupMinH() const {return _PopupMinH;} + sint32 getPopupMaxH() const {return _PopupMaxH;} + sint32 getMinW() const {return _MinW;} + void setMinW(sint32 minW) { _MinW = minW;} + void setMaxW(sint32 maxW) { _MaxW = maxW;} + sint32 getMaxW() const {return _MaxW;} + void setPopupMinW(sint32 minW); + void setPopupMaxW(sint32 maxW); + void setPopupMinH(sint32 minW); + void setPopupMaxH(sint32 maxW); + + + // backup the current position of this container + void backupPosition(); + // restore the current position of this container + void restorePosition(); + // get x for backup position + sint32 getBackupX() const { return _BackupX; } + sint32 getBackupY() const { return _BackupY; } + // Set backup position + void setBackupPosition(sint32 x, sint32 y); + // clear backup + void clearBackup() { _PositionBackuped = false; } + // Test if position has been backuped (flag cleared by 'restorePosition()') + bool isPositionBackuped() const { return _PositionBackuped; } + // check if the container has been moved, resized, or popuped by the user (and eventually clear that flag) + bool getTouchFlag(bool clearFlag) const; + // from CInterfaceGroup + virtual void restoreAllContainersBackupPosition() { restorePosition(); } + + // when isModal() is true, the whole interface cannot switch desktop + bool isModal() const { return _Modal; } + void setModal(bool modal) { _Modal = modal; } + + // return true if the container has a modal parent window setuped => the whole interface cannot switch desktop + bool isModalSon() const { return !_ModalParents.empty(); } + + // return the help web page of this container. "" if none + const std::string &getHelpPage() const { return _HelpPage; } + // set the help web page of this container. "" if none. NB: the help button is not updated + void setHelpPage(const std::string &newPage); + + void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; } + sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } + + protected: + uint8 _ICurrentRolloverAlphaContainer; + uint8 _HighLightedAlpha; + float _CurrentRolloverAlphaContainer; + float _CurrentRolloverAlphaContent; + sint32 _LayerSetup; + ucstring _TitleTextOpened; + ucstring _TitleTextClosed; + CViewText *_TitleOpened; + CViewText *_TitleClosed; + sint32 _TitleDeltaMaxW; + CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable) + CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin + CCtrlButton *_HelpButton; // Help button + + CGroupList *_List; + CCtrlScroll *_ScrollBar; + CGroupContainer *_OldFatherContainer; + + // NB: _ModalParentNames is a list of modal parent, separated by '|' + std::string _ModalParentNames; // Modal handling between container (container can be linked together, + std::vector _ModalSons; // when the son is active the parent is not active + std::vector _ModalParents; // (but the rest of the interface is)) + + uint _InsertionOrder; + uint _BlinkDT; + uint _NumBlinks; + + CInterfaceGroup *_Content; // Read From Script + CInterfaceGroup *_HeaderOpened; // Read From Script + CInterfaceGroup *_HeaderClosed; // Read From Script + + CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available + + // + CCtrlMover *_Mover; + + IChildrenObs *_Obs; + + // If layer==0 constraint on resize + sint32 _PopupMinW; + sint32 _PopupMaxW; + sint32 _PopupMinH; + sint32 _PopupMaxH; + // If layer>0 constraint on resize + sint32 _MinW; + sint32 _MaxW; + + // backuped position + sint32 _BackupX; + sint32 _BackupY; + + // old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet + sint32 _PopupX; + sint32 _PopupY; + sint32 _PopupW; + sint32 _PopupH; + // + sint32 _RefW; + + + sint32 _MoverDeltaW; + + // action handler + IActionHandler *_AHOnOpen; + CStringShared _AHOnOpenParams; + IActionHandler *_AHOnClose; + CStringShared _AHOnCloseParams; + IActionHandler *_AHOnCloseButton; + CStringShared _AHOnCloseButtonParams; + IActionHandler *_AHOnMove; + CStringShared _AHOnMoveParams; + IActionHandler *_AHOnResize; + CStringShared _AHOnResizeParams; + IActionHandler *_AHOnBeginMove; + CStringShared _AHOnBeginMoveParams; + + // action handler to test whether the windows can be deactivated (when the close button is pressed) + IActionHandler *_AHOnDeactiveCheck; + CStringShared _AHOnDeactiveCheckParams; + + + // Observer to know when children have moved + IChildrenObs *_ChildrenObs; + + // list of container that are poped up + std::vector _PopedCont; + + // Open management + bool _Openable : 1; // Is the container can be manually opened or closed ? + bool _Opened : 1; // Is the container currently opened or closed ? + bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0) + // and close when poped in... + bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start + bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0) + + // Move management + bool _Movable : 1; // Is the container movable ? + bool _MovableInParentList: 1; + bool _Lockable : 1; + bool _MovingInParentList : 1; // Mgt : currently moving ? + + // Pop up / pop in + bool _Popable : 1; + bool _Poped : 1; + + bool _EnabledResizer : 1; + + bool _HighLighted : 1; + bool _Blinking : 1; + bool _BlinkState : 1; + + bool _Savable : 1; + bool _ActiveSavable : 1; + + // Display title background or not + bool _HeaderActive : 1; + bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ? + // + enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString}; + uint8 _TitleClass : 2; + // + mutable bool _TouchFlag : 1; + bool _PositionBackuped : 1; + bool _Modal : 1; // the container is modal and prevent from switching virtual desktop + // + bool _EnabledHelpButton : 1; // Is the Button Help is enabled ? + // + bool _TitleOverExtendViewText : 1; // Does the title over extend view text + bool _Localize : 1; + + CInterfaceProperty _HeaderColor; + + + + sint8 _ContentYOffset; + + // Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value + sint8 _ResizerTopSize; + uint8 _ICurrentRolloverAlphaContent; + + + static bool _ValidateCanDeactivate; + + CStringShared _OptionsName; + + // Web Page used for help + CStringShared _HelpPage; + + private: + + sint32 getLayer(); + void updateResizerSize(CCtrlResizer *cr); + void updateRightButton(); + void updateHelpButton(); + void updateMover(); + void updateViewOpenState(); + void updateTitle(); + + void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH); + void createResizerMaxH(); + void removeResizerMaxH(); + + TTileClass convertTitleClass(const char *ptr); + + static COptionsContainerMove *getMoveOptions(); + + COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used + + bool hasKeyboardFocus() const; + + // private for modal system + void addModalParent (CGroupContainer *pParent); + void addModalSon (CGroupContainer *pSon); + + // Avoid each frame setup layer0, layer1 etc... + enum {NumLayerName=10}; + static const std::string _OptionLayerName[NumLayerName]; + + public: + // for use by CCtrlMover + // Tell that this group is moving in its parent list + void setMovingInParentList(bool enable); + CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; } + CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; } + CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; } + // set the 'hasMoved' flag + void touch(bool touched = true) { _TouchFlag = touched; } + + friend class CICDeactive; + }; + +} + +#endif // RZ_INTERFACE_CONTAINER_H + +/* End of interface_container.h */ diff --git a/code/nel/src/gui/group_container.cpp b/code/nel/src/gui/group_container.cpp new file mode 100644 index 000000000..42cc52a65 --- /dev/null +++ b/code/nel/src/gui/group_container.cpp @@ -0,0 +1,4005 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_container.h" +#include "nel/gui/interface_options.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/group_editbox.h" +#include "nel/gui/view_text_formated.h" +#include "nel/gui/view_text_id.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/group_list.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/ctrl_scroll.h" +#include "nel/gui/view_text.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_pointer_base.h" +#include "nel/misc/i18n.h" +#include "nel/misc/algo.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +namespace +{ + const sint SIZE_W_LEFT = 16; + const sint DELTA_BEFORE_POPUP = 32; + const sint DELTA_BEFORE_MOVING_IN_PARENT_LIST = 16; +} + +namespace NLGUI +{ + + bool CGroupContainer::_ValidateCanDeactivate = true; + + //#define DRAW_GC_TEST_QUADS + + + #ifdef DRAW_GC_TEST_QUADS + static void drawGCTestQuad(sint renderLayer, sint32 xreal, sint32 yreal, sint32 wreal, sint32 hreal, CRGBA color) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if(rVR.isMinimized()) + return; + sint32 x, y, w, h; + rVR.getClipWindow(x, y, w, h); + uint32 sw, sh; + rVR.getScreenSize(sw, sh); + rVR.setClipWindow(0, 0, (sint32) sw, (sint32) sh); + rVR.drawRotFlipBitmap (renderLayer, xreal, yreal, wreal, hreal, 0, false, rVR.getBlankTextureId(), color ); + rVR.setClipWindow(x, y, w ,h); + } + #endif + + + // *************************************************************************** + const string CGroupContainer::_OptionLayerName[CGroupContainer::NumLayerName]= + { + "layer0", + "layer1", + "layer2", + "layer3", + "layer4", + "layer5", + "layer6", + "layer7", + "layer8", + "layer9", + }; + + + // *************************************************************************** + // CCtrlResizer + // *************************************************************************** + + // *************************************************************************** + CCtrlResizer::CCtrlResizer(const TCtorParam ¶m) + : CCtrlBase(param) + { + WMin = WMax = 0; + HMin = HMax = 0; + _ResizerPos = Hotspot_BR; + IsMaxH = false; + _MouseDown = false; + _XBias = 0; + _YBias = 0; + resizer = true; + } + + + // *************************************************************************** + THotSpot CCtrlResizer::getRealResizerPos() const + { + CGroupContainer *parent = dynamic_cast(getParent()); + if (parent) + { + THotSpot resizerPos = _ResizerPos; + if (!IsMaxH && parent->getPopupMinH() == parent->getPopupMaxH()) + { + resizerPos = (THotSpot) (resizerPos & ~(Hotspot_Bx | Hotspot_Mx | Hotspot_Tx)); + } + if (parent->getPopupMinW() == parent->getPopupMaxW()) + { + resizerPos = (THotSpot) (resizerPos & ~(Hotspot_xR | Hotspot_xM | Hotspot_xL)); + } + return resizerPos; + } + return _ResizerPos; + } + + // *************************************************************************** + void CCtrlResizer::draw () + { + #ifdef DRAW_GC_TEST_QUADS + CRGBA col; + switch(ResizerPos) + { + case Hotspot_TR: col = CRGBA::Yellow; break; + case Hotspot_MR: col = CRGBA::Blue; break; + case Hotspot_BR: col = CRGBA::Yellow; break; + case Hotspot_BM: col = CRGBA::Blue; break; + case Hotspot_BL: col = CRGBA::Yellow; break; + case Hotspot_ML: col = CRGBA::Blue; break; + case Hotspot_TL: col = CRGBA::Yellow; break; + case Hotspot_TM: col = CRGBA::Blue; break; + } + + drawGCTestQuad(_RenderLayer, _XReal, _YReal, _WReal, _HReal, col); + #endif + } + + // *************************************************************************** + bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active || !_Parent) + return false; + + if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) + { + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; + if (edsf.hasFocus() == false && _MouseDown) + { + _MouseDown = false; + _Parent->invalidateCoords(); + return true; + } + } + } + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc.getX(), eventDesc.getY())) + return false; + + CGroupContainer *gc = dynamic_cast(_Parent); + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + // must check that parent isn't closed + if (gc) + { + + if (!gc->isOpen()) return false; + if (gc->getLayerSetup() != 0) return false; + if (gc->isLocked()) return true; + if (IsMaxH) + gc->setPopupMaxH(gc->getH()); + } + _MouseDown = true; + _MouseDownX = eventDesc.getX(); + _MouseDownY = eventDesc.getY(); + _XBias = 0; + _YBias = 0; + return true; + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + _MouseDown = false; + _Parent->invalidateCoords(); + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) + { + if (_MouseDown) + { + //nlinfo("x = %d, y = %d", eventDesc.getX() + _XReal, eventDesc.getY() + _YReal); + sint32 dx = eventDesc.getX() - _MouseDownX; + sint32 dy = eventDesc.getY() - _MouseDownY; + + + THotSpot resizerPos = getRealResizerPos(); + + // horizontal resize + if (dx != 0) + { + if (_XBias > 0) + { + _XBias += dx; + if (_XBias < 0) + { + dx = _XBias; + _XBias = 0; + } + else + { + dx = 0; + } + } + else if (_XBias < 0) + { + _XBias += dx; + if (_XBias > 0) + { + dx = _XBias; + _XBias = 0; + } + else + { + dx = 0; + } + } + if (resizerPos & Hotspot_xR) + { + sint32 effectiveDX = resizeW (dx); + if (effectiveDX != 0 && gc) gc->touch(); + if (_Parent->getPosRef() & Hotspot_xR) + { + _Parent->setX(_Parent->getX() + effectiveDX); + } + _XBias += dx - effectiveDX; + } + else if (resizerPos & Hotspot_xL) + { + sint32 effectiveDX = resizeW (- dx); + if (effectiveDX != 0 && gc) gc->touch(); + if (_Parent->getPosRef() & Hotspot_xL) + { + _Parent->setX(_Parent->getX() - effectiveDX); + } + _XBias += dx + effectiveDX; + } + } + + // vertical resize + if (dy != 0) + { + if (_YBias > 0) + { + _YBias += dy; + if (_YBias < 0) + { + dy = _YBias; + _YBias = 0; + } + else + { + dy = 0; + } + } + else if (_YBias < 0) + { + _YBias += dy; + if (_YBias > 0) + { + dy = _YBias; + _YBias = 0; + } + else + { + dy = 0; + } + } + if (resizerPos & Hotspot_Tx) + { + sint32 effectiveDY = resizeH (dy); + if (effectiveDY != 0 && gc) gc->touch(); + if (_Parent->getPosRef() & Hotspot_Tx) + { + _Parent->setY(_Parent->getY() + effectiveDY); + } + _YBias += dy - effectiveDY; + } + else if (resizerPos & Hotspot_Bx) + { + sint32 effectiveDY = resizeH (- dy); + if (effectiveDY != 0 && gc) gc->touch(); + if (_Parent->getPosRef() & Hotspot_Bx) + { + _Parent->setY(_Parent->getY() + effectiveDY); + } + _YBias += dy + effectiveDY; + } + } + + _Parent->invalidateCoords(); + + // update pos + _MouseDownX = eventDesc.getX(); + _MouseDownY = eventDesc.getY(); + + // + // call resize handler of parent container if any + if (gc && gc->getAHOnResizePtr() != NULL) + { + CAHManager::getInstance()->runActionHandler(gc->getAHOnResize(), gc, gc->getAHOnResizeParams()); + } + } + return true; + } + } + return false; + } + + // *************************************************************************** + sint32 CCtrlResizer::resizeW (sint32 dx) + { + sint32 newW = _Parent->getW(); + newW += dx; + sint32 clippedNewW = newW; + NLMISC::clamp(clippedNewW, WMin, WMax); + // clip by screen + uint32 sw, sh; + CViewRenderer &vr = *CViewRenderer::getInstance(); + vr.getScreenSize(sw, sh); + if (_Parent->getPosRef() & Hotspot_xR) + { + if (_ResizerPos & Hotspot_xR) + { + clippedNewW = std::min((sint32) sw + _Parent->getW() - _Parent->getXReal(), clippedNewW); + } + else + { + clippedNewW = std::min(clippedNewW, _Parent->getXReal()); + } + } + else + { + if (_ResizerPos & Hotspot_xL) + { + clippedNewW = std::min(clippedNewW, _Parent->getXReal() + _Parent->getW()); + } + else + { + clippedNewW = std::min((sint32) sw - _Parent->getXReal(), clippedNewW); + } + } + // + dx = clippedNewW - _Parent->getW(); + _Parent->setW (clippedNewW); + return dx; + } + + // *************************************************************************** + sint32 CCtrlResizer::resizeH (sint32 dy) + { + // if the owner is a container, special resize applied + CGroupContainer *gc = NULL; + gc = dynamic_cast(_Parent); + if (gc == NULL) + return 0; + + // resize popupmaxh or h, according to IsMaxH. + sint32 oldH; + if (IsMaxH) + oldH= gc->getPopupMaxH(); + else + oldH= _Parent->getH(); + + // new H + sint32 clippedNewH= oldH + dy; + // if IsMaxH, don't clamp by HMax + if (IsMaxH) + clippedNewH = std::max(clippedNewH, HMin); + else + NLMISC::clamp(clippedNewH, HMin, HMax); + + + // clip by screen + uint32 sw, sh; + CViewRenderer &vr = *CViewRenderer::getInstance(); + vr.getScreenSize(sw, sh); + if (_Parent->getPosRef() & Hotspot_Tx) + { + if (_ResizerPos & Hotspot_Tx) + { + clippedNewH = std::min((sint32) sh + oldH - _Parent->getY(), clippedNewH); + } + else + { + clippedNewH = std::min(clippedNewH, _Parent->getY()); + } + } + else + { + if (_ResizerPos & Hotspot_Tx) + { + clippedNewH = std::min((sint32) sh - _Parent->getY(), clippedNewH); + } + else + { + clippedNewH = std::min(clippedNewH, _Parent->getY() + oldH); + } + } + + // set final result + dy = clippedNewH - oldH; + if (IsMaxH) + gc->setPopupMaxH(clippedNewH); + else + gc->setH(clippedNewH); + return dy; + } + + + // *************************************************************************** + // CCtrlMover + // *************************************************************************** + + // *************************************************************************** + CCtrlMover::CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen) + : CCtrlBase(param) + { + _Moving= false; + _CanMove = canMove; + _CanOpen = canOpen; + _HasMoved = false; + _MovingInParentList = false; + _ParentScrollingUp = false; + _ParentScrollingDown = false; + _WaitToOpenClose = false; + } + + // *************************************************************************** + CCtrlMover::~CCtrlMover() + { + } + + // *************************************************************************** + COptionsContainerInsertion *CCtrlMover::getInsertionOptions() + { + static NLMISC::CRefPtr insertionOptions; + if (insertionOptions) return insertionOptions; + insertionOptions = (COptionsContainerInsertion *) CWidgetManager::getInstance()->getOptions("container_insertion_opt"); + return insertionOptions; + } + + + // *************************************************************************** + void CCtrlMover::draw () + { + #ifdef DRAW_GC_TEST_QUADS + drawGCTestQuad(_RenderLayer, _XReal, _YReal, _WReal, _HReal, CRGBA(255, 0, 0, 127)); + #endif + + // No Op if window is minimized + if(CViewRenderer::getInstance()->isMinimized()) + return; + + // draw insertion position if moving in parent list + if (_MovingInParentList) + { + COptionsContainerInsertion *options = getInsertionOptions(); + if (!options) return; + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); + uint32 sw, sh; + rVR.getScreenSize(sw, sh); + rVR.setClipWindow (0, 0, (sint32) sw, (sint32) sh); + CViewRenderer &vr = *CViewRenderer::getInstance(); + // + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return; + CGroupList *gl = gc->getPreviousParentList(); + if (!gl) return; + // + sint32 arrowWidth, arrowHeight; + // + if (_ParentScrollingUp) + { + sint32 topPosY = gl->getChild(0)->getYReal(); + if (gc->getYReal() < topPosY) + { + vr.getTextureSizeFromId(options->TxId_T_Arrow, arrowWidth, arrowHeight); + // insertion position is too high, just draw an arrow pointing to top + sint32 px = gl->getXReal() + (gl->getWReal() >> 1) - (arrowWidth >> 1); + vr.drawRotFlipBitmap(gc->getRenderLayer(), px, _ParentListTop - arrowHeight - 2, arrowWidth, arrowHeight, 0, 0, options->TxId_T_Arrow); + } + } + // + if (_ParentScrollingDown) + { + sint32 bottomPosY = gl->getChild(gl->getNumChildren() - 1)->getYReal() - gl->getChild(gl->getNumChildren() - 1)->getHReal(); + if (gc->getYReal() - gc->getHReal() > bottomPosY) + { + vr.getTextureSizeFromId(options->TxId_B_Arrow, arrowWidth, arrowHeight); + // draw an arrow pointing at bottom + // insertion position is too high, just draw an arrow pointing to top + sint32 px = gl->getXReal() + (gl->getWReal() >> 1) - (arrowWidth >> 1); + vr.drawRotFlipBitmap(gc->getRenderLayer(), px, _ParentListBottom + 2, arrowWidth, arrowHeight, 0, 0, options->TxId_B_Arrow); + } + } + + + if (!_ParentScrollingUp && !_ParentScrollingDown) + { + sint32 posY; + if (_InsertionIndex == (sint32) gl->getNumChildren()) + { + posY = gl->getChild(_InsertionIndex - 1)->getYReal(); + } + else + { + posY = gl->getChild(_InsertionIndex)->getYReal() + gl->getChild(_InsertionIndex)->getHReal(); + + } + // draw insertion bar + // + sint32 barWidth, barHeight; + vr.getTextureSizeFromId(options->TxId_InsertionBar, barWidth, barHeight); + if (posY >= _ParentListBottom && posY <= _ParentListTop) + { + sint32 py = posY - (barHeight >> 1) - 3; + vr.drawRotFlipBitmap(gc->getRenderLayer(), gl->getXReal(), py, gl->getWReal(), barHeight, 0, 0, options->TxId_InsertionBar); + } + } + rVR.setClipWindow(oldSciX, oldSciY, oldSciW, oldSciH); + } + } + + // *************************************************************************** + bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (CCtrlBase::handleEvent(event)) return true; + if (!_Active) + return false; + + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) + { + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; + if (edsf.hasFocus() == false && _Moving) + { + stopMove(); + return true; + } + } + } + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + // the ctrl must have been captured + if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) + return false; + + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return false; + if (gc->isLockable()) + { + if (gc->isLocked()) + { + return false; // do nothing + } + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && _WaitToOpenClose) + { + if (_WaitToOpenClose) + { + _WaitToOpenClose = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + // _WaitToOpen can only be set if the container is popable + if (gc) + { + // A double click has been made + gc->setHighLighted(false); + if (gc->isPopuped()) + { + // pop in the window + gc->setPopupX(gc->getX()); + gc->setPopupY(gc->getY()); + gc->setPopupW(gc->getW()); + //sint32 currH, minH, maxH; + //gc->getResizableChildrenH(currH, minH, maxH); + //gc->setPopupChildrenH(currH); + // + gc->popin(); + } + else + { + // pop the window + gc->popupCurrentPos(); + gc->forceRolloverAlpha(); + if (gc->getPopupW() != -1) + { + gc->setX(gc->getPopupX()); + gc->setY(gc->getPopupY()); + gc->setW(gc->getPopupW()); + // must resize the children to get correct height + //gc->setChildrenH(gc->getPopupChildrenH()); + } + else + { + gc->setW(gc->getRefW()); + } + } + gc->invalidateCoords(2); + // + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + } + return true; + } + } + + if (_WaitToOpenClose) + { + _WaitToOpenClose = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + } + + if (_CanOpen || gc->isOpenWhenPopup()) + { + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + if (!_Parent) return false; + gc->setHighLighted(false); + if (_HasMoved || _MovingInParentList) + { + stopMove(); + return true; + } + if (isIn(eventDesc.getX(), eventDesc.getY())) + { + + if (gc->isPopable()) + { + _WaitToOpenClose = true; + CWidgetManager::getInstance()->registerClockMsgTarget(this); + _WaitToOpenCloseDate = times.thisFrameMs; + } + else + { + _Moving = false; + if (gc->isOpenable() && !gc->isOpenWhenPopup()) + { + gc->setOpen(!gc->isOpen()); + } + else + { + return runTitleActionHandler(); + } + } + _Moving = false; + return true; + } + else + { + return false; + } + } + } + + + // Move Window Mgt. + if(!_Moving && !_MovingInParentList) + { + if (_CanMove) + { + // Enter Moving? + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown ) + { + _MoveStartX= _Parent->getX()-eventDesc.getX(); + _MoveStartY= _Parent->getY()-eventDesc.getY(); + _MoveDeltaXReal= _Parent->getXReal() - _Parent->getX(); + _MoveDeltaYReal= _Parent->getYReal() - _Parent->getY(); + _Moving= true; + // set the window at top. + CWidgetManager::getInstance()->setTopWindow(_Parent); + if (gc->getAHOnBeginMovePtr()) + { + CAHManager::getInstance()->runActionHandler(gc->getAHOnBeginMove(), gc, gc->getAHOnBeginMoveParams()); + } + return true; + } + } + } + else + { + // Leave Moving? + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup ) + { + stopMove(); + return true; + } + // Move + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ) + { + _HasMoved = true; + if (gc) gc->touch(); + // new coords + sint32 x= eventDesc.getX() + _MoveStartX; + sint32 y= eventDesc.getY() + _MoveStartY; + + // if the father is a container and is popable (but not poped), move it only if the user has moved the mouse enough + if (_Parent && !_MovingInParentList) + { + if (gc && gc->getLayerSetup() != 0) + { + if (gc->isMovableInParentList() && !gc->isPopable()) + { + if (abs(y - _Parent->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST) + { + // There should be at least one other entry in the parent list + CGroupList *parentList = dynamic_cast(gc->getParent()); + if (!parentList) return false; + if (parentList->getNbElement() == 1) return false; + setMovingInParent(gc, x, y, eventDesc); + updateInsertionIndex(parentList, eventDesc.getY()); + return true; + } + } + + if (gc->isPopable()) + { + if (!gc->isMovableInParentList()) + { + if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP || abs(y - _Parent->getY()) > DELTA_BEFORE_POPUP) + { + setPoped(gc, x, y, eventDesc); + return true; + } + } + else + { + if (abs(y - _Parent->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST) + { + // There should be at least one other entry in the parent list + CGroupList *parentList = dynamic_cast(gc->getParent()); + if (!parentList) return false; + if (parentList->getNbElement() == 1) return false; + setMovingInParent(gc, x, y, eventDesc); + updateInsertionIndex(parentList, eventDesc.getY()); + return true; + } + else // the mouse should move on the side of the container to turn it into a popup + //if (_Parent->getX() - x > DELTA_BEFORE_POPUP || x - (_Parent->getX() + _Parent->getWReal()) > DELTA_BEFORE_POPUP) + if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP) + { + setPoped(gc, x, y, eventDesc); + return true; + } + } + } + + if (abs(x - _Parent->getX()) > 1 || abs(y - _Parent->getY()) > 1) + { + gc->setHighLighted(true); + return true; + } + else + { + gc->setHighLighted(false); + return true; // mouse has not moved enough + } + } + } + + if (!_MovingInParentList) + { + // clip, in real coords space + uint32 wScreen, hScreen; + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); + x+= _MoveDeltaXReal; + y+= _MoveDeltaYReal; + + clamp(x, 0, (sint32)wScreen-_Parent->getWReal()); + clamp(y, 0, (sint32)hScreen-_Parent->getHReal()); + x-= _MoveDeltaXReal; + y-= _MoveDeltaYReal; + // move window + _Parent->setX(x); + _Parent->setY(y); + + // if some action handler to call when moving + if(gc->getAHOnMovePtr()) + { + // udpate XReal/YReal coords only of the container + gc->CInterfaceElement::updateCoords(); + // execute the AH + CAHManager::getInstance()->runActionHandler(gc->getAHOnMovePtr(), this, gc->getAHOnMoveParams()); + } + } + else + { + if (!gc) return false; + const CGroupList *gl = gc->getPreviousParentList(); + if (gl) + { + updateInsertionIndex(gl, eventDesc.getY()); + // compute visible portion of list + sint32 glSciX, glSciY, glSciW, glSciH; + gl->getClip(glSciX, glSciY, glSciW, glSciH); + _ParentListTop = glSciY + glSciH; + _ParentListBottom = glSciY; + // the control is moving in its parent list, so the x coordinate doesn't change + y += _MoveDeltaYReal; + // if the group is at the bottom of screen or at the bottom of the list, must clamp & scroll down + if (y < _ParentListBottom) + { + if (_ParentScrollingUp) + { + _ParentScrollingUp = false; + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass + } + if (glSciY > gl->getYReal()) // is there need for scroll ? + { + if (!_ParentScrollingDown) + { + _ParentScrollingDown = true; + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass + _ScrollTime = 0; + } + } + else + { + if (_ParentScrollingDown) + { + _ParentScrollingDown = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass + } + } + y = _ParentListBottom; + } + else + { + if (_ParentScrollingDown) + { + _ParentScrollingDown = false; + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass + } + sint32 topY = y + _Parent->getHReal(); + if (topY > _ParentListTop) + { + // idem for top + if (glSciY + glSciH < gl->getYReal() + gl->getHReal()) // is there need for scroll ? + { + if (!_ParentScrollingUp) + { + _ParentScrollingUp = true; + CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass + _ScrollTime = 0; + } + } + else + { + if (_ParentScrollingUp) + { + _ParentScrollingDown = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass + } + } + y = _ParentListTop - _Parent->getHReal(); + } + } + y -= _MoveDeltaYReal; + // move window + _Parent->setY(y); + } + } + // just invalidate position (1 pass) + _Parent->invalidateCoords(1); + return true; + } + } + } + if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) + { + if (_WaitToOpenClose) + { + uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); + if ((times.thisFrameMs - _WaitToOpenCloseDate) > dbclickDelay) + { + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return false; + _WaitToOpenClose = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + // do the open action + if (gc->isOpenable() && !gc->isOpenWhenPopup()) + { + gc->setOpen(!gc->isOpen()); + } + else + { + // if can't open, just call the action handler + return runTitleActionHandler(); + } + } + } + else if (_ParentScrollingDown || _ParentScrollingUp) + { + handleScrolling(); + } + } + } + return false; + } + + // *************************************************************************** + void CCtrlMover::handleScrolling() + { + const uint pixPerMS = 7; // the number of millisecond to move of one pixel in the parent scrollbar + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return; + CGroupList *gl = gc->getPreviousParentList(); + if (!gl) return; + + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + if (_ParentScrollingUp) + { + sint32 topPosY = gl->getChild(0)->getYReal(); + // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar + if (gc->getYReal() < topPosY) + { + _ScrollTime += times.frameDiffMs; + sint32 deltaY = (sint32) (_ScrollTime / pixPerMS); + if (deltaY != 0) + { + CGroupContainer *currGC = gc->getPreviousContainer(); + while (currGC) + { + CCtrlScroll *cs = currGC->getScroll(); + if (cs) + { + sint32 dy = cs->moveTrackY(deltaY); + if (dy != 0) break; + }// + currGC = currGC->getFatherContainer(); + } + gl->invalidateCoords(); + gc->invalidateCoords(); + _ScrollTime = _ScrollTime % (sint64) pixPerMS; + } + } + else + { + _ParentScrollingUp = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + _InsertionIndex = 0; + } + } + // + if (_ParentScrollingDown) + { + // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar + sint32 bottomPosY = gl->getChild(gl->getNumChildren() - 1)->getYReal() - gl->getChild(gl->getNumChildren() - 1)->getHReal(); + if (gc->getYReal() - gc->getHReal() > bottomPosY) + { + _ScrollTime += times.frameDiffMs; + sint32 deltaY = - (sint32) (_ScrollTime / pixPerMS); + if (deltaY != 0) + { + CGroupContainer *currGC = gc->getPreviousContainer(); + while (currGC) + { + CCtrlScroll *cs = currGC->getScroll(); + if (cs) + { + sint32 dy = cs->moveTrackY(deltaY); + if (dy != 0) break; + } + currGC = currGC->getFatherContainer(); + } + gl->invalidateCoords(); + gc->invalidateCoords(); + _ScrollTime = _ScrollTime % pixPerMS; + } + } + else + { + _ParentScrollingDown = false; + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + _InsertionIndex = gl->getNumChildren(); + } + } + } + + // *************************************************************************** + bool CCtrlMover::runTitleActionHandler() + { + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return false; + CInterfaceGroup *gr = gc->isOpen() ? gc->getHeaderOpened() : gc->getHeaderClosed(); + if (gr && !gr->getLeftClickHandler().empty()) + { + CAHManager::getInstance()->runActionHandler(gr->getLeftClickHandler(), this, gr->getLeftClickHandlerParams()); + return true; + } + // try with the main group + if (!gc->getLeftClickHandler().empty()) + { + CAHManager::getInstance()->runActionHandler(gc->getLeftClickHandler(), this, gc->getLeftClickHandlerParams()); + return true; + } + return false; + } + + // *************************************************************************** + void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) + { + gc->setHighLighted(false); + sint32 deltaX = x - _Parent->getX(); + sint32 deltaY = y - _Parent->getY(); + // pop up the window + gc->popupCurrentPos(); // NB : this has the side effect of destroying this object during the call to CGroupContainer::update(), because the mover is recreated during the setup ! + // So from now we shouldn't use anything that use the 'this' pointer + // TODO : maybe there a more clean way to do that ? (except that we may not call update() in popupCurrentPos() ) + if (gc->isLockable()) + { + gc->setLocked(false); + } + gc->setW(gc->getRefW()); + gc->updateCoords(); + gc->updateCoords(); + gc->updateCoords(); + // now the window is in screen coordinates + sint32 newX = gc->getXReal() + deltaX; + sint32 newY = gc->getYReal() + deltaY; + uint32 wScreen, hScreen; + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); + clamp(newX, 0, (sint32)wScreen - gc->getWReal()); + clamp(newY, 0, (sint32)hScreen - gc->getHReal()); + // move window + gc->setX(newX); + gc->setY(newY + gc->getHReal()); + // just invalidate position (1 pass) + gc->updateCoords(); + + // delegate to the new created control mover + CCtrlMover *cm = gc->getCtrlMover(); + cm->_MoveStartX= gc->getX()-eventDesc.getX(); + cm->_MoveStartY= gc->getY()-eventDesc.getY(); + cm->_MoveDeltaXReal= gc->getXReal() - gc->getX(); + cm->_MoveDeltaYReal= gc->getYReal() - gc->getY(); + cm->_Moving= true; + CWidgetManager::getInstance()->setCapturePointerLeft(cm); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + } + + // *************************************************************************** + void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) + { + if (!gc) return; + sint32 deltaY = y - gc->getY(); + CGroupList *parentList = dynamic_cast(gc->getParent()); + if (!parentList) return; + // sint32 startIndex = parentList->getElementIndex(gc); + gc->setHighLighted(false); + sint32 oldX = _Parent->getXReal(); + gc->setMovingInParentList(true); + sint32 gcWidth = gc->getWReal(); + // pop up the window + gc->popupCurrentPos(); // this doesn't change the order in setup + gc->setSizeRef(0); + gc->setW(gcWidth); + gc->setX(oldX); + gc->updateCoords(); + gc->updateCoords(); + gc->updateCoords(); + // now the window is in screen coordinates + sint32 newY = gc->getYReal() + deltaY; + // + parentList->updateCoords(); + // get clip rect from parent list + sint32 glSciX, glSciY, glSciW, glSciH; + parentList->getClip(glSciX, glSciY, glSciW, glSciH); + _ParentListTop = glSciY + glSciH; + _ParentListBottom = glSciY; + // clip by parent list coords + clamp(newY, _ParentListBottom, _ParentListTop - gc->getHReal()); + // move window + gc->setY(newY + gc->getHReal()); + // just invalidate position (1 pass) + gc->updateCoords(); + + // reupdate pos + _MoveStartY= gc->getY()-eventDesc.getY(); + _MoveDeltaYReal= gc->getYReal() - gc->getY(); + + CWidgetManager::getInstance()->setCapturePointerLeft(this); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + _Moving = false; + _MovingInParentList = true; + + // register to get time events + } + + // *************************************************************************** + void CCtrlMover::updateInsertionIndex(const CGroupList *gl, sint32 posY) + { + if (!gl) return; + for(uint k = 0; k < gl->getNumChildren(); ++k) + { + CViewBase *child = gl->getChild(k); + if (child->getYReal() <= posY) + { + if (posY < child->getYReal() + (child->getHReal() >> 1)) + { + _InsertionIndex = k + 1; + return; + } + else + { + _InsertionIndex = k; + return; + } + } + } + _InsertionIndex = gl->getNumChildren(); + } + + // *************************************************************************** + void CCtrlMover::stopMove() + { + _ParentScrollingUp = false; + _ParentScrollingDown = false; + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + _HasMoved = false; + if (_Moving) + { + _Moving = false; + } + else + { + _MovingInParentList = false; + // insert at good position in the parent list + CGroupContainer *gc = dynamic_cast(_Parent); + if (!gc) return; + gc->popin(_InsertionIndex); + if (gc->getChildrenObs()) + { + gc->getChildrenObs()->childrenMoved(_StartIndex, _InsertionIndex, gc); + } + } + } + + + // *************************************************************************** + // CGroupContainer + // *************************************************************************** + + NLMISC_REGISTER_OBJECT(CViewBase, CGroupContainer, std::string, "container"); + + // *************************************************************************** + CGroupContainer::CGroupContainer(const TCtorParam ¶m) + : CGroupContainerBase(param) + { + // faster than a virual call + _IsGroupContainer = true; + + _CurrentRolloverAlphaContainer = 0.f; + _CurrentRolloverAlphaContent = 0.f; + + _LayerSetup = -1; + _Localize = true; + _Content = NULL; + _HeaderOpened = NULL; + _HeaderClosed = NULL; + _TitleOpened = NULL; + _TitleClosed = NULL; + _TitleDeltaMaxW = 0; + _ViewOpenState = NULL; + _RightButton = NULL; + _HelpButton = NULL; + _List = NULL; + _ScrollBar = NULL; + _Mover= NULL; + _OldFatherContainer = NULL; + _InsertionOrder = 0; + _MinW = 222; + _MaxW = 320; + _BackupX = 0; + _BackupY = 0; + _PopupMinW = 222; + _PopupMaxW = 500; + _PopupMinH = 48; + _PopupMaxH = 500; + + _BlinkDT = 0; + _ChildrenObs = NULL; + _NumBlinks = 0; + + _PopupX = -1; + _PopupY = -1; + _PopupW = -1; + + _RefW = 0; + + _Openable = true; + _Opened = false; + _OpenWhenPopup = false; + _OpenAtStart = false; + _OpenedBeforePopup = false; + + _Lockable = true; + + _EnabledResizer = true; + _ResizerTopSize = -1; + _Movable = false; + _MovableInParentList = false; + _Popable = false; + _Poped = false; + _HighLighted = false; + _Blinking = false; + _BlinkState = false; + _MovingInParentList = false; + _ActiveSavable = true; + _Savable = true; + _TitleClass = TitleText; + _TouchFlag = false; + _PositionBackuped = false; + _Modal = false; + + _HeaderActive = true; + _EnabledRightButton = true; + _EnabledHelpButton = true; + _TitleOverExtendViewText = false; + + + // action handler + _AHOnOpen = NULL; + _AHOnClose = NULL; + _AHOnCloseButton = NULL; + _AHOnMove = NULL; + _AHOnDeactiveCheck = NULL; + _AHOnResize = NULL; + _AHOnAlphaSettingsChanged = NULL; + _AHOnBeginMove = NULL; + + std::fill(_Resizer, _Resizer + NumResizers, (CCtrlResizer *) 0); + + _ContentYOffset = 0; + } + + // *************************************************************************** + CGroupContainer::~CGroupContainer() + { + } + + // *************************************************************************** + CGroupContainer::TTileClass CGroupContainer::convertTitleClass(const char *ptr) + { + if(nlstricmp(ptr, "formated")==0) + return TitleTextFormated; + if(nlstricmp(ptr, "text_id")==0) + return TitleTextId; + if(nlstricmp(ptr, "text_dyn_string")==0) + return TitleTextDynString; + // default + return TitleText; + } + + // *************************************************************************** + bool CGroupContainer::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur,parentGroup)) + return false; + CXMLAutoPtr ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"localize"); + if (ptr) _Localize = convertBool((const char*)ptr); + + // Type of the view text of the title + ptr = xmlGetProp (cur, (xmlChar*)"title_class"); + if (ptr) + { + _TitleClass = convertTitleClass((const char*)ptr); + // if textid, don't localize, because the title is a DB path + if(_TitleClass==TitleTextId || _TitleClass==TitleTextDynString) + _Localize= false; + } + + // y offset for content + ptr = xmlGetProp (cur, (xmlChar*)"content_y_offset"); + if (ptr) + { + fromString((const char*)ptr, _ContentYOffset); + } + + // text of the title + ptr = xmlGetProp (cur, (xmlChar*)"title"); + if (ptr) + { + if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); + else _TitleTextOpened = string((const char*)ptr); + if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); + else _TitleTextClosed = string((const char*)ptr); + } + + ptr = xmlGetProp (cur, (xmlChar*)"title_opened"); + if (ptr) + { + if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); + else _TitleTextOpened = string((const char*)ptr); + } + + ptr = xmlGetProp (cur, (xmlChar*)"title_closed"); + if (ptr) + { + if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); + else _TitleTextClosed = string((const char*)ptr); + } + + ptr = xmlGetProp (cur, (xmlChar*)"header_active"); + if (ptr) + _HeaderActive = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"header_color"); + if (ptr) + _HeaderColor.link(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"right_button"); + if (ptr) + { + _EnabledRightButton = convertBool(ptr); + // Default; take same state than the right button + _EnabledHelpButton = _EnabledRightButton; + } + + // but user may ovveride this case + ptr = xmlGetProp (cur, (xmlChar*)"help_button"); + if (ptr) + _EnabledHelpButton = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"movable"); + if (ptr) + _Movable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"popable"); + if (ptr) + _Popable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"lockable"); + if (ptr) + _Lockable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"locked"); + if (ptr) + _Locked = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"openable"); + if (ptr) + _Openable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"opened"); + if (ptr) + _OpenAtStart = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"modal"); + if (ptr) + _Modal = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"open_when_popup"); + if (ptr) + { + _OpenWhenPopup = convertBool(ptr); + if (_OpenWhenPopup) + _OpenAtStart = false; + } + + ptr = xmlGetProp (cur, (xmlChar*)"resizer"); + if (ptr) + _EnabledResizer = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"resizer_top_size"); + _ResizerTopSize= -1; + if (ptr) + fromString((const char*)ptr, _ResizerTopSize); + + CAHManager::getInstance()->parseAH(cur, "on_open", "on_open_params", _AHOnOpen, _AHOnOpenParams); + CAHManager::getInstance()->parseAH(cur, "on_close", "on_close_params", _AHOnClose, _AHOnCloseParams); + CAHManager::getInstance()->parseAH(cur, "on_close_button", "on_close_button_params", _AHOnCloseButton, _AHOnCloseButtonParams); + CAHManager::getInstance()->parseAH(cur, "on_move", "on_move_params", _AHOnMove, _AHOnMoveParams); + CAHManager::getInstance()->parseAH(cur, "on_deactive_check", "on_deactive_check_params", _AHOnDeactiveCheck, _AHOnDeactiveCheckParams); + CAHManager::getInstance()->parseAH(cur, "on_resize", "on_resize_params", _AHOnResize, _AHOnResizeParams); + CAHManager::getInstance()->parseAH(cur, "on_alpha_settings_changed", "on_alpha_settings_changed_params", _AHOnAlphaSettingsChanged, _AHOnAlphaSettingsChangedParams); + CAHManager::getInstance()->parseAH(cur, "on_begin_move", "on_begin_move_params", _AHOnBeginMove, _AHOnBeginMoveParams); + + + ptr = xmlGetProp (cur, (xmlChar*)"max_w"); + if (ptr) + fromString((const char*)ptr, _MaxW); + ptr = xmlGetProp (cur, (xmlChar*)"min_w"); + if (ptr) + fromString((const char*)ptr, _MinW); + + ptr = xmlGetProp (cur, (xmlChar*)"pop_max_w"); + if (ptr) + fromString((const char*)ptr, _PopupMaxW); + ptr = xmlGetProp (cur, (xmlChar*)"pop_min_w"); + if (ptr) + fromString((const char*)ptr, _PopupMinW); + + ptr = xmlGetProp (cur, (xmlChar*)"pop_max_h"); + if (ptr) + fromString((const char*)ptr, _PopupMaxH); + ptr = xmlGetProp (cur, (xmlChar*)"pop_min_h"); + if (ptr) + fromString((const char*)ptr, _PopupMinH); + + ptr = xmlGetProp (cur, (xmlChar*)"movable_in_parent_list"); + if (ptr) _MovableInParentList = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"savable"); + if (ptr) _Savable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"active_savable"); + if (ptr) _ActiveSavable = convertBool(ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"modal_parent"); + if (ptr) _ModalParentNames = (const char*)ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"options"); + if (ptr) _OptionsName = (const char*)ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"title_delta_max_w"); + if (ptr) fromString((const char*)ptr, _TitleDeltaMaxW); + + ptr = xmlGetProp (cur, (xmlChar*)"title_over_extend_view_text"); + _TitleOverExtendViewText= false; + if (ptr) _TitleOverExtendViewText = convertBool(ptr); + + + ptr = xmlGetProp (cur, (xmlChar*)"help_page"); + if (ptr) _HelpPage = (const char*)ptr; + + _RefW = _W; + return true; + } + + // *************************************************************************** + void CGroupContainer::updateCoords() + { + if (_Mover && _Mover->isMovingInParentList()) + { + // must clamp by parent coords, now it has been updated + CGroupList *gl = getPreviousParentList(); + if (gl) + { + sint32 cx, cy, cw, ch; + gl->getClip(cx, cy, cw, ch); + sint32 currYReal = getYReal(); + clamp(currYReal, cy, cy + ch - getHReal()); + if (currYReal != getYReal()) + { + setY(getY() + currYReal - getYReal()); + } + } + } + + setup(); + + bool bHasChild = (_List->getNbElement() > 0); + + // clamp popupmaxh if resizemax mode + if ((_LayerSetup == 0) && bHasChild && _EnabledResizer) + { + // Clip by screen + uint32 sw, sh; + CViewRenderer &vr = *CViewRenderer::getInstance(); + vr.getScreenSize(sw, sh); + // ensure the maxH is > minH and < sh (prioritary > minH, in case of sh_PopupMinW && _W>(sint32)sw) _W= sw; + if((sint32)sh>_PopupMinH && _H>(sint32)sh) _H= sh; + } + + COptionsLayer *pLayer = getContainerOptions(); + sint32 newH = 0; + + // Get base header size + if (_LayerSetup == 0) + { + setMaxH(_PopupMaxH); + // _W is given by scripter-man + newH = pLayer->H_T; + } + else + { + if (_SizeRef & 1) + { + _W = _Parent->getW(); + } + setMaxH (16384); // No scrollbar for container of layer > 0 + newH = pLayer->H_T; + } + + if (_Opened) + { + if (_HeaderOpened != NULL) + { + if (_HeaderOpened->getPosRef()&Hotspot_xR) + _HeaderOpened->setX (-pLayer->W_R); + if (_HeaderOpened->getPosRef()&Hotspot_xL) + _HeaderOpened->setX (pLayer->W_L); + _HeaderOpened->setY (- newH); + _HeaderOpened->setW (_W-(pLayer->W_L+pLayer->W_R)); + _HeaderOpened->updateCoords(); + newH += max (_HeaderOpened->getHReal(), pLayer->getValSInt32 ("header_h")); + } + else + { + newH += pLayer->getValSInt32 ("header_h"); + } + + newH -= (sint32) _ContentYOffset; + + // Calculate content size part + if (_Content != NULL) + { + if (_Content->getPosRef()&Hotspot_xR) + _Content->setX (-pLayer->W_R); + else if (_Content->getPosRef()&Hotspot_xL) + _Content->setX (pLayer->W_L); + _Content->setY (-newH); + _Content->setW (-(pLayer->W_L+pLayer->W_R)); + if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // Content is constant in H + { + _Content->setSizeRef (1); // w + _Content->updateCoords(); + newH += _Content->getHReal(); + } + else + { + _Content->setSizeRef (3); // wh + _Content->setH (-newH - pLayer->H_B); // Sub header and top, bottom bitmaps + } + } + + if (bHasChild) + newH += pLayer->H_B_Open; + else + newH += pLayer->H_B; + + if (_LayerSetup == 0) + { + _List->setX (pLayer->W_M_Open); + _ScrollBar->setX (pLayer->Scrollbar_Offset_X); + _ScrollBar->setY(-newH); + } + else + { + _List->setX (0); + } + _List->setY (-newH); + + // Calculate list max height if top container + if (_LayerSetup == 0) + { + // zeH is the height to substract to total height of the container to obtain height of the list + sint32 zeH = pLayer->H_T + pLayer->H_B_Open + pLayer->H_EM_Open; + + if (_HeaderOpened != NULL) + zeH += max (_HeaderOpened->getHReal(), pLayer->getValSInt32 ("header_h")); + else + zeH += pLayer->getValSInt32 ("header_h"); + + if (_Content != NULL) + zeH += _Content->getHReal(); + + if (_List != NULL) + _List->setMaxH (max((sint32)0, _MaxH-zeH)); + } + else + { + if (_List != NULL) + _List->setMaxH (16384); + } + + if (_LayerSetup == 0) + { + _List->forceSizeW(_W - pLayer->W_M_Open); + } + else + { + _List->forceSizeW(_W); + } + + + //CInterfaceElement::updateCoords(); + CInterfaceGroup::updateCoords(); + + newH += ((_List->getHReal() < _List->getMaxH()) ? _List->getHReal() : _List->getMaxH()); + + if (_LayerSetup == 0) + { + if ((!bHasChild) || (_List->getHReal() < _List->getMaxH())) + _ScrollBar->setActive (false); + else + _ScrollBar->setActive (true); + } + + if (_LayerSetup == 0) + { + if (_List->getNbElement() > 0) + { + newH += pLayer->H_EM_Open; + } + } + + if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // H is depending on the header and content and list + _H = newH; + + } + else // Closed + { + if (_HeaderClosed != NULL) + { + if (_HeaderClosed->getPosRef()&Hotspot_xR) + _HeaderClosed->setX (-pLayer->W_R); + else if (_HeaderClosed->getPosRef()&Hotspot_xL) + _HeaderClosed->setX (pLayer->W_L); + _HeaderClosed->setY (-newH); + _HeaderClosed->setW (_W-(pLayer->W_L+pLayer->W_R)); + _HeaderClosed->updateCoords(); + newH += max (_HeaderClosed->getHReal(), pLayer->getValSInt32 ("header_h")); + } + else + { + newH += pLayer->getValSInt32 ("header_h"); + } + newH += pLayer->H_B; + + if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // H is depending on the header and content and list + _H = newH; + + CInterfaceGroup::updateCoords(); + } + + + if (_Mover != NULL) + { + _Mover->setW (_W+_MoverDeltaW); + _Mover->updateCoords(); + } + + // Set MaxW for title according to current Container Width + _TitleOpened->setLineMaxW(_W + _TitleDeltaMaxW); + _TitleClosed->setLineMaxW(_W + _TitleDeltaMaxW); + + _TitleOpened->updateCoords(); + _TitleClosed->updateCoords(); + if (_ViewOpenState != NULL) _ViewOpenState->updateCoords(); + if (_RightButton != NULL) _RightButton->updateCoords(); + if (_HelpButton != NULL) _HelpButton->updateCoords(); + if (_ScrollBar != NULL) _ScrollBar->updateCoords(); + if (_Content != NULL) _Content->updateCoords(); + if (_HeaderClosed != NULL) _HeaderClosed->updateCoords(); + if (_HeaderOpened != NULL) _HeaderOpened->updateCoords(); + + CInterfaceElement::updateCoords(); + + if (_LayerSetup == 0) + { + // test if must clip + uint32 wScreen, hScreen; + CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); + if (_WReal <= (sint32) wScreen && _HReal <= (sint32) hScreen) + { + sint32 newX = _XReal; + sint32 newY = _YReal; + clamp(newX, 0, (sint32)wScreen - _WReal); + clamp(newY, 0, (sint32)hScreen - _HReal); + if (newX != _XReal || newY != _YReal) + { + setX(_X + newX - _XReal); + setY(_Y + newY - _YReal); + CInterfaceGroup::updateCoords(); + } + } + } + + // resizers + for(uint k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) updateResizerSize(_Resizer[k]); + } + } + + // *************************************************************************** + void CGroupContainer::updateResizerSize(CCtrlResizer *cr) + { + COptionsContainerMove *options = getMoveOptions(); + if (!options) return; + + // Yoyo: The +1 stuff is important, maybe because of the HotSpot MiddleMiddle style... + + // Choose H + if (!(cr->getResizerPos() & Hotspot_Tx) && !(cr->getResizerPos() & Hotspot_Bx)) + { + // if no special topH size + if(_ResizerTopSize<0) + cr->setH (_H - 2 * options->ResizerSize + 1); // Bottom and Top same value + else + cr->setH (_H - options->ResizerSize - _ResizerTopSize + 1); // Top different from bottom + } + else + { + // if no special topH size, or if the resizer is not the top one + if(_ResizerTopSize<0 || !(cr->getResizerPos() & Hotspot_Tx)) + cr->setH(options->ResizerSize + 1); + else + cr->setH(_ResizerTopSize + 1); + } + + // Choose W + if (!(cr->getResizerPos() & Hotspot_xR) && !(cr->getResizerPos() & Hotspot_xL)) + { + cr->setW (_W - 2 * options->ResizerSize + 1); + } + else + { + cr->setW(options->ResizerSize + 1); + } + + // update coordinate + cr->updateCoords(); + } + + // *************************************************************************** + void CGroupContainer::draw () + { + H_AUTO( RZ_Interface_CGroupContainer_draw ) + + if (_LayerSetup == -1) return; + + float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + CRGBA oldGlobalColor = CWidgetManager::getInstance()->getGlobalColor(); + CRGBA oldGColForGrayed = CWidgetManager::getInstance()->getGlobalColor(); + if (_Blinking) + { + const uint blinkDuration = 300; + if (((_BlinkDT / 300) & 1) == 0) + { + CRGBA newCol = oldGlobalColor; + clamp(newCol.R, 64, 192); + clamp(newCol.G, 64, 192); + clamp(newCol.B, 64, 192); + newCol.R = ~newCol.R; + newCol.G = ~newCol.G; + newCol.B = ~newCol.B; + if (abs(newCol.R - oldGlobalColor.R) < 64) newCol.R = 192; + if (abs(newCol.G - oldGlobalColor.G) < 64) newCol.G = 192; + if (abs(newCol.B - oldGlobalColor.B) < 64) newCol.B = 192; + CWidgetManager::getInstance()->setGlobalColor(newCol); + _BlinkState = true; + } + else + { + if (_BlinkState) // was previously on ? + { + if (_NumBlinks != 0) // if dont blink for ever + { + -- _NumBlinks; + if (_NumBlinks == 0) + { + disableBlink(); + } + } + } + _BlinkState = false; + } + _BlinkDT += std::min((uint) times.frameDiffMs, blinkDuration); + } + + CGroupContainer *parentGC = NULL; + if (getParent() && getParent()->getParent()) + { + if (getParent()->getParent()->isGroupContainer()) + { + parentGC = static_cast(getParent()->getParent()); + } + } + + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); + + // Draw the container + CViewRenderer &rVR = *CViewRenderer::getInstance(); + CRGBA col = CWidgetManager::getInstance()->getGlobalColor(); + + bool bGrayed = isGrayed(); + if (bGrayed) + { + col.R = col.R / 2; + col.G = col.G / 2; + col.B = col.B / 2; + CWidgetManager::getInstance()->setGlobalColor(col); + oldGlobalColor.R = oldGlobalColor.R / 2; + oldGlobalColor.G = oldGlobalColor.G / 2; + oldGlobalColor.B = oldGlobalColor.B / 2; + } + + if (_MovingInParentList) + { + // display half tone when moving in parent + col.A >>= 1; + } + // if the father is a group container, do modulation too + if (parentGC) + { + // _CurrentContainerAlpha = (uint8) (((uint16) parentGC->getCurrentContainerAlpha() * (uint16) _ContainerAlpha) >> 8); + _CurrentContainerAlpha = parentGC->getCurrentContainerAlpha(); + } + else + { + _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; + } + // modulate by container alpha color + col.A = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) col.A) >> 8); + // Modulate by parent rollover + if (parentGC) + { + // _ICurrentRolloverAlpha = (uint8) (((uint16) parentGC->_ICurrentRolloverAlpha * (uint16) _ICurrentRolloverAlpha) >> 8); + _ICurrentRolloverAlphaContent = parentGC->_ICurrentRolloverAlphaContent; + _ICurrentRolloverAlphaContainer = parentGC->_ICurrentRolloverAlphaContainer; + } + else + { + uint8 rolloverFactorContent = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContent()) : _RolloverAlphaContent; + _ICurrentRolloverAlphaContent = (uint8) (255 - rolloverFactorContent + rolloverFactorContent * _CurrentRolloverAlphaContent); + uint8 rolloverFactorContainer = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContainer()) : _RolloverAlphaContainer; + _ICurrentRolloverAlphaContainer = (uint8) (255 - rolloverFactorContainer + rolloverFactorContainer * _CurrentRolloverAlphaContainer); + } + // Modulate alpha by rollover alpha + col.A = (uint8) (((uint16) _ICurrentRolloverAlphaContainer * (uint16) col.A) >> 8); + // + COptionsLayer *pLayer = getContainerOptions(); + // h is the size of what is on top of the child list + sint32 x, y, w, h; + + h = pLayer->H_T + pLayer->H_B_Open; + + if (_Opened) + { + if (_HeaderOpened != NULL) + h += max (_HeaderOpened->getHReal(), pLayer->HeaderH); + else + h += pLayer->HeaderH; + + if (_Content != NULL) + h += _Content->getHReal(); + + h -= _ContentYOffset; + } + else + { + h = _HReal; + } + bool bHasChild = (_List->getNbElement() > 0); + + x = _XReal; + y = _YReal+_HReal-h; + w = _WReal; + sint8 rl = _RenderLayer; + if (_LayerSetup == 0) + { + // Top Left + rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_TL, pLayer->W_TL, pLayer->H_TL, 0, false, pLayer->TxId_TL, col); + // Top + if (pLayer->Tile_T == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, pLayer->Tile_T-1, col); + // Top Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_TR, y+h-pLayer->H_TR, pLayer->W_TR, pLayer->H_TR, 0, false, pLayer->TxId_TR, col); + + if ((!_Opened) || (_Opened && !bHasChild)) + { // Not opened + // Left + if (pLayer->Tile_L == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, col); + else + rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); + // Right + if (pLayer->Tile_R == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR), 0, false, pLayer->TxId_R, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); + // Bottom Left + rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL, pLayer->H_BL, 0, false, pLayer->TxId_BL, col); + // Bottom + if (pLayer->Tile_B == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, pLayer->Tile_B-1, col); + // Bottom Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR, y, pLayer->W_BR, pLayer->H_BR, 0, false, pLayer->TxId_BR, col); + // Content + if (pLayer->Tile_Blank == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); + } + else + { // Opened + // Left + if (pLayer->Tile_L == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, col); + else + rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); + // Right + if (pLayer->Tile_R == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); + // Bottom Left + rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL_Open, pLayer->H_BL_Open, 0, false, pLayer->TxId_BL_Open, col); + // Bottom + if (pLayer->Tile_B_Open == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, pLayer->Tile_B_Open-1, col); + // Bottom Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR_Open, y, pLayer->W_BR_Open, pLayer->H_BR_Open, 0, false, pLayer->TxId_BR_Open, col); + // Content + if (pLayer->Tile_Blank == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); + // ScrollBar Placement + if (pLayer->Tile_M_Open == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x, _YReal+pLayer->H_EL_Open, pLayer->W_M_Open, _HReal-h-pLayer->H_EL_Open, 0, false, pLayer->TxId_M_Open, col); + else + rVR.drawRotFlipBitmapTiled (rl, x, _YReal+pLayer->H_EL_Open, pLayer->W_M_Open, _HReal-h-pLayer->H_EL_Open, 0, false, pLayer->TxId_M_Open, pLayer->Tile_M_Open-1, col); + // Ending Left + rVR.drawRotFlipBitmap (rl, x, _YReal, pLayer->W_EL_Open, pLayer->H_EL_Open, 0, false, pLayer->TxId_EL_Open, col); + // Ending Middle + if (pLayer->Tile_EM_Open == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_EL_Open, _YReal, w-(pLayer->W_EL_Open+pLayer->W_ER_Open), pLayer->H_EM_Open, 0, false, pLayer->TxId_EM_Open, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_EL_Open, _YReal, w-(pLayer->W_EL_Open+pLayer->W_ER_Open), pLayer->H_EM_Open, 0, false, pLayer->TxId_EM_Open, pLayer->Tile_EM_Open-1, col); + // Ending Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_ER_Open, _YReal, pLayer->W_ER_Open, pLayer->H_ER_Open, 0, false, pLayer->TxId_ER_Open, col); + } + } + else // Version for layer 1,2,3 + { + // Top Left + rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_TL, pLayer->W_TL, pLayer->H_TL, 0, false, pLayer->TxId_TL, col); + // Top + if (pLayer->Tile_T == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, pLayer->Tile_T-1, col); + // Top Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_TR, y+h-pLayer->H_TR, pLayer->W_TR, pLayer->H_TR, 0, false, pLayer->TxId_TR, col); + + if ((!_Opened) || (_Opened && !bHasChild)) + { + // Left + if (pLayer->Tile_L == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, col); + else + rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); + // Right + if (pLayer->Tile_T == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_R, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); + // Bottom Left + rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL, pLayer->H_BL, 0, false, pLayer->TxId_BL, col); + // Bottom + if (pLayer->Tile_B == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, pLayer->Tile_B-1, col); + // Bottom Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR, y, pLayer->W_BR, pLayer->H_BR, 0, false, pLayer->TxId_BR, col); + // Content + if (pLayer->Tile_Blank == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); + } + else + { + // Left + if (pLayer->Tile_L == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, col); + else + rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); + // Right + if (pLayer->Tile_R == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); + // Bottom Left + rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL_Open, pLayer->H_BL_Open, 0, false, pLayer->TxId_BL_Open, col); + // Bottom + if (pLayer->Tile_B_Open == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, pLayer->Tile_B_Open-1, col); + // Bottom Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR_Open, y, pLayer->W_BR_Open, pLayer->H_BR_Open, 0, false, pLayer->TxId_BR_Open, col); + // Content + if (pLayer->Tile_Blank == 0) + rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B_Open, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B_Open, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); + } + } + + + if (_Blinking) + { + CWidgetManager::getInstance()->setGlobalColor(oldGlobalColor); + } + + // Top window : title is highlighted + if (_LayerSetup == 0) + { + CRGBA c = CRGBA(255,255,255,255); + // Display the header in white if we are the last clicked window + if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != this) + { + if (_HeaderColor.getNodePtr() != NULL) + c = _HeaderColor.getRGBA(); + if (bGrayed) + { + c.R = c.R / 2; + c.G = c.G / 2; + c.B = c.B / 2; + } + c.A = 255; + } + if (_TitleClosed != NULL) _TitleClosed->setColor(c); + if (_TitleOpened != NULL) _TitleOpened->setColor(c); + if (_ViewOpenState != NULL) _ViewOpenState->setColor(c); + if (_RightButton != NULL) + { + _RightButton->setColor(c); + _RightButton->setColorPushed(c); + _RightButton->setColorOver(c); + } + if (_HelpButton != NULL) + { + _HelpButton->setColor(c); + _HelpButton->setColorPushed(c); + _HelpButton->setColorOver(c); + } + } + + // Render inside window + + uint8 oldAlphaContent = CWidgetManager::getInstance()->getContentAlpha(); + uint8 oldAlphaContainer = _CurrentContainerAlpha; + if (parentGC) + { + // _CurrentContentAlpha = (uint8) (((uint16) _ContentAlpha * (uint16) parentGC->getCurrentContentAlpha()) >> 8); + _CurrentContentAlpha = parentGC->getCurrentContentAlpha(); + _CurrentContainerAlpha = parentGC->getCurrentContainerAlpha(); + } + else + { + _CurrentContentAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContentAlpha() : _ContentAlpha; + _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; + } + // set content alpha multiplied by rollover alpha + CWidgetManager::getInstance()->setContentAlpha((uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8)); + // set content alpha multiplied by rollover alpha + _CurrentContainerAlpha = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) _ICurrentRolloverAlphaContainer) >> 8); + + // Display the color title bar (if the header is active) + if (_LayerSetup == 0) + { + if (_HeaderActive) + { + CRGBA c(255,255,255,255); + if (_HeaderColor.getNodePtr() != NULL) + c = _HeaderColor.getRGBA(); + if (bGrayed) + { + c.R = c.R / 2; + c.G = c.G / 2; + c.B = c.B / 2; + } + c.A = (uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8); + // Left + rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_L_Header, pLayer->W_L_Header, pLayer->H_L_Header, 0, false, pLayer->TxId_L_Header, c); + // Middle + if (pLayer->Tile_M_Header == 0) // Tiling ? + rVR.drawRotFlipBitmap (rl, x+pLayer->W_L_Header, y+h-pLayer->H_M_Header, w-(pLayer->W_L_Header+pLayer->W_R_Header), pLayer->H_M_Header, 0, false, pLayer->TxId_M_Header, c); + else + rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L_Header, y+h-pLayer->H_M_Header, w-(pLayer->W_L_Header+pLayer->W_R_Header), pLayer->H_M_Header, 0, false, pLayer->TxId_M_Header, pLayer->Tile_M_Header-1, c); + // Right + rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R_Header, y+h-pLayer->H_R_Header, pLayer->W_R_Header, pLayer->H_R_Header, 0, false, pLayer->TxId_R_Header, c); + } + } + + + CInterfaceGroup::draw(); + + + if (_LayerSetup == 0) + if ((_HighLighted) || (_CurrentContainerAlpha <= 128)) + { + uint8 nInverted = (128-_CurrentContainerAlpha)/2; + if (!_HighLighted) + col.A = nInverted; + else + col.A = max(_HighLightedAlpha, nInverted); + sint32 hw, hh; // size of highlight texture + rVR.getTextureSizeFromId(pLayer->TxId_TL_HighLight, hw, hh); + // corners + rVR.drawRotFlipBitmap (_RenderLayer, x, y + h - hh, hw, hh, 0, false, pLayer->TxId_TL_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, y + h - hh, hw, hh, 0, false, pLayer->TxId_TR_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal, hw, hh, 0, false, pLayer->TxId_BL_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, _YReal, hw, hh, 0, false, pLayer->TxId_BR_HighLight, col); + // border + rVR.drawRotFlipBitmap (_RenderLayer, x + hw, y + h - hh, _WReal - 2 * hw, hh, 0, false, pLayer->TxId_T_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x + hw, _YReal, _WReal - 2 * hw, hh, 0, false, pLayer->TxId_B_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal + hh, hw, _HReal - 2 * hh, 0, false, pLayer->TxId_L_HighLight, col); + rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, _YReal + hh, hw, _HReal - 2 * hh, 0, false, pLayer->TxId_R_HighLight, col); + } + + + CWidgetManager::getInstance()->setContentAlpha(oldAlphaContent); + _CurrentContainerAlpha = oldAlphaContainer; + + + // manage rollover + CViewPointerBase *mousePointer = CWidgetManager::getInstance()->getPointer(); + if (mousePointer) + { + bool dontFade = false; + // bool alphaUp = false; + // should not applied if the container is being resized + if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) + { + CInterfaceGroup *ig = CWidgetManager::getInstance()->getCapturePointerLeft()->getParent(); + while (ig) + { + if (ig == this) + { + dontFade = true; + break; + } + ig = ig->getParent(); + } + } + + if (hasKeyboardFocus()) dontFade =true; + + bool isOver = false; + + if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) + if (isIn(mousePointer->getX(), mousePointer->getY())) + { + CInterfaceGroup *ig = CWidgetManager::getInstance()->getCurrentWindowUnder(); + while (ig) + { + if (ig == this) + { + isOver = true; + break; + } + ig = ig->getParent(); + } + } + if (dontFade || isOver) + { + _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); + + _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); + } + else + { + _CurrentRolloverAlphaContent -= (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContent = std::max(0.f, _CurrentRolloverAlphaContent); + + _CurrentRolloverAlphaContainer -= (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContainer = std::max(0.f, _CurrentRolloverAlphaContainer); + } + } + + if (bGrayed) + { + CWidgetManager::getInstance()->setGlobalColor(oldGColForGrayed); + } + + + // Restore the old clip window + restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); + } + + // *************************************************************************** + void CGroupContainer::clearViews() + { + CInterfaceGroup::clearViews(); + } + + // *************************************************************************** + bool CGroupContainer::handleEvent (const NLGUI::CEventDescriptor& event) + { + if (!_Active) + return false; + + if (_MovingInParentList) + { + return true; + } + + if (!checkIfModal(event)) + return false; + + if (!CInterfaceGroup::handleEvent(event)) + { + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + // MouseWheel mgt + if ((_LayerSetup == 0) && (isIn(eventDesc.getX(), eventDesc.getY()))) + { + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + if (_ScrollBar != NULL) + _ScrollBar->moveTrackY (eventDesc.getWheel()*12); + return true; + } + } + } + return false; + } + + return true; + } + + // *************************************************************************** + void CGroupContainer::open() + { + disableBlink(); + _Opened = true; + _OpenAtStart = true; + if (_TitleOpened != NULL) _TitleOpened->setActive(true); + if (_TitleClosed != NULL) _TitleClosed->setActive(false); + + if ((_Openable) && (_LayerSetup >= 0)) + { + COptionsLayer *pLayer = getContainerOptions(); + if (_ViewOpenState != NULL) _ViewOpenState->setTexture(pLayer->getValStr ("open_state_tx_opened")); + } + + if (_List != NULL) _List->setActive(true); + + if (_ScrollBar != NULL) _ScrollBar->setActive(true); + if (_Content != NULL) _Content->setActive(true); + if (_HeaderClosed != NULL) _HeaderClosed->setActive(false); + if (_HeaderOpened != NULL) _HeaderOpened->setActive(true); + + invalidateCoords(); + + // call action handler if any + if (_AHOnOpen != NULL) + { + CAHManager::getInstance()->runActionHandler(_AHOnOpen, this, _AHOnOpenParams); + } + + } + + // *************************************************************************** + void CGroupContainer::close() + { + _Opened = false; + if (_TitleOpened != NULL) _TitleOpened->setActive(false); + if (_TitleClosed != NULL) _TitleClosed->setActive(true); + if ((_Openable) && (_LayerSetup >= 0)) + { + COptionsLayer *pLayer = getContainerOptions(); + if (_ViewOpenState != NULL) _ViewOpenState->setTexture(pLayer->getValStr ("open_state_tx_closed")); + } + if (_List != NULL) _List->setActive(false); + + if (_ScrollBar != NULL) _ScrollBar->setActive(false); + if (_Content != NULL) _Content->setActive(false); + if (_HeaderClosed != NULL) _HeaderClosed->setActive(true); + if (_HeaderOpened != NULL) _HeaderOpened->setActive(false); + invalidateCoords(); + + // call action handler if any + if (_AHOnClose != NULL) + { + CAHManager::getInstance()->runActionHandler(_AHOnClose, this, _AHOnCloseParams); + } + } + + // *************************************************************************** + void CGroupContainer::attachContainer (CGroupContainer *pIC, sint insertionOrder /* = -1 */) + { + if (_List == NULL) + { + _List = new CGroupList(CViewBase::TCtorParam()); + _List->setId (_Id+":list"); + _List->setParent (this); + } + + // Remove from the list if already inserted + _List->delChild (pIC, true); + if (insertionOrder == -1) + { + _List->addChild (pIC, false); // Do not delete it on remove ! + } + else + { + uint k = 0; + for(k = 0; k < (uint) _List->getNbElement(); ++k) + { + if (_List->getOrder(k) > (uint) insertionOrder) break; + } + _List->addChildAtIndex(pIC, k, false); + _List->setOrder(k, insertionOrder); + } + + // Create MaxH Resizer if not already created + createResizerMaxH(); + } + + + // *************************************************************************** + bool CGroupContainer::attachContainerAtIndex(CGroupContainer *pIC, uint index) + { + if (_List == NULL) + { + _List = new CGroupList(CViewBase::TCtorParam()); + _List->setId (_Id+":list"); + _List->setParent (this); + } + if (index > (uint) _List->getNbElement()) + { + nlwarning("Bad index"); + return false; + } + uint eltOrder; + if (index == (uint) _List->getNbElement()) + { + if (_List->getNbElement() == 0) + { + eltOrder = 0; + } + else + { + eltOrder = _List->getOrder(index - 1); + } + } + else + { + eltOrder = _List->getOrder(index); + } + uint k; + for(k = index; k < (uint) _List->getNbElement(); ++k) + { + _List->setOrder(k, _List->getOrder(k) + 1); + } + // change insertion order of poped containers + for(k = 0; k < _PopedCont.size(); ++k) + { + if (_PopedCont[k]->_InsertionOrder >= eltOrder) + { + ++ _PopedCont[k]->_InsertionOrder; + } + } + attachContainer(pIC, eltOrder); + return true; + } + + + // *************************************************************************** + void CGroupContainer::detachContainer (CGroupContainer *pIC) + { + if (!pIC) return; + nlassert(_List != NULL); + nlassert(pIC->getProprietaryContainer() == this); // should be a son of that container + nlassert(!pIC->isPopuped()); // if the container is poped, should pop it in before detaching it! + _List->delChild (pIC); + _List->invalidateCoords(2); + + // Remove MaxH Resizer if exist + if (_List->getNumChildren() == 0) + { + removeResizerMaxH(); + } + + } + + // *************************************************************************** + void CGroupContainer::removeAllContainers() + { + if (!_List) return; + _List->deleteAllChildren(); + } + + // *************************************************************************** + void CGroupContainer::setMovable(bool b) + { + if (_Movable != b) + { + _Movable = b; + if (_LayerSetup != -1) + { + updateMover(); + } + } + } + + // Make from layer + // *************************************************************************** + void CGroupContainer::setup() + { + sint32 nNewLayer = getLayer(); + if (_LayerSetup == nNewLayer) + return; + + _LayerSetup = nNewLayer; + + if ((_LayerSetup == 0) && _Popable) + { + _Poped = true; + } + else + { + _Poped = false; + } + + + COptionsLayer *pLayer = getContainerOptions(_LayerSetup); + + if (_LayerSetup == 0) + { + setParentPosRef(Hotspot_BL); + setPosRef(Hotspot_TL); + } + else + { + setParentPosRef(Hotspot_TL); + setPosRef(Hotspot_TL); + } + + // At start, consider all closed. + + // Title when the container is opened + updateTitle(); + + // Opened state view (tells the user if the container is openable (if the view appears) and if its opened/closed + updateViewOpenState(); + + // Multi usage button + updateRightButton(); + + // Help button + updateHelpButton(); + + // if the window is popable, + + if (_List == NULL) + _List = new CGroupList(CViewBase::TCtorParam()); + _List->setId(_Id+":list"); + _List->setParent (this); + _List->setParentPos (this); + _List->setParentPosRef (Hotspot_TL); + _List->setPosRef (Hotspot_TL); + _List->setActive (_Opened); + + if (_LayerSetup == 0) + { + _ScrollBar = new CCtrlScroll(CViewBase::TCtorParam()); + _ScrollBar->setId (_Id+":sb"); + _ScrollBar->setParent (this); + _ScrollBar->setParentPos (this); + _ScrollBar->setParentPosRef (Hotspot_TL); + _ScrollBar->setPosRef (Hotspot_TL); + _ScrollBar->setTarget(_List); + _ScrollBar->setW (pLayer->Scrollbar_W); // TODO read this from somewhere + _ScrollBar->setAlign (3); // Top + _ScrollBar->setTextureBottomOrLeft (pLayer->TxId_B_Scrollbar); + _ScrollBar->setTextureMiddle (pLayer->TxId_M_Scrollbar); + _ScrollBar->setTextureTopOrRight (pLayer->TxId_T_Scrollbar); + _ScrollBar->setTextureMiddleTile ((uint8)pLayer->Tile_M_Scrollbar); + _ScrollBar->setActive (false); + } + else + { + _ScrollBar = NULL; + } + + + // del all previous resizers + uint k; + for(k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) + { + delCtrl (toString("rz%d", (int) k)); + _Resizer[k] = NULL; + } + } + + // Create Mover + updateMover(); + + // Remove previous controls / views + + delGroup ("list", true); + delCtrl ("sb"); + + COptionsContainerMove *options = getMoveOptions(); + + // create resizer? + if ((_LayerSetup == 0) && (_EnabledResizer)) + { + if (options) + { + sint yOffset; + // if no specific top Size specified + if(_ResizerTopSize<0) + yOffset= -options->ResizerSize; + else + yOffset= -_ResizerTopSize; + // create the resizers + createResizer(0, Hotspot_TL, Hotspot_TM, options->ResizerSize, 0, false); + createResizer(1, Hotspot_TR, Hotspot_TR, 0, 0, false); + createResizer(2, Hotspot_TR, Hotspot_MR, 0, yOffset, false); + createResizer(3, Hotspot_BR, Hotspot_BR, 0, 0, false); + createResizer(4, Hotspot_BR, Hotspot_BM, -options->ResizerSize, 0, false); + createResizer(5, Hotspot_BL, Hotspot_BL, 0, 0, false); + createResizer(6, Hotspot_TL, Hotspot_ML, 0, yOffset, false); + createResizer(7, Hotspot_TL, Hotspot_TL, 0, 0, false); + } + } + + if ((_LayerSetup == 0) && (options)) + { + createResizerMaxH(); + } + + addGroup (_List); + if (_ScrollBar != NULL) addCtrl (_ScrollBar); + + // Link with script + + _Content = getGroup ("content"); + if (_Content != NULL) + { + // Content must be (TL TL), (TR TR) or (TM TM) + _Content->setPosRef( (THotSpot)((_Content->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); + _Content->setParentPosRef(_Content->getPosRef()); + _Content->setActive (false); + } + + _HeaderOpened = getGroup ("header_opened"); + if (_HeaderOpened != NULL) + { + // Header opened must be (TL TL), (TR TR) or (TM TM) + _HeaderOpened->setPosRef( (THotSpot)((_HeaderOpened->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); + _HeaderOpened->setParentPosRef(_HeaderOpened->getPosRef()); + _HeaderOpened->setActive (_Opened); + } + + _HeaderClosed = getGroup ("header_closed"); + if (_HeaderClosed != NULL) + { + // Header closed must be (TL TL), (TR TR) or (TM TM) + _HeaderClosed->setPosRef( (THotSpot)((_HeaderClosed->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); + _HeaderClosed->setParentPosRef(_HeaderClosed->getPosRef()); + _HeaderClosed->setActive (!_Opened); + } + + _List->setActive(_Opened); + if (_ScrollBar != NULL) _ScrollBar->setActive(_Opened); + if (_Content != NULL) _Content->setActive(_Opened); + + if (!_ModalParentNames.empty()) + { + // reassign the first setup time + setModalParentList(_ModalParentNames); + } + + invalidateCoords (); + } + + + // *************************************************************************** + // Update right button depending on pop, popable, layer and locked + void CGroupContainer::updateRightButton() + { + if ((_EnabledRightButton) && (!((_LayerSetup>0)&&(!_Popable)))) + { + COptionsLayer *pLayer = getContainerOptions(); + + // Create right button + if (_RightButton == NULL) + { + _RightButton = new CCtrlButton(CViewBase::TCtorParam()); + _RightButton->setId(_Id+":rightbut"); + _RightButton->setType(CCtrlBaseButton::PushButton); + _RightButton->setParent (this); + _RightButton->setParentPos (this); + _RightButton->setParentPosRef (Hotspot_TR); + _RightButton->setPosRef (Hotspot_TR); + _RightButton->setModulateGlobalColorAll (getModulateGlobalColor()); + _RightButton->setModulateGlobalColorOver (true); + addCtrl (_RightButton); + } + _RightButton->setX(pLayer->getValSInt32 ("right_button_offset_x")); + _RightButton->setY(pLayer->getValSInt32 ("right_button_offset_y")); + + if (_LayerSetup == 0) + { + if (_Locked) + { + _RightButton->setTexture (pLayer->getValStr ("right_button_tx_locked")); + _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_locked")); + _RightButton->setTextureOver (""); + _RightButton->setActionOnLeftClick (""); + _RightButton->setDefaultContextHelp(string("")); + } + else + { + // If the container is normally a layer>0 and is poped ? popin button + if (_OldFatherContainer != NULL) + { + _RightButton->setTexture (pLayer->getValStr ("right_button_tx_popin")); + _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_popin")); + _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); + _RightButton->setActionOnLeftClick ("ic_popin"); + _RightButton->setDefaultContextHelp(CI18N::get("uiPopinWindow")); + } + else // else the container can be deactivated ? deactivate button + { + _RightButton->setTexture (pLayer->getValStr ("right_button_tx_deactive")); + _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_deactive")); + _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); + _RightButton->setActionOnLeftClick ("ic_deactive"); + _RightButton->setDefaultContextHelp(CI18N::get("uiClose")); + } + } + } + else + { + // If the container can be a popup ? popup button + if (_Popable) + { + _RightButton->setTexture (pLayer->getValStr ("right_button_tx_popup")); + _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_popup")); + _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); + _RightButton->setActionOnLeftClick ("ic_popup"); + _RightButton->setDefaultContextHelp(CI18N::get("uiPopupWindow")); + } + _RightButton->setActive(!_Locked); + } + } + else + { + // Delete right button + delCtrl ("rightbut"); + _RightButton = NULL; + } + } + + + // *************************************************************************** + void CGroupContainer::updateHelpButton() + { + // enable the help button only if has some help page + if ( _EnabledHelpButton && !_HelpPage.empty() ) + { + COptionsLayer *pLayer = getContainerOptions(); + + // Create Help button + if (_HelpButton == NULL) + { + _HelpButton = new CCtrlButton(CViewBase::TCtorParam()); + _HelpButton->setId(_Id+":helpbut"); + _HelpButton->setType(CCtrlBaseButton::PushButton); + _HelpButton->setParent (this); + _HelpButton->setParentPos (this); + _HelpButton->setParentPosRef (Hotspot_TR); + _HelpButton->setPosRef (Hotspot_TR); + _HelpButton->setModulateGlobalColorAll (getModulateGlobalColor()); + _HelpButton->setModulateGlobalColorOver (true); + addCtrl (_HelpButton); + + _HelpButton->setX(pLayer->getValSInt32 ("help_button_offset_x")); + _HelpButton->setY(pLayer->getValSInt32 ("help_button_offset_y")); + + _HelpButton->setTexture (pLayer->getValStr ("help_button_tx")); + _HelpButton->setTexturePushed (pLayer->getValStr ("help_button_tx")); + _HelpButton->setTextureOver (pLayer->getValStr ("help_button_tx_over")); + _HelpButton->setActionOnLeftClick ("ic_help"); + _HelpButton->setDefaultContextHelp(CI18N::get("uiHelp")); + } + + // if not layer 0 + if (_LayerSetup > 0) + { + // if locked, the right button is not displayed => take its pos instead + if(_Locked) + { + _HelpButton->setX(pLayer->getValSInt32 ("help_button_offset_x")); + _HelpButton->setY(pLayer->getValSInt32 ("help_button_offset_y")); + } + else + { + _HelpButton->setX(pLayer->getValSInt32 ("right_button_offset_x")); + _HelpButton->setY(pLayer->getValSInt32 ("right_button_offset_y")); + } + } + } + else + { + // Delete help button + delCtrl ("helpbut"); + _HelpButton = NULL; + } + } + + + // *************************************************************************** + void CGroupContainer::updateMover() + { + if (_Movable || _Popable || _Openable) + { + COptionsContainerMove *options = getMoveOptions(); + _Mover = new CCtrlMover(CViewText::TCtorParam(), _Movable || _Popable || _MovableInParentList, _Openable); + _Mover->setId (_Id+":mover"); + _Mover->setParent (this); + _Mover->setParentPos (this); + _Mover->setParentPosRef (Hotspot_TM); + _Mover->setPosRef (Hotspot_TM); + if (_Poped && _EnabledResizer) + _Mover->setY (options->TrackYWithTopResizer); + else + _Mover->setY (options->TrackY); + _Mover->setH (options->TrackH); + _MoverDeltaW= options->TrackW; + } + else + { + _Mover = NULL; + } + delCtrl ("mover"); + if (_Mover != NULL) + addCtrl (_Mover, 0); + invalidateCoords(); + } + + // *************************************************************************** + void CGroupContainer::updateViewOpenState() + { + if (_Openable) + { + COptionsLayer *pLayer = getContainerOptions(); + if (_ViewOpenState == NULL) + { + _ViewOpenState = new CViewBitmap(CViewBase::TCtorParam()); + _ViewOpenState->setId(_Id+":open_state"); + _ViewOpenState->setParent (this); + _ViewOpenState->setParentPos (this); + _ViewOpenState->setParentPosRef (Hotspot_TL); + _ViewOpenState->setPosRef (Hotspot_TL); + _ViewOpenState->setModulateGlobalColor (getModulateGlobalColor()); + addView (_ViewOpenState); + } + _ViewOpenState->setX(pLayer->getValSInt32 ("open_state_offset_x")); + _ViewOpenState->setY(pLayer->getValSInt32 ("open_state_offset_y")); + + if (_Opened) + _ViewOpenState->setTexture (pLayer->getValStr ("open_state_tx_opened")); + else + _ViewOpenState->setTexture (pLayer->getValStr ("open_state_tx_closed")); + _ViewOpenState->setActive(!_Locked); + } + else + { + _ViewOpenState = NULL; + delView ("open_state"); + } + } + + // *************************************************************************** + void CGroupContainer::updateTitle() + { + COptionsLayer *pLayer = getContainerOptions(); + if (_TitleOpened == NULL) + { + switch(_TitleClass) + { + case TitleTextFormated: + { + CViewTextFormated *vtf = new CViewTextFormated(CViewBase::TCtorParam()); + vtf->setFormatString(_TitleTextOpened); + _TitleOpened = vtf; + } + break; + case TitleTextId: + case TitleTextDynString: + { + CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); + // the title here is actually the DB path + vti->setDBTextID(_TitleTextOpened.toString()); + vti->setDynamicString(_TitleClass==TitleTextDynString); + _TitleOpened = vti; + } + break; + default: + _TitleOpened = new CViewText(CViewBase::TCtorParam()); + } + _TitleOpened->setId(_Id+":titopen"); + _TitleOpened->setParent (this); + _TitleOpened->setParentPos (this); + _TitleOpened->setParentPosRef (Hotspot_TL); + _TitleOpened->setPosRef (Hotspot_TL); + _TitleOpened->setShadow (true); + _TitleOpened->setColor (CRGBA(255,255,255,255)); + _TitleOpened->setModulateGlobalColor(getModulateGlobalColor()); + _TitleOpened->setOverExtendViewText(_TitleOverExtendViewText); + addView (_TitleOpened); + } + + if (_Openable) + { + _TitleOpened->setX (pLayer->getValSInt32 ("title_offset_openable_x")); + _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_openable_y")); + } + else + { + _TitleOpened->setX (pLayer->getValSInt32 ("title_offset_x")); + _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); + } + _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); + if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); + _TitleOpened->setActive (_Opened); + + // Title when the container is closed + if (_TitleClosed == NULL) + { + switch(_TitleClass) + { + case TitleTextFormated: + { + CViewTextFormated *vtf = new CViewTextFormated(CViewBase::TCtorParam()); + vtf->setFormatString(_TitleTextClosed); + _TitleClosed = vtf; + } + break; + case TitleTextId: + case TitleTextDynString: + { + CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); + // the title here is actually the DB path + vti->setDBTextID(_TitleTextClosed.toString()); + vti->setDynamicString(_TitleClass==TitleTextDynString); + _TitleClosed = vti; + } + break; + default: + _TitleClosed = new CViewText(CViewBase::TCtorParam()); + } + _TitleClosed->setId(_Id+":titclose"); + _TitleClosed->setParent (this); + _TitleClosed->setParentPos (this); + _TitleClosed->setParentPosRef (Hotspot_TL); + _TitleClosed->setPosRef (Hotspot_TL); + _TitleClosed->setShadow (true); + _TitleClosed->setColor (CRGBA(255,255,255,255)); + _TitleClosed->setModulateGlobalColor(getModulateGlobalColor()); + _TitleClosed->setOverExtendViewText(_TitleOverExtendViewText); + addView (_TitleClosed); + } + + if (_Openable) + { + _TitleClosed->setX (pLayer->getValSInt32 ("title_offset_openable_x")); + _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_openable_y")); + } + else + { + _TitleClosed->setX (pLayer->getValSInt32 ("title_offset_x")); + _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); + } + _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); + if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); + _TitleClosed->setActive(!_Opened); + + + } + + // *************************************************************************** + // bMaxH is a boolean to know if the resizer act on the content or on the child list + void CGroupContainer::createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH) + { + CCtrlResizer *cr = new CCtrlResizer(CViewText::TCtorParam()); + cr->setId (_Id+toString(":rz%d", (int) index)); + cr->setParent (this); + cr->setParentPos (this); + cr->setResizerPos(type); + + if (_LayerSetup != 0) + { + cr->WMin = _MinW; + cr->WMax = _MaxW; + } + else + { + cr->WMin = _PopupMinW; + cr->WMax = _PopupMaxW; + cr->HMin = _PopupMinH; + cr->HMax = _PopupMaxH; + } + + cr->setParentPosRef (posRef); + cr->setPosRef (posRef); + + cr->setX(offsetX); + cr->setY(offsetY); + + cr->IsMaxH = bMaxH; + + updateResizerSize(cr); + _Resizer[index] = cr; + addCtrl (_Resizer[index], 0); + } + + // *************************************************************************** + void CGroupContainer::createResizerMaxH() + { + if (_LayerSetup != 0) return; + if (_List == NULL) return; + if (_List->getNumChildren() == 0) return; + + COptionsContainerMove *options = getMoveOptions(); + + // Create corner resizer if we asked for all resizer + if (_EnabledResizer) + { + if (_Resizer[1] == NULL) createResizer(1, Hotspot_TR, Hotspot_TR, 0, 0, true); + if (_Resizer[3] == NULL) createResizer(3, Hotspot_BR, Hotspot_BR, 0, 0, true); + if (_Resizer[5] == NULL) createResizer(5, Hotspot_BL, Hotspot_BL, 0, 0, true); + if (_Resizer[7] == NULL) createResizer(7, Hotspot_TL, Hotspot_TL, 0, 0, true); + _Resizer[1]->IsMaxH = true; + _Resizer[3]->IsMaxH = true; + _Resizer[5]->IsMaxH = true; + _Resizer[7]->IsMaxH = true; + } + + if (_Resizer[0] == NULL) createResizer(0, Hotspot_TL, Hotspot_TM, options->ResizerSize, 0, true); + if (_Resizer[4] == NULL) createResizer(4, Hotspot_BR, Hotspot_BM, -options->ResizerSize, 0, true); + _Resizer[0]->IsMaxH = true; + _Resizer[4]->IsMaxH = true; + } + + // *************************************************************************** + void CGroupContainer::removeResizerMaxH() + { + if (_LayerSetup != 0) return; + if (_List == NULL) return; + if (_List->getNumChildren() != 0) return; + + for (uint i = 0; i < NumResizers; ++i) + if ((i != 6) && (i != 2)) // 6 == right and 2 == left + if (_Resizer[i] != NULL) + { + delCtrl ( toString(":rz%d", (int) i) ); + _Resizer[i] = NULL; + } + } + + // *************************************************************************** + sint32 CGroupContainer::getLayer() + { + if (_MovingInParentList) + { + // keep the previous layer + return _LayerSetup; + } + else + { + // Count Nb of Parent + CInterfaceGroup *pIG = this; + sint32 nNbParent = 0; + while (pIG != NULL) + { + pIG = pIG->getParent(); + if (pIG != NULL) + nNbParent++; + } + return (nNbParent-1)/2; + } + } + + // *************************************************************************** + COptionsLayer *CGroupContainer::getContainerOptions(sint32 ls) + { + if (ls == -1) + ls = _LayerSetup; + + string sTmp; + const string *sLayerName; + if (_OptionsName.empty()) + { + nlassert((uint32)lsgetOptions(*sLayerName); + nlassert(pLayer != NULL); + return pLayer; + } + + // *************************************************************************** + void CGroupContainer::setContent (CInterfaceGroup *pC) + { + if (_Content != NULL) + delGroup (_Content); + _Content = pC; + if (_Content) + { + _Content->setId (_Id+":content"); + _Content->setActive (false); + _Content->setParentPosRef (Hotspot_TL); + _Content->setPosRef (Hotspot_TL); + _Content->setParent (this); + addGroup (_Content); + } + } + + // *************************************************************************** + std::string CGroupContainer::getTitle () const + { + return _TitleTextOpened.toString(); + } + + // *************************************************************************** + void CGroupContainer::setTitle (const std::string &title) + { + if (_Localize) setUCTitle (CI18N::get(title)); + else setUCTitle (title); + } + + // *************************************************************************** + std::string CGroupContainer::getTitleOpened () const + { + return _TitleTextOpened.toString(); + } + + // *************************************************************************** + void CGroupContainer::setTitleOpened (const std::string &title) + { + if (_Localize) setUCTitleOpened (CI18N::get(title)); + else setUCTitleOpened (title); + } + + // *************************************************************************** + std::string CGroupContainer::getTitleClosed () const + { + return _TitleTextClosed.toString(); + } + + // *************************************************************************** + void CGroupContainer::setTitleClosed (const std::string &title) + { + if (_Localize) setUCTitleClosed (CI18N::get(title)); + else setUCTitleClosed (title); + } + + // *************************************************************************** + void CGroupContainer::setUCTitleOpened(const ucstring &title) + { + _TitleTextOpened = title; + if (_TitleOpened != NULL) + _TitleOpened->setText (title); + invalidateCoords(); + } + + // *************************************************************************** + void CGroupContainer::setUCTitleClosed(const ucstring &title) + { + _TitleTextClosed = title; + if (_TitleClosed != NULL) + _TitleClosed->setText (_TitleTextClosed); + invalidateCoords(); + } + + // *************************************************************************** + void CGroupContainer::setUCTitle(const ucstring &title) + { + setUCTitleOpened(title); + setUCTitleClosed(title); + } + + // *************************************************************************** + ucstring CGroupContainer::getUCTitle () const + { + return getUCTitleOpened(); + } + + // *************************************************************************** + ucstring CGroupContainer::getUCTitleOpened () const + { + return _TitleTextOpened; + } + + // *************************************************************************** + ucstring CGroupContainer::getUCTitleClosed () const + { + return _TitleTextClosed; + } + + // *************************************************************************** + void CGroupContainer::launch () + { + if (_OpenAtStart) + open(); + + CInterfaceGroup::launch(); + } + + // *************************************************************************** + void CGroupContainer::setActive (bool state) + { + if(state != getActive() && getLayer()==0) + { + if (state) + CWidgetManager::getInstance()->setTopWindow(this); + else + CWidgetManager::getInstance()->setBackWindow(this); + } + CAHManager::getInstance()->submitEvent((state?"show:":"hide:")+getId()); + + CInterfaceGroup::setActive(state); + } + + // *************************************************************************** + /*bool CGroupContainer::isWindowUnder (sint32 x, sint32 y) + { + bool bGrayed = false; + CGroupContainer *pSon = _ModalSon; + if ((pSon != NULL) && pSon->getActive()) + bGrayed = true; + + if (bGrayed) return NULL; + return CInterfaceGroup::isWindowUnder(x,y); + }*/ + + // *************************************************************************** + bool CGroupContainer::getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB) + { + bool bGrayed = isGrayed(); + if (bGrayed) return false; + return CInterfaceGroup::getViewsUnder(x, y, clipX, clipY, clipW, clipH, vVB); + } + + // *************************************************************************** + bool CGroupContainer::getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL) + { + bool bGrayed = isGrayed(); + if (bGrayed) return false; + return CInterfaceGroup::getCtrlsUnder(x,y,clipX,clipY,clipW,clipH,vICL); + } + + // *************************************************************************** + void CGroupContainer::popupCurrentPos() + { + if (!_Popable && !_MovableInParentList) + { + nlwarning(" The window is not popable or cannot move in parent list."); + return; + } + if (_LayerSetup == 0) + { + nlwarning(" The window is already poped."); + return; + } + if (!_Parent || !_Parent->getParent()) + { + nlwarning(" Window has not parent."); + return; + } + // remove the group from its father + CGroupContainer *parentContainer = dynamic_cast(_Parent->getParent()); + if (!parentContainer) + { + nlwarning(" Container is not son of another container"); + return; + } + _OldFatherContainer = parentContainer; + sint32 eltIndex = parentContainer->_List->getElementIndex(this); + if (eltIndex == -1) + { + nlwarning(" Can't get index in owner group"); + return; + } + _InsertionOrder = parentContainer->_List->getOrder(eltIndex); + parentContainer->detachContainer(this); + + parentContainer->_PopedCont.push_back(this); + + // put at the base of hierarchy + CInterfaceGroup *parent = _Parent; + if (!parent) return; + while (parent->getParent()) + { + parent = parent->getParent(); + } + _Parent = parent; + _ParentPos = parent; + + CWidgetManager::getInstance()->makeWindow(this); + CWidgetManager::getInstance()->setTopWindow(this); + CWidgetManager::getInstance()->clearViewUnders(); + CWidgetManager::getInstance()->clearCtrlsUnders(); + + // update coords (put coords in world) + setX(getXReal()); + setY(getYReal() + getHReal()); + setParentPosRef(Hotspot_BL); + setPosRef(Hotspot_TL); + + // clamp coords + // width + sint32 w = getW(); + clamp(w, _PopupMinW, _PopupMaxW); + setW(w); + + invalidateCoords(); + + // setup the new controls + _Poped = true; + _OpenedBeforePopup = _Opened; + _Opened = true; + disableBlink(); + setup(); + } + + // *************************************************************************** + void CGroupContainer::popin(sint32 insertPos /* = -1 */, bool putBackInFatherContainer /*= true*/) + { + if (!_OldFatherContainer) + { + nlwarning(" The window wasn't previously attached.(%s)",this->_Id.c_str()); + return; + } + + if (!_Popable && !_MovableInParentList) + { + nlwarning(" The window is not popable or cannot move in parent list.(%s)",this->_Id.c_str()); + return; + } + if (!_MovingInParentList && _LayerSetup != 0) + { + nlwarning(" The window should be in layer 0.(%s)",this->_Id.c_str()); + return; + } + if (!_Parent) + { + nlwarning(" The window has no parent.(%s)",this->_Id.c_str()); + return; + } + + touch(); + _List->setOfsY(0); + + _MovingInParentList = false; + CWidgetManager::getInstance()->unMakeWindow(this); + CWidgetManager::getInstance()->clearViewUnders(); + CWidgetManager::getInstance()->clearCtrlsUnders(); + _Parent = NULL; + _ParentPos = NULL; + std::vector::iterator it = std::find(_PopedCont.begin(), _PopedCont.end(), this); + if (it != _PopedCont.end()) + { + // replace by last element + *it = _PopedCont.back(); + _PopedCont.pop_back(); + } + if (putBackInFatherContainer) + { + bool active = getActive(); + _Poped = false; + if (insertPos == -1) + { + _OldFatherContainer->attachContainer(this, _InsertionOrder); + } + else + { + if (!_OldFatherContainer->attachContainerAtIndex(this, insertPos)) + { + nlwarning("Couldn't attach to previous container"); + return; + } + } + setActive(active); + _OldFatherContainer = NULL; + if (_OpenWhenPopup) + { + setOpen(false); + } + else + { + setOpen(_OpenedBeforePopup); + } + } + + invalidateCoords(); + + _OldFatherContainer = NULL; + setup(); + } + + // *************************************************************************** + void CGroupContainer::enableBlink(uint numBlinks /*=0*/) + { + _Blinking = true; + _NumBlinks = numBlinks; + _BlinkDT = 0; + _BlinkState = true; + } + + // *************************************************************************** + void CGroupContainer::disableBlink() + { + _Blinking = false; + _NumBlinks = 0; + _BlinkDT = 0; + _BlinkState = false; + } + + + // *************************************************************************** + void CGroupContainer::setMovingInParentList(bool enable) + { + _MovingInParentList = enable; + } + + // *************************************************************************** + void CGroupContainer::popup() + { + if (_Poped) return; + touch(); + setHighLighted(false); + // pop the window + popupCurrentPos(); + if (getPopupW() != -1) + { + setX(getPopupX()); + setY(getPopupY()); + setW(getPopupW()); + setH(getPopupH()); + } + else + { + setW(getRefW()); // Do not know what we need to do that ... + } + invalidateCoords(2); + } + + // *************************************************************************** + COptionsContainerMove *CGroupContainer::getMoveOptions() + { + static NLMISC::CRefPtr moveOptions; + if (moveOptions) return moveOptions; + moveOptions = (COptionsContainerMove *) CWidgetManager::getInstance()->getOptions("container_move_opt"); + return moveOptions; + } + + + // *************************************************************************** + // Actions Handlers + // *************************************************************************** + + // *************************************************************************** + class CICOpen : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + pIC->open(); + } + }; + REGISTER_ACTION_HANDLER (CICOpen, "ic_open"); + + // *************************************************************************** + class CICClose : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + pIC->close(); + } + }; + REGISTER_ACTION_HANDLER (CICClose, "ic_close"); + + // *************************************************************************** + class CICDeactive : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + if (pIC->isLocked()) return; + + // check if the window can be really closed + CGroupContainer::_ValidateCanDeactivate = true; + if (!pIC->getAHOnDeactiveCheck().empty()) + { + CAHManager::getInstance()->runActionHandler(pIC->getAHOnDeactiveCheck(), pCaller, pIC->getAHOnDeactiveCheckParams()); + } + + if (CGroupContainer::_ValidateCanDeactivate) + { + // send close button msg + if (!pIC->getAHOnCloseButton().empty()) + { + CAHManager::getInstance()->runActionHandler(pIC->getAHOnCloseButton(), pCaller, pIC->getAHOnCloseButtonParams()); + } + CWidgetManager::getInstance()->setBackWindow(pIC); + pIC->setActive(false); + } + } + }; + REGISTER_ACTION_HANDLER (CICDeactive, "ic_deactive"); + + // *************************************************************************** + class CICPopup : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + if (pIC->isLocked()) return; + // + pIC->popup(); + // + + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + } + }; + REGISTER_ACTION_HANDLER (CICPopup, "ic_popup"); + + // *************************************************************************** + class CICPopin : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + if (pIC->isLocked()) return; + // memorize popup position + pIC->setPopupX(pIC->getX()); + pIC->setPopupY(pIC->getY()); + pIC->setPopupW(pIC->getW()); + pIC->setPopupH(pIC->getH()); + // + pIC->popin(); + + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + CWidgetManager::getInstance()->setCapturePointerRight(NULL); + } + }; + REGISTER_ACTION_HANDLER (CICPopin, "ic_popin"); + + // *************************************************************************** + class CICLock : public IActionHandler + { + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CInterfaceGroup *pIG = pCaller->getParent(); + if (pIG == NULL) return; + CGroupContainer *pIC = dynamic_cast(pIG); + if (pIC == NULL) return; + pIC->setLocked(!pIC->isLocked()); + } + }; + REGISTER_ACTION_HANDLER(CICLock, "ic_lock"); + + // *************************************************************************** + class CICHelp : public IActionHandler + { + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + // get the container to get help + if(!pCaller) + return; + CGroupContainer *pIC = dynamic_cast(pCaller->getRootWindow()); + if (pIC == NULL) return; + + // if found the help page + const std::string &helpPage= pIC->getHelpPage(); + if(!helpPage.empty()) + { + + // open the web browser, and point to the page + CAHManager::getInstance()->runActionHandler("launch_help", NULL, "url=" + helpPage); + } + } + }; + REGISTER_ACTION_HANDLER(CICHelp, "ic_help"); + + // *************************************************************************** + CGroupContainer *CGroupContainer::getFatherContainer() const + { + if (_Parent && _Parent->getParent()) + { + return dynamic_cast(_Parent->getParent()); + } + return NULL; + } + + // *************************************************************************** + CGroupContainer *CGroupContainer::getProprietaryContainer() const + { + if (_Parent && _Parent->getParent()) + { + return dynamic_cast(_Parent->getParent()); + } + else + { + return _OldFatherContainer; + } + } + + // *************************************************************************** + void CGroupContainer::setOpenable(bool openable) + { + // COptionsLayer *pLayer = getContainerOptions(); + // COptionsContainerMove *options = getMoveOptions(); + _Openable = openable; + + updateTitle(); + updateViewOpenState(); + updateMover(); + } + + // *************************************************************************** + void CGroupContainer::rollOverAlphaUp() + { + + CViewPointerBase *vp = CWidgetManager::getInstance()->getPointer(); + float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); + if (!isIn(vp->getX(), vp->getY())) + { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); + + _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); + _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); + } + } + + // *************************************************************************** + void CGroupContainer::forceRolloverAlpha() + { + _CurrentRolloverAlphaContent = hasKeyboardFocus() ? 1.0f : 0.f; + _CurrentRolloverAlphaContainer = hasKeyboardFocus() ? 1.0f : 0.f; + } + + // *************************************************************************** + bool CGroupContainer::hasKeyboardFocus() const + { + + if (CWidgetManager::getInstance()->getCaptureKeyboard() != NULL) + { + const CGroupEditBox *geb = dynamic_cast(CWidgetManager::getInstance()->getCaptureKeyboard()); + if (geb) + { + const CInterfaceGroup *gr = geb->getParent(); + while(gr) + { + if (gr == this) + { + return true; + } + gr = gr->getParent(); + } + } + } + return false; + } + + // *************************************************************************** + void CGroupContainer::setLockable(bool lockable) + { + if (lockable == _Lockable) return; + setup(); + } + + // *************************************************************************** + void CGroupContainer::setLocked(bool locked) + { + if (!_Lockable) + { + nlwarning("Container is not lockable"); + return; + } + if (locked == _Locked) return; + _Locked = locked; + if (_LayerSetup == 0) + { + updateRightButton(); + updateHelpButton(); + if (_ViewOpenState != NULL) _ViewOpenState->setActive(!_Locked); + if (_Mover != NULL) _Mover->setActive(!_Locked); + } + } + + // *************************************************************************** + std::string CGroupContainer::getTitleColorAsString() const + { + // return one of the title opened.... + if(!_TitleOpened) + return std::string(); + + return _TitleOpened->getColorAsString(); + } + + // *************************************************************************** + void CGroupContainer::setTitleColorAsString(const std::string &col) + { + // Set both colors + if(_TitleOpened) + _TitleOpened->setColorAsString(col); + if(_TitleClosed) + _TitleClosed->setColorAsString(col); + } + + // *************************************************************************** + void CGroupContainer::setModalParentList (const std::string &name) + { + _ModalParentNames = name; + + // can have multiple parent + vector modalParents; + NLMISC::splitString(name, "|", modalParents); + // add each of them (if possible) + for(uint i=0;i(CWidgetManager::getInstance()->getElementFromId(modalParents[i])); + if (pGC == NULL) + pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+modalParents[i])); + if (pGC == NULL) + nlwarning(" not found %s",modalParents[i].c_str()); + else + addModalParent (pGC); + } + } + + // *************************************************************************** + void CGroupContainer::addModalParent (CGroupContainer *pParent) + { + if(pParent==NULL) return; + // Look if parent not already added + for(uint i=0;i<_ModalParents.size();++i) + if(_ModalParents[i] == pParent) + return; + // add me to the parent + pParent->addModalSon(this); + _ModalParents.push_back(pParent); + } + + // *************************************************************************** + void CGroupContainer::addModalSon (CGroupContainer *pSon) + { + if (pSon == NULL) return; + // Look if the son not already added + for (uint i = 0; i < _ModalSons.size(); ++i) + if (_ModalSons[i] == pSon) + return; + _ModalSons.push_back(pSon); + } + + // *************************************************************************** + bool CGroupContainer::checkIfModal(const NLGUI::CEventDescriptor& event) + { + bool bRet = true; + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if ((eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) + { + bRet = blinkAllSons(); + } + // Additionaly, if it is a UP, don't blink, but return false if some son active + if (bRet && ( + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) || + (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)) + ) + { + bRet= !isGrayed(); + } + } + return bRet; + } + + // *************************************************************************** + bool CGroupContainer::isGrayed() const + { + bool bGrayed = false; + for (uint i = 0; i < _ModalSons.size(); ++i) + { + CGroupContainer *pSon = _ModalSons[i]; + if (pSon->getActive()) + bGrayed = true; + } + return bGrayed; + } + + // *************************************************************************** + bool CGroupContainer::blinkAllSons() + { + bool bRet = true; + vector allSons = _ModalSons; + uint i,j; + // Recurs all sons (because allSons grow while sons are added). NB: if there is a graph, it will freeze.... + for (i = 0; i < allSons.size(); ++i) + { + CGroupContainer *pSon = allSons[i]; + for (j = 0; j < pSon->_ModalSons.size(); ++j) + allSons.push_back(pSon->_ModalSons[j]); + } + // Then for all sons and descendants, blink + for (i = 0; i < allSons.size(); ++i) + { + CGroupContainer *pSon = allSons[i]; + if (pSon->getActive()) + { + pSon->enableBlink(3); + bRet = false; + } + } + return bRet; + } + + + // *************************************************************************** + void CGroupContainer::forceOpen() + { + // Force open the container. + open(); + // Ensure it is Active too + setActive(true); + } + + // *************************************************************************** + void CGroupContainer::backupPosition() + { + _BackupX = getX(); + _BackupY = getY(); + _PositionBackuped = true; + } + + // *************************************************************************** + void CGroupContainer::restorePosition() + { + if (!_PositionBackuped) return; + setX(_BackupX); + setY(_BackupY); + _PositionBackuped = false; + } + + // *************************************************************************** + bool CGroupContainer::getTouchFlag(bool clearFlag) const + { + bool touchFlag = _TouchFlag; + if (clearFlag) + { + _TouchFlag = false; + } + return touchFlag; + } + + // *************************************************************************** + void CGroupContainer::setBackupPosition(sint32 x, sint32 y) + { + _BackupX = x; + _BackupY = y; + _PositionBackuped = true; + } + + // *************************************************************************** + void CGroupContainer::setPopupMinW(sint32 minW) + { + _PopupMinW = minW; + // TODO : avoid this stupid copy (issue in CCtrResizer..) + for(uint k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) _Resizer[k]->WMin = minW; + } + } + + // *************************************************************************** + void CGroupContainer::setPopupMaxW(sint32 maxW) + { + _PopupMaxW = maxW; + // TODO : avoid this stupid copy (issue in CCtrResizer..) + for(uint k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) _Resizer[k]->WMax = maxW; + } + } + + // *************************************************************************** + void CGroupContainer::setPopupMinH(sint32 minH) + { + _PopupMinH = minH; + // TODO : avoid this stupid copy (issue in CCtrResizer..) + for(uint k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) _Resizer[k]->HMin = minH; + } + } + + // *************************************************************************** + void CGroupContainer::setPopupMaxH(sint32 maxH) + { + _PopupMaxH = maxH; + // TODO : avoid this stupid copy (issue in CCtrResizer..) + for(uint k = 0; k < NumResizers; ++k) + { + if (_Resizer[k]) _Resizer[k]->HMax = maxH; + } + } + // *************************************************************************** + int CGroupContainer::luaSetHeaderColor(CLuaState &ls) + { + const char *funcName = "setHeaderColor"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + _HeaderColor.link(ls.toString(1)); + return 0; + } + + // *************************************************************************** + CRGBA CGroupContainer::getDrawnHeaderColor () const + { + CRGBA c = CRGBA(255,255,255,255); + + // Display the header in white if we are the last clicked window + if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != static_cast(this)) + { + if (_HeaderColor.getNodePtr() != NULL) + c = _HeaderColor.getRGBA(); + if (isGrayed()) + { + c.R = c.R / 2; + c.G = c.G / 2; + c.B = c.B / 2; + } + c.A = 255; + } + + return c; + } + + // *************************************************************************** + void CGroupContainer::setHelpPage(const std::string &newPage) + { + _HelpPage= newPage; + } + + // *************************************************************************** + void CGroupContainer::requireAttention() + { + if (getActive()) + { + // Window have headers opened => blink it if is not the top window + if (isOpen()) + { + if (getId() != CWidgetManager::getInstance()->getTopWindow()->getId()) + { + enableBlink(3); + } + } + // Window have headers closed => change color of header + else + { + setHeaderColor("UI:SAVE:WIN:COLORS:INFOS"); + } + } + else + { + // Must open this window everytime someone tell something on it + setActive(true); + } + } + + + // *************************************************************************** + int CGroupContainer::luaBlink(CLuaState &ls) + { + const char *funcName = "blink"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + enableBlink((uint) ls.toNumber(1)); + return 0; + } + + // *************************************************************************** + void CGroupContainer::setRightButtonEnabled(bool enabled) + { + if (_EnabledRightButton == enabled) return; + _EnabledRightButton = enabled; + updateRightButton(); + } + + // *************************************************************************** + void CGroupContainer::setContentYOffset(sint32 value) + { + #ifdef NL_DEBUG + nlassert(value <= 127 && value >= -128); + #endif + if (value > 127 || value < -128) + { + // for lua exported value, let know the user that there was some problem + throw NLMISC::Exception("y_offset must be in the [-128, 127] range"); + } + _ContentYOffset = (sint8) value; + invalidateCoords(); + } + + +} + diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp index 7ded55f53..b05b5f3cc 100644 --- a/code/ryzom/client/src/cursor_functions.cpp +++ b/code/ryzom/client/src/cursor_functions.cpp @@ -28,7 +28,7 @@ #include "net_manager.h" #include "interface_v3/interface_manager.h" #include "interface_v3/interface_3d_scene.h" -#include "interface_v3/group_container.h" +#include "nel/gui/group_container.h" #include "sheet_manager.h" #include "interface_v3/inventory_manager.h" #include "interface_v3/guild_manager.h" diff --git a/code/ryzom/client/src/entity_cl.cpp b/code/ryzom/client/src/entity_cl.cpp index da31caebc..0f1c75253 100644 --- a/code/ryzom/client/src/entity_cl.cpp +++ b/code/ryzom/client/src/entity_cl.cpp @@ -54,7 +54,7 @@ #include "client_cfg.h" #include "nel/gui/action_handler.h" #include "interface_v3/interface_manager.h" -#include "interface_v3/group_container.h" +#include "nel/gui/group_container.h" #include "interface_v3/guild_manager.h" #include "interface_v3/skill_manager.h" #include "user_entity.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_base.cpp b/code/ryzom/client/src/interface_v3/action_handler_base.cpp index e9f413322..e66c4e2af 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_base.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_base.cpp @@ -20,12 +20,12 @@ #include "nel/gui/interface_expr.h" #include "interface_manager.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "dbctrl_sheet.h" #include "interface_3d_scene.h" #include "character_3d.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "people_interraction.h" #include "../r2/editor.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index a38912556..91b9add54 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -38,7 +38,7 @@ #include "ctrl_sheet_selection.h" #include "nel/gui/interface_expr.h" #include "group_menu.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "inventory_manager.h" #include "guild_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index a610b26fe..987a6d1b4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -26,7 +26,7 @@ #include "skill_manager.h" #include "dbctrl_sheet.h" #include "nel/gui/interface_expr.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "group_quick_help.h" #include "nel/gui/view_text_id.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index c36bbdfa7..273e05d36 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -18,7 +18,7 @@ #include "action_handler_misc.h" #include "interface_manager.h" #include "nel/gui/ctrl_button.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "people_interraction.h" #include "nel/misc/algo.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index 9a1466479..f7d3c7772 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -31,7 +31,7 @@ #include "interface_manager.h" #include "dbctrl_sheet.h" #include "dbgroup_build_phrase.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "sphrase_manager.h" #include "sbrick_manager.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index b3ea4d6ff..1fcc35684 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "bot_chat_manager.h" #include "nel/gui/action_handler.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "macrocmd_manager.h" #include "chat_window.h" #include "people_interraction.h" diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index 48e611348..dd981f0b4 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -25,7 +25,7 @@ #include "nel/gui/action_handler.h" #include "../client_cfg.h" #include "nel/gui/ctrl_base_button.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "../string_manager_client.h" #include "../net_manager.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp index 4897defa3..fe181f2e4 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_mission.cpp @@ -24,7 +24,7 @@ #include "bot_chat_page_all.h" #include "dbgroup_list_sheet_trade.h" #include "nel/gui/action_handler.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "dbctrl_sheet.h" #include "nel/gui/view_text_id.h" #include "../net_manager.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index e98019b25..d329d8f04 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -36,10 +36,10 @@ #include "dbctrl_sheet.h" #include "nel/gui/group_editbox.h" #include "group_tab.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "action_handler_help.h" #include "../string_manager_client.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "dbgroup_list_sheet_text.h" #include "nel/gui/ctrl_text_button.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index 9592697a3..fe5d12cf4 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -30,7 +30,7 @@ #include "people_interraction.h" #include "../connection.h" // -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "group_tab.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index d63871ba2..add950b54 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -31,10 +31,10 @@ namespace NLGUI class CViewText; class CGroupList; class CGroupEditBox; + class CGroupContainer; } class CChatWindow; -class CGroupContainer; /** Interface to react to a chat box entry * Derivers should define the msgEntered member function to handle entry event. @@ -120,7 +120,7 @@ public: /** Get the container associated with this chat window * NB : you should not change the name of the window ! Use rename instead */ - CGroupContainer *getContainer() const { return _Chat; } + NLGUI::CGroupContainer *getContainer() const { return _Chat; } // NLGUI::CGroupEditBox *getEditBox() const; /** try to rename the chat window @@ -162,7 +162,7 @@ protected: ~CChatWindow(); protected: IChatWindowListener *_Listener; - NLMISC::CRefPtr _Chat; + NLMISC::CRefPtr _Chat; NLGUI::CGroupEditBox *_EB; bool _ParentBlink; static CChatWindow *_ChatWindowLaunchingCommand; @@ -191,7 +191,7 @@ public: void setTabIndex(sint32 n); // Free Teller - CGroupContainer *createFreeTeller(const ucstring &winName, const std::string &winColor=""); + NLGUI::CGroupContainer *createFreeTeller(const ucstring &winName, const std::string &winColor=""); void setActiveFreeTeller(const ucstring &winName, bool bActive=true); ucstring getFreeTellerName(const std::string &containerID); bool removeFreeTeller(const std::string &containerID); // Return true if free teller found @@ -205,10 +205,10 @@ public: protected: friend class CChatWindowManager; - std::vector _FreeTellers; + std::vector _FreeTellers; void getAssociatedSubWindow(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, NLGUI::CGroupList *&gl, class CCtrlTabButton *&tab); - void updateFreeTellerHeader(CGroupContainer &ft); + void updateFreeTellerHeader(NLGUI::CGroupContainer &ft); private: /** Get a valid string to use like ui id diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp index c6b9f7a23..e9f636733 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.cpp @@ -20,7 +20,7 @@ #include "dbgroup_list_sheet.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/interface_property.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h index f9b29d83e..5bcf9e903 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet.h @@ -27,11 +27,9 @@ namespace NLGUI { class CCtrlBaseButton; class CCtrlScroll; + class CGroupContainer; } -// *************************************************************************** -class CGroupContainer; - // *************************************************************************** /** * A List of item (ctrl sheet) diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index fd98d08b9..105b53904 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" #include "dbgroup_list_sheet_text.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h index f5d5fdb67..531e0e8b9 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h @@ -31,13 +31,13 @@ namespace NLGUI { class CCtrlButton; class CCtrlScroll; + class CGroupContainer; } // *************************************************************************** class CHandlerListSheetTradeSelect; class CHandlerListSheetTradeRightClick; -class CGroupContainer; // *************************************************************************** /** diff --git a/code/ryzom/client/src/interface_v3/group_career.h b/code/ryzom/client/src/interface_v3/group_career.h index 1de90e2c7..640f203c4 100644 --- a/code/ryzom/client/src/interface_v3/group_career.h +++ b/code/ryzom/client/src/interface_v3/group_career.h @@ -20,7 +20,7 @@ #define NL_GROUP_CAREER_H #include "nel/misc/types_nl.h" -#include "group_container.h" +#include "nel/gui/group_container.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/group_compas.h b/code/ryzom/client/src/interface_v3/group_compas.h index 9277c2e76..33184f301 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.h +++ b/code/ryzom/client/src/interface_v3/group_compas.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/vector_2f.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_menu.h" #include "animal_position_state.h" diff --git a/code/ryzom/client/src/interface_v3/group_container.cpp b/code/ryzom/client/src/interface_v3/group_container.cpp deleted file mode 100644 index d101e968b..000000000 --- a/code/ryzom/client/src/interface_v3/group_container.cpp +++ /dev/null @@ -1,4003 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_container.h" -#include "nel/gui/interface_options.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/action_handler.h" -#include "nel/gui/group_editbox.h" -#include "nel/gui/view_text_formated.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/group_list.h" -#include "nel/gui/ctrl_button.h" -#include "nel/gui/ctrl_scroll.h" -#include "nel/gui/view_text.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_pointer_base.h" - - -// *************************************************************************** -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -extern NL3D::UDriver *Driver; - - -static const sint SIZE_W_LEFT = 16; - -static const sint DELTA_BEFORE_POPUP = 32; -static const sint DELTA_BEFORE_MOVING_IN_PARENT_LIST = 16; - -bool CGroupContainer::_ValidateCanDeactivate = true; - - - -//#define DRAW_GC_TEST_QUADS - - -#ifdef DRAW_GC_TEST_QUADS - static void drawGCTestQuad(sint renderLayer, sint32 xreal, sint32 yreal, sint32 wreal, sint32 hreal, CRGBA color) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if(rVR.isMinimized()) - return; - sint32 x, y, w, h; - rVR.getClipWindow(x, y, w, h); - uint32 sw, sh; - rVR.getScreenSize(sw, sh); - rVR.setClipWindow(0, 0, (sint32) sw, (sint32) sh); - rVR.drawRotFlipBitmap (renderLayer, xreal, yreal, wreal, hreal, 0, false, rVR.getBlankTextureId(), color ); - rVR.setClipWindow(x, y, w ,h); - } -#endif - - -// *************************************************************************** -const string CGroupContainer::_OptionLayerName[CGroupContainer::NumLayerName]= -{ - "layer0", - "layer1", - "layer2", - "layer3", - "layer4", - "layer5", - "layer6", - "layer7", - "layer8", - "layer9", -}; - - -// *************************************************************************** -// CCtrlResizer -// *************************************************************************** - -// *************************************************************************** -CCtrlResizer::CCtrlResizer(const TCtorParam ¶m) -: CCtrlBase(param) -{ - WMin = WMax = 0; - HMin = HMax = 0; - _ResizerPos = Hotspot_BR; - IsMaxH = false; - _MouseDown = false; - _XBias = 0; - _YBias = 0; - resizer = true; -} - - -// *************************************************************************** -THotSpot CCtrlResizer::getRealResizerPos() const -{ - CGroupContainer *parent = dynamic_cast(getParent()); - if (parent) - { - THotSpot resizerPos = _ResizerPos; - if (!IsMaxH && parent->getPopupMinH() == parent->getPopupMaxH()) - { - resizerPos = (THotSpot) (resizerPos & ~(Hotspot_Bx | Hotspot_Mx | Hotspot_Tx)); - } - if (parent->getPopupMinW() == parent->getPopupMaxW()) - { - resizerPos = (THotSpot) (resizerPos & ~(Hotspot_xR | Hotspot_xM | Hotspot_xL)); - } - return resizerPos; - } - return _ResizerPos; -} - -// *************************************************************************** -void CCtrlResizer::draw () -{ - #ifdef DRAW_GC_TEST_QUADS - CRGBA col; - switch(ResizerPos) - { - case Hotspot_TR: col = CRGBA::Yellow; break; - case Hotspot_MR: col = CRGBA::Blue; break; - case Hotspot_BR: col = CRGBA::Yellow; break; - case Hotspot_BM: col = CRGBA::Blue; break; - case Hotspot_BL: col = CRGBA::Yellow; break; - case Hotspot_ML: col = CRGBA::Blue; break; - case Hotspot_TL: col = CRGBA::Yellow; break; - case Hotspot_TM: col = CRGBA::Blue; break; - } - - drawGCTestQuad(_RenderLayer, _XReal, _YReal, _WReal, _HReal, col); - #endif -} - -// *************************************************************************** -bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active || !_Parent) - return false; - - if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) - { - const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; - if (edsf.hasFocus() == false && _MouseDown) - { - _MouseDown = false; - _Parent->invalidateCoords(); - return true; - } - } - } - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - CGroupContainer *gc = dynamic_cast(_Parent); - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - // must check that parent isn't closed - if (gc) - { - - if (!gc->isOpen()) return false; - if (gc->getLayerSetup() != 0) return false; - if (gc->isLocked()) return true; - if (IsMaxH) - gc->setPopupMaxH(gc->getH()); - } - _MouseDown = true; - _MouseDownX = eventDesc.getX(); - _MouseDownY = eventDesc.getY(); - _XBias = 0; - _YBias = 0; - return true; - } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - _MouseDown = false; - _Parent->invalidateCoords(); - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) - { - if (_MouseDown) - { - //nlinfo("x = %d, y = %d", eventDesc.getX() + _XReal, eventDesc.getY() + _YReal); - sint32 dx = eventDesc.getX() - _MouseDownX; - sint32 dy = eventDesc.getY() - _MouseDownY; - - - THotSpot resizerPos = getRealResizerPos(); - - // horizontal resize - if (dx != 0) - { - if (_XBias > 0) - { - _XBias += dx; - if (_XBias < 0) - { - dx = _XBias; - _XBias = 0; - } - else - { - dx = 0; - } - } - else if (_XBias < 0) - { - _XBias += dx; - if (_XBias > 0) - { - dx = _XBias; - _XBias = 0; - } - else - { - dx = 0; - } - } - if (resizerPos & Hotspot_xR) - { - sint32 effectiveDX = resizeW (dx); - if (effectiveDX != 0 && gc) gc->touch(); - if (_Parent->getPosRef() & Hotspot_xR) - { - _Parent->setX(_Parent->getX() + effectiveDX); - } - _XBias += dx - effectiveDX; - } - else if (resizerPos & Hotspot_xL) - { - sint32 effectiveDX = resizeW (- dx); - if (effectiveDX != 0 && gc) gc->touch(); - if (_Parent->getPosRef() & Hotspot_xL) - { - _Parent->setX(_Parent->getX() - effectiveDX); - } - _XBias += dx + effectiveDX; - } - } - - // vertical resize - if (dy != 0) - { - if (_YBias > 0) - { - _YBias += dy; - if (_YBias < 0) - { - dy = _YBias; - _YBias = 0; - } - else - { - dy = 0; - } - } - else if (_YBias < 0) - { - _YBias += dy; - if (_YBias > 0) - { - dy = _YBias; - _YBias = 0; - } - else - { - dy = 0; - } - } - if (resizerPos & Hotspot_Tx) - { - sint32 effectiveDY = resizeH (dy); - if (effectiveDY != 0 && gc) gc->touch(); - if (_Parent->getPosRef() & Hotspot_Tx) - { - _Parent->setY(_Parent->getY() + effectiveDY); - } - _YBias += dy - effectiveDY; - } - else if (resizerPos & Hotspot_Bx) - { - sint32 effectiveDY = resizeH (- dy); - if (effectiveDY != 0 && gc) gc->touch(); - if (_Parent->getPosRef() & Hotspot_Bx) - { - _Parent->setY(_Parent->getY() + effectiveDY); - } - _YBias += dy + effectiveDY; - } - } - - _Parent->invalidateCoords(); - - // update pos - _MouseDownX = eventDesc.getX(); - _MouseDownY = eventDesc.getY(); - - // - // call resize handler of parent container if any - if (gc && gc->getAHOnResizePtr() != NULL) - { - CAHManager::getInstance()->runActionHandler(gc->getAHOnResize(), gc, gc->getAHOnResizeParams()); - } - } - return true; - } - } - return false; -} - -// *************************************************************************** -sint32 CCtrlResizer::resizeW (sint32 dx) -{ - sint32 newW = _Parent->getW(); - newW += dx; - sint32 clippedNewW = newW; - NLMISC::clamp(clippedNewW, WMin, WMax); - // clip by screen - uint32 sw, sh; - CViewRenderer &vr = *CViewRenderer::getInstance(); - vr.getScreenSize(sw, sh); - if (_Parent->getPosRef() & Hotspot_xR) - { - if (_ResizerPos & Hotspot_xR) - { - clippedNewW = std::min((sint32) sw + _Parent->getW() - _Parent->getXReal(), clippedNewW); - } - else - { - clippedNewW = std::min(clippedNewW, _Parent->getXReal()); - } - } - else - { - if (_ResizerPos & Hotspot_xL) - { - clippedNewW = std::min(clippedNewW, _Parent->getXReal() + _Parent->getW()); - } - else - { - clippedNewW = std::min((sint32) sw - _Parent->getXReal(), clippedNewW); - } - } - // - dx = clippedNewW - _Parent->getW(); - _Parent->setW (clippedNewW); - return dx; -} - -// *************************************************************************** -sint32 CCtrlResizer::resizeH (sint32 dy) -{ - // if the owner is a container, special resize applied - CGroupContainer *gc = NULL; - gc = dynamic_cast(_Parent); - if (gc == NULL) - return 0; - - // resize popupmaxh or h, according to IsMaxH. - sint32 oldH; - if (IsMaxH) - oldH= gc->getPopupMaxH(); - else - oldH= _Parent->getH(); - - // new H - sint32 clippedNewH= oldH + dy; - // if IsMaxH, don't clamp by HMax - if (IsMaxH) - clippedNewH = std::max(clippedNewH, HMin); - else - NLMISC::clamp(clippedNewH, HMin, HMax); - - - // clip by screen - uint32 sw, sh; - CViewRenderer &vr = *CViewRenderer::getInstance(); - vr.getScreenSize(sw, sh); - if (_Parent->getPosRef() & Hotspot_Tx) - { - if (_ResizerPos & Hotspot_Tx) - { - clippedNewH = std::min((sint32) sh + oldH - _Parent->getY(), clippedNewH); - } - else - { - clippedNewH = std::min(clippedNewH, _Parent->getY()); - } - } - else - { - if (_ResizerPos & Hotspot_Tx) - { - clippedNewH = std::min((sint32) sh - _Parent->getY(), clippedNewH); - } - else - { - clippedNewH = std::min(clippedNewH, _Parent->getY() + oldH); - } - } - - // set final result - dy = clippedNewH - oldH; - if (IsMaxH) - gc->setPopupMaxH(clippedNewH); - else - gc->setH(clippedNewH); - return dy; -} - - -// *************************************************************************** -// CCtrlMover -// *************************************************************************** - -// *************************************************************************** -CCtrlMover::CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen) -: CCtrlBase(param) -{ - _Moving= false; - _CanMove = canMove; - _CanOpen = canOpen; - _HasMoved = false; - _MovingInParentList = false; - _ParentScrollingUp = false; - _ParentScrollingDown = false; - _WaitToOpenClose = false; -} - -// *************************************************************************** -CCtrlMover::~CCtrlMover() -{ -} - -// *************************************************************************** -COptionsContainerInsertion *CCtrlMover::getInsertionOptions() -{ - static NLMISC::CRefPtr insertionOptions; - if (insertionOptions) return insertionOptions; - insertionOptions = (COptionsContainerInsertion *) CWidgetManager::getInstance()->getOptions("container_insertion_opt"); - return insertionOptions; -} - - -// *************************************************************************** -void CCtrlMover::draw () -{ - #ifdef DRAW_GC_TEST_QUADS - drawGCTestQuad(_RenderLayer, _XReal, _YReal, _WReal, _HReal, CRGBA(255, 0, 0, 127)); - #endif - - // No Op if window is minimized - if(CViewRenderer::getInstance()->isMinimized()) - return; - - // draw insertion position if moving in parent list - if (_MovingInParentList) - { - COptionsContainerInsertion *options = getInsertionOptions(); - if (!options) return; - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 oldSciX, oldSciY, oldSciW, oldSciH; - rVR.getClipWindow (oldSciX, oldSciY, oldSciW, oldSciH); - uint32 sw, sh; - rVR.getScreenSize(sw, sh); - rVR.setClipWindow (0, 0, (sint32) sw, (sint32) sh); - CViewRenderer &vr = *CViewRenderer::getInstance(); - // - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return; - CGroupList *gl = gc->getPreviousParentList(); - if (!gl) return; - // - sint32 arrowWidth, arrowHeight; - // - if (_ParentScrollingUp) - { - sint32 topPosY = gl->getChild(0)->getYReal(); - if (gc->getYReal() < topPosY) - { - vr.getTextureSizeFromId(options->TxId_T_Arrow, arrowWidth, arrowHeight); - // insertion position is too high, just draw an arrow pointing to top - sint32 px = gl->getXReal() + (gl->getWReal() >> 1) - (arrowWidth >> 1); - vr.drawRotFlipBitmap(gc->getRenderLayer(), px, _ParentListTop - arrowHeight - 2, arrowWidth, arrowHeight, 0, 0, options->TxId_T_Arrow); - } - } - // - if (_ParentScrollingDown) - { - sint32 bottomPosY = gl->getChild(gl->getNumChildren() - 1)->getYReal() - gl->getChild(gl->getNumChildren() - 1)->getHReal(); - if (gc->getYReal() - gc->getHReal() > bottomPosY) - { - vr.getTextureSizeFromId(options->TxId_B_Arrow, arrowWidth, arrowHeight); - // draw an arrow pointing at bottom - // insertion position is too high, just draw an arrow pointing to top - sint32 px = gl->getXReal() + (gl->getWReal() >> 1) - (arrowWidth >> 1); - vr.drawRotFlipBitmap(gc->getRenderLayer(), px, _ParentListBottom + 2, arrowWidth, arrowHeight, 0, 0, options->TxId_B_Arrow); - } - } - - - if (!_ParentScrollingUp && !_ParentScrollingDown) - { - sint32 posY; - if (_InsertionIndex == (sint32) gl->getNumChildren()) - { - posY = gl->getChild(_InsertionIndex - 1)->getYReal(); - } - else - { - posY = gl->getChild(_InsertionIndex)->getYReal() + gl->getChild(_InsertionIndex)->getHReal(); - - } - // draw insertion bar - // - sint32 barWidth, barHeight; - vr.getTextureSizeFromId(options->TxId_InsertionBar, barWidth, barHeight); - if (posY >= _ParentListBottom && posY <= _ParentListTop) - { - sint32 py = posY - (barHeight >> 1) - 3; - vr.drawRotFlipBitmap(gc->getRenderLayer(), gl->getXReal(), py, gl->getWReal(), barHeight, 0, 0, options->TxId_InsertionBar); - } - } - rVR.setClipWindow(oldSciX, oldSciY, oldSciW, oldSciH); - } -} - -// *************************************************************************** -bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (CCtrlBase::handleEvent(event)) return true; - if (!_Active) - return false; - - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) - { - const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; - if (edsf.hasFocus() == false && _Moving) - { - stopMove(); - return true; - } - } - } - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - // the ctrl must have been captured - if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) - return false; - - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return false; - if (gc->isLockable()) - { - if (gc->isLocked()) - { - return false; // do nothing - } - } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown && _WaitToOpenClose) - { - if (_WaitToOpenClose) - { - _WaitToOpenClose = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - // _WaitToOpen can only be set if the container is popable - if (gc) - { - // A double click has been made - gc->setHighLighted(false); - if (gc->isPopuped()) - { - // pop in the window - gc->setPopupX(gc->getX()); - gc->setPopupY(gc->getY()); - gc->setPopupW(gc->getW()); - //sint32 currH, minH, maxH; - //gc->getResizableChildrenH(currH, minH, maxH); - //gc->setPopupChildrenH(currH); - // - gc->popin(); - } - else - { - // pop the window - gc->popupCurrentPos(); - gc->forceRolloverAlpha(); - if (gc->getPopupW() != -1) - { - gc->setX(gc->getPopupX()); - gc->setY(gc->getPopupY()); - gc->setW(gc->getPopupW()); - // must resize the children to get correct height - //gc->setChildrenH(gc->getPopupChildrenH()); - } - else - { - gc->setW(gc->getRefW()); - } - } - gc->invalidateCoords(2); - // - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - } - return true; - } - } - - if (_WaitToOpenClose) - { - _WaitToOpenClose = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - } - - if (_CanOpen || gc->isOpenWhenPopup()) - { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - if (!_Parent) return false; - gc->setHighLighted(false); - if (_HasMoved || _MovingInParentList) - { - stopMove(); - return true; - } - if (isIn(eventDesc.getX(), eventDesc.getY())) - { - - if (gc->isPopable()) - { - _WaitToOpenClose = true; - CWidgetManager::getInstance()->registerClockMsgTarget(this); - _WaitToOpenCloseDate = times.thisFrameMs; - } - else - { - _Moving = false; - if (gc->isOpenable() && !gc->isOpenWhenPopup()) - { - gc->setOpen(!gc->isOpen()); - } - else - { - return runTitleActionHandler(); - } - } - _Moving = false; - return true; - } - else - { - return false; - } - } - } - - - // Move Window Mgt. - if(!_Moving && !_MovingInParentList) - { - if (_CanMove) - { - // Enter Moving? - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown ) - { - _MoveStartX= _Parent->getX()-eventDesc.getX(); - _MoveStartY= _Parent->getY()-eventDesc.getY(); - _MoveDeltaXReal= _Parent->getXReal() - _Parent->getX(); - _MoveDeltaYReal= _Parent->getYReal() - _Parent->getY(); - _Moving= true; - // set the window at top. - CWidgetManager::getInstance()->setTopWindow(_Parent); - if (gc->getAHOnBeginMovePtr()) - { - CAHManager::getInstance()->runActionHandler(gc->getAHOnBeginMove(), gc, gc->getAHOnBeginMoveParams()); - } - return true; - } - } - } - else - { - // Leave Moving? - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup ) - { - stopMove(); - return true; - } - // Move - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove ) - { - _HasMoved = true; - if (gc) gc->touch(); - // new coords - sint32 x= eventDesc.getX() + _MoveStartX; - sint32 y= eventDesc.getY() + _MoveStartY; - - // if the father is a container and is popable (but not poped), move it only if the user has moved the mouse enough - if (_Parent && !_MovingInParentList) - { - if (gc && gc->getLayerSetup() != 0) - { - if (gc->isMovableInParentList() && !gc->isPopable()) - { - if (abs(y - _Parent->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST) - { - // There should be at least one other entry in the parent list - CGroupList *parentList = dynamic_cast(gc->getParent()); - if (!parentList) return false; - if (parentList->getNbElement() == 1) return false; - setMovingInParent(gc, x, y, eventDesc); - updateInsertionIndex(parentList, eventDesc.getY()); - return true; - } - } - - if (gc->isPopable()) - { - if (!gc->isMovableInParentList()) - { - if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP || abs(y - _Parent->getY()) > DELTA_BEFORE_POPUP) - { - setPoped(gc, x, y, eventDesc); - return true; - } - } - else - { - if (abs(y - _Parent->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST) - { - // There should be at least one other entry in the parent list - CGroupList *parentList = dynamic_cast(gc->getParent()); - if (!parentList) return false; - if (parentList->getNbElement() == 1) return false; - setMovingInParent(gc, x, y, eventDesc); - updateInsertionIndex(parentList, eventDesc.getY()); - return true; - } - else // the mouse should move on the side of the container to turn it into a popup - //if (_Parent->getX() - x > DELTA_BEFORE_POPUP || x - (_Parent->getX() + _Parent->getWReal()) > DELTA_BEFORE_POPUP) - if (abs(x - _Parent->getX()) > DELTA_BEFORE_POPUP) - { - setPoped(gc, x, y, eventDesc); - return true; - } - } - } - - if (abs(x - _Parent->getX()) > 1 || abs(y - _Parent->getY()) > 1) - { - gc->setHighLighted(true); - return true; - } - else - { - gc->setHighLighted(false); - return true; // mouse has not moved enough - } - } - } - - if (!_MovingInParentList) - { - // clip, in real coords space - uint32 wScreen, hScreen; - CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); - x+= _MoveDeltaXReal; - y+= _MoveDeltaYReal; - - clamp(x, 0, (sint32)wScreen-_Parent->getWReal()); - clamp(y, 0, (sint32)hScreen-_Parent->getHReal()); - x-= _MoveDeltaXReal; - y-= _MoveDeltaYReal; - // move window - _Parent->setX(x); - _Parent->setY(y); - - // if some action handler to call when moving - if(gc->getAHOnMovePtr()) - { - // udpate XReal/YReal coords only of the container - gc->CInterfaceElement::updateCoords(); - // execute the AH - CAHManager::getInstance()->runActionHandler(gc->getAHOnMovePtr(), this, gc->getAHOnMoveParams()); - } - } - else - { - if (!gc) return false; - const CGroupList *gl = gc->getPreviousParentList(); - if (gl) - { - updateInsertionIndex(gl, eventDesc.getY()); - // compute visible portion of list - sint32 glSciX, glSciY, glSciW, glSciH; - gl->getClip(glSciX, glSciY, glSciW, glSciH); - _ParentListTop = glSciY + glSciH; - _ParentListBottom = glSciY; - // the control is moving in its parent list, so the x coordinate doesn't change - y += _MoveDeltaYReal; - // if the group is at the bottom of screen or at the bottom of the list, must clamp & scroll down - if (y < _ParentListBottom) - { - if (_ParentScrollingUp) - { - _ParentScrollingUp = false; - CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass - } - if (glSciY > gl->getYReal()) // is there need for scroll ? - { - if (!_ParentScrollingDown) - { - _ParentScrollingDown = true; - CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass - _ScrollTime = 0; - } - } - else - { - if (_ParentScrollingDown) - { - _ParentScrollingDown = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass - } - } - y = _ParentListBottom; - } - else - { - if (_ParentScrollingDown) - { - _ParentScrollingDown = false; - CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass - } - sint32 topY = y + _Parent->getHReal(); - if (topY > _ParentListTop) - { - // idem for top - if (glSciY + glSciH < gl->getYReal() + gl->getHReal()) // is there need for scroll ? - { - if (!_ParentScrollingUp) - { - _ParentScrollingUp = true; - CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass - _ScrollTime = 0; - } - } - else - { - if (_ParentScrollingUp) - { - _ParentScrollingDown = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass - } - } - y = _ParentListTop - _Parent->getHReal(); - } - } - y -= _MoveDeltaYReal; - // move window - _Parent->setY(y); - } - } - // just invalidate position (1 pass) - _Parent->invalidateCoords(1); - return true; - } - } - } - if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) - { - if (_WaitToOpenClose) - { - uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); - if ((times.thisFrameMs - _WaitToOpenCloseDate) > dbclickDelay) - { - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return false; - _WaitToOpenClose = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - // do the open action - if (gc->isOpenable() && !gc->isOpenWhenPopup()) - { - gc->setOpen(!gc->isOpen()); - } - else - { - // if can't open, just call the action handler - return runTitleActionHandler(); - } - } - } - else if (_ParentScrollingDown || _ParentScrollingUp) - { - handleScrolling(); - } - } - } - return false; -} - -// *************************************************************************** -void CCtrlMover::handleScrolling() -{ - const uint pixPerMS = 7; // the number of millisecond to move of one pixel in the parent scrollbar - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return; - CGroupList *gl = gc->getPreviousParentList(); - if (!gl) return; - - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - if (_ParentScrollingUp) - { - sint32 topPosY = gl->getChild(0)->getYReal(); - // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar - if (gc->getYReal() < topPosY) - { - _ScrollTime += times.frameDiffMs; - sint32 deltaY = (sint32) (_ScrollTime / pixPerMS); - if (deltaY != 0) - { - CGroupContainer *currGC = gc->getPreviousContainer(); - while (currGC) - { - CCtrlScroll *cs = currGC->getScroll(); - if (cs) - { - sint32 dy = cs->moveTrackY(deltaY); - if (dy != 0) break; - }// - currGC = currGC->getFatherContainer(); - } - gl->invalidateCoords(); - gc->invalidateCoords(); - _ScrollTime = _ScrollTime % (sint64) pixPerMS; - } - } - else - { - _ParentScrollingUp = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - _InsertionIndex = 0; - } - } - // - if (_ParentScrollingDown) - { - // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar - sint32 bottomPosY = gl->getChild(gl->getNumChildren() - 1)->getYReal() - gl->getChild(gl->getNumChildren() - 1)->getHReal(); - if (gc->getYReal() - gc->getHReal() > bottomPosY) - { - _ScrollTime += times.frameDiffMs; - sint32 deltaY = - (sint32) (_ScrollTime / pixPerMS); - if (deltaY != 0) - { - CGroupContainer *currGC = gc->getPreviousContainer(); - while (currGC) - { - CCtrlScroll *cs = currGC->getScroll(); - if (cs) - { - sint32 dy = cs->moveTrackY(deltaY); - if (dy != 0) break; - } - currGC = currGC->getFatherContainer(); - } - gl->invalidateCoords(); - gc->invalidateCoords(); - _ScrollTime = _ScrollTime % pixPerMS; - } - } - else - { - _ParentScrollingDown = false; - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - _InsertionIndex = gl->getNumChildren(); - } - } -} - -// *************************************************************************** -bool CCtrlMover::runTitleActionHandler() -{ - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return false; - CInterfaceGroup *gr = gc->isOpen() ? gc->getHeaderOpened() : gc->getHeaderClosed(); - if (gr && !gr->getLeftClickHandler().empty()) - { - CAHManager::getInstance()->runActionHandler(gr->getLeftClickHandler(), this, gr->getLeftClickHandlerParams()); - return true; - } - // try with the main group - if (!gc->getLeftClickHandler().empty()) - { - CAHManager::getInstance()->runActionHandler(gc->getLeftClickHandler(), this, gc->getLeftClickHandlerParams()); - return true; - } - return false; -} - -// *************************************************************************** -void CCtrlMover::setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) -{ - gc->setHighLighted(false); - sint32 deltaX = x - _Parent->getX(); - sint32 deltaY = y - _Parent->getY(); - // pop up the window - gc->popupCurrentPos(); // NB : this has the side effect of destroying this object during the call to CGroupContainer::update(), because the mover is recreated during the setup ! - // So from now we shouldn't use anything that use the 'this' pointer - // TODO : maybe there a more clean way to do that ? (except that we may not call update() in popupCurrentPos() ) - if (gc->isLockable()) - { - gc->setLocked(false); - } - gc->setW(gc->getRefW()); - gc->updateCoords(); - gc->updateCoords(); - gc->updateCoords(); - // now the window is in screen coordinates - sint32 newX = gc->getXReal() + deltaX; - sint32 newY = gc->getYReal() + deltaY; - uint32 wScreen, hScreen; - CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); - clamp(newX, 0, (sint32)wScreen - gc->getWReal()); - clamp(newY, 0, (sint32)hScreen - gc->getHReal()); - // move window - gc->setX(newX); - gc->setY(newY + gc->getHReal()); - // just invalidate position (1 pass) - gc->updateCoords(); - - // delegate to the new created control mover - CCtrlMover *cm = gc->getCtrlMover(); - cm->_MoveStartX= gc->getX()-eventDesc.getX(); - cm->_MoveStartY= gc->getY()-eventDesc.getY(); - cm->_MoveDeltaXReal= gc->getXReal() - gc->getX(); - cm->_MoveDeltaYReal= gc->getYReal() - gc->getY(); - cm->_Moving= true; - CWidgetManager::getInstance()->setCapturePointerLeft(cm); - CWidgetManager::getInstance()->setCapturePointerRight(NULL); -} - -// *************************************************************************** -void CCtrlMover::setMovingInParent(CGroupContainer *gc, sint32 /* x */, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc) -{ - if (!gc) return; - sint32 deltaY = y - gc->getY(); - CGroupList *parentList = dynamic_cast(gc->getParent()); - if (!parentList) return; -// sint32 startIndex = parentList->getElementIndex(gc); - gc->setHighLighted(false); - sint32 oldX = _Parent->getXReal(); - gc->setMovingInParentList(true); - sint32 gcWidth = gc->getWReal(); - // pop up the window - gc->popupCurrentPos(); // this doesn't change the order in setup - gc->setSizeRef(0); - gc->setW(gcWidth); - gc->setX(oldX); - gc->updateCoords(); - gc->updateCoords(); - gc->updateCoords(); - // now the window is in screen coordinates - sint32 newY = gc->getYReal() + deltaY; - // - parentList->updateCoords(); - // get clip rect from parent list - sint32 glSciX, glSciY, glSciW, glSciH; - parentList->getClip(glSciX, glSciY, glSciW, glSciH); - _ParentListTop = glSciY + glSciH; - _ParentListBottom = glSciY; - // clip by parent list coords - clamp(newY, _ParentListBottom, _ParentListTop - gc->getHReal()); - // move window - gc->setY(newY + gc->getHReal()); - // just invalidate position (1 pass) - gc->updateCoords(); - - // reupdate pos - _MoveStartY= gc->getY()-eventDesc.getY(); - _MoveDeltaYReal= gc->getYReal() - gc->getY(); - - CWidgetManager::getInstance()->setCapturePointerLeft(this); - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - _Moving = false; - _MovingInParentList = true; - - // register to get time events -} - -// *************************************************************************** -void CCtrlMover::updateInsertionIndex(const CGroupList *gl, sint32 posY) -{ - if (!gl) return; - for(uint k = 0; k < gl->getNumChildren(); ++k) - { - CViewBase *child = gl->getChild(k); - if (child->getYReal() <= posY) - { - if (posY < child->getYReal() + (child->getHReal() >> 1)) - { - _InsertionIndex = k + 1; - return; - } - else - { - _InsertionIndex = k; - return; - } - } - } - _InsertionIndex = gl->getNumChildren(); -} - -// *************************************************************************** -void CCtrlMover::stopMove() -{ - _ParentScrollingUp = false; - _ParentScrollingDown = false; - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - _HasMoved = false; - if (_Moving) - { - _Moving = false; - } - else - { - _MovingInParentList = false; - // insert at good position in the parent list - CGroupContainer *gc = dynamic_cast(_Parent); - if (!gc) return; - gc->popin(_InsertionIndex); - if (gc->getChildrenObs()) - { - gc->getChildrenObs()->childrenMoved(_StartIndex, _InsertionIndex, gc); - } - } -} - - -// *************************************************************************** -// CGroupContainer -// *************************************************************************** - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupContainer, std::string, "container"); - -// *************************************************************************** -CGroupContainer::CGroupContainer(const TCtorParam ¶m) -: CGroupContainerBase(param) -{ - // faster than a virual call - _IsGroupContainer = true; - - _CurrentRolloverAlphaContainer = 0.f; - _CurrentRolloverAlphaContent = 0.f; - - _LayerSetup = -1; - _Localize = true; - _Content = NULL; - _HeaderOpened = NULL; - _HeaderClosed = NULL; - _TitleOpened = NULL; - _TitleClosed = NULL; - _TitleDeltaMaxW = 0; - _ViewOpenState = NULL; - _RightButton = NULL; - _HelpButton = NULL; - _List = NULL; - _ScrollBar = NULL; - _Mover= NULL; - _OldFatherContainer = NULL; - _InsertionOrder = 0; - _MinW = 222; - _MaxW = 320; - _BackupX = 0; - _BackupY = 0; - _PopupMinW = 222; - _PopupMaxW = 500; - _PopupMinH = 48; - _PopupMaxH = 500; - - _BlinkDT = 0; - _ChildrenObs = NULL; - _NumBlinks = 0; - - _PopupX = -1; - _PopupY = -1; - _PopupW = -1; - - _RefW = 0; - - _Openable = true; - _Opened = false; - _OpenWhenPopup = false; - _OpenAtStart = false; - _OpenedBeforePopup = false; - - _Lockable = true; - - _EnabledResizer = true; - _ResizerTopSize = -1; - _Movable = false; - _MovableInParentList = false; - _Popable = false; - _Poped = false; - _HighLighted = false; - _Blinking = false; - _BlinkState = false; - _MovingInParentList = false; - _ActiveSavable = true; - _Savable = true; - _TitleClass = TitleText; - _TouchFlag = false; - _PositionBackuped = false; - _Modal = false; - - _HeaderActive = true; - _EnabledRightButton = true; - _EnabledHelpButton = true; - _TitleOverExtendViewText = false; - - - // action handler - _AHOnOpen = NULL; - _AHOnClose = NULL; - _AHOnCloseButton = NULL; - _AHOnMove = NULL; - _AHOnDeactiveCheck = NULL; - _AHOnResize = NULL; - _AHOnAlphaSettingsChanged = NULL; - _AHOnBeginMove = NULL; - - std::fill(_Resizer, _Resizer + NumResizers, (CCtrlResizer *) 0); - - _ContentYOffset = 0; -} - -// *************************************************************************** -CGroupContainer::~CGroupContainer() -{ -} - -// *************************************************************************** -CGroupContainer::TTileClass CGroupContainer::convertTitleClass(const char *ptr) -{ - if(nlstricmp(ptr, "formated")==0) - return TitleTextFormated; - if(nlstricmp(ptr, "text_id")==0) - return TitleTextId; - if(nlstricmp(ptr, "text_dyn_string")==0) - return TitleTextDynString; - // default - return TitleText; -} - -// *************************************************************************** -bool CGroupContainer::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur,parentGroup)) - return false; - CXMLAutoPtr ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"localize"); - if (ptr) _Localize = convertBool((const char*)ptr); - - // Type of the view text of the title - ptr = xmlGetProp (cur, (xmlChar*)"title_class"); - if (ptr) - { - _TitleClass = convertTitleClass((const char*)ptr); - // if textid, don't localize, because the title is a DB path - if(_TitleClass==TitleTextId || _TitleClass==TitleTextDynString) - _Localize= false; - } - - // y offset for content - ptr = xmlGetProp (cur, (xmlChar*)"content_y_offset"); - if (ptr) - { - fromString((const char*)ptr, _ContentYOffset); - } - - // text of the title - ptr = xmlGetProp (cur, (xmlChar*)"title"); - if (ptr) - { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); - } - - ptr = xmlGetProp (cur, (xmlChar*)"title_opened"); - if (ptr) - { - if (_Localize) _TitleTextOpened = CI18N::get(string((const char*)ptr)); - else _TitleTextOpened = string((const char*)ptr); - } - - ptr = xmlGetProp (cur, (xmlChar*)"title_closed"); - if (ptr) - { - if (_Localize) _TitleTextClosed = CI18N::get(string((const char*)ptr)); - else _TitleTextClosed = string((const char*)ptr); - } - - ptr = xmlGetProp (cur, (xmlChar*)"header_active"); - if (ptr) - _HeaderActive = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"header_color"); - if (ptr) - _HeaderColor.link(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"right_button"); - if (ptr) - { - _EnabledRightButton = convertBool(ptr); - // Default; take same state than the right button - _EnabledHelpButton = _EnabledRightButton; - } - - // but user may ovveride this case - ptr = xmlGetProp (cur, (xmlChar*)"help_button"); - if (ptr) - _EnabledHelpButton = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"movable"); - if (ptr) - _Movable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"popable"); - if (ptr) - _Popable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"lockable"); - if (ptr) - _Lockable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"locked"); - if (ptr) - _Locked = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"openable"); - if (ptr) - _Openable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"opened"); - if (ptr) - _OpenAtStart = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"modal"); - if (ptr) - _Modal = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"open_when_popup"); - if (ptr) - { - _OpenWhenPopup = convertBool(ptr); - if (_OpenWhenPopup) - _OpenAtStart = false; - } - - ptr = xmlGetProp (cur, (xmlChar*)"resizer"); - if (ptr) - _EnabledResizer = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"resizer_top_size"); - _ResizerTopSize= -1; - if (ptr) - fromString((const char*)ptr, _ResizerTopSize); - - CAHManager::getInstance()->parseAH(cur, "on_open", "on_open_params", _AHOnOpen, _AHOnOpenParams); - CAHManager::getInstance()->parseAH(cur, "on_close", "on_close_params", _AHOnClose, _AHOnCloseParams); - CAHManager::getInstance()->parseAH(cur, "on_close_button", "on_close_button_params", _AHOnCloseButton, _AHOnCloseButtonParams); - CAHManager::getInstance()->parseAH(cur, "on_move", "on_move_params", _AHOnMove, _AHOnMoveParams); - CAHManager::getInstance()->parseAH(cur, "on_deactive_check", "on_deactive_check_params", _AHOnDeactiveCheck, _AHOnDeactiveCheckParams); - CAHManager::getInstance()->parseAH(cur, "on_resize", "on_resize_params", _AHOnResize, _AHOnResizeParams); - CAHManager::getInstance()->parseAH(cur, "on_alpha_settings_changed", "on_alpha_settings_changed_params", _AHOnAlphaSettingsChanged, _AHOnAlphaSettingsChangedParams); - CAHManager::getInstance()->parseAH(cur, "on_begin_move", "on_begin_move_params", _AHOnBeginMove, _AHOnBeginMoveParams); - - - ptr = xmlGetProp (cur, (xmlChar*)"max_w"); - if (ptr) - fromString((const char*)ptr, _MaxW); - ptr = xmlGetProp (cur, (xmlChar*)"min_w"); - if (ptr) - fromString((const char*)ptr, _MinW); - - ptr = xmlGetProp (cur, (xmlChar*)"pop_max_w"); - if (ptr) - fromString((const char*)ptr, _PopupMaxW); - ptr = xmlGetProp (cur, (xmlChar*)"pop_min_w"); - if (ptr) - fromString((const char*)ptr, _PopupMinW); - - ptr = xmlGetProp (cur, (xmlChar*)"pop_max_h"); - if (ptr) - fromString((const char*)ptr, _PopupMaxH); - ptr = xmlGetProp (cur, (xmlChar*)"pop_min_h"); - if (ptr) - fromString((const char*)ptr, _PopupMinH); - - ptr = xmlGetProp (cur, (xmlChar*)"movable_in_parent_list"); - if (ptr) _MovableInParentList = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"savable"); - if (ptr) _Savable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"active_savable"); - if (ptr) _ActiveSavable = convertBool(ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"modal_parent"); - if (ptr) _ModalParentNames = (const char*)ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"options"); - if (ptr) _OptionsName = (const char*)ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"title_delta_max_w"); - if (ptr) fromString((const char*)ptr, _TitleDeltaMaxW); - - ptr = xmlGetProp (cur, (xmlChar*)"title_over_extend_view_text"); - _TitleOverExtendViewText= false; - if (ptr) _TitleOverExtendViewText = convertBool(ptr); - - - ptr = xmlGetProp (cur, (xmlChar*)"help_page"); - if (ptr) _HelpPage = (const char*)ptr; - - _RefW = _W; - return true; -} - -// *************************************************************************** -void CGroupContainer::updateCoords() -{ - if (_Mover && _Mover->isMovingInParentList()) - { - // must clamp by parent coords, now it has been updated - CGroupList *gl = getPreviousParentList(); - if (gl) - { - sint32 cx, cy, cw, ch; - gl->getClip(cx, cy, cw, ch); - sint32 currYReal = getYReal(); - clamp(currYReal, cy, cy + ch - getHReal()); - if (currYReal != getYReal()) - { - setY(getY() + currYReal - getYReal()); - } - } - } - - setup(); - - bool bHasChild = (_List->getNbElement() > 0); - - // clamp popupmaxh if resizemax mode - if ((_LayerSetup == 0) && bHasChild && _EnabledResizer) - { - // Clip by screen - uint32 sw, sh; - CViewRenderer &vr = *CViewRenderer::getInstance(); - vr.getScreenSize(sw, sh); - // ensure the maxH is > minH and < sh (prioritary > minH, in case of sh_PopupMinW && _W>(sint32)sw) _W= sw; - if((sint32)sh>_PopupMinH && _H>(sint32)sh) _H= sh; - } - - COptionsLayer *pLayer = getContainerOptions(); - sint32 newH = 0; - - // Get base header size - if (_LayerSetup == 0) - { - setMaxH(_PopupMaxH); - // _W is given by scripter-man - newH = pLayer->H_T; - } - else - { - if (_SizeRef & 1) - { - _W = _Parent->getW(); - } - setMaxH (16384); // No scrollbar for container of layer > 0 - newH = pLayer->H_T; - } - - if (_Opened) - { - if (_HeaderOpened != NULL) - { - if (_HeaderOpened->getPosRef()&Hotspot_xR) - _HeaderOpened->setX (-pLayer->W_R); - if (_HeaderOpened->getPosRef()&Hotspot_xL) - _HeaderOpened->setX (pLayer->W_L); - _HeaderOpened->setY (- newH); - _HeaderOpened->setW (_W-(pLayer->W_L+pLayer->W_R)); - _HeaderOpened->updateCoords(); - newH += max (_HeaderOpened->getHReal(), pLayer->getValSInt32 ("header_h")); - } - else - { - newH += pLayer->getValSInt32 ("header_h"); - } - - newH -= (sint32) _ContentYOffset; - - // Calculate content size part - if (_Content != NULL) - { - if (_Content->getPosRef()&Hotspot_xR) - _Content->setX (-pLayer->W_R); - else if (_Content->getPosRef()&Hotspot_xL) - _Content->setX (pLayer->W_L); - _Content->setY (-newH); - _Content->setW (-(pLayer->W_L+pLayer->W_R)); - if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // Content is constant in H - { - _Content->setSizeRef (1); // w - _Content->updateCoords(); - newH += _Content->getHReal(); - } - else - { - _Content->setSizeRef (3); // wh - _Content->setH (-newH - pLayer->H_B); // Sub header and top, bottom bitmaps - } - } - - if (bHasChild) - newH += pLayer->H_B_Open; - else - newH += pLayer->H_B; - - if (_LayerSetup == 0) - { - _List->setX (pLayer->W_M_Open); - _ScrollBar->setX (pLayer->Scrollbar_Offset_X); - _ScrollBar->setY(-newH); - } - else - { - _List->setX (0); - } - _List->setY (-newH); - - // Calculate list max height if top container - if (_LayerSetup == 0) - { - // zeH is the height to substract to total height of the container to obtain height of the list - sint32 zeH = pLayer->H_T + pLayer->H_B_Open + pLayer->H_EM_Open; - - if (_HeaderOpened != NULL) - zeH += max (_HeaderOpened->getHReal(), pLayer->getValSInt32 ("header_h")); - else - zeH += pLayer->getValSInt32 ("header_h"); - - if (_Content != NULL) - zeH += _Content->getHReal(); - - if (_List != NULL) - _List->setMaxH (max((sint32)0, _MaxH-zeH)); - } - else - { - if (_List != NULL) - _List->setMaxH (16384); - } - - if (_LayerSetup == 0) - { - _List->forceSizeW(_W - pLayer->W_M_Open); - } - else - { - _List->forceSizeW(_W); - } - - - //CInterfaceElement::updateCoords(); - CInterfaceGroup::updateCoords(); - - newH += ((_List->getHReal() < _List->getMaxH()) ? _List->getHReal() : _List->getMaxH()); - - if (_LayerSetup == 0) - { - if ((!bHasChild) || (_List->getHReal() < _List->getMaxH())) - _ScrollBar->setActive (false); - else - _ScrollBar->setActive (true); - } - - if (_LayerSetup == 0) - { - if (_List->getNbElement() > 0) - { - newH += pLayer->H_EM_Open; - } - } - - if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // H is depending on the header and content and list - _H = newH; - - } - else // Closed - { - if (_HeaderClosed != NULL) - { - if (_HeaderClosed->getPosRef()&Hotspot_xR) - _HeaderClosed->setX (-pLayer->W_R); - else if (_HeaderClosed->getPosRef()&Hotspot_xL) - _HeaderClosed->setX (pLayer->W_L); - _HeaderClosed->setY (-newH); - _HeaderClosed->setW (_W-(pLayer->W_L+pLayer->W_R)); - _HeaderClosed->updateCoords(); - newH += max (_HeaderClosed->getHReal(), pLayer->getValSInt32 ("header_h")); - } - else - { - newH += pLayer->getValSInt32 ("header_h"); - } - newH += pLayer->H_B; - - if ((bHasChild) || (!_EnabledResizer) || (_LayerSetup>0)) // H is depending on the header and content and list - _H = newH; - - CInterfaceGroup::updateCoords(); - } - - - if (_Mover != NULL) - { - _Mover->setW (_W+_MoverDeltaW); - _Mover->updateCoords(); - } - - // Set MaxW for title according to current Container Width - _TitleOpened->setLineMaxW(_W + _TitleDeltaMaxW); - _TitleClosed->setLineMaxW(_W + _TitleDeltaMaxW); - - _TitleOpened->updateCoords(); - _TitleClosed->updateCoords(); - if (_ViewOpenState != NULL) _ViewOpenState->updateCoords(); - if (_RightButton != NULL) _RightButton->updateCoords(); - if (_HelpButton != NULL) _HelpButton->updateCoords(); - if (_ScrollBar != NULL) _ScrollBar->updateCoords(); - if (_Content != NULL) _Content->updateCoords(); - if (_HeaderClosed != NULL) _HeaderClosed->updateCoords(); - if (_HeaderOpened != NULL) _HeaderOpened->updateCoords(); - - CInterfaceElement::updateCoords(); - - if (_LayerSetup == 0) - { - // test if must clip - uint32 wScreen, hScreen; - CViewRenderer::getInstance()->getScreenSize(wScreen, hScreen); - if (_WReal <= (sint32) wScreen && _HReal <= (sint32) hScreen) - { - sint32 newX = _XReal; - sint32 newY = _YReal; - clamp(newX, 0, (sint32)wScreen - _WReal); - clamp(newY, 0, (sint32)hScreen - _HReal); - if (newX != _XReal || newY != _YReal) - { - setX(_X + newX - _XReal); - setY(_Y + newY - _YReal); - CInterfaceGroup::updateCoords(); - } - } - } - - // resizers - for(uint k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) updateResizerSize(_Resizer[k]); - } -} - -// *************************************************************************** -void CGroupContainer::updateResizerSize(CCtrlResizer *cr) -{ - COptionsContainerMove *options = getMoveOptions(); - if (!options) return; - - // Yoyo: The +1 stuff is important, maybe because of the HotSpot MiddleMiddle style... - - // Choose H - if (!(cr->getResizerPos() & Hotspot_Tx) && !(cr->getResizerPos() & Hotspot_Bx)) - { - // if no special topH size - if(_ResizerTopSize<0) - cr->setH (_H - 2 * options->ResizerSize + 1); // Bottom and Top same value - else - cr->setH (_H - options->ResizerSize - _ResizerTopSize + 1); // Top different from bottom - } - else - { - // if no special topH size, or if the resizer is not the top one - if(_ResizerTopSize<0 || !(cr->getResizerPos() & Hotspot_Tx)) - cr->setH(options->ResizerSize + 1); - else - cr->setH(_ResizerTopSize + 1); - } - - // Choose W - if (!(cr->getResizerPos() & Hotspot_xR) && !(cr->getResizerPos() & Hotspot_xL)) - { - cr->setW (_W - 2 * options->ResizerSize + 1); - } - else - { - cr->setW(options->ResizerSize + 1); - } - - // update coordinate - cr->updateCoords(); -} - -// *************************************************************************** -void CGroupContainer::draw () -{ - H_AUTO( RZ_Interface_CGroupContainer_draw ) - - if (_LayerSetup == -1) return; - - float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - CRGBA oldGlobalColor = CWidgetManager::getInstance()->getGlobalColor(); - CRGBA oldGColForGrayed = CWidgetManager::getInstance()->getGlobalColor(); - if (_Blinking) - { - const uint blinkDuration = 300; - if (((_BlinkDT / 300) & 1) == 0) - { - CRGBA newCol = oldGlobalColor; - clamp(newCol.R, 64, 192); - clamp(newCol.G, 64, 192); - clamp(newCol.B, 64, 192); - newCol.R = ~newCol.R; - newCol.G = ~newCol.G; - newCol.B = ~newCol.B; - if (abs(newCol.R - oldGlobalColor.R) < 64) newCol.R = 192; - if (abs(newCol.G - oldGlobalColor.G) < 64) newCol.G = 192; - if (abs(newCol.B - oldGlobalColor.B) < 64) newCol.B = 192; - CWidgetManager::getInstance()->setGlobalColor(newCol); - _BlinkState = true; - } - else - { - if (_BlinkState) // was previously on ? - { - if (_NumBlinks != 0) // if dont blink for ever - { - -- _NumBlinks; - if (_NumBlinks == 0) - { - disableBlink(); - } - } - } - _BlinkState = false; - } - _BlinkDT += std::min((uint) times.frameDiffMs, blinkDuration); - } - - CGroupContainer *parentGC = NULL; - if (getParent() && getParent()->getParent()) - { - if (getParent()->getParent()->isGroupContainer()) - { - parentGC = static_cast(getParent()->getParent()); - } - } - - sint32 oldSciX, oldSciY, oldSciW, oldSciH; - makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); - - // Draw the container - CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA col = CWidgetManager::getInstance()->getGlobalColor(); - - bool bGrayed = isGrayed(); - if (bGrayed) - { - col.R = col.R / 2; - col.G = col.G / 2; - col.B = col.B / 2; - CWidgetManager::getInstance()->setGlobalColor(col); - oldGlobalColor.R = oldGlobalColor.R / 2; - oldGlobalColor.G = oldGlobalColor.G / 2; - oldGlobalColor.B = oldGlobalColor.B / 2; - } - - if (_MovingInParentList) - { - // display half tone when moving in parent - col.A >>= 1; - } - // if the father is a group container, do modulation too - if (parentGC) - { - // _CurrentContainerAlpha = (uint8) (((uint16) parentGC->getCurrentContainerAlpha() * (uint16) _ContainerAlpha) >> 8); - _CurrentContainerAlpha = parentGC->getCurrentContainerAlpha(); - } - else - { - _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; - } - // modulate by container alpha color - col.A = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) col.A) >> 8); - // Modulate by parent rollover - if (parentGC) - { - // _ICurrentRolloverAlpha = (uint8) (((uint16) parentGC->_ICurrentRolloverAlpha * (uint16) _ICurrentRolloverAlpha) >> 8); - _ICurrentRolloverAlphaContent = parentGC->_ICurrentRolloverAlphaContent; - _ICurrentRolloverAlphaContainer = parentGC->_ICurrentRolloverAlphaContainer; - } - else - { - uint8 rolloverFactorContent = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContent()) : _RolloverAlphaContent; - _ICurrentRolloverAlphaContent = (uint8) (255 - rolloverFactorContent + rolloverFactorContent * _CurrentRolloverAlphaContent); - uint8 rolloverFactorContainer = _UseGlobalAlpha ? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContainer()) : _RolloverAlphaContainer; - _ICurrentRolloverAlphaContainer = (uint8) (255 - rolloverFactorContainer + rolloverFactorContainer * _CurrentRolloverAlphaContainer); - } - // Modulate alpha by rollover alpha - col.A = (uint8) (((uint16) _ICurrentRolloverAlphaContainer * (uint16) col.A) >> 8); - // - COptionsLayer *pLayer = getContainerOptions(); - // h is the size of what is on top of the child list - sint32 x, y, w, h; - - h = pLayer->H_T + pLayer->H_B_Open; - - if (_Opened) - { - if (_HeaderOpened != NULL) - h += max (_HeaderOpened->getHReal(), pLayer->HeaderH); - else - h += pLayer->HeaderH; - - if (_Content != NULL) - h += _Content->getHReal(); - - h -= _ContentYOffset; - } - else - { - h = _HReal; - } - bool bHasChild = (_List->getNbElement() > 0); - - x = _XReal; - y = _YReal+_HReal-h; - w = _WReal; - sint8 rl = _RenderLayer; - if (_LayerSetup == 0) - { - // Top Left - rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_TL, pLayer->W_TL, pLayer->H_TL, 0, false, pLayer->TxId_TL, col); - // Top - if (pLayer->Tile_T == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, pLayer->Tile_T-1, col); - // Top Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_TR, y+h-pLayer->H_TR, pLayer->W_TR, pLayer->H_TR, 0, false, pLayer->TxId_TR, col); - - if ((!_Opened) || (_Opened && !bHasChild)) - { // Not opened - // Left - if (pLayer->Tile_L == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, col); - else - rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); - // Right - if (pLayer->Tile_R == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR), 0, false, pLayer->TxId_R, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); - // Bottom Left - rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL, pLayer->H_BL, 0, false, pLayer->TxId_BL, col); - // Bottom - if (pLayer->Tile_B == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, pLayer->Tile_B-1, col); - // Bottom Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR, y, pLayer->W_BR, pLayer->H_BR, 0, false, pLayer->TxId_BR, col); - // Content - if (pLayer->Tile_Blank == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); - } - else - { // Opened - // Left - if (pLayer->Tile_L == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, col); - else - rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); - // Right - if (pLayer->Tile_R == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); - // Bottom Left - rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL_Open, pLayer->H_BL_Open, 0, false, pLayer->TxId_BL_Open, col); - // Bottom - if (pLayer->Tile_B_Open == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, pLayer->Tile_B_Open-1, col); - // Bottom Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR_Open, y, pLayer->W_BR_Open, pLayer->H_BR_Open, 0, false, pLayer->TxId_BR_Open, col); - // Content - if (pLayer->Tile_Blank == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_R+pLayer->W_L), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); - // ScrollBar Placement - if (pLayer->Tile_M_Open == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x, _YReal+pLayer->H_EL_Open, pLayer->W_M_Open, _HReal-h-pLayer->H_EL_Open, 0, false, pLayer->TxId_M_Open, col); - else - rVR.drawRotFlipBitmapTiled (rl, x, _YReal+pLayer->H_EL_Open, pLayer->W_M_Open, _HReal-h-pLayer->H_EL_Open, 0, false, pLayer->TxId_M_Open, pLayer->Tile_M_Open-1, col); - // Ending Left - rVR.drawRotFlipBitmap (rl, x, _YReal, pLayer->W_EL_Open, pLayer->H_EL_Open, 0, false, pLayer->TxId_EL_Open, col); - // Ending Middle - if (pLayer->Tile_EM_Open == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_EL_Open, _YReal, w-(pLayer->W_EL_Open+pLayer->W_ER_Open), pLayer->H_EM_Open, 0, false, pLayer->TxId_EM_Open, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_EL_Open, _YReal, w-(pLayer->W_EL_Open+pLayer->W_ER_Open), pLayer->H_EM_Open, 0, false, pLayer->TxId_EM_Open, pLayer->Tile_EM_Open-1, col); - // Ending Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_ER_Open, _YReal, pLayer->W_ER_Open, pLayer->H_ER_Open, 0, false, pLayer->TxId_ER_Open, col); - } - } - else // Version for layer 1,2,3 - { - // Top Left - rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_TL, pLayer->W_TL, pLayer->H_TL, 0, false, pLayer->TxId_TL, col); - // Top - if (pLayer->Tile_T == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_TL, y+h-pLayer->H_T, w-(pLayer->W_TL+pLayer->W_TR), pLayer->H_T, 0, false, pLayer->TxId_T, pLayer->Tile_T-1, col); - // Top Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_TR, y+h-pLayer->H_TR, pLayer->W_TR, pLayer->H_TR, 0, false, pLayer->TxId_TR, col); - - if ((!_Opened) || (_Opened && !bHasChild)) - { - // Left - if (pLayer->Tile_L == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, col); - else - rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL, pLayer->W_L, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); - // Right - if (pLayer->Tile_T == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_R, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR, pLayer->W_R, h-(pLayer->H_BL+pLayer->H_TL), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); - // Bottom Left - rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL, pLayer->H_BL, 0, false, pLayer->TxId_BL, col); - // Bottom - if (pLayer->Tile_B == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL, y, w-(pLayer->W_BL+pLayer->W_BR), pLayer->H_B, 0, false, pLayer->TxId_B, pLayer->Tile_B-1, col); - // Bottom Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR, y, pLayer->W_BR, pLayer->H_BR, 0, false, pLayer->TxId_BR, col); - // Content - if (pLayer->Tile_Blank == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); - } - else - { - // Left - if (pLayer->Tile_L == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, col); - else - rVR.drawRotFlipBitmapTiled (rl, x, y+pLayer->H_BL_Open, pLayer->W_L, h-(pLayer->H_BL_Open+pLayer->H_TL), 0, false, pLayer->TxId_L, pLayer->Tile_L-1, col); - // Right - if (pLayer->Tile_R == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+w-pLayer->W_R, y+pLayer->H_BR_Open, pLayer->W_R, h-(pLayer->H_TR+pLayer->H_BR_Open), 0, false, pLayer->TxId_R, pLayer->Tile_R-1, col); - // Bottom Left - rVR.drawRotFlipBitmap (rl, x, y, pLayer->W_BL_Open, pLayer->H_BL_Open, 0, false, pLayer->TxId_BL_Open, col); - // Bottom - if (pLayer->Tile_B_Open == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_BL_Open, y, w-(pLayer->W_BL_Open+pLayer->W_BR_Open), pLayer->H_B_Open, 0, false, pLayer->TxId_B_Open, pLayer->Tile_B_Open-1, col); - // Bottom Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_BR_Open, y, pLayer->W_BR_Open, pLayer->H_BR_Open, 0, false, pLayer->TxId_BR_Open, col); - // Content - if (pLayer->Tile_Blank == 0) - rVR.drawRotFlipBitmap (rl, x+pLayer->W_L, y+pLayer->H_B_Open, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, col); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L, y+pLayer->H_B_Open, w-(pLayer->W_L+pLayer->W_R), h-(pLayer->H_B_Open+pLayer->H_T), 0, false, pLayer->TxId_Blank, pLayer->Tile_Blank-1, col); - } - } - - - if (_Blinking) - { - CWidgetManager::getInstance()->setGlobalColor(oldGlobalColor); - } - - // Top window : title is highlighted - if (_LayerSetup == 0) - { - CRGBA c = CRGBA(255,255,255,255); - // Display the header in white if we are the last clicked window - if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != this) - { - if (_HeaderColor.getNodePtr() != NULL) - c = _HeaderColor.getRGBA(); - if (bGrayed) - { - c.R = c.R / 2; - c.G = c.G / 2; - c.B = c.B / 2; - } - c.A = 255; - } - if (_TitleClosed != NULL) _TitleClosed->setColor(c); - if (_TitleOpened != NULL) _TitleOpened->setColor(c); - if (_ViewOpenState != NULL) _ViewOpenState->setColor(c); - if (_RightButton != NULL) - { - _RightButton->setColor(c); - _RightButton->setColorPushed(c); - _RightButton->setColorOver(c); - } - if (_HelpButton != NULL) - { - _HelpButton->setColor(c); - _HelpButton->setColorPushed(c); - _HelpButton->setColorOver(c); - } - } - - // Render inside window - - uint8 oldAlphaContent = CWidgetManager::getInstance()->getContentAlpha(); - uint8 oldAlphaContainer = _CurrentContainerAlpha; - if (parentGC) - { - // _CurrentContentAlpha = (uint8) (((uint16) _ContentAlpha * (uint16) parentGC->getCurrentContentAlpha()) >> 8); - _CurrentContentAlpha = parentGC->getCurrentContentAlpha(); - _CurrentContainerAlpha = parentGC->getCurrentContainerAlpha(); - } - else - { - _CurrentContentAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContentAlpha() : _ContentAlpha; - _CurrentContainerAlpha = _UseGlobalAlpha ? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha; - } - // set content alpha multiplied by rollover alpha - CWidgetManager::getInstance()->setContentAlpha((uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8)); - // set content alpha multiplied by rollover alpha - _CurrentContainerAlpha = (uint8) (((uint16) _CurrentContainerAlpha * (uint16) _ICurrentRolloverAlphaContainer) >> 8); - - // Display the color title bar (if the header is active) - if (_LayerSetup == 0) - { - if (_HeaderActive) - { - CRGBA c(255,255,255,255); - if (_HeaderColor.getNodePtr() != NULL) - c = _HeaderColor.getRGBA(); - if (bGrayed) - { - c.R = c.R / 2; - c.G = c.G / 2; - c.B = c.B / 2; - } - c.A = (uint8) (((uint16) _CurrentContentAlpha * (uint16) _ICurrentRolloverAlphaContent) >> 8); - // Left - rVR.drawRotFlipBitmap (rl, x, y+h-pLayer->H_L_Header, pLayer->W_L_Header, pLayer->H_L_Header, 0, false, pLayer->TxId_L_Header, c); - // Middle - if (pLayer->Tile_M_Header == 0) // Tiling ? - rVR.drawRotFlipBitmap (rl, x+pLayer->W_L_Header, y+h-pLayer->H_M_Header, w-(pLayer->W_L_Header+pLayer->W_R_Header), pLayer->H_M_Header, 0, false, pLayer->TxId_M_Header, c); - else - rVR.drawRotFlipBitmapTiled (rl, x+pLayer->W_L_Header, y+h-pLayer->H_M_Header, w-(pLayer->W_L_Header+pLayer->W_R_Header), pLayer->H_M_Header, 0, false, pLayer->TxId_M_Header, pLayer->Tile_M_Header-1, c); - // Right - rVR.drawRotFlipBitmap (rl, x+w-pLayer->W_R_Header, y+h-pLayer->H_R_Header, pLayer->W_R_Header, pLayer->H_R_Header, 0, false, pLayer->TxId_R_Header, c); - } - } - - - CInterfaceGroup::draw(); - - - if (_LayerSetup == 0) - if ((_HighLighted) || (_CurrentContainerAlpha <= 128)) - { - uint8 nInverted = (128-_CurrentContainerAlpha)/2; - if (!_HighLighted) - col.A = nInverted; - else - col.A = max(_HighLightedAlpha, nInverted); - sint32 hw, hh; // size of highlight texture - rVR.getTextureSizeFromId(pLayer->TxId_TL_HighLight, hw, hh); - // corners - rVR.drawRotFlipBitmap (_RenderLayer, x, y + h - hh, hw, hh, 0, false, pLayer->TxId_TL_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, y + h - hh, hw, hh, 0, false, pLayer->TxId_TR_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal, hw, hh, 0, false, pLayer->TxId_BL_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, _YReal, hw, hh, 0, false, pLayer->TxId_BR_HighLight, col); - // border - rVR.drawRotFlipBitmap (_RenderLayer, x + hw, y + h - hh, _WReal - 2 * hw, hh, 0, false, pLayer->TxId_T_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x + hw, _YReal, _WReal - 2 * hw, hh, 0, false, pLayer->TxId_B_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal + hh, hw, _HReal - 2 * hh, 0, false, pLayer->TxId_L_HighLight, col); - rVR.drawRotFlipBitmap (_RenderLayer, x + _WReal - hw, _YReal + hh, hw, _HReal - 2 * hh, 0, false, pLayer->TxId_R_HighLight, col); - } - - - CWidgetManager::getInstance()->setContentAlpha(oldAlphaContent); - _CurrentContainerAlpha = oldAlphaContainer; - - - // manage rollover - CViewPointerBase *mousePointer = CWidgetManager::getInstance()->getPointer(); - if (mousePointer) - { - bool dontFade = false; -// bool alphaUp = false; - // should not applied if the container is being resized - if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) - { - CInterfaceGroup *ig = CWidgetManager::getInstance()->getCapturePointerLeft()->getParent(); - while (ig) - { - if (ig == this) - { - dontFade = true; - break; - } - ig = ig->getParent(); - } - } - - if (hasKeyboardFocus()) dontFade =true; - - bool isOver = false; - - if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) - if (isIn(mousePointer->getX(), mousePointer->getY())) - { - CInterfaceGroup *ig = CWidgetManager::getInstance()->getCurrentWindowUnder(); - while (ig) - { - if (ig == this) - { - isOver = true; - break; - } - ig = ig->getParent(); - } - } - if (dontFade || isOver) - { - _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); - - _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); - } - else - { - _CurrentRolloverAlphaContent -= (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContent = std::max(0.f, _CurrentRolloverAlphaContent); - - _CurrentRolloverAlphaContainer -= (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContainer = std::max(0.f, _CurrentRolloverAlphaContainer); - } - } - - if (bGrayed) - { - CWidgetManager::getInstance()->setGlobalColor(oldGColForGrayed); - } - - - // Restore the old clip window - restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); -} - -// *************************************************************************** -void CGroupContainer::clearViews() -{ - CInterfaceGroup::clearViews(); -} - -// *************************************************************************** -bool CGroupContainer::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active) - return false; - - if (_MovingInParentList) - { - return true; - } - - if (!checkIfModal(event)) - return false; - - if (!CInterfaceGroup::handleEvent(event)) - { - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - // MouseWheel mgt - if ((_LayerSetup == 0) && (isIn(eventDesc.getX(), eventDesc.getY()))) - { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - if (_ScrollBar != NULL) - _ScrollBar->moveTrackY (eventDesc.getWheel()*12); - return true; - } - } - } - return false; - } - - return true; -} - -// *************************************************************************** -void CGroupContainer::open() -{ - disableBlink(); - _Opened = true; - _OpenAtStart = true; - if (_TitleOpened != NULL) _TitleOpened->setActive(true); - if (_TitleClosed != NULL) _TitleClosed->setActive(false); - - if ((_Openable) && (_LayerSetup >= 0)) - { - COptionsLayer *pLayer = getContainerOptions(); - if (_ViewOpenState != NULL) _ViewOpenState->setTexture(pLayer->getValStr ("open_state_tx_opened")); - } - - if (_List != NULL) _List->setActive(true); - - if (_ScrollBar != NULL) _ScrollBar->setActive(true); - if (_Content != NULL) _Content->setActive(true); - if (_HeaderClosed != NULL) _HeaderClosed->setActive(false); - if (_HeaderOpened != NULL) _HeaderOpened->setActive(true); - - invalidateCoords(); - - // call action handler if any - if (_AHOnOpen != NULL) - { - CAHManager::getInstance()->runActionHandler(_AHOnOpen, this, _AHOnOpenParams); - } - -} - -// *************************************************************************** -void CGroupContainer::close() -{ - _Opened = false; - if (_TitleOpened != NULL) _TitleOpened->setActive(false); - if (_TitleClosed != NULL) _TitleClosed->setActive(true); - if ((_Openable) && (_LayerSetup >= 0)) - { - COptionsLayer *pLayer = getContainerOptions(); - if (_ViewOpenState != NULL) _ViewOpenState->setTexture(pLayer->getValStr ("open_state_tx_closed")); - } - if (_List != NULL) _List->setActive(false); - - if (_ScrollBar != NULL) _ScrollBar->setActive(false); - if (_Content != NULL) _Content->setActive(false); - if (_HeaderClosed != NULL) _HeaderClosed->setActive(true); - if (_HeaderOpened != NULL) _HeaderOpened->setActive(false); - invalidateCoords(); - - // call action handler if any - if (_AHOnClose != NULL) - { - CAHManager::getInstance()->runActionHandler(_AHOnClose, this, _AHOnCloseParams); - } -} - -// *************************************************************************** -void CGroupContainer::attachContainer (CGroupContainer *pIC, sint insertionOrder /* = -1 */) -{ - if (_List == NULL) - { - _List = new CGroupList(CViewBase::TCtorParam()); - _List->setId (_Id+":list"); - _List->setParent (this); - } - - // Remove from the list if already inserted - _List->delChild (pIC, true); - if (insertionOrder == -1) - { - _List->addChild (pIC, false); // Do not delete it on remove ! - } - else - { - uint k = 0; - for(k = 0; k < (uint) _List->getNbElement(); ++k) - { - if (_List->getOrder(k) > (uint) insertionOrder) break; - } - _List->addChildAtIndex(pIC, k, false); - _List->setOrder(k, insertionOrder); - } - - // Create MaxH Resizer if not already created - createResizerMaxH(); -} - - -// *************************************************************************** -bool CGroupContainer::attachContainerAtIndex(CGroupContainer *pIC, uint index) -{ - if (_List == NULL) - { - _List = new CGroupList(CViewBase::TCtorParam()); - _List->setId (_Id+":list"); - _List->setParent (this); - } - if (index > (uint) _List->getNbElement()) - { - nlwarning("Bad index"); - return false; - } - uint eltOrder; - if (index == (uint) _List->getNbElement()) - { - if (_List->getNbElement() == 0) - { - eltOrder = 0; - } - else - { - eltOrder = _List->getOrder(index - 1); - } - } - else - { - eltOrder = _List->getOrder(index); - } - uint k; - for(k = index; k < (uint) _List->getNbElement(); ++k) - { - _List->setOrder(k, _List->getOrder(k) + 1); - } - // change insertion order of poped containers - for(k = 0; k < _PopedCont.size(); ++k) - { - if (_PopedCont[k]->_InsertionOrder >= eltOrder) - { - ++ _PopedCont[k]->_InsertionOrder; - } - } - attachContainer(pIC, eltOrder); - return true; -} - - -// *************************************************************************** -void CGroupContainer::detachContainer (CGroupContainer *pIC) -{ - if (!pIC) return; - nlassert(_List != NULL); - nlassert(pIC->getProprietaryContainer() == this); // should be a son of that container - nlassert(!pIC->isPopuped()); // if the container is poped, should pop it in before detaching it! - _List->delChild (pIC); - _List->invalidateCoords(2); - - // Remove MaxH Resizer if exist - if (_List->getNumChildren() == 0) - { - removeResizerMaxH(); - } - -} - -// *************************************************************************** -void CGroupContainer::removeAllContainers() -{ - if (!_List) return; - _List->deleteAllChildren(); -} - -// *************************************************************************** -void CGroupContainer::setMovable(bool b) -{ - if (_Movable != b) - { - _Movable = b; - if (_LayerSetup != -1) - { - updateMover(); - } - } -} - -// Make from layer -// *************************************************************************** -void CGroupContainer::setup() -{ - sint32 nNewLayer = getLayer(); - if (_LayerSetup == nNewLayer) - return; - - _LayerSetup = nNewLayer; - - if ((_LayerSetup == 0) && _Popable) - { - _Poped = true; - } - else - { - _Poped = false; - } - - - COptionsLayer *pLayer = getContainerOptions(_LayerSetup); - - if (_LayerSetup == 0) - { - setParentPosRef(Hotspot_BL); - setPosRef(Hotspot_TL); - } - else - { - setParentPosRef(Hotspot_TL); - setPosRef(Hotspot_TL); - } - - // At start, consider all closed. - - // Title when the container is opened - updateTitle(); - - // Opened state view (tells the user if the container is openable (if the view appears) and if its opened/closed - updateViewOpenState(); - - // Multi usage button - updateRightButton(); - - // Help button - updateHelpButton(); - - // if the window is popable, - - if (_List == NULL) - _List = new CGroupList(CViewBase::TCtorParam()); - _List->setId(_Id+":list"); - _List->setParent (this); - _List->setParentPos (this); - _List->setParentPosRef (Hotspot_TL); - _List->setPosRef (Hotspot_TL); - _List->setActive (_Opened); - - if (_LayerSetup == 0) - { - _ScrollBar = new CCtrlScroll(CViewBase::TCtorParam()); - _ScrollBar->setId (_Id+":sb"); - _ScrollBar->setParent (this); - _ScrollBar->setParentPos (this); - _ScrollBar->setParentPosRef (Hotspot_TL); - _ScrollBar->setPosRef (Hotspot_TL); - _ScrollBar->setTarget(_List); - _ScrollBar->setW (pLayer->Scrollbar_W); // TODO read this from somewhere - _ScrollBar->setAlign (3); // Top - _ScrollBar->setTextureBottomOrLeft (pLayer->TxId_B_Scrollbar); - _ScrollBar->setTextureMiddle (pLayer->TxId_M_Scrollbar); - _ScrollBar->setTextureTopOrRight (pLayer->TxId_T_Scrollbar); - _ScrollBar->setTextureMiddleTile ((uint8)pLayer->Tile_M_Scrollbar); - _ScrollBar->setActive (false); - } - else - { - _ScrollBar = NULL; - } - - - // del all previous resizers - uint k; - for(k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) - { - delCtrl (toString("rz%d", (int) k)); - _Resizer[k] = NULL; - } - } - - // Create Mover - updateMover(); - - // Remove previous controls / views - - delGroup ("list", true); - delCtrl ("sb"); - - COptionsContainerMove *options = getMoveOptions(); - - // create resizer? - if ((_LayerSetup == 0) && (_EnabledResizer)) - { - if (options) - { - sint yOffset; - // if no specific top Size specified - if(_ResizerTopSize<0) - yOffset= -options->ResizerSize; - else - yOffset= -_ResizerTopSize; - // create the resizers - createResizer(0, Hotspot_TL, Hotspot_TM, options->ResizerSize, 0, false); - createResizer(1, Hotspot_TR, Hotspot_TR, 0, 0, false); - createResizer(2, Hotspot_TR, Hotspot_MR, 0, yOffset, false); - createResizer(3, Hotspot_BR, Hotspot_BR, 0, 0, false); - createResizer(4, Hotspot_BR, Hotspot_BM, -options->ResizerSize, 0, false); - createResizer(5, Hotspot_BL, Hotspot_BL, 0, 0, false); - createResizer(6, Hotspot_TL, Hotspot_ML, 0, yOffset, false); - createResizer(7, Hotspot_TL, Hotspot_TL, 0, 0, false); - } - } - - if ((_LayerSetup == 0) && (options)) - { - createResizerMaxH(); - } - - addGroup (_List); - if (_ScrollBar != NULL) addCtrl (_ScrollBar); - - // Link with script - - _Content = getGroup ("content"); - if (_Content != NULL) - { - // Content must be (TL TL), (TR TR) or (TM TM) - _Content->setPosRef( (THotSpot)((_Content->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); - _Content->setParentPosRef(_Content->getPosRef()); - _Content->setActive (false); - } - - _HeaderOpened = getGroup ("header_opened"); - if (_HeaderOpened != NULL) - { - // Header opened must be (TL TL), (TR TR) or (TM TM) - _HeaderOpened->setPosRef( (THotSpot)((_HeaderOpened->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); - _HeaderOpened->setParentPosRef(_HeaderOpened->getPosRef()); - _HeaderOpened->setActive (_Opened); - } - - _HeaderClosed = getGroup ("header_closed"); - if (_HeaderClosed != NULL) - { - // Header closed must be (TL TL), (TR TR) or (TM TM) - _HeaderClosed->setPosRef( (THotSpot)((_HeaderClosed->getPosRef() & (Hotspot_xL|Hotspot_xM|Hotspot_xR)) | Hotspot_Tx) ); - _HeaderClosed->setParentPosRef(_HeaderClosed->getPosRef()); - _HeaderClosed->setActive (!_Opened); - } - - _List->setActive(_Opened); - if (_ScrollBar != NULL) _ScrollBar->setActive(_Opened); - if (_Content != NULL) _Content->setActive(_Opened); - - if (!_ModalParentNames.empty()) - { - // reassign the first setup time - setModalParentList(_ModalParentNames); - } - - invalidateCoords (); -} - - -// *************************************************************************** -// Update right button depending on pop, popable, layer and locked -void CGroupContainer::updateRightButton() -{ - if ((_EnabledRightButton) && (!((_LayerSetup>0)&&(!_Popable)))) - { - COptionsLayer *pLayer = getContainerOptions(); - - // Create right button - if (_RightButton == NULL) - { - _RightButton = new CCtrlButton(CViewBase::TCtorParam()); - _RightButton->setId(_Id+":rightbut"); - _RightButton->setType(CCtrlBaseButton::PushButton); - _RightButton->setParent (this); - _RightButton->setParentPos (this); - _RightButton->setParentPosRef (Hotspot_TR); - _RightButton->setPosRef (Hotspot_TR); - _RightButton->setModulateGlobalColorAll (getModulateGlobalColor()); - _RightButton->setModulateGlobalColorOver (true); - addCtrl (_RightButton); - } - _RightButton->setX(pLayer->getValSInt32 ("right_button_offset_x")); - _RightButton->setY(pLayer->getValSInt32 ("right_button_offset_y")); - - if (_LayerSetup == 0) - { - if (_Locked) - { - _RightButton->setTexture (pLayer->getValStr ("right_button_tx_locked")); - _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_locked")); - _RightButton->setTextureOver (""); - _RightButton->setActionOnLeftClick (""); - _RightButton->setDefaultContextHelp(string("")); - } - else - { - // If the container is normally a layer>0 and is poped ? popin button - if (_OldFatherContainer != NULL) - { - _RightButton->setTexture (pLayer->getValStr ("right_button_tx_popin")); - _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_popin")); - _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); - _RightButton->setActionOnLeftClick ("ic_popin"); - _RightButton->setDefaultContextHelp(CI18N::get("uiPopinWindow")); - } - else // else the container can be deactivated ? deactivate button - { - _RightButton->setTexture (pLayer->getValStr ("right_button_tx_deactive")); - _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_deactive")); - _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); - _RightButton->setActionOnLeftClick ("ic_deactive"); - _RightButton->setDefaultContextHelp(CI18N::get("uiClose")); - } - } - } - else - { - // If the container can be a popup ? popup button - if (_Popable) - { - _RightButton->setTexture (pLayer->getValStr ("right_button_tx_popup")); - _RightButton->setTexturePushed (pLayer->getValStr ("right_button_tx_popup")); - _RightButton->setTextureOver (pLayer->getValStr ("right_button_tx_over")); - _RightButton->setActionOnLeftClick ("ic_popup"); - _RightButton->setDefaultContextHelp(CI18N::get("uiPopupWindow")); - } - _RightButton->setActive(!_Locked); - } - } - else - { - // Delete right button - delCtrl ("rightbut"); - _RightButton = NULL; - } -} - - -// *************************************************************************** -void CGroupContainer::updateHelpButton() -{ - // enable the help button only if has some help page - if ( _EnabledHelpButton && !_HelpPage.empty() ) - { - COptionsLayer *pLayer = getContainerOptions(); - - // Create Help button - if (_HelpButton == NULL) - { - _HelpButton = new CCtrlButton(CViewBase::TCtorParam()); - _HelpButton->setId(_Id+":helpbut"); - _HelpButton->setType(CCtrlBaseButton::PushButton); - _HelpButton->setParent (this); - _HelpButton->setParentPos (this); - _HelpButton->setParentPosRef (Hotspot_TR); - _HelpButton->setPosRef (Hotspot_TR); - _HelpButton->setModulateGlobalColorAll (getModulateGlobalColor()); - _HelpButton->setModulateGlobalColorOver (true); - addCtrl (_HelpButton); - - _HelpButton->setX(pLayer->getValSInt32 ("help_button_offset_x")); - _HelpButton->setY(pLayer->getValSInt32 ("help_button_offset_y")); - - _HelpButton->setTexture (pLayer->getValStr ("help_button_tx")); - _HelpButton->setTexturePushed (pLayer->getValStr ("help_button_tx")); - _HelpButton->setTextureOver (pLayer->getValStr ("help_button_tx_over")); - _HelpButton->setActionOnLeftClick ("ic_help"); - _HelpButton->setDefaultContextHelp(CI18N::get("uiHelp")); - } - - // if not layer 0 - if (_LayerSetup > 0) - { - // if locked, the right button is not displayed => take its pos instead - if(_Locked) - { - _HelpButton->setX(pLayer->getValSInt32 ("help_button_offset_x")); - _HelpButton->setY(pLayer->getValSInt32 ("help_button_offset_y")); - } - else - { - _HelpButton->setX(pLayer->getValSInt32 ("right_button_offset_x")); - _HelpButton->setY(pLayer->getValSInt32 ("right_button_offset_y")); - } - } - } - else - { - // Delete help button - delCtrl ("helpbut"); - _HelpButton = NULL; - } -} - - -// *************************************************************************** -void CGroupContainer::updateMover() -{ - if (_Movable || _Popable || _Openable) - { - COptionsContainerMove *options = getMoveOptions(); - _Mover = new CCtrlMover(CViewText::TCtorParam(), _Movable || _Popable || _MovableInParentList, _Openable); - _Mover->setId (_Id+":mover"); - _Mover->setParent (this); - _Mover->setParentPos (this); - _Mover->setParentPosRef (Hotspot_TM); - _Mover->setPosRef (Hotspot_TM); - if (_Poped && _EnabledResizer) - _Mover->setY (options->TrackYWithTopResizer); - else - _Mover->setY (options->TrackY); - _Mover->setH (options->TrackH); - _MoverDeltaW= options->TrackW; - } - else - { - _Mover = NULL; - } - delCtrl ("mover"); - if (_Mover != NULL) - addCtrl (_Mover, 0); - invalidateCoords(); -} - -// *************************************************************************** -void CGroupContainer::updateViewOpenState() -{ - if (_Openable) - { - COptionsLayer *pLayer = getContainerOptions(); - if (_ViewOpenState == NULL) - { - _ViewOpenState = new CViewBitmap(CViewBase::TCtorParam()); - _ViewOpenState->setId(_Id+":open_state"); - _ViewOpenState->setParent (this); - _ViewOpenState->setParentPos (this); - _ViewOpenState->setParentPosRef (Hotspot_TL); - _ViewOpenState->setPosRef (Hotspot_TL); - _ViewOpenState->setModulateGlobalColor (getModulateGlobalColor()); - addView (_ViewOpenState); - } - _ViewOpenState->setX(pLayer->getValSInt32 ("open_state_offset_x")); - _ViewOpenState->setY(pLayer->getValSInt32 ("open_state_offset_y")); - - if (_Opened) - _ViewOpenState->setTexture (pLayer->getValStr ("open_state_tx_opened")); - else - _ViewOpenState->setTexture (pLayer->getValStr ("open_state_tx_closed")); - _ViewOpenState->setActive(!_Locked); - } - else - { - _ViewOpenState = NULL; - delView ("open_state"); - } -} - -// *************************************************************************** -void CGroupContainer::updateTitle() -{ - COptionsLayer *pLayer = getContainerOptions(); - if (_TitleOpened == NULL) - { - switch(_TitleClass) - { - case TitleTextFormated: - { - CViewTextFormated *vtf = new CViewTextFormated(CViewBase::TCtorParam()); - vtf->setFormatString(_TitleTextOpened); - _TitleOpened = vtf; - } - break; - case TitleTextId: - case TitleTextDynString: - { - CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); - // the title here is actually the DB path - vti->setDBTextID(_TitleTextOpened.toString()); - vti->setDynamicString(_TitleClass==TitleTextDynString); - _TitleOpened = vti; - } - break; - default: - _TitleOpened = new CViewText(CViewBase::TCtorParam()); - } - _TitleOpened->setId(_Id+":titopen"); - _TitleOpened->setParent (this); - _TitleOpened->setParentPos (this); - _TitleOpened->setParentPosRef (Hotspot_TL); - _TitleOpened->setPosRef (Hotspot_TL); - _TitleOpened->setShadow (true); - _TitleOpened->setColor (CRGBA(255,255,255,255)); - _TitleOpened->setModulateGlobalColor(getModulateGlobalColor()); - _TitleOpened->setOverExtendViewText(_TitleOverExtendViewText); - addView (_TitleOpened); - } - - if (_Openable) - { - _TitleOpened->setX (pLayer->getValSInt32 ("title_offset_openable_x")); - _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_openable_y")); - } - else - { - _TitleOpened->setX (pLayer->getValSInt32 ("title_offset_x")); - _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); - } - _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); - _TitleOpened->setActive (_Opened); - - // Title when the container is closed - if (_TitleClosed == NULL) - { - switch(_TitleClass) - { - case TitleTextFormated: - { - CViewTextFormated *vtf = new CViewTextFormated(CViewBase::TCtorParam()); - vtf->setFormatString(_TitleTextClosed); - _TitleClosed = vtf; - } - break; - case TitleTextId: - case TitleTextDynString: - { - CViewTextID *vti= new CViewTextID(CViewBase::TCtorParam()); - // the title here is actually the DB path - vti->setDBTextID(_TitleTextClosed.toString()); - vti->setDynamicString(_TitleClass==TitleTextDynString); - _TitleClosed = vti; - } - break; - default: - _TitleClosed = new CViewText(CViewBase::TCtorParam()); - } - _TitleClosed->setId(_Id+":titclose"); - _TitleClosed->setParent (this); - _TitleClosed->setParentPos (this); - _TitleClosed->setParentPosRef (Hotspot_TL); - _TitleClosed->setPosRef (Hotspot_TL); - _TitleClosed->setShadow (true); - _TitleClosed->setColor (CRGBA(255,255,255,255)); - _TitleClosed->setModulateGlobalColor(getModulateGlobalColor()); - _TitleClosed->setOverExtendViewText(_TitleOverExtendViewText); - addView (_TitleClosed); - } - - if (_Openable) - { - _TitleClosed->setX (pLayer->getValSInt32 ("title_offset_openable_x")); - _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_openable_y")); - } - else - { - _TitleClosed->setX (pLayer->getValSInt32 ("title_offset_x")); - _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); - } - _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); - _TitleClosed->setActive(!_Opened); - - -} - -// *************************************************************************** -// bMaxH is a boolean to know if the resizer act on the content or on the child list -void CGroupContainer::createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH) -{ - CCtrlResizer *cr = new CCtrlResizer(CViewText::TCtorParam()); - cr->setId (_Id+toString(":rz%d", (int) index)); - cr->setParent (this); - cr->setParentPos (this); - cr->setResizerPos(type); - - if (_LayerSetup != 0) - { - cr->WMin = _MinW; - cr->WMax = _MaxW; - } - else - { - cr->WMin = _PopupMinW; - cr->WMax = _PopupMaxW; - cr->HMin = _PopupMinH; - cr->HMax = _PopupMaxH; - } - - cr->setParentPosRef (posRef); - cr->setPosRef (posRef); - - cr->setX(offsetX); - cr->setY(offsetY); - - cr->IsMaxH = bMaxH; - - updateResizerSize(cr); - _Resizer[index] = cr; - addCtrl (_Resizer[index], 0); -} - -// *************************************************************************** -void CGroupContainer::createResizerMaxH() -{ - if (_LayerSetup != 0) return; - if (_List == NULL) return; - if (_List->getNumChildren() == 0) return; - - COptionsContainerMove *options = getMoveOptions(); - - // Create corner resizer if we asked for all resizer - if (_EnabledResizer) - { - if (_Resizer[1] == NULL) createResizer(1, Hotspot_TR, Hotspot_TR, 0, 0, true); - if (_Resizer[3] == NULL) createResizer(3, Hotspot_BR, Hotspot_BR, 0, 0, true); - if (_Resizer[5] == NULL) createResizer(5, Hotspot_BL, Hotspot_BL, 0, 0, true); - if (_Resizer[7] == NULL) createResizer(7, Hotspot_TL, Hotspot_TL, 0, 0, true); - _Resizer[1]->IsMaxH = true; - _Resizer[3]->IsMaxH = true; - _Resizer[5]->IsMaxH = true; - _Resizer[7]->IsMaxH = true; - } - - if (_Resizer[0] == NULL) createResizer(0, Hotspot_TL, Hotspot_TM, options->ResizerSize, 0, true); - if (_Resizer[4] == NULL) createResizer(4, Hotspot_BR, Hotspot_BM, -options->ResizerSize, 0, true); - _Resizer[0]->IsMaxH = true; - _Resizer[4]->IsMaxH = true; -} - -// *************************************************************************** -void CGroupContainer::removeResizerMaxH() -{ - if (_LayerSetup != 0) return; - if (_List == NULL) return; - if (_List->getNumChildren() != 0) return; - - for (uint i = 0; i < NumResizers; ++i) - if ((i != 6) && (i != 2)) // 6 == right and 2 == left - if (_Resizer[i] != NULL) - { - delCtrl ( toString(":rz%d", (int) i) ); - _Resizer[i] = NULL; - } -} - -// *************************************************************************** -sint32 CGroupContainer::getLayer() -{ - if (_MovingInParentList) - { - // keep the previous layer - return _LayerSetup; - } - else - { - // Count Nb of Parent - CInterfaceGroup *pIG = this; - sint32 nNbParent = 0; - while (pIG != NULL) - { - pIG = pIG->getParent(); - if (pIG != NULL) - nNbParent++; - } - return (nNbParent-1)/2; - } -} - -// *************************************************************************** -COptionsLayer *CGroupContainer::getContainerOptions(sint32 ls) -{ - if (ls == -1) - ls = _LayerSetup; - - string sTmp; - const string *sLayerName; - if (_OptionsName.empty()) - { - nlassert((uint32)lsgetOptions(*sLayerName); - nlassert(pLayer != NULL); - return pLayer; -} - -// *************************************************************************** -void CGroupContainer::setContent (CInterfaceGroup *pC) -{ - if (_Content != NULL) - delGroup (_Content); - _Content = pC; - if (_Content) - { - _Content->setId (_Id+":content"); - _Content->setActive (false); - _Content->setParentPosRef (Hotspot_TL); - _Content->setPosRef (Hotspot_TL); - _Content->setParent (this); - addGroup (_Content); - } -} - -// *************************************************************************** -std::string CGroupContainer::getTitle () const -{ - return _TitleTextOpened.toString(); -} - -// *************************************************************************** -void CGroupContainer::setTitle (const std::string &title) -{ - if (_Localize) setUCTitle (CI18N::get(title)); - else setUCTitle (title); -} - -// *************************************************************************** -std::string CGroupContainer::getTitleOpened () const -{ - return _TitleTextOpened.toString(); -} - -// *************************************************************************** -void CGroupContainer::setTitleOpened (const std::string &title) -{ - if (_Localize) setUCTitleOpened (CI18N::get(title)); - else setUCTitleOpened (title); -} - -// *************************************************************************** -std::string CGroupContainer::getTitleClosed () const -{ - return _TitleTextClosed.toString(); -} - -// *************************************************************************** -void CGroupContainer::setTitleClosed (const std::string &title) -{ - if (_Localize) setUCTitleClosed (CI18N::get(title)); - else setUCTitleClosed (title); -} - -// *************************************************************************** -void CGroupContainer::setUCTitleOpened(const ucstring &title) -{ - _TitleTextOpened = title; - if (_TitleOpened != NULL) - _TitleOpened->setText (title); - invalidateCoords(); -} - -// *************************************************************************** -void CGroupContainer::setUCTitleClosed(const ucstring &title) -{ - _TitleTextClosed = title; - if (_TitleClosed != NULL) - _TitleClosed->setText (_TitleTextClosed); - invalidateCoords(); -} - -// *************************************************************************** -void CGroupContainer::setUCTitle(const ucstring &title) -{ - setUCTitleOpened(title); - setUCTitleClosed(title); -} - -// *************************************************************************** -ucstring CGroupContainer::getUCTitle () const -{ - return getUCTitleOpened(); -} - -// *************************************************************************** -ucstring CGroupContainer::getUCTitleOpened () const -{ - return _TitleTextOpened; -} - -// *************************************************************************** -ucstring CGroupContainer::getUCTitleClosed () const -{ - return _TitleTextClosed; -} - -// *************************************************************************** -void CGroupContainer::launch () -{ - if (_OpenAtStart) - open(); - - CInterfaceGroup::launch(); -} - -// *************************************************************************** -void CGroupContainer::setActive (bool state) -{ - if(state != getActive() && getLayer()==0) - { - if (state) - CWidgetManager::getInstance()->setTopWindow(this); - else - CWidgetManager::getInstance()->setBackWindow(this); - } - CAHManager::getInstance()->submitEvent((state?"show:":"hide:")+getId()); - - CInterfaceGroup::setActive(state); -} - -// *************************************************************************** -/*bool CGroupContainer::isWindowUnder (sint32 x, sint32 y) -{ - bool bGrayed = false; - CGroupContainer *pSon = _ModalSon; - if ((pSon != NULL) && pSon->getActive()) - bGrayed = true; - - if (bGrayed) return NULL; - return CInterfaceGroup::isWindowUnder(x,y); -}*/ - -// *************************************************************************** -bool CGroupContainer::getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB) -{ - bool bGrayed = isGrayed(); - if (bGrayed) return false; - return CInterfaceGroup::getViewsUnder(x, y, clipX, clipY, clipW, clipH, vVB); -} - -// *************************************************************************** -bool CGroupContainer::getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL) -{ - bool bGrayed = isGrayed(); - if (bGrayed) return false; - return CInterfaceGroup::getCtrlsUnder(x,y,clipX,clipY,clipW,clipH,vICL); -} - -// *************************************************************************** -void CGroupContainer::popupCurrentPos() -{ - if (!_Popable && !_MovableInParentList) - { - nlwarning(" The window is not popable or cannot move in parent list."); - return; - } - if (_LayerSetup == 0) - { - nlwarning(" The window is already poped."); - return; - } - if (!_Parent || !_Parent->getParent()) - { - nlwarning(" Window has not parent."); - return; - } - // remove the group from its father - CGroupContainer *parentContainer = dynamic_cast(_Parent->getParent()); - if (!parentContainer) - { - nlwarning(" Container is not son of another container"); - return; - } - _OldFatherContainer = parentContainer; - sint32 eltIndex = parentContainer->_List->getElementIndex(this); - if (eltIndex == -1) - { - nlwarning(" Can't get index in owner group"); - return; - } - _InsertionOrder = parentContainer->_List->getOrder(eltIndex); - parentContainer->detachContainer(this); - - parentContainer->_PopedCont.push_back(this); - - // put at the base of hierarchy - CInterfaceGroup *parent = _Parent; - if (!parent) return; - while (parent->getParent()) - { - parent = parent->getParent(); - } - _Parent = parent; - _ParentPos = parent; - - CWidgetManager::getInstance()->makeWindow(this); - CWidgetManager::getInstance()->setTopWindow(this); - CWidgetManager::getInstance()->clearViewUnders(); - CWidgetManager::getInstance()->clearCtrlsUnders(); - - // update coords (put coords in world) - setX(getXReal()); - setY(getYReal() + getHReal()); - setParentPosRef(Hotspot_BL); - setPosRef(Hotspot_TL); - - // clamp coords - // width - sint32 w = getW(); - clamp(w, _PopupMinW, _PopupMaxW); - setW(w); - - invalidateCoords(); - - // setup the new controls - _Poped = true; - _OpenedBeforePopup = _Opened; - _Opened = true; - disableBlink(); - setup(); -} - -// *************************************************************************** -void CGroupContainer::popin(sint32 insertPos /* = -1 */, bool putBackInFatherContainer /*= true*/) -{ - if (!_OldFatherContainer) - { - nlwarning(" The window wasn't previously attached.(%s)",this->_Id.c_str()); - return; - } - - if (!_Popable && !_MovableInParentList) - { - nlwarning(" The window is not popable or cannot move in parent list.(%s)",this->_Id.c_str()); - return; - } - if (!_MovingInParentList && _LayerSetup != 0) - { - nlwarning(" The window should be in layer 0.(%s)",this->_Id.c_str()); - return; - } - if (!_Parent) - { - nlwarning(" The window has no parent.(%s)",this->_Id.c_str()); - return; - } - - touch(); - _List->setOfsY(0); - - _MovingInParentList = false; - CWidgetManager::getInstance()->unMakeWindow(this); - CWidgetManager::getInstance()->clearViewUnders(); - CWidgetManager::getInstance()->clearCtrlsUnders(); - _Parent = NULL; - _ParentPos = NULL; - std::vector::iterator it = std::find(_PopedCont.begin(), _PopedCont.end(), this); - if (it != _PopedCont.end()) - { - // replace by last element - *it = _PopedCont.back(); - _PopedCont.pop_back(); - } - if (putBackInFatherContainer) - { - bool active = getActive(); - _Poped = false; - if (insertPos == -1) - { - _OldFatherContainer->attachContainer(this, _InsertionOrder); - } - else - { - if (!_OldFatherContainer->attachContainerAtIndex(this, insertPos)) - { - nlwarning("Couldn't attach to previous container"); - return; - } - } - setActive(active); - _OldFatherContainer = NULL; - if (_OpenWhenPopup) - { - setOpen(false); - } - else - { - setOpen(_OpenedBeforePopup); - } - } - - invalidateCoords(); - - _OldFatherContainer = NULL; - setup(); -} - -// *************************************************************************** -void CGroupContainer::enableBlink(uint numBlinks /*=0*/) -{ - _Blinking = true; - _NumBlinks = numBlinks; - _BlinkDT = 0; - _BlinkState = true; -} - -// *************************************************************************** -void CGroupContainer::disableBlink() -{ - _Blinking = false; - _NumBlinks = 0; - _BlinkDT = 0; - _BlinkState = false; -} - - -// *************************************************************************** -void CGroupContainer::setMovingInParentList(bool enable) -{ - _MovingInParentList = enable; -} - -// *************************************************************************** -void CGroupContainer::popup() -{ - if (_Poped) return; - touch(); - setHighLighted(false); - // pop the window - popupCurrentPos(); - if (getPopupW() != -1) - { - setX(getPopupX()); - setY(getPopupY()); - setW(getPopupW()); - setH(getPopupH()); - } - else - { - setW(getRefW()); // Do not know what we need to do that ... - } - invalidateCoords(2); -} - -// *************************************************************************** -COptionsContainerMove *CGroupContainer::getMoveOptions() -{ - static NLMISC::CRefPtr moveOptions; - if (moveOptions) return moveOptions; - moveOptions = (COptionsContainerMove *) CWidgetManager::getInstance()->getOptions("container_move_opt"); - return moveOptions; -} - - -// *************************************************************************** -// Actions Handlers -// *************************************************************************** - -// *************************************************************************** -class CICOpen : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - pIC->open(); - } -}; -REGISTER_ACTION_HANDLER (CICOpen, "ic_open"); - -// *************************************************************************** -class CICClose : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - pIC->close(); - } -}; -REGISTER_ACTION_HANDLER (CICClose, "ic_close"); - -// *************************************************************************** -class CICDeactive : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - if (pIC->isLocked()) return; - - // check if the window can be really closed - CGroupContainer::_ValidateCanDeactivate = true; - if (!pIC->getAHOnDeactiveCheck().empty()) - { - CAHManager::getInstance()->runActionHandler(pIC->getAHOnDeactiveCheck(), pCaller, pIC->getAHOnDeactiveCheckParams()); - } - - if (CGroupContainer::_ValidateCanDeactivate) - { - // send close button msg - if (!pIC->getAHOnCloseButton().empty()) - { - CAHManager::getInstance()->runActionHandler(pIC->getAHOnCloseButton(), pCaller, pIC->getAHOnCloseButtonParams()); - } - CWidgetManager::getInstance()->setBackWindow(pIC); - pIC->setActive(false); - } - } -}; -REGISTER_ACTION_HANDLER (CICDeactive, "ic_deactive"); - -// *************************************************************************** -class CICPopup : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - if (pIC->isLocked()) return; - // - pIC->popup(); - // - - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - } -}; -REGISTER_ACTION_HANDLER (CICPopup, "ic_popup"); - -// *************************************************************************** -class CICPopin : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - if (pIC->isLocked()) return; - // memorize popup position - pIC->setPopupX(pIC->getX()); - pIC->setPopupY(pIC->getY()); - pIC->setPopupW(pIC->getW()); - pIC->setPopupH(pIC->getH()); - // - pIC->popin(); - - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - CWidgetManager::getInstance()->setCapturePointerRight(NULL); - } -}; -REGISTER_ACTION_HANDLER (CICPopin, "ic_popin"); - -// *************************************************************************** -class CICLock : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CInterfaceGroup *pIG = pCaller->getParent(); - if (pIG == NULL) return; - CGroupContainer *pIC = dynamic_cast(pIG); - if (pIC == NULL) return; - pIC->setLocked(!pIC->isLocked()); - } -}; -REGISTER_ACTION_HANDLER(CICLock, "ic_lock"); - -// *************************************************************************** -class CICHelp : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - // get the container to get help - if(!pCaller) - return; - CGroupContainer *pIC = dynamic_cast(pCaller->getRootWindow()); - if (pIC == NULL) return; - - // if found the help page - const std::string &helpPage= pIC->getHelpPage(); - if(!helpPage.empty()) - { - - // open the web browser, and point to the page - CAHManager::getInstance()->runActionHandler("launch_help", NULL, "url=" + helpPage); - } - } -}; -REGISTER_ACTION_HANDLER(CICHelp, "ic_help"); - -// *************************************************************************** -CGroupContainer *CGroupContainer::getFatherContainer() const -{ - if (_Parent && _Parent->getParent()) - { - return dynamic_cast(_Parent->getParent()); - } - return NULL; -} - -// *************************************************************************** -CGroupContainer *CGroupContainer::getProprietaryContainer() const -{ - if (_Parent && _Parent->getParent()) - { - return dynamic_cast(_Parent->getParent()); - } - else - { - return _OldFatherContainer; - } -} - -// *************************************************************************** -void CGroupContainer::setOpenable(bool openable) -{ -// COptionsLayer *pLayer = getContainerOptions(); -// COptionsContainerMove *options = getMoveOptions(); - _Openable = openable; - - updateTitle(); - updateViewOpenState(); - updateMover(); -} - -// *************************************************************************** -void CGroupContainer::rollOverAlphaUp() -{ - - CViewPointerBase *vp = CWidgetManager::getInstance()->getPointer(); - float speed = CWidgetManager::getInstance()->getAlphaRolloverSpeed(); - if (!isIn(vp->getX(), vp->getY())) - { - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - _CurrentRolloverAlphaContainer += (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContainer = std::min(1.f, _CurrentRolloverAlphaContainer); - - _CurrentRolloverAlphaContent += (float) (speed * times.frameDiffMs); - _CurrentRolloverAlphaContent = std::min(1.f, _CurrentRolloverAlphaContent); - } -} - -// *************************************************************************** -void CGroupContainer::forceRolloverAlpha() -{ - _CurrentRolloverAlphaContent = hasKeyboardFocus() ? 1.0f : 0.f; - _CurrentRolloverAlphaContainer = hasKeyboardFocus() ? 1.0f : 0.f; -} - -// *************************************************************************** -bool CGroupContainer::hasKeyboardFocus() const -{ - - if (CWidgetManager::getInstance()->getCaptureKeyboard() != NULL) - { - const CGroupEditBox *geb = dynamic_cast(CWidgetManager::getInstance()->getCaptureKeyboard()); - if (geb) - { - const CInterfaceGroup *gr = geb->getParent(); - while(gr) - { - if (gr == this) - { - return true; - } - gr = gr->getParent(); - } - } - } - return false; -} - -// *************************************************************************** -void CGroupContainer::setLockable(bool lockable) -{ - if (lockable == _Lockable) return; - setup(); -} - -// *************************************************************************** -void CGroupContainer::setLocked(bool locked) -{ - if (!_Lockable) - { - nlwarning("Container is not lockable"); - return; - } - if (locked == _Locked) return; - _Locked = locked; - if (_LayerSetup == 0) - { - updateRightButton(); - updateHelpButton(); - if (_ViewOpenState != NULL) _ViewOpenState->setActive(!_Locked); - if (_Mover != NULL) _Mover->setActive(!_Locked); - } -} - -// *************************************************************************** -std::string CGroupContainer::getTitleColorAsString() const -{ - // return one of the title opened.... - if(!_TitleOpened) - return std::string(); - - return _TitleOpened->getColorAsString(); -} - -// *************************************************************************** -void CGroupContainer::setTitleColorAsString(const std::string &col) -{ - // Set both colors - if(_TitleOpened) - _TitleOpened->setColorAsString(col); - if(_TitleClosed) - _TitleClosed->setColorAsString(col); -} - -// *************************************************************************** -void CGroupContainer::setModalParentList (const std::string &name) -{ - _ModalParentNames = name; - - // can have multiple parent - vector modalParents; - splitString(name, "|", modalParents); - // add each of them (if possible) - for(uint i=0;i(CWidgetManager::getInstance()->getElementFromId(modalParents[i])); - if (pGC == NULL) - pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+modalParents[i])); - if (pGC == NULL) - nlwarning(" not found %s",modalParents[i].c_str()); - else - addModalParent (pGC); - } -} - -// *************************************************************************** -void CGroupContainer::addModalParent (CGroupContainer *pParent) -{ - if(pParent==NULL) return; - // Look if parent not already added - for(uint i=0;i<_ModalParents.size();++i) - if(_ModalParents[i] == pParent) - return; - // add me to the parent - pParent->addModalSon(this); - _ModalParents.push_back(pParent); -} - -// *************************************************************************** -void CGroupContainer::addModalSon (CGroupContainer *pSon) -{ - if (pSon == NULL) return; - // Look if the son not already added - for (uint i = 0; i < _ModalSons.size(); ++i) - if (_ModalSons[i] == pSon) - return; - _ModalSons.push_back(pSon); -} - -// *************************************************************************** -bool CGroupContainer::checkIfModal(const NLGUI::CEventDescriptor& event) -{ - bool bRet = true; - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if ((eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) || - (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)) - { - bRet = blinkAllSons(); - } - // Additionaly, if it is a UP, don't blink, but return false if some son active - if (bRet && ( - (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) || - (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)) - ) - { - bRet= !isGrayed(); - } - } - return bRet; -} - -// *************************************************************************** -bool CGroupContainer::isGrayed() const -{ - bool bGrayed = false; - for (uint i = 0; i < _ModalSons.size(); ++i) - { - CGroupContainer *pSon = _ModalSons[i]; - if (pSon->getActive()) - bGrayed = true; - } - return bGrayed; -} - -// *************************************************************************** -bool CGroupContainer::blinkAllSons() -{ - bool bRet = true; - vector allSons = _ModalSons; - uint i,j; - // Recurs all sons (because allSons grow while sons are added). NB: if there is a graph, it will freeze.... - for (i = 0; i < allSons.size(); ++i) - { - CGroupContainer *pSon = allSons[i]; - for (j = 0; j < pSon->_ModalSons.size(); ++j) - allSons.push_back(pSon->_ModalSons[j]); - } - // Then for all sons and descendants, blink - for (i = 0; i < allSons.size(); ++i) - { - CGroupContainer *pSon = allSons[i]; - if (pSon->getActive()) - { - pSon->enableBlink(3); - bRet = false; - } - } - return bRet; -} - - -// *************************************************************************** -void CGroupContainer::forceOpen() -{ - // Force open the container. - open(); - // Ensure it is Active too - setActive(true); -} - -// *************************************************************************** -void CGroupContainer::backupPosition() -{ - _BackupX = getX(); - _BackupY = getY(); - _PositionBackuped = true; -} - -// *************************************************************************** -void CGroupContainer::restorePosition() -{ - if (!_PositionBackuped) return; - setX(_BackupX); - setY(_BackupY); - _PositionBackuped = false; -} - -// *************************************************************************** -bool CGroupContainer::getTouchFlag(bool clearFlag) const -{ - bool touchFlag = _TouchFlag; - if (clearFlag) - { - _TouchFlag = false; - } - return touchFlag; -} - -// *************************************************************************** -void CGroupContainer::setBackupPosition(sint32 x, sint32 y) -{ - _BackupX = x; - _BackupY = y; - _PositionBackuped = true; -} - -// *************************************************************************** -void CGroupContainer::setPopupMinW(sint32 minW) -{ - _PopupMinW = minW; - // TODO : avoid this stupid copy (issue in CCtrResizer..) - for(uint k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) _Resizer[k]->WMin = minW; - } -} - -// *************************************************************************** -void CGroupContainer::setPopupMaxW(sint32 maxW) -{ - _PopupMaxW = maxW; - // TODO : avoid this stupid copy (issue in CCtrResizer..) - for(uint k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) _Resizer[k]->WMax = maxW; - } -} - -// *************************************************************************** -void CGroupContainer::setPopupMinH(sint32 minH) -{ - _PopupMinH = minH; - // TODO : avoid this stupid copy (issue in CCtrResizer..) - for(uint k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) _Resizer[k]->HMin = minH; - } -} - -// *************************************************************************** -void CGroupContainer::setPopupMaxH(sint32 maxH) -{ - _PopupMaxH = maxH; - // TODO : avoid this stupid copy (issue in CCtrResizer..) - for(uint k = 0; k < NumResizers; ++k) - { - if (_Resizer[k]) _Resizer[k]->HMax = maxH; - } -} -// *************************************************************************** -int CGroupContainer::luaSetHeaderColor(CLuaState &ls) -{ - const char *funcName = "setHeaderColor"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - _HeaderColor.link(ls.toString(1)); - return 0; -} - -// *************************************************************************** -CRGBA CGroupContainer::getDrawnHeaderColor () const -{ - CRGBA c = CRGBA(255,255,255,255); - - // Display the header in white if we are the last clicked window - if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != static_cast(this)) - { - if (_HeaderColor.getNodePtr() != NULL) - c = _HeaderColor.getRGBA(); - if (isGrayed()) - { - c.R = c.R / 2; - c.G = c.G / 2; - c.B = c.B / 2; - } - c.A = 255; - } - - return c; -} - -// *************************************************************************** -void CGroupContainer::setHelpPage(const std::string &newPage) -{ - _HelpPage= newPage; -} - -// *************************************************************************** -void CGroupContainer::requireAttention() -{ - if (getActive()) - { - // Window have headers opened => blink it if is not the top window - if (isOpen()) - { - if (getId() != CWidgetManager::getInstance()->getTopWindow()->getId()) - { - enableBlink(3); - } - } - // Window have headers closed => change color of header - else - { - setHeaderColor("UI:SAVE:WIN:COLORS:INFOS"); - } - } - else - { - // Must open this window everytime someone tell something on it - setActive(true); - } -} - - -// *************************************************************************** -int CGroupContainer::luaBlink(CLuaState &ls) -{ - const char *funcName = "blink"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - enableBlink((uint) ls.toNumber(1)); - return 0; -} - -// *************************************************************************** -void CGroupContainer::setRightButtonEnabled(bool enabled) -{ - if (_EnabledRightButton == enabled) return; - _EnabledRightButton = enabled; - updateRightButton(); -} - -// *************************************************************************** -void CGroupContainer::setContentYOffset(sint32 value) -{ - #ifdef NL_DEBUG - nlassert(value <= 127 && value >= -128); - #endif - if (value > 127 || value < -128) - { - // for lua exported value, let know the user that there was some problem - throw NLMISC::Exception("y_offset must be in the [-128, 127] range"); - } - _ContentYOffset = (sint8) value; - invalidateCoords(); -} - - diff --git a/code/ryzom/client/src/interface_v3/group_container.h b/code/ryzom/client/src/interface_v3/group_container.h deleted file mode 100644 index fd966aadf..000000000 --- a/code/ryzom/client/src/interface_v3/group_container.h +++ /dev/null @@ -1,655 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_GROUP_CONTAINER_H -#define RZ_GROUP_CONTAINER_H - -#include "nel/gui/interface_group.h" -#include "nel/gui/group_container_base.h" -#include "nel/misc/smart_ptr.h" - -namespace NLGUI -{ - class CEventDescriptorLocalised; - class CCtrlButton; - class CCtrlScroll; - class CViewText; - class CViewBitmap; - class CGroupList; - class COptionsContainerInsertion; - class COptionsContainerMove; - class COptionsLayer; -} - -class CGroupContainer; - -// *************************************************************************** -/** - * class describing a resizer for the container - * \author Matthieu 'TrapII' Besson - * \date 2003 - */ -class CCtrlResizer : public CCtrlBase -{ - -public: - - CCtrlResizer(const TCtorParam ¶m); - virtual void draw (); - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - // Add a big delta so when the user is over the Resizer, always take it whatever other controls under - virtual uint getDeltaDepth() const { return 100; } - - // get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded - // if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded - THotSpot getRealResizerPos() const; - THotSpot getResizerPos() const { return _ResizerPos; } - void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; } - - bool IsMaxH; // Do this resizer is a MaxH resizer ? - - // Max sizes for the parent - sint32 WMin, WMax; - sint32 HMin, HMax; - - // from CCtrlBase - virtual bool canChangeVirtualDesktop() const { return !_MouseDown; } - -private: - - sint32 resizeW (sint32 dx); - sint32 resizeH (sint32 dy); - -private: - THotSpot _ResizerPos; // how the resizer should resize its parent - bool _MouseDown; - sint32 _MouseDownX; - sint32 _MouseDownY; - sint32 _XBias; - sint32 _YBias; -}; - - -// *************************************************************************** -/** - * Class describing a Mover for the container - * Clicking on it can also open the container - * This can be used to move a container if it is movable. - * If the container is popable, it will first pull it of the hierarchy, then it becomes movable. - * It can also be used to change the position of a group container that is inserted in the list of another container. - * \author Lionel Berenguier - * \date 2003 - */ -class CCtrlMover : public CCtrlBase -{ -public: - - CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen); - ~CCtrlMover(); - virtual void draw (); - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - bool canMove() { return _CanMove; } - - bool isMoving() const {return _Moving;} - bool isMovingInParentList() const { return _MovingInParentList; } - - // from CCtrlBase - virtual bool canChangeVirtualDesktop() const { return !_Moving; } - -private: - sint32 _MoveStartX, _MoveStartY; - sint32 _MoveDeltaXReal, _MoveDeltaYReal; - sint64 _ScrollTime; - sint32 _StartIndex; - sint32 _InsertionIndex; - // clip window from parent list - sint32 _ParentListTop; - sint32 _ParentListBottom; - // - sint64 _WaitToOpenCloseDate; - // - bool _CanMove : 1; - bool _CanOpen : 1; - bool _Moving : 1; - bool _MovingInParentList : 1; - bool _HasMoved : 1; - bool _ParentScrollingUp : 1; - bool _ParentScrollingDown : 1; - bool _StopScrolling : 1; // stop scrolling at next draw - bool _WaitToOpenClose : 1; - // - static COptionsContainerInsertion *getInsertionOptions(); -private: - void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); - void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); - void updateInsertionIndex(const CGroupList *gl, sint32 posY); - void stopMove(); - bool runTitleActionHandler(); - void handleScrolling(); - -}; - - -// *************************************************************************** -/** - * class describing a group of views controls and other groups - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CGroupContainer : public CGroupContainerBase -{ -public: - enum { NumResizers = 8 }; -public: - // observer to know when children have moved. This can be used to keep external datas in sync - struct IChildrenObs - { - virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0; - }; -public: - CGroupContainer(const TCtorParam ¶m); - ~CGroupContainer(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - virtual void updateCoords (); - - virtual void draw (); - - virtual void clearViews (); - - virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); - - virtual void launch (); - - virtual void setActive (bool state); - - virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group - - virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); - - void open(); - - void close(); - - void setup(); // Create the container - - /** If insertion order is -1, pIC is added at the end of the container - * otherwise it is inserted after containers of a lower order - */ - void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1); - // Insert a container at the given index. - bool attachContainerAtIndex(CGroupContainer *pIC, uint index); - - // Before a container is detached from parent, it should be pop in - void detachContainer (CGroupContainer *pIC); - void removeAllContainers(); - - void setOpen(bool opened) - { - if (opened) - { - open(); - } - else - { - close(); - } - } - bool isOpen() const { return _Opened; } - - // Force Open for container setActive and open() - virtual void forceOpen(); - - /// Set the title open and close - virtual bool isMovable() const {return _Movable;} - void setMovable(bool b); - - void setContent (CInterfaceGroup *pC); - - std::string getTitle () const; - void setTitle (const std::string &title); - std::string getTitleOpened () const; - void setTitleOpened (const std::string &title); - std::string getTitleClosed () const; - void setTitleClosed (const std::string &title); - std::string getTitleColorAsString() const; - void setTitleColorAsString(const std::string &col); - - void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); } - - // Get the header color draw. NB: depends if grayed, and if active. - NLMISC::CRGBA getDrawnHeaderColor () const; - - ucstring getUCTitleOpened () const; - void setUCTitleOpened (const ucstring &title); - ucstring getUCTitleClosed () const; - void setUCTitleClosed (const ucstring &title); - ucstring getUCTitle () const; - void setUCTitle (const ucstring &title); - - void setPopable(bool popable) { _Popable = popable; } - bool isPopable() const { return _Popable; } - bool isPopuped() const { return _Poped; } - - - void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; } - bool isMovableInParentList() const { return _MovableInParentList; } - - // high light the border of the container - void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; } - bool isHighLighted() const { return _HighLighted; } - - // y offset for content of container - sint32 getContentYOffset() const { return (sint32) _ContentYOffset; } - void setContentYOffset(sint32 value); - - // Window requires attention - void requireAttention(); - - // Lua exports - int luaBlink(CLuaState &ls); - int luaSetHeaderColor(CLuaState &ls); - - REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase) - REFLECT_LUA_METHOD("blink", luaBlink); - REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor); - REFLECT_STRING("title", getTitle, setTitle); - REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); - REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); - REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); - REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); - REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); - REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); - REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); - REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW); - REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW); - REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW); - REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset); - REFLECT_BOOL("openable", isOpenable, setOpenable); - REFLECT_BOOL("opened", isOpen, setOpen); - REFLECT_BOOL("lockable", isLockable, setLockable); - REFLECT_BOOL("locked", isLocked, setLocked); - - REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); - REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); - REFLECT_EXPORT_END - - sint32 getLayerSetup() const { return _LayerSetup; } - - // if this window is popable, pop it at its actual position - void popupCurrentPos(); - // Popup at previous memorized position - void popup(); - /** Popin the window and possibly put it back in its father container, using the order defined in the list of the container. - * \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL) - * \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list - */ - void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true); - - // get the mover control associated with that control, or NULL if none - CCtrlMover *getCtrlMover() const { return _Mover; } - - // true if there is a mover and if the window is being moved - bool isMoving() const { return _Mover && _Mover->isMoving(); } - - /** Force the container to blink (to tell the user that an event has happened). - * This uses the global color, so the container must use it - * This state is automatically disabled if the container is opened - * \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise - */ - virtual void enableBlink(uint numBlinks = 0); - virtual void disableBlink(); - virtual bool isBlinking() const { return _Blinking; } - - CGroupList *getList() const { return _List; } - - CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; } - CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; } - CInterfaceGroup *getContent() const { return _Content; } - - void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; } - IChildrenObs *getChildrenObs() const { return _ChildrenObs; } - - // Get current father container (if any). - CGroupContainer *getFatherContainer() const; - // Get current father container (if any). If the container is popup, it gives the proprietary container - CGroupContainer *getProprietaryContainer() const; - - - bool isOpenable() const { return _Openable; } - void setOpenable(bool openable); - - bool getHeaderActive() const { return _HeaderActive; } - void setHeaderActive(bool active) { _HeaderActive = active; } - - bool getRightButtonEnabled() const { return _EnabledRightButton; } - void setRightButtonEnabled(bool enabled); - - CCtrlScroll *getScroll() const { return _ScrollBar; } - - bool isSavable() const { return _Savable; } - void setSavable(bool savable) { _Savable = savable; } - bool isActiveSavable() const { return _ActiveSavable; } - - bool isLocalize() const { return _Localize; } - void setLocalize(bool localize) { _Localize = localize; } - - void setPopupX(sint32 x) { _PopupX = x; } - void setPopupY(sint32 y) { _PopupY = y; } - void setPopupW(sint32 w) { _PopupW = w; } - void setPopupH(sint32 h) { _PopupH = h; } - - sint32 getPopupX() const { return _PopupX; } - sint32 getPopupY() const { return _PopupY; } - sint32 getPopupW() const { return _PopupW; } - sint32 getPopupH() const { return _PopupH; } - - sint32 getRefW() const { return _RefW; } - - /** Increase the rollover alpha for the current frame. - * Example of use : an edit box that has focus in a group container - */ - void rollOverAlphaUp(); - // force the rollover alpha to its max value, depending on there's keyboard focus or not - void forceRolloverAlpha(); - - bool isOpenWhenPopup() const { return _OpenWhenPopup; } - - /// Locking of window (prevent it from being moved) - void setLockable(bool lockable); - bool isLockable() const { return _Lockable; } - void setLocked(bool locked); - - // to be called by the 'deactive check' handler - static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } - const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); } - const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; } - // - const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); } - const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; } - // - IActionHandler *getAHOnMovePtr() const { return _AHOnMove; } - const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); } - const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; } - // - IActionHandler *getAHOnResizePtr() const { return _AHOnResize; } - const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); } - const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } - // - IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; } - const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); } - const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; } - - // - void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } - void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } - - void setModalParentList (const std::string &name); - bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) - bool isGrayed() const; - bool blinkAllSons(); - - // true if the resizer is enabled. - bool getEnabledResizer() const {return _EnabledResizer;} - - sint32 getPopupMinW() const {return _PopupMinW;} - sint32 getPopupMaxW() const {return _PopupMaxW;} - sint32 getPopupMinH() const {return _PopupMinH;} - sint32 getPopupMaxH() const {return _PopupMaxH;} - sint32 getMinW() const {return _MinW;} - void setMinW(sint32 minW) { _MinW = minW;} - void setMaxW(sint32 maxW) { _MaxW = maxW;} - sint32 getMaxW() const {return _MaxW;} - void setPopupMinW(sint32 minW); - void setPopupMaxW(sint32 maxW); - void setPopupMinH(sint32 minW); - void setPopupMaxH(sint32 maxW); - - - // backup the current position of this container - void backupPosition(); - // restore the current position of this container - void restorePosition(); - // get x for backup position - sint32 getBackupX() const { return _BackupX; } - sint32 getBackupY() const { return _BackupY; } - // Set backup position - void setBackupPosition(sint32 x, sint32 y); - // clear backup - void clearBackup() { _PositionBackuped = false; } - // Test if position has been backuped (flag cleared by 'restorePosition()') - bool isPositionBackuped() const { return _PositionBackuped; } - // check if the container has been moved, resized, or popuped by the user (and eventually clear that flag) - bool getTouchFlag(bool clearFlag) const; - // from CInterfaceGroup - virtual void restoreAllContainersBackupPosition() { restorePosition(); } - - // when isModal() is true, the whole interface cannot switch desktop - bool isModal() const { return _Modal; } - void setModal(bool modal) { _Modal = modal; } - - // return true if the container has a modal parent window setuped => the whole interface cannot switch desktop - bool isModalSon() const { return !_ModalParents.empty(); } - - // return the help web page of this container. "" if none - const std::string &getHelpPage() const { return _HelpPage; } - // set the help web page of this container. "" if none. NB: the help button is not updated - void setHelpPage(const std::string &newPage); - - void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; } - sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } - -protected: - uint8 _ICurrentRolloverAlphaContainer; - uint8 _HighLightedAlpha; - float _CurrentRolloverAlphaContainer; - float _CurrentRolloverAlphaContent; - sint32 _LayerSetup; - ucstring _TitleTextOpened; - ucstring _TitleTextClosed; - CViewText *_TitleOpened; - CViewText *_TitleClosed; - sint32 _TitleDeltaMaxW; - CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable) - CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin - CCtrlButton *_HelpButton; // Help button - - CGroupList *_List; - CCtrlScroll *_ScrollBar; - CGroupContainer *_OldFatherContainer; - - // NB: _ModalParentNames is a list of modal parent, separated by '|' - std::string _ModalParentNames; // Modal handling between container (container can be linked together, - std::vector _ModalSons; // when the son is active the parent is not active - std::vector _ModalParents; // (but the rest of the interface is)) - - uint _InsertionOrder; - uint _BlinkDT; - uint _NumBlinks; - - CInterfaceGroup *_Content; // Read From Script - CInterfaceGroup *_HeaderOpened; // Read From Script - CInterfaceGroup *_HeaderClosed; // Read From Script - - CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available - - // - CCtrlMover *_Mover; - - IChildrenObs *_Obs; - - // If layer==0 constraint on resize - sint32 _PopupMinW; - sint32 _PopupMaxW; - sint32 _PopupMinH; - sint32 _PopupMaxH; - // If layer>0 constraint on resize - sint32 _MinW; - sint32 _MaxW; - - // backuped position - sint32 _BackupX; - sint32 _BackupY; - - // old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet - sint32 _PopupX; - sint32 _PopupY; - sint32 _PopupW; - sint32 _PopupH; - // - sint32 _RefW; - - - sint32 _MoverDeltaW; - - // action handler - IActionHandler *_AHOnOpen; - CStringShared _AHOnOpenParams; - IActionHandler *_AHOnClose; - CStringShared _AHOnCloseParams; - IActionHandler *_AHOnCloseButton; - CStringShared _AHOnCloseButtonParams; - IActionHandler *_AHOnMove; - CStringShared _AHOnMoveParams; - IActionHandler *_AHOnResize; - CStringShared _AHOnResizeParams; - IActionHandler *_AHOnBeginMove; - CStringShared _AHOnBeginMoveParams; - - // action handler to test whether the windows can be deactivated (when the close button is pressed) - IActionHandler *_AHOnDeactiveCheck; - CStringShared _AHOnDeactiveCheckParams; - - - // Observer to know when children have moved - IChildrenObs *_ChildrenObs; - - // list of container that are poped up - std::vector _PopedCont; - - // Open management - bool _Openable : 1; // Is the container can be manually opened or closed ? - bool _Opened : 1; // Is the container currently opened or closed ? - bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0) - // and close when poped in... - bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start - bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0) - - // Move management - bool _Movable : 1; // Is the container movable ? - bool _MovableInParentList: 1; - bool _Lockable : 1; - bool _MovingInParentList : 1; // Mgt : currently moving ? - - // Pop up / pop in - bool _Popable : 1; - bool _Poped : 1; - - bool _EnabledResizer : 1; - - bool _HighLighted : 1; - bool _Blinking : 1; - bool _BlinkState : 1; - - bool _Savable : 1; - bool _ActiveSavable : 1; - - // Display title background or not - bool _HeaderActive : 1; - bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ? - // - enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString}; - uint8 _TitleClass : 2; - // - mutable bool _TouchFlag : 1; - bool _PositionBackuped : 1; - bool _Modal : 1; // the container is modal and prevent from switching virtual desktop - // - bool _EnabledHelpButton : 1; // Is the Button Help is enabled ? - // - bool _TitleOverExtendViewText : 1; // Does the title over extend view text - bool _Localize : 1; - - CInterfaceProperty _HeaderColor; - - - - sint8 _ContentYOffset; - - // Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value - sint8 _ResizerTopSize; - uint8 _ICurrentRolloverAlphaContent; - - - static bool _ValidateCanDeactivate; - - CStringShared _OptionsName; - - // Web Page used for help - CStringShared _HelpPage; - -private: - - sint32 getLayer(); - void updateResizerSize(CCtrlResizer *cr); - void updateRightButton(); - void updateHelpButton(); - void updateMover(); - void updateViewOpenState(); - void updateTitle(); - - void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH); - void createResizerMaxH(); - void removeResizerMaxH(); - - TTileClass convertTitleClass(const char *ptr); - - static COptionsContainerMove *getMoveOptions(); - - COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used - - bool hasKeyboardFocus() const; - - // private for modal system - void addModalParent (CGroupContainer *pParent); - void addModalSon (CGroupContainer *pSon); - - // Avoid each frame setup layer0, layer1 etc... - enum {NumLayerName=10}; - static const std::string _OptionLayerName[NumLayerName]; - -public: - // for use by CCtrlMover - // Tell that this group is moving in its parent list - void setMovingInParentList(bool enable); - CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; } - CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; } - CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; } - // set the 'hasMoved' flag - void touch(bool touched = true) { _TouchFlag = touched; } - - friend class CICDeactive; -}; - - -#endif // RZ_INTERFACE_CONTAINER_H - -/* End of interface_container.h */ diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index af53eaf51..d1ac6fff6 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -19,7 +19,7 @@ #include "stdpch.h" // #include "interface_manager.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_header.h" #include "nel/gui/lua_ihm.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 422af5755..9e40cadb7 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -30,7 +30,7 @@ extern "C" #include "group_html.h" #include "nel/gui/group_list.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "view_link.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.h b/code/ryzom/client/src/interface_v3/group_in_scene.h index ad2139d98..578d25226 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene.h @@ -21,7 +21,7 @@ #define CL_GROUP_IN_SCENE_HELP_H #include "nel/misc/types_nl.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_menu.h" diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 7593780b7..f337f9f97 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -27,7 +27,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/group_editbox.h" #include "../string_manager_client.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/action_handler.h" #include "../dummy_progress.h" #include "group_compas.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index ae8791c6c..f789e4738 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -25,7 +25,7 @@ #include "../client_chat_manager.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 7d9d6239f..bdb37b895 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -24,7 +24,7 @@ #include "../client_chat_manager.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index bb6f66f38..16a323fa4 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -24,7 +24,7 @@ #include "nel/gui/action_handler.h" #include "nel/gui/view_text.h" #include "dbctrl_sheet.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_menu.h" #include "group_html.h" #include "../init_main_loop.h" diff --git a/code/ryzom/client/src/interface_v3/interface_config.cpp b/code/ryzom/client/src/interface_v3/interface_config.cpp index de9924061..6272f39b2 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.cpp +++ b/code/ryzom/client/src/interface_v3/interface_config.cpp @@ -20,7 +20,7 @@ #include "interface_config.h" #include "interface_manager.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/ctrl_scroll.h" using namespace NLMISC; diff --git a/code/ryzom/client/src/interface_v3/interface_config.h b/code/ryzom/client/src/interface_v3/interface_config.h index 9e3becba6..9f427d905 100644 --- a/code/ryzom/client/src/interface_v3/interface_config.h +++ b/code/ryzom/client/src/interface_v3/interface_config.h @@ -21,9 +21,13 @@ #include "nel/misc/stream.h" -class CGroupContainer; +namespace NLGUI +{ + class CGroupContainer; +} + namespace NLMISC{ -class CCDBNodeLeaf; + class CCDBNodeLeaf; } /** @@ -77,8 +81,8 @@ public: // ------------------------------ void serial (NLMISC::IStream &f); // ------------------------------ - void setFrom (CGroupContainer *pGC); - void setTo (CGroupContainer *pGC); + void setFrom ( NLGUI::CGroupContainer *pGC); + void setTo ( NLGUI::CGroupContainer *pGC); }; // Image of a desktop @@ -96,7 +100,7 @@ public: // Set current desktop from this desktop image void toCurrentDesktop(); // Update image of the given group container (added to the list if it does not exist) - void updateGroupContainerImage(CGroupContainer &gc); + void updateGroupContainerImage( NLGUI::CGroupContainer &gc); // Remove a group container from the image void removeGroupContainerImage(const std::string &groupName); private: diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp index f08d99672..b95a970ba 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_game.cpp @@ -22,7 +22,7 @@ #include "interface_manager.h" #include "nel/gui/interface_element.h" #include "chat_window.h" -#include "group_container.h" +#include "nel/gui/group_container.h" // client #include "../client_chat_manager.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b7b7e0958..80991490e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -62,7 +62,7 @@ // Group #include "nel/gui/group_list.h" #include "group_menu.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_modal.h" #include "nel/gui/group_editbox.h" #include "group_in_scene_bubble.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 507bcb855..5bd8c98f8 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -69,9 +69,9 @@ extern bool g_hidden; namespace NLGUI { class CInterfaceOptions; + class CGroupContainer; } -class CGroupContainer; class CInterfaceAnim; class CGroupMenu; diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index ec5a22938..62bc9c0a6 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -68,7 +68,7 @@ #include "nel/gui/group_list.h" #include "nel/gui/group_tree.h" #include "group_menu.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_scrolltext.h" #include "nel/gui/group_editbox.h" #include "group_skills.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 91f23427c..85266d3d8 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -37,9 +37,9 @@ namespace NLGUI class CInterfaceLink; class CCtrlBase; class CGroupList; + class CGroupContainer; } -class CGroupContainer; class CInterfaceAnim; class CViewPointer; class CBrickJob; diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index c56a36457..cc057c235 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -29,6 +29,7 @@ namespace NLGUI class CInterfaceGroup; class CViewText; class CCtrlTextButton; + class CGroupContainer; } using namespace NLGUI; @@ -66,7 +67,7 @@ typedef CInterfacePtr::TInterfacePtr CViewTextPtr; typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; -typedef CInterfacePtr::TInterfacePtr CGroupContainerPtr; +typedef CInterfacePtr::TInterfacePtr CGroupContainerPtr; #endif // NL_INTERFACE_POINTER_H diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index c76abf959..dd3664d1f 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -23,7 +23,7 @@ #include "interface_manager.h" #include "bot_chat_page_trade.h" #include "bot_chat_page_all.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_menu.h" #include "nel/misc/cdb_leaf.h" #include "nel/misc/cdb_branch.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index d4d2d87ad..00abdaf88 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -28,7 +28,7 @@ #include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_modal_get_key.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.h b/code/ryzom/client/src/interface_v3/macrocmd_key.h index 527efbed2..2a7fd82b7 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.h +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.h @@ -21,7 +21,10 @@ #include "../actions_client.h" -class CGroupContainer; +namespace NLGUI +{ + class CGroupContainer; +} // *************************************************************************** #define WIN_EDITCMD_TITLE_NEW_KEY "uiNewKey" @@ -47,7 +50,7 @@ public: void checkCurrentCommandValidity(); public: - CGroupContainer *Win; + NLGUI::CGroupContainer *Win; std::string WinName; bool CanDefineKey; diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 099b6f364..52c7ae45a 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -29,7 +29,7 @@ #include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" #include "dbgroup_combo_box.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "group_modal_get_key.h" #include "task_bar_manager.h" #include "sphrase_manager.h" diff --git a/code/ryzom/client/src/interface_v3/music_player.h b/code/ryzom/client/src/interface_v3/music_player.h index f367d3df8..51fec7402 100644 --- a/code/ryzom/client/src/interface_v3/music_player.h +++ b/code/ryzom/client/src/interface_v3/music_player.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/stream.h" #include "dbctrl_sheet.h" -#include "group_container.h" +#include "nel/gui/group_container.h" // *************************************************************************** /* diff --git a/code/ryzom/client/src/interface_v3/people_list.cpp b/code/ryzom/client/src/interface_v3/people_list.cpp index 3eb1c500f..9bf60df92 100644 --- a/code/ryzom/client/src/interface_v3/people_list.cpp +++ b/code/ryzom/client/src/interface_v3/people_list.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" #include "people_list.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_list.h" #include "nel/gui/view_bitmap.h" #include "interface_manager.h" diff --git a/code/ryzom/client/src/interface_v3/people_list.h b/code/ryzom/client/src/interface_v3/people_list.h index a3748c01a..0e4245427 100644 --- a/code/ryzom/client/src/interface_v3/people_list.h +++ b/code/ryzom/client/src/interface_v3/people_list.h @@ -21,7 +21,7 @@ // client -#include "group_container.h" +#include "nel/gui/group_container.h" #include "chat_window.h" #include "interface_pointer.h" // NeL diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 2df8c0dda..b6d5a8ba8 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -30,7 +30,7 @@ #include "nel/gui/interface_group.h" #include "nel/gui/group_frame.h" #include "nel/gui/group_container_base.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "nel/gui/group_list.h" #include "dbgroup_select_number.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp index 0edece1a1..7e307abbb 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.cpp +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.cpp @@ -25,7 +25,7 @@ #include "dbgroup_list_sheet.h" #include "nel/gui/action_handler.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "../actions_client.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/task_bar_manager.h b/code/ryzom/client/src/interface_v3/task_bar_manager.h index 4b4169d36..ab9d3273a 100644 --- a/code/ryzom/client/src/interface_v3/task_bar_manager.h +++ b/code/ryzom/client/src/interface_v3/task_bar_manager.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/stream.h" #include "dbctrl_sheet.h" -#include "group_container.h" +#include "nel/gui/group_container.h" // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index e1e18248d..0b30cf47a 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -27,7 +27,7 @@ // #include "nel/misc/xml_auto_ptr.h" // -#include "group_container.h" +#include "nel/gui/group_container.h" #include "interface_3d_scene.h" // #include "../r2/editor.h" diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index 8696ce245..7b1b85e30 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -23,11 +23,10 @@ #include "nel/misc/events.h" #include "nel/gui/view_pointer_base.h" -class CGroupContainer; - namespace NLGUI { class CCtrlBase; + class CGroupContainer; } /** diff --git a/code/ryzom/client/src/interface_v3/view_radar.cpp b/code/ryzom/client/src/interface_v3/view_radar.cpp index 0a4ee8113..d7462cfc6 100644 --- a/code/ryzom/client/src/interface_v3/view_radar.cpp +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp @@ -23,7 +23,7 @@ #include "view_radar.h" #include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" -#include "group_container.h" +#include "nel/gui/group_container.h" #include "../npc_icon.h" #include "nel/misc/fast_floor.h" diff --git a/code/ryzom/client/src/outpost_manager.cpp b/code/ryzom/client/src/outpost_manager.cpp index 31d0fd647..6c77c66e9 100644 --- a/code/ryzom/client/src/outpost_manager.cpp +++ b/code/ryzom/client/src/outpost_manager.cpp @@ -20,7 +20,7 @@ #include "outpost_manager.h" #include "net_manager.h" #include "interface_v3/interface_manager.h" -#include "interface_v3/group_container.h" +#include "nel/gui/group_container.h" #include "nel/misc/bit_mem_stream.h" #include "game_share/generic_xml_msg_mngr.h" diff --git a/code/ryzom/client/src/r2/instance_map_deco.cpp b/code/ryzom/client/src/r2/instance_map_deco.cpp index c6b1b2dae..3f766deb6 100644 --- a/code/ryzom/client/src/r2/instance_map_deco.cpp +++ b/code/ryzom/client/src/r2/instance_map_deco.cpp @@ -21,7 +21,7 @@ #include "tool.h" // #include "nel/gui/ctrl_quad.h" -#include "../interface_v3/group_container.h" +#include "nel/gui/group_container.h" // #include "nel/misc/i18n.h" // diff --git a/code/ryzom/client/src/r2/npc_editor.cpp b/code/ryzom/client/src/r2/npc_editor.cpp index 5522b2014..e24f6d900 100644 --- a/code/ryzom/client/src/r2/npc_editor.cpp +++ b/code/ryzom/client/src/r2/npc_editor.cpp @@ -21,7 +21,7 @@ #include "../interface_v3/character_3d.h" #include "editor.h" #include "../interface_v3/interface_manager.h" -#include "../interface_v3/group_container.h" +#include "nel/gui/group_container.h" #include "displayer_visual_entity.h" #include "../interface_v3/dbgroup_combo_box.h" diff --git a/code/ryzom/client/src/r2/npc_editor.h b/code/ryzom/client/src/r2/npc_editor.h index 2262732f7..5ee2b58a7 100644 --- a/code/ryzom/client/src/r2/npc_editor.h +++ b/code/ryzom/client/src/r2/npc_editor.h @@ -20,8 +20,12 @@ // Misc #include "nel/misc/singleton.h" +namespace NLGUI +{ + class CGroupContainer; +} + class CEntityCL; -class CGroupContainer; namespace R2 { @@ -47,7 +51,7 @@ private: private: CDisplayerVisualEntity * _DisplayerVE; - CGroupContainer * _NPCWindow; + NLGUI::CGroupContainer * _NPCWindow; }; diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h index 9b82fc724..d5cffc1cf 100644 --- a/code/ryzom/client/src/r2/tool.h +++ b/code/ryzom/client/src/r2/tool.h @@ -26,12 +26,12 @@ // class CInterfaceManager; -class CGroupContainer; namespace NLGUI { class CEventDescriptor; class CLuaObject; + class CGroupContainer; } class CGroupMap; From 5aa1f67e3d86c87dc502def16fbe5235ca4e018a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 21:03:23 +0200 Subject: [PATCH 098/339] CHANGED: #1471 CGroupScrollText no longer depends on the Ryzom client time data. --- .../src/interface_v3/group_scrolltext.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp index b58569313..0c4ec9e8b 100644 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp @@ -14,21 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - - - -#include "stdpch.h" #include "group_scrolltext.h" #include "nel/gui/group_list.h" #include "nel/gui/view_text.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" - -#include "../time_client.h" #include "nel/misc/i18n.h" +#include "nel/gui/widget_manager.h" NLMISC_REGISTER_OBJECT(CViewBase, CGroupScrollText, std::string, "scroll_text"); @@ -204,13 +197,15 @@ class CSTUp : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); if (pST == NULL) return; if (pST->getList() == NULL) return; // get the font height from the text template of the list const CViewText *vt = pST->getList()->getTextTemplatePtr(); if (!vt) return; - pST->_EllapsedTime += DT64; + pST->_EllapsedTime += times.frameDiffMs; // pST->setH(std::min((sint32) pST->getMaxHeight(), (sint32) (pST->_StartHeight + pST->_EllapsedTime / 9))); pST->setH((sint32) (pST->_StartHeight + pST->_EllapsedTime / 9)); pST->invalidateCoords(); @@ -224,13 +219,15 @@ class CSTDown : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); if (pST == NULL) return; if (pST->getList() == NULL) return; // get the font height from the text template of the list const CViewText *vt = pST->getList()->getTextTemplatePtr(); if (!vt) return; - pST->_EllapsedTime += DT64; + pST->_EllapsedTime += times.frameDiffMs; // pST->setH(std::max((sint32) pST->getMinHeight(), (sint32) (pST->_StartHeight - pST->_EllapsedTime / 9))); pST->setH((sint32) (pST->_StartHeight - pST->_EllapsedTime / 9)); pST->invalidateCoords(); From 82e2759971c95b04b523d4c6ba5d0d074911d184 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 21:24:48 +0200 Subject: [PATCH 099/339] CHANGED: #1471 CGroupScrollText is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/group_scrolltext.h | 86 +++++++ code/nel/src/gui/group_scrolltext.cpp | 242 ++++++++++++++++++ .../client/src/interface_v3/group_html.h | 2 +- .../src/interface_v3/group_scrolltext.cpp | 237 ----------------- .../src/interface_v3/group_scrolltext.h | 86 ------- .../src/interface_v3/interface_parser.cpp | 2 +- 6 files changed, 330 insertions(+), 325 deletions(-) create mode 100644 code/nel/include/nel/gui/group_scrolltext.h create mode 100644 code/nel/src/gui/group_scrolltext.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_scrolltext.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_scrolltext.h diff --git a/code/nel/include/nel/gui/group_scrolltext.h b/code/nel/include/nel/gui/group_scrolltext.h new file mode 100644 index 000000000..9806d61f4 --- /dev/null +++ b/code/nel/include/nel/gui/group_scrolltext.h @@ -0,0 +1,86 @@ +// Ryzom - MMORPG Framework +// 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 CL_GROUP_SCROLLTEXT_H +#define CL_GROUP_SCROLLTEXT_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + +namespace NLGUI +{ + class CCtrlBaseButton; + class CCtrlScroll; + class CGroupList; + + // Can be used to build a chat window or anything that displays sequences of strings + /** + * Widget to have a resizable scrolltext and its scrollbar + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2002 + */ + class CGroupScrollText : public CInterfaceGroup + { + public: + /// Constructor + CGroupScrollText(const TCtorParam ¶m); + ~CGroupScrollText(); + + /// CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + virtual void checkCoords (); + virtual void draw (); + virtual void clearViews (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + // get the list associated to this group + CGroupList *getList() const { return _List; } + + // Get the scroll bar + CCtrlScroll *getScrollBar() const { return _ScrollBar; } + + // from CCtrlBase + virtual void elementCaptured(CCtrlBase *capturedElement); + + + REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup) + REFLECT_EXPORT_END + + private: + CGroupList *_List; + CCtrlScroll *_ScrollBar; + CCtrlBaseButton *_ButtonAdd; + CCtrlBaseButton *_ButtonSub; + bool _Settuped; + bool _InvertScrollBar; + sint32 _ListHeight; + protected: + void setup(); + void updateScrollBar(); + public: + // private use for action handlers + sint32 _StartHeight; + sint64 _EllapsedTime; + }; + +} + +#endif diff --git a/code/nel/src/gui/group_scrolltext.cpp b/code/nel/src/gui/group_scrolltext.cpp new file mode 100644 index 000000000..b2e603bf8 --- /dev/null +++ b/code/nel/src/gui/group_scrolltext.cpp @@ -0,0 +1,242 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_scrolltext.h" +#include "nel/gui/group_list.h" +#include "nel/gui/view_text.h" +#include "nel/gui/ctrl_scroll.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/action_handler.h" +#include "nel/misc/i18n.h" +#include "nel/gui/widget_manager.h" + +NLMISC_REGISTER_OBJECT(CViewBase, CGroupScrollText, std::string, "scroll_text"); + +namespace NLGUI +{ + + //======================================================================== + CGroupScrollText::CGroupScrollText(const TCtorParam ¶m) : + CInterfaceGroup(param), + _List(NULL), + _ScrollBar(NULL), + _ButtonAdd(NULL), + _ButtonSub(NULL), + _Settuped(false), + _InvertScrollBar(true), + _ListHeight(0), + _StartHeight(0), + _EllapsedTime(0) + { + _IsGroupScrollText = true; + } + + //======================================================================== + CGroupScrollText::~CGroupScrollText() + { + } + + //======================================================================== + bool CGroupScrollText::parse(xmlNodePtr cur,CInterfaceGroup *parentGroup) + { + if(!CInterfaceGroup::parse(cur, parentGroup)) + return false; + CXMLAutoPtr ptr; + + // invert scroll bar? + ptr = xmlGetProp (cur, (xmlChar*)"invert_scroll_bar"); + if(ptr) _InvertScrollBar= convertBool(ptr); + + return true; + } + + //======================================================================== + void CGroupScrollText::updateCoords() + { + CInterfaceGroup::updateCoords(); + if (!_Settuped) setup(); + updateScrollBar(); + // re-update of scrollbar + if(_ScrollBar) + _ScrollBar->updateCoords(); + } + + //======================================================================== + void CGroupScrollText::updateScrollBar() + { + if (_List && _ScrollBar) + { + if (_List->getHReal() < _List->getMaxHReal()) + { + _ScrollBar->setActive(false); + } + else + { + _ScrollBar->setActive(true); + } + } + } + + //======================================================================== + void CGroupScrollText::checkCoords () + { + // update scrollbar if necessary + if (_List) + { + if (_List->getH() != _ListHeight) // see if the scrollbar should be updated + { + invalidateCoords(); + _ListHeight = _List->getH(); + } + } + CInterfaceGroup::checkCoords(); + } + + //======================================================================== + void CGroupScrollText::draw() + { + CInterfaceGroup::draw(); + } + + //======================================================================== + void CGroupScrollText::clearViews() + { + CInterfaceGroup::clearViews(); + } + + //======================================================================== + bool CGroupScrollText::handleEvent(const NLGUI::CEventDescriptor &event) + { + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + // + if (_List && _ScrollBar) + { + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + if (isIn(eventDesc.getX(), eventDesc.getY())) + { + sint32 h = _List->getMaxHReal() / 2; + if (h == 0) h = 1; + _ScrollBar->moveTargetY(- eventDesc.getWheel() * h); + return true; + } + } + } + } + if (CInterfaceGroup::handleEvent(event)) return true; + return false; + } + + //======================================================================== + void CGroupScrollText::setup() + { + // bind to the controls + _ScrollBar = dynamic_cast(CInterfaceGroup::getCtrl("scroll_bar")); + _ButtonAdd = dynamic_cast(CInterfaceGroup::getCtrl("button_add")); + _ButtonSub = dynamic_cast(CInterfaceGroup::getCtrl("button_sub")); + _List = dynamic_cast(CInterfaceGroup::getGroup("text_list")); + + if(_ScrollBar == NULL) + nlwarning(" scroll bar 'scroll_bar' missing or bad type.(%s)",this->_Id.c_str()); + // Add and sub button are not required + /* + if(buttonAdd == NULL) + nlwarning("Interface: CGroupScrollText: button 'button_add' missing or bad type"); + if(buttonSub == NULL) + nlwarning("Interface: CGroupScrollText: button 'button_sub' missing or bad type"); + */ + if(_List == NULL) + nlwarning(" group list 'text_list' missing or bad type"); + + // actions + if (_ButtonAdd) _ButtonAdd->setActionOnClockTick("gst_add"); + if (_ButtonSub) _ButtonSub->setActionOnClockTick("gst_sub"); + + // bind the scrollbar to the list + if (_ScrollBar) + { + _ScrollBar->setTarget(_List); + //_ScrollBar->setInverted(_InvertScrollBar); + } + _Settuped = true; + } + + //======================================================================== + void CGroupScrollText::elementCaptured(CCtrlBase *capturedElement) + { + if (capturedElement == _ButtonAdd || capturedElement == _ButtonSub) + { + // reset the counters for increase + _EllapsedTime = 0; + _StartHeight = getH(); + } + } + + // *************************************************************************** + // *************************************************************************** + // Actions Handlers + // *************************************************************************** + // *************************************************************************** + + + // *************************************************************************** + class CSTUp : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); + if (pST == NULL) return; + if (pST->getList() == NULL) return; + // get the font height from the text template of the list + const CViewText *vt = pST->getList()->getTextTemplatePtr(); + if (!vt) return; + pST->_EllapsedTime += times.frameDiffMs; + // pST->setH(std::min((sint32) pST->getMaxHeight(), (sint32) (pST->_StartHeight + pST->_EllapsedTime / 9))); + pST->setH((sint32) (pST->_StartHeight + pST->_EllapsedTime / 9)); + pST->invalidateCoords(); + } + }; + REGISTER_ACTION_HANDLER (CSTUp, "gst_add"); + + // *************************************************************************** + class CSTDown : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); + if (pST == NULL) return; + if (pST->getList() == NULL) return; + // get the font height from the text template of the list + const CViewText *vt = pST->getList()->getTextTemplatePtr(); + if (!vt) return; + pST->_EllapsedTime += times.frameDiffMs; + // pST->setH(std::max((sint32) pST->getMinHeight(), (sint32) (pST->_StartHeight - pST->_EllapsedTime / 9))); + pST->setH((sint32) (pST->_StartHeight - pST->_EllapsedTime / 9)); + pST->invalidateCoords(); + } + }; + REGISTER_ACTION_HANDLER (CSTDown, "gst_sub"); + +} + diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index a0a4b7d7d..9f03ab050 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -25,7 +25,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/interface_group.h" -#include "group_scrolltext.h" +#include "nel/gui/group_scrolltext.h" #include "nel/gui/group_tree.h" #include "nel/gui/ctrl_button.h" #include "group_table.h" diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp b/code/ryzom/client/src/interface_v3/group_scrolltext.cpp deleted file mode 100644 index 0c4ec9e8b..000000000 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.cpp +++ /dev/null @@ -1,237 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_scrolltext.h" -#include "nel/gui/group_list.h" -#include "nel/gui/view_text.h" -#include "nel/gui/ctrl_scroll.h" -#include "nel/gui/ctrl_button.h" -#include "nel/gui/action_handler.h" -#include "nel/misc/i18n.h" -#include "nel/gui/widget_manager.h" - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupScrollText, std::string, "scroll_text"); - -//======================================================================== -CGroupScrollText::CGroupScrollText(const TCtorParam ¶m) : - CInterfaceGroup(param), - _List(NULL), - _ScrollBar(NULL), - _ButtonAdd(NULL), - _ButtonSub(NULL), - _Settuped(false), - _InvertScrollBar(true), - _ListHeight(0), - _StartHeight(0), - _EllapsedTime(0) -{ - _IsGroupScrollText = true; -} - -//======================================================================== -CGroupScrollText::~CGroupScrollText() -{ -} - -//======================================================================== -bool CGroupScrollText::parse(xmlNodePtr cur,CInterfaceGroup *parentGroup) -{ - if(!CInterfaceGroup::parse(cur, parentGroup)) - return false; - CXMLAutoPtr ptr; - - // invert scroll bar? - ptr = xmlGetProp (cur, (xmlChar*)"invert_scroll_bar"); - if(ptr) _InvertScrollBar= convertBool(ptr); - - return true; -} - -//======================================================================== -void CGroupScrollText::updateCoords() -{ - CInterfaceGroup::updateCoords(); - if (!_Settuped) setup(); - updateScrollBar(); - // re-update of scrollbar - if(_ScrollBar) - _ScrollBar->updateCoords(); -} - -//======================================================================== -void CGroupScrollText::updateScrollBar() -{ - if (_List && _ScrollBar) - { - if (_List->getHReal() < _List->getMaxHReal()) - { - _ScrollBar->setActive(false); - } - else - { - _ScrollBar->setActive(true); - } - } -} - -//======================================================================== -void CGroupScrollText::checkCoords () -{ - // update scrollbar if necessary - if (_List) - { - if (_List->getH() != _ListHeight) // see if the scrollbar should be updated - { - invalidateCoords(); - _ListHeight = _List->getH(); - } - } - CInterfaceGroup::checkCoords(); -} - -//======================================================================== -void CGroupScrollText::draw() -{ - CInterfaceGroup::draw(); -} - -//======================================================================== -void CGroupScrollText::clearViews() -{ - CInterfaceGroup::clearViews(); -} - -//======================================================================== -bool CGroupScrollText::handleEvent(const NLGUI::CEventDescriptor &event) -{ - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - // - if (_List && _ScrollBar) - { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - if (isIn(eventDesc.getX(), eventDesc.getY())) - { - sint32 h = _List->getMaxHReal() / 2; - if (h == 0) h = 1; - _ScrollBar->moveTargetY(- eventDesc.getWheel() * h); - return true; - } - } - } - } - if (CInterfaceGroup::handleEvent(event)) return true; - return false; -} - -//======================================================================== -void CGroupScrollText::setup() -{ - // bind to the controls - _ScrollBar = dynamic_cast(CInterfaceGroup::getCtrl("scroll_bar")); - _ButtonAdd = dynamic_cast(CInterfaceGroup::getCtrl("button_add")); - _ButtonSub = dynamic_cast(CInterfaceGroup::getCtrl("button_sub")); - _List = dynamic_cast(CInterfaceGroup::getGroup("text_list")); - - if(_ScrollBar == NULL) - nlwarning(" scroll bar 'scroll_bar' missing or bad type.(%s)",this->_Id.c_str()); - // Add and sub button are not required - /* - if(buttonAdd == NULL) - nlwarning("Interface: CGroupScrollText: button 'button_add' missing or bad type"); - if(buttonSub == NULL) - nlwarning("Interface: CGroupScrollText: button 'button_sub' missing or bad type"); - */ - if(_List == NULL) - nlwarning(" group list 'text_list' missing or bad type"); - - // actions - if (_ButtonAdd) _ButtonAdd->setActionOnClockTick("gst_add"); - if (_ButtonSub) _ButtonSub->setActionOnClockTick("gst_sub"); - - // bind the scrollbar to the list - if (_ScrollBar) - { - _ScrollBar->setTarget(_List); - //_ScrollBar->setInverted(_InvertScrollBar); - } - _Settuped = true; -} - -//======================================================================== -void CGroupScrollText::elementCaptured(CCtrlBase *capturedElement) -{ - if (capturedElement == _ButtonAdd || capturedElement == _ButtonSub) - { - // reset the counters for increase - _EllapsedTime = 0; - _StartHeight = getH(); - } -} - -// *************************************************************************** -// *************************************************************************** -// Actions Handlers -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -class CSTUp : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); - if (pST == NULL) return; - if (pST->getList() == NULL) return; - // get the font height from the text template of the list - const CViewText *vt = pST->getList()->getTextTemplatePtr(); - if (!vt) return; - pST->_EllapsedTime += times.frameDiffMs; -// pST->setH(std::min((sint32) pST->getMaxHeight(), (sint32) (pST->_StartHeight + pST->_EllapsedTime / 9))); - pST->setH((sint32) (pST->_StartHeight + pST->_EllapsedTime / 9)); - pST->invalidateCoords(); - } -}; -REGISTER_ACTION_HANDLER (CSTUp, "gst_add"); - -// *************************************************************************** -class CSTDown : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - CGroupScrollText *pST = dynamic_cast(pCaller->getParent()); - if (pST == NULL) return; - if (pST->getList() == NULL) return; - // get the font height from the text template of the list - const CViewText *vt = pST->getList()->getTextTemplatePtr(); - if (!vt) return; - pST->_EllapsedTime += times.frameDiffMs; -// pST->setH(std::max((sint32) pST->getMinHeight(), (sint32) (pST->_StartHeight - pST->_EllapsedTime / 9))); - pST->setH((sint32) (pST->_StartHeight - pST->_EllapsedTime / 9)); - pST->invalidateCoords(); - } -}; -REGISTER_ACTION_HANDLER (CSTDown, "gst_sub"); - diff --git a/code/ryzom/client/src/interface_v3/group_scrolltext.h b/code/ryzom/client/src/interface_v3/group_scrolltext.h deleted file mode 100644 index 88fc2c6cb..000000000 --- a/code/ryzom/client/src/interface_v3/group_scrolltext.h +++ /dev/null @@ -1,86 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_GROUP_SCROLLTEXT_H -#define CL_GROUP_SCROLLTEXT_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/interface_group.h" - -namespace NLGUI -{ - class CCtrlBaseButton; - class CCtrlScroll; - class CGroupList; -} - -// Can be used to build a chat window or anything that displays sequences of strings -/** - * Widget to have a resizable scrolltext and its scrollbar - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2002 - */ -class CGroupScrollText : public CInterfaceGroup -{ -public: - /// Constructor - CGroupScrollText(const TCtorParam ¶m); - ~CGroupScrollText(); - - /// CInterfaceGroup Interface - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void updateCoords (); - virtual void checkCoords (); - virtual void draw (); - virtual void clearViews (); - virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); - - // get the list associated to this group - CGroupList *getList() const { return _List; } - - // Get the scroll bar - CCtrlScroll *getScrollBar() const { return _ScrollBar; } - - // from CCtrlBase - virtual void elementCaptured(CCtrlBase *capturedElement); - - - REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup) - REFLECT_EXPORT_END - -private: - CGroupList *_List; - CCtrlScroll *_ScrollBar; - CCtrlBaseButton *_ButtonAdd; - CCtrlBaseButton *_ButtonSub; - bool _Settuped; - bool _InvertScrollBar; - sint32 _ListHeight; -protected: - void setup(); - void updateScrollBar(); -public: - // private use for action handlers - sint32 _StartHeight; - sint64 _EllapsedTime; -}; - - -#endif diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 62bc9c0a6..c896d1538 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -69,7 +69,7 @@ #include "nel/gui/group_tree.h" #include "group_menu.h" #include "nel/gui/group_container.h" -#include "group_scrolltext.h" +#include "nel/gui/group_scrolltext.h" #include "nel/gui/group_editbox.h" #include "group_skills.h" #include "group_html_forum.h" From 67f71ddf15a0963c91b03c7d2b7c2a0bcf5d4170 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 22:04:33 +0200 Subject: [PATCH 100/339] CHANGED: #1471 CViewTextMenu, CGroupSubMenu, CGroupMenu no longer depend on CInterfaceManager and CInterfaceParser. --- code/nel/include/nel/gui/widget_manager.h | 2 + .../client/src/interface_v3/group_menu.cpp | 43 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 9f6f685c9..98fae80d6 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -49,6 +49,8 @@ namespace NLGUI virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0; virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; + virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; + virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; }; /// Manages the GUI widgets diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp index b0a062049..931571d0b 100644 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ b/code/ryzom/client/src/interface_v3/group_menu.cpp @@ -14,31 +14,32 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -// ------------------------------------------------------------------------------------------------ -#include "stdpch.h" -#include "interface_manager.h" +#include "nel/gui/interface_options.h" #include "nel/gui/interface_expr.h" #include "group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/action_handler.h" // Just for getAllParams #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" - #include "nel/misc/i18n.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/group_list.h" +#include "nel/gui/ctrl_scroll.h" +#include "nel/gui/view_pointer_base.h" + using namespace NLMISC; using namespace std; -static const std::string ID_MENU_CHECKBOX = "menu_cb"; -static const std::string ID_MENU_SEPARATOR = "menu_separator"; -static const std::string ID_MENU_SUBMENU = "menu_sb"; - -static const uint MENU_WIDGET_X = 2; -static const uint LEFT_MENU_WIDGET_X = 4; +namespace +{ + const std::string ID_MENU_CHECKBOX = "menu_cb"; + const std::string ID_MENU_SEPARATOR = "menu_separator"; + const std::string ID_MENU_SUBMENU = "menu_sb"; + const uint MENU_WIDGET_X = 2; + const uint LEFT_MENU_WIDGET_X = 4; +} // ------------------------------------------------------------------------------------------------ // CGroupSubMenu @@ -235,7 +236,6 @@ void CGroupSubMenu::initOptions(CInterfaceGroup *parent) bool CGroupSubMenu::parse (xmlNodePtr cur, CInterfaceGroup *parent) { initOptions(parent); - CInterfaceManager *im = CInterfaceManager::getInstance(); // the children while (cur) { @@ -341,7 +341,7 @@ bool CGroupSubMenu::parse (xmlNodePtr cur, CInterfaceGroup *parent) } string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; - CInterfaceGroup *pUGLeft = im->createGroupInstance((const char*)usergroup, completeId, vparams); + CInterfaceGroup *pUGLeft = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); if (pUGLeft) setUserGroupLeft((uint)_Lines.size()-1, pUGLeft, true); } @@ -356,7 +356,7 @@ bool CGroupSubMenu::parse (xmlNodePtr cur, CInterfaceGroup *parent) } string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; - CInterfaceGroup *pUG = im->createGroupInstance((const char*)usergroup, completeId, vparams); + CInterfaceGroup *pUG = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); if (pUG) setUserGroupRight((uint)_Lines.size()-1, pUG, true); } @@ -866,7 +866,6 @@ void CGroupSubMenu::checkCoords() if (_GroupMenu == NULL) return; // if the mouse goes out the window, unselect all (because handleEvent may not be called) - CInterfaceManager *pIM = CInterfaceManager::getInstance(); sint xMouse= CWidgetManager::getInstance()->getPointer()->getX(); sint yMouse= CWidgetManager::getInstance()->getPointer()->getY(); if (!((xMouse >= _XReal) && @@ -982,7 +981,7 @@ bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) // If a line is selected and the line is not grayed if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed())) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHName, CWidgetManager::getInstance()->getCtrlLaunchingModal(), _Lines[_Selected].AHParams ); @@ -1135,15 +1134,15 @@ void CGroupSubMenu::addSeparatorAtIndex(uint index, const std::string &id) nlwarning("Bad index"); return; } - CInterfaceManager *im = CInterfaceManager::getInstance(); + // create the real separator. It may be larger than the group list, this is why we create a separate group - CInterfaceGroup *separator = im->createGroupInstance("menu_separator", "", NULL, 0); + CInterfaceGroup *separator = CWidgetManager::parser->createGroupInstance("menu_separator", "", NULL, 0); if (!separator) return; separator->setId(ID_MENU_SEPARATOR); addGroup(separator); separator->setParent(this); // create place holder group - CInterfaceGroup *ph = im->createGroupInstance("menu_separator_empty", "", NULL, 0); + CInterfaceGroup *ph = CWidgetManager::parser->createGroupInstance("menu_separator_empty", "", NULL, 0); if (!ph) { delGroup(separator); @@ -1935,7 +1934,7 @@ bool CGroupMenu::parse (xmlNodePtr in, CInterfaceGroup *parentGroup) CGroupSubMenu *gmExtended = NULL; if (prop) { - CInterfaceManager *im = CInterfaceManager::getInstance(); + CGroupMenu *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); if (!gm) { From bb32f759c10ae435c560a4ad1a67f194610d47bc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 23 Jun 2012 22:38:10 +0200 Subject: [PATCH 101/339] CHANGED: #1471 CViewTextMenu, CGroupSubMenu, CGroupMenu are now part of the NELGUI library and are under the NLGUI namespace. --- code/nel/include/nel/gui/group_menu.h | 395 +++ code/nel/src/gui/group_menu.cpp | 2302 +++++++++++++++++ code/ryzom/client/src/game_context_menu.cpp | 2 +- code/ryzom/client/src/game_context_menu.h | 10 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../interface_v3/action_handler_phrase.cpp | 2 +- .../src/interface_v3/dbgroup_combo_box.cpp | 2 +- .../src/interface_v3/dbgroup_combo_box.h | 3 +- .../client/src/interface_v3/group_compas.h | 2 +- .../client/src/interface_v3/group_in_scene.h | 2 +- .../client/src/interface_v3/group_menu.cpp | 2300 ---------------- .../client/src/interface_v3/group_menu.h | 396 --- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../interface_v3/interface_options_ryzom.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_pointer.h | 3 +- .../src/interface_v3/inventory_manager.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../register_interface_elements.cpp | 2 +- 22 files changed, 2722 insertions(+), 2717 deletions(-) create mode 100644 code/nel/include/nel/gui/group_menu.h create mode 100644 code/nel/src/gui/group_menu.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_menu.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_menu.h diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h new file mode 100644 index 000000000..b9aad97e8 --- /dev/null +++ b/code/nel/include/nel/gui/group_menu.h @@ -0,0 +1,395 @@ +// Ryzom - MMORPG Framework +// 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 RZ_GROUP_MENU_H +#define RZ_GROUP_MENU_H + +#include "nel/gui/interface_group.h" +#include "nel/gui/group_modal.h" +#include "nel/gui/group_submenu_base.h" +#include "nel/gui/view_text.h" +#include "nel/gui/ctrl_text_button.h" + +namespace NLGUI +{ + class CCtrlScroll; + class CViewBitmap; + class CGroupList; + class CGroupMenu; + + + /** + * CViewTextMenu is an element of a sub menu + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CViewTextMenu : public CViewText + { + public: + + CViewTextMenu(const TCtorParam ¶m) : CViewText(param) + { + _Grayed = false; + _Checked = false; + _Checkable = false; + _CheckBox = NULL; + Over = false; + } + + bool getGrayed() const; + void setGrayed (bool g); + bool getChecked() const { return _Checked; } + void setChecked(bool c); + bool getCheckable() const { return _Checkable; } + void setCheckable(bool c); + void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; } + CViewBitmap * getCheckBox() const { return _CheckBox; } + bool getFormatted () const { return getMultiLine (); } + + virtual sint32 getAlpha() const; + virtual void setAlpha (sint32 a); + + REFLECT_EXPORT_START(CViewTextMenu, CViewText) + REFLECT_BOOL("grayed", getGrayed, setGrayed); + REFLECT_BOOL("checked", getChecked, setChecked); + REFLECT_EXPORT_END + + public: + + bool Over; + NLMISC::CRGBA OldColor; + NLMISC::CRGBA OldShadowColor; + NLMISC::CRGBA OldColorOver; + NLMISC::CRGBA OldShadowColorOver; + NLMISC::CRGBA OldColorGrayed; + NLMISC::CRGBA OldShadowColorGrayed; + + private: + CViewBitmap *_CheckBox; + bool _Grayed; + bool _Checked; + bool _Checkable; + }; + + /** + * CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu) + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + + class CGroupSubMenu : public CGroupSubMenuBase + { + public: + + CGroupSubMenu(const TCtorParam ¶m); + virtual ~CGroupSubMenu(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL); + + virtual void checkCoords(); + + virtual void updateCoords (); + + virtual void draw (); + + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + virtual CInterfaceElement* getElement (const std::string &id); + + // retrieve the index of a line from its id (-1 if not found) + sint getLineFromId(const std::string &id); + + CViewTextMenu* addLine (const ucstring &name, const std::string &ah, + const std::string ¶ms, const std::string &id="", + const std::string &cond = std::string(), const std::string &texture="", + bool checkable = false, bool checked = false, bool formatted = false + ); + CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + const std::string ¶ms, const std::string &id="", + const std::string &cond = std::string(), const std::string &texture="", + bool checkable = false, bool checked = false, bool formatted = false + ); + void addSeparator(const std::string &id = ""); + void addSeparatorAtIndex(uint index, const std::string &id = ""); + + + uint getNumLine() const { return (uint)_Lines.size(); } + void removeLine(uint index); + const std::string getActionHandler(uint lineIndex) const; + const std::string getActionHandlerParam(uint lineIndex) const; + + void openSubMenu (sint32 nb); + + void hideSubMenus (); + + // reset all entries of the sub menu + void reset(); + + virtual void setActive (bool state); + + // Tell if the line is a separator or not + bool isSeparator (uint i) const; + + /** Set a user defined group at the given line + * 'ownership' tells whether this menu should remove the group when it is deleted + * Setting a user group on a line with a separator is illegal + */ + void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership); + CInterfaceGroup *getUserGroupRight(uint line) const; + // + void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership); + CInterfaceGroup *getUserGroupLeft(uint line) const; + + void removeAllUserGroups(); + + uint getNumLines() const { return (uint)_Lines.size(); } + + // return pointer to submenu or NULL if there's none + CGroupSubMenu *getSubMenu(uint index) const; + void setSubMenu(uint index, CGroupSubMenu *sub); + + // if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup) + void setSelectable(uint lineIndex, bool selectable); + bool getSelectable(uint lineIndex) const; + + // Gray a line. + void setGrayedLine(uint line, bool g); + + // Hide a line. + void setHiddenLine(uint line, bool h); + + // Max Visible Line (-1 == no limit) + void setMaxVisibleLine(sint32 mvl); + sint32 getMaxVisibleLine() { return _MaxVisibleLine; } + + // Get the Line Id (not the full Id) + const std::string &getLineId(uint index); + + int luaGetNumLine(CLuaState &ls); + int luaGetSubMenu(CLuaState &ls); + int luaAddSubMenu(CLuaState &ls); + int luaGetLineId(CLuaState &ls); + int luaGetLineFromId(CLuaState &ls); + int luaIsSeparator(CLuaState &ls); + int luaAddLine(CLuaState &ls); + int luaAddLineAtIndex(CLuaState &ls); + int luaAddSeparator(CLuaState &ls); + int luaAddSeparatorAtIndex(CLuaState &ls); + int luaRemoveLine(CLuaState &ls); + int luaSetUserGroupRight(CLuaState &ls); + int luaGetUserGroupRight(CLuaState &ls); + int luaSetUserGroupLeft(CLuaState &ls); + int luaGetUserGroupLeft(CLuaState &ls); + int luaReset(CLuaState &ls); + int luaSetMaxVisibleLine(CLuaState &ls); + // + REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase) + REFLECT_LUA_METHOD("getNumLine", luaGetNumLine); + REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index + REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found + REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu); + REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu); + REFLECT_LUA_METHOD("isSeparator", luaIsSeparator); + REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id + REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id + REFLECT_LUA_METHOD("addSeparator", luaAddSeparator); + REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex); + REFLECT_LUA_METHOD("removeLine", luaRemoveLine); + REFLECT_LUA_METHOD("reset", luaReset); + REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr + REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line + REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr + REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line + REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine); + REFLECT_EXPORT_END + + protected: + + struct SSubMenuEntry + { + CViewTextMenu *ViewText; // Backup of the children that are in grouplist + CInterfaceGroup *Separator; + std::string AHName; + std::string AHParams; + std::string Id; + std::string Cond; // condition to know if the entry is grayed + CViewBitmap *CheckBox; + CViewBitmap *RightArrow; + CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow + CInterfaceGroup *UserGroupLeft; + bool UserGroupRightOwnership; + bool UserGroupLeftOwnership; + bool Selectable; + sint32 HReal; // max H of the view text and the other user group + sint32 TextDY; // Y of the view text to set + SSubMenuEntry() + { + ViewText = NULL; + Separator = NULL; + CheckBox = NULL; + RightArrow = NULL; + UserGroupRight = NULL; + UserGroupLeft = NULL; + UserGroupRightOwnership = false; + Selectable = true; + HReal= 0; + TextDY= 0; + } + }; + + protected: + + CGroupList *_GroupList; + CCtrlScroll *_ScrollBar; + CViewBitmap *_SelectionView; + std::vector _Lines; + std::vector _SubMenus; + + CGroupMenu *_GroupMenu; // Master parent + sint32 _Selected; + + sint32 _MaxVisibleLine; // -1 == no limit + + friend class CGroupMenu; + private: + /** Clone this menu, and set its new father + * If appendToMenu is NULL, the menu is just copied + * otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu. + * NB : user groups are not duplicated + */ + CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const; + void initOptions(CInterfaceGroup *parent); + CViewBitmap *createCheckBox(bool checked); + CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center); + }; + + /** + * class describing a menu composed of one or more CGroupListSubMenu + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CGroupMenu : public CGroupModal + { + + public: + + CGroupMenu(const TCtorParam ¶m); + virtual ~CGroupMenu(); + + TCaseMode getCaseMode() { return _CaseMode; } + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + virtual void draw (); + + void recurseDraw(CGroupSubMenu *pSubMenu); + + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + virtual CInterfaceElement* getElement (const std::string &id); + + virtual void setActive (bool state); + + virtual bool isWindowUnder (sint32 x, sint32 y); + + // add line with a string, for backward compatibility + void addLine (const std::string &name, const std::string &ah, const std::string ¶ms, + const std::string &id = std::string(), + const std::string &cond = std::string(), const std::string &texture="", + bool checkable = false, bool checked = false); + uint getNumLine() const; + void deleteLine(uint index); + const std::string getActionHandler(uint lineIndex) const; + const std::string getActionHandlerParam(uint lineIndex) const; + + + void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + const std::string &id = std::string(), + const std::string &cond = std::string(), const std::string &texture="", + bool checkable = false, bool checked = false + ); + void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", + const std::string &id = std::string(), + const std::string &cond = std::string(), const std::string &texture="", + bool checkable = false, bool checked = false + ); + void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true); + void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true); + + // clear all sub menus + void reset (); + + // set the minW of the RootMenu. + void setMinW(sint32 minW); + + // Gray a line on the RootMenu + void setGrayedLine(uint line, bool g); + + CGroupSubMenu *getRootMenu() const { return _RootMenu; } + + // Max Visible Line (-1 == no limit) + void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); } + sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); } + + // special for menu launched from a modal.... + bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;} + void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;} + + int luaGetRootMenu(CLuaState &ls); + int luaSetMinW(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupMenu, CGroupModal) + REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu); + REFLECT_LUA_METHOD("setMinW", luaSetMinW); + REFLECT_EXPORT_END + + protected: + TCaseMode _CaseMode; + + CGroupSubMenu *_RootMenu; + + // Text lookup + NLMISC::CRGBA _Color; + NLMISC::CRGBA _ShadowColor; + + bool _CloseSubMenuUsingPopModal; + bool _Shadow; + bool _Formatted; + uint8 _Space; + sint32 _FontSize; + + NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it + NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it + NLMISC::CRGBA _HighLightOver; // Background color of the selection + + NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable + NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable + + friend class CGroupSubMenu; + }; + +} + +#endif // RZ_GROUP_MENU_H + +/* End of group_menu.h */ + + diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp new file mode 100644 index 000000000..6fbd586fd --- /dev/null +++ b/code/nel/src/gui/group_menu.cpp @@ -0,0 +1,2302 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/interface_options.h" +#include "nel/gui/interface_expr.h" +#include "nel/gui/group_menu.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/action_handler.h" // Just for getAllParams +#include "nel/gui/lua_ihm.h" +#include "nel/misc/i18n.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/group_list.h" +#include "nel/gui/ctrl_scroll.h" +#include "nel/gui/view_pointer_base.h" + + +using namespace NLMISC; +using namespace std; + + +namespace +{ + const std::string ID_MENU_CHECKBOX = "menu_cb"; + const std::string ID_MENU_SEPARATOR = "menu_separator"; + const std::string ID_MENU_SUBMENU = "menu_sb"; + const uint MENU_WIDGET_X = 2; + const uint LEFT_MENU_WIDGET_X = 4; +} + +namespace NLGUI +{ + + // ------------------------------------------------------------------------------------------------ + // CGroupSubMenu + // ------------------------------------------------------------------------------------------------ + + // ------------------------------------------------------------------------------------------------ + bool CViewTextMenu::getGrayed() const + { + return _Grayed; + } + + // ------------------------------------------------------------------------------------------------ + void CViewTextMenu::setGrayed (bool g) + { + _Grayed = g; + } + + // ------------------------------------------------------------------------------------------------ + void CViewTextMenu::setCheckable(bool c) + { + if (!c) + { + _Checkable = false; + _CheckBox = NULL; + } + else + { + _Checkable = true; + } + } + + // ------------------------------------------------------------------------------------------------ + void CViewTextMenu::setChecked(bool c) + { + if (_CheckBox) + { + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); + if (!pIO) return; + _CheckBox->setTexture(pIO->getValStr(c ? "checked_bitmap" : "unchecked_bitmap")); + } + _Checked = c; + } + + // ------------------------------------------------------------------------------------------------ + sint32 CViewTextMenu::getAlpha() const + { + if (_Grayed) + { + return OldColorGrayed.A; + } + else + { + if (Over) + return OldColorOver.A; + else + return OldColor.A; + } + } + + // ------------------------------------------------------------------------------------------------ + void CViewTextMenu::setAlpha (sint32 a) + { + OldShadowColor.A = OldColor.A = (uint8)a; + OldShadowColorOver.A = OldColorOver.A = (uint8)a; + OldShadowColorGrayed.A = OldShadowColorGrayed.A = (uint8)a; + } + + // ------------------------------------------------------------------------------------------------ + // CGroupSubMenu + // ------------------------------------------------------------------------------------------------ + + // ------------------------------------------------------------------------------------------------ + CGroupSubMenu::CGroupSubMenu(const TCtorParam ¶m) + : CGroupSubMenuBase(param) + { + _SelectionView = NULL; + _GroupList = NULL; + _GroupMenu = NULL; + _Selected = -1; + _MaxVisibleLine = -1; + _ScrollBar = NULL; + } + + // ------------------------------------------------------------------------------------------------ + CGroupSubMenu::~CGroupSubMenu() + { + removeAllUserGroups(); + } + + // ------------------------------------------------------------------------------------------------ + sint CGroupSubMenu::getLineFromId(const std::string &id) + { + for (uint k = 0; k < _Lines.size(); ++k) + { + if (_Lines[k].Id == id) + { + return (sint) k; + } + } + return -1; + } + + // ------------------------------------------------------------------------------------------------ + CGroupSubMenu *CGroupSubMenu::getSubMenu(uint index) const + { + if (index >= _SubMenus.size()) + { + nlassert("bad index"); + return NULL; + } + return _SubMenus[index]; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setSubMenu(uint index, CGroupSubMenu *sub) + { + nlassert(sub != NULL); + nlassert(index < _SubMenus.size()); + + if (_SubMenus[index] != NULL) + { + // must delete from the group menu (if not found, just delete) + if( !_GroupMenu || !_GroupMenu->delGroup(_SubMenus[index]) ) + delete _SubMenus[index]; + _SubMenus[index] = NULL; + delView(_Lines[index].RightArrow); + } + + if (_Lines[index].CheckBox) + _Lines[index].RightArrow = createRightArrow(_Lines[index].CheckBox, true); + else + _Lines[index].RightArrow = createRightArrow(_GroupList, false); + + sub->_GroupMenu = _GroupMenu; + sub->initOptions(this); + _GroupMenu->addGroup (sub); + sub->_DispType = _GroupMenu->_DispType; + _SubMenus[index] = sub; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::initOptions(CInterfaceGroup *parent) + { + // Initialization + // me + _Parent = _GroupMenu; + if (parent == NULL) + { + setParentPos (_GroupMenu); + setParentPosRef (Hotspot_TL); + setPosRef (Hotspot_TL); + } + else + { + setParentPos (parent); + setParentPosRef (Hotspot_BR); + setPosRef (Hotspot_BL); + } + _DisplayFrame = true; + _ResizeFromChildH = true; + _ResizeFromChildW = true; + _ResizeFromChildHMargin = 8; + _ResizeFromChildWMargin = 8; + _ModulateGlobalColor = _GroupMenu->_ModulateGlobalColor; + // the selection + if (_SelectionView == NULL) + { + _SelectionView = new CViewBitmap(CViewBase::TCtorParam()); + // CInterfaceManager *pIM = CInterfaceManager::getInstance(); + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + _SelectionView->setParent (this); + _SelectionView->setActive (false); + _SelectionView->setTexture ("blank.tga"); + _SelectionView->setScale (true); + _SelectionView->setX (4); + _SelectionView->setSizeRef(1); // sizeref on W + _SelectionView->setW (-8); + addView (_SelectionView, 0); + } + // the group list + if (_GroupList == NULL) + { + _GroupList = new CGroupList(CViewBase::TCtorParam()); + _GroupList->setParent (this); + _GroupList->setParentPos (this); + _GroupList->setX (4); + _GroupList->setY (4); + _GroupList->setSpace (_GroupMenu->_Space); + addGroup (_GroupList); + } + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupSubMenu::parse (xmlNodePtr cur, CInterfaceGroup *parent) + { + initOptions(parent); + // the children + while (cur) + { + CViewTextMenu *pV = NULL; + + CXMLAutoPtr id((const char*) xmlGetProp (cur, (xmlChar*)"id")); + + if (stricmp((char*)cur->name, "separator") == 0) + { + if (id) + { + addSeparator((const char *) id); + } + else + { + addSeparator(); + } + } + else + if (stricmp((char*)cur->name, "action") == 0) + { + string strId, strAh, strParams, strCond, strTexture=""; + ucstring ucstrName; + + if (id) strId = (const char*)id; + CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); + + if (name) + { + const char *ptrName = (const char*)name; + ucstrName = ucstring(ptrName); + if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) + ucstrName = CI18N::get (ptrName); + } + + CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); + if (ah) strAh = (const char*)ah; + CXMLAutoPtr cond((const char*) xmlGetProp (cur, (xmlChar*)"cond")); + if (cond) strCond = (const char*)cond; + CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params")); + if (params) strParams = (const char*)params; + CXMLAutoPtr strCheckable((const char*) xmlGetProp (cur, (xmlChar*)"checkable")); + bool bCheckable = false; + if (strCheckable) bCheckable = convertBool (strCheckable); + CXMLAutoPtr strChecked((const char*) xmlGetProp (cur, (xmlChar*)"checked")); + bool bChecked = false; + if (strChecked) bChecked = convertBool (strChecked); + bool bFormatted = false; + CXMLAutoPtr strFormatted((const char*) xmlGetProp (cur, (xmlChar*)"formatted")); + if (strFormatted) bFormatted = convertBool (strFormatted); + + pV = addLine (ucstrName, strAh, strParams, strId, strCond, strTexture, bCheckable, bChecked, bFormatted); + + CXMLAutoPtr strSelectable((const char*) xmlGetProp (cur, (xmlChar*)"selectable")); + bool bSelectable = true; + if (strSelectable) bSelectable = convertBool (strSelectable); + _Lines.back().Selectable = bSelectable; + + + CXMLAutoPtr grayed((const char*) xmlGetProp (cur, (xmlChar*)"grayed")); + bool bGrayed = false; + if (grayed) bGrayed = convertBool (grayed); + pV->setGrayed(bGrayed); + + // Is this line has a sub menu ? + xmlNodePtr child = cur->children; + if (child != NULL) + { + if (_Lines.back().CheckBox) + { + _Lines.back().RightArrow = createRightArrow(_Lines.back().CheckBox, true); + } + else + { + _Lines.back().RightArrow = createRightArrow(_GroupList, false); + } + // and create the sub menu + CGroupSubMenu *childMenu = new CGroupSubMenu(CViewText::TCtorParam()); + childMenu->_GroupMenu = _GroupMenu; + childMenu->parse (child, this); + + CXMLAutoPtr MVL((const char*) xmlGetProp(cur, (xmlChar*)"max_visible_line")); + if (MVL) + { + sint32 maxVisibleLine; + fromString((const char*)MVL, maxVisibleLine); + childMenu->setMaxVisibleLine(maxVisibleLine); + } + + _SubMenus.back() = childMenu; + } + + // Add user groups + // Left + CXMLAutoPtr usergroup((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_l")); + if (usergroup) + { + vector< pair > vparams; + CXMLAutoPtr ugparams((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_params_l")); + if (ugparams) + { + IActionHandler::getAllParams((const char*)ugparams, vparams); + } + + string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; + CInterfaceGroup *pUGLeft = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); + if (pUGLeft) + setUserGroupLeft((uint)_Lines.size()-1, pUGLeft, true); + } + usergroup = (char*) xmlGetProp (cur, (xmlChar*)"usergroup_r"); + if (usergroup) + { + vector< pair > vparams; + CXMLAutoPtr ugparams((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_params_r")); + if (ugparams) + { + IActionHandler::getAllParams((const char*)ugparams, vparams); + } + + string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; + CInterfaceGroup *pUG = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); + if (pUG) + setUserGroupRight((uint)_Lines.size()-1, pUG, true); + } + } + cur = cur->next; + } + + _GroupMenu->addGroup (this); + this->_DispType = _GroupMenu->_DispType; + + return true; + } + + + // ------------------------------------------------------------------------------------------------ + CViewBitmap *CGroupSubMenu::createCheckBox(bool checked) + { + // Put the left arrow to the line + CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); + pVB->setParent (this); + pVB->setParentPos (_GroupList); + pVB->setParentPosRef (Hotspot_BR); + pVB->setPosRef (Hotspot_BL); + CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); + if (pIO) + { + pVB->setTexture(pIO->getValStr(checked ? "checked_bitmap" : "unchecked_bitmap")); + } + pVB->setX (MENU_WIDGET_X); + pVB->setId (ID_MENU_CHECKBOX); // always rescale to parent in update coords + addView (pVB); + return pVB; + } + + + // ------------------------------------------------------------------------------------------------ + CViewBitmap *CGroupSubMenu::createRightArrow(CInterfaceElement *parentPos, bool center) + { + // Put the left arrow to the line + CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); + pVB->setParent (this); + pVB->setParentPos (parentPos); + if (!center) + { + pVB->setParentPosRef (Hotspot_BR); + pVB->setPosRef (Hotspot_BL); + } + else + { + pVB->setParentPosRef (Hotspot_MR); + pVB->setPosRef (Hotspot_ML); + } + pVB->setTexture("w_arrow_right_3.tga"); + pVB->setX (MENU_WIDGET_X); + pVB->setId (ID_MENU_SUBMENU); // rescale to parent in update coords if asked (not needed if there's already on the left a checkbox) + addView (pVB); + return pVB; + } + + // ------------------------------------------------------------------------------------------------ + #define GET_REF_ELM(__index__) \ + CInterfaceElement *refElm; \ + sint32 refElmYReal= 0; \ + sint32 refElmHReal= 0; \ + refElm = _Lines[__index__].ViewText; \ + if(refElm) \ + { \ + refElmYReal= refElm->getYReal() - _Lines[__index__].TextDY; \ + refElmHReal= _Lines[__index__].HReal; \ + } + + void CGroupSubMenu::updateCoords () + { + if (_ParentPos == _GroupMenu) + { + // Root Menu + setX(_GroupMenu->SpawnMouseX); + setY(_GroupMenu->SpawnMouseY); + CGroupFrame::updateCoords(); + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 screenW, screenH; + rVR.getScreenSize(screenW, screenH); + if ((_XReal+_WReal) > (sint32)screenW) + setX(screenW-_WReal); + if (_YReal < 0) + setY(_HReal); + } + else + // The sub menu may go outside the screen in Y. => clamp it as possible + { + /* X/Y coords have normally been updated before by "parent" sub menus + Why? because setSubMenu() is typically called in "parent first" order (or it is exactly what is done in ::parse()) + => Parent CGroupSubMenu::updateCoords() are called before their sons in CGroupMenu::updateCoords() !!! + => No Need to call _SubMenus[RALineNb]->updateCoords() below ! (else would call too much time because of recursion!!) + */ + + // must udpate correct Real coords + CGroupFrame::updateCoords(); + + // get screen size + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 screenW, screenH; + rVR.getScreenSize(screenW, screenH); + + sint32 hReal= getHReal(); + // If the H is too big, abort.. can't do anything + if(hReal<=(sint32)screenH) + { + sint32 yReal= getYReal(); + + // compute the shift to apply to the Y of the sub menu, to respect (as possible) the screen + sint32 dyClamp= 0; + if(yReal<0) + dyClamp= - yReal; + if(yReal+hReal>(sint32)screenH) + dyClamp= screenH - (yReal+hReal); + // change then the Y + if(dyClamp!=0) + { + setY(getY()+dyClamp); + CGroupFrame::updateCoords(); + } + } + } + + // not yet setuped? + if (!_GroupList) return; + + // get text dy position + sint32 textDYPos= 0; + textDYPos= -(1+_GroupList->getSpace())/2; + + // Set the arrows at the right positions (in _Views we have selection and the right arrows) + sint32 CBLineNb = 0; // check box + sint32 RALineNb = 0; // right arrow + uint32 i; + + sint32 maxUserGroupWidth = 0; + // compute max width of user groups, & adapt max height for each line + uint k; + + // update all left user groups to get their width + sint32 maxLeftUGWidth = 0; + for(k = 0; k < _Lines.size(); ++k) + { + if (_Lines[k].UserGroupLeft) + { + _Lines[k].UserGroupLeft->updateCoords(); + maxLeftUGWidth = std::max(_Lines[k].UserGroupLeft->getWReal(), maxLeftUGWidth); + } + } + + _GroupList->setX(LEFT_MENU_WIDGET_X + maxLeftUGWidth); + + // active separators when needed + bool activeLineSeen = false; + for (i = 0; i < _Lines.size(); ++i) + { + if (_Lines[i].Separator != NULL) + { + if (i == _Lines.size() - 1) + { + _Lines[i].Separator->setActive(false); + break; + } + _Lines[i].Separator->setActive(activeLineSeen); + activeLineSeen = false; + } + else + { + if (_Lines[i].ViewText && _Lines[i].ViewText->getActive()) activeLineSeen = true; + } + } + + CGroupFrame::updateCoords(); + + bool mustUpdate = false; + + if (_MaxVisibleLine > 0 && sint32(_Lines.size())>_MaxVisibleLine) + { + for(k = 0; k < _Lines.size(); ++k) + if (_Lines[k].ViewText) + { + // compute max height of widgets on the left of text + sint32 widgetMaxH = 0; + if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); + if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); + if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); + if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); + widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal()); + _GroupList->setMaxH(widgetMaxH*_MaxVisibleLine+_GroupList->getSpace()*(_MaxVisibleLine-1)); + if (_ScrollBar == NULL) + { + _ScrollBar = new CCtrlScroll(CViewBase::TCtorParam()); + _ScrollBar->setParent (this); + _ScrollBar->setParentPos (_GroupList); + _ScrollBar->setPosRef (Hotspot_BL); + _ScrollBar->setParentPosRef (Hotspot_BR); + _ScrollBar->setX (4); + _ScrollBar->setY (0); + _ScrollBar->setW (8); + _ScrollBar->setTextureBottomOrLeft ("w_scroll_l123_b.tga"); + _ScrollBar->setTextureMiddle ("w_scroll_l123_m.tga"); + _ScrollBar->setTextureTopOrRight ("w_scroll_l123_t.tga"); + _ScrollBar->setTarget(_GroupList); + _SelectionView->setW (-8-8-2); + addCtrl(_ScrollBar); + mustUpdate = true; + } + break; + } + } + else + { + _SelectionView->setW(-8); + } + + + // *** Setup Text + for(k = 0; k < _Lines.size(); ++k) + { + CInterfaceGroup *ig = _Lines[k].UserGroupRight; + if (ig) + { + ig->updateCoords(); + maxUserGroupWidth = std::max(maxUserGroupWidth, ig->getWReal()); + } + if (_Lines[k].ViewText) + { + // compute max height of widgets on the left of text + sint32 widgetMaxH = 0; + if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); + if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); + if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); + if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); + + sint32 textHReal= _Lines[k].ViewText->getHReal(); + _Lines[k].HReal= max(widgetMaxH, textHReal); + _Lines[k].TextDY= textDYPos; + if(widgetMaxH>textHReal) + _Lines[k].TextDY+= (widgetMaxH-textHReal) / 2; + } + } + + + // *** Update Text Positions + // sint32 currX = 0; + for(k = 0; k < _Lines.size(); ++k) + { + if (_Lines[k].ViewText) + { + // Setup Y + _Lines[k].ViewText->setY(_Lines[k].TextDY); + } + } + + + + if (mustUpdate) + { + CGroupFrame::updateCoords(); + } + + + // *** Setup SubMenus and CheckBoxes Positions + sint32 maxViewW = 0; + for (i = 1; i < _Views.size(); ++i) + { + CViewBitmap *pVB = dynamic_cast(_Views[i]); + if (pVB == NULL) continue; + if (pVB->getId() == ID_MENU_SUBMENU) + { + // Look for the next line of the menu that contains a sub menu + for(;;) + { + nlassert (RALineNb < (sint32)_SubMenus.size()); + if (_SubMenus[RALineNb] != NULL) // has a check box or an arrow to indicate submenu ? + { + break; + } + ++RALineNb; + } + + // get refElm and refElmYReal + GET_REF_ELM(RALineNb) + + // if there is a check box, y is 0 + if (_Lines[RALineNb].CheckBox || _Lines[RALineNb].UserGroupRight) + { + pVB->setY(0); + pVB->setX(MENU_WIDGET_X); + } + else + { + sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); + // Setup the arrow at the right pos + if(_GroupList->getMaxH()>=limY && limY>=0) + { + pVB->setY(refElmYReal + (refElmHReal - pVB->getHReal()) / 2 - _GroupList->getYReal()); + pVB->setColor(_Lines[RALineNb].ViewText->getColor()); + pVB->setActive(_Lines[RALineNb].ViewText->getActive()); + pVB->setX(maxUserGroupWidth + MENU_WIDGET_X); + } + else + { + pVB->setY(0); + pVB->setActive(false); + } + } + + if (_GroupMenu->SpawnOnMousePos) + { + _SubMenus[RALineNb]->setParentPos (this); + + // According to mouse position, set the sub menu on the left or right, begin at top or bottom + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 screenW, screenH; + rVR.getScreenSize(screenW, screenH); + if ((_GroupMenu->SpawnMouseX <= ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY <= ((sint32)screenH/2))) + { + _SubMenus[RALineNb]->setParentPosRef(Hotspot_BR); + _SubMenus[RALineNb]->setPosRef(Hotspot_BL); + _SubMenus[RALineNb]->setY (refElmYReal - _GroupList->getYReal()); + } + if ((_GroupMenu->SpawnMouseX <= ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY > ((sint32)screenH/2))) + { + _SubMenus[RALineNb]->setParentPosRef(Hotspot_TR); + _SubMenus[RALineNb]->setPosRef(Hotspot_TL); + _SubMenus[RALineNb]->setY (refElmHReal+(refElmYReal - _GroupList->getYReal()) - _GroupList->getHReal()); + } + if ((_GroupMenu->SpawnMouseX > ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY <= ((sint32)screenH/2))) + { + _SubMenus[RALineNb]->setParentPosRef(Hotspot_BL); + _SubMenus[RALineNb]->setPosRef(Hotspot_BR); + _SubMenus[RALineNb]->setY (refElmYReal - _GroupList->getYReal()); + } + if ((_GroupMenu->SpawnMouseX > ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY > ((sint32)screenH/2))) + { + _SubMenus[RALineNb]->setParentPosRef(Hotspot_TL); + _SubMenus[RALineNb]->setPosRef(Hotspot_TR); + _SubMenus[RALineNb]->setY (refElmHReal+(refElmYReal - _GroupList->getYReal()) - _GroupList->getHReal()); + } + _SubMenus[RALineNb]->setX(0); + } + else + { + // Setup sub menu + _SubMenus[RALineNb]->setParentPos (this); + _SubMenus[RALineNb]->setParentPosRef (Hotspot_BR); + _SubMenus[RALineNb]->setPosRef (Hotspot_BL); + _SubMenus[RALineNb]->setY (16+refElmYReal - _GroupList->getYReal() - _SubMenus[RALineNb]->getHReal()); + } + + ++RALineNb; + } + else if (pVB->getId() == ID_MENU_CHECKBOX) + { + for(;;) + { + nlassert (CBLineNb < (sint32)_SubMenus.size()); + if (_Lines[CBLineNb].CheckBox != NULL) // has a check box or an arrow to indicate submenu ? + { + break; + } + ++CBLineNb; + } + // Setup the arrow at the right pos + if (!_Lines[CBLineNb].UserGroupRight) + { + // get refElm and refElmYReal + GET_REF_ELM(CBLineNb) + + pVB->setX(maxUserGroupWidth + 2 * MENU_WIDGET_X); + + sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); + // Setup the arrow at the right pos + if(_GroupList->getMaxH()>=limY && limY>=0) + { + pVB->setY(refElmYReal + (refElmHReal - pVB->getHReal()) / 2 - _GroupList->getYReal()); + pVB->setActive(_Lines[CBLineNb].ViewText->getActive()); + } + else + { + pVB->setY(0); + pVB->setActive(false); + } + } + else + { + pVB->setY(0); + pVB->setX(MENU_WIDGET_X); + } + pVB->setColor (_Lines[CBLineNb].ViewText->getColor()); + // + ++CBLineNb; + } + + if (maxViewW<(pVB->getWReal()+pVB->getX())) maxViewW = pVB->getWReal()+pVB->getX(); + } + + // setup scrollbar position in function of views width + if(maxViewW>0 && _ScrollBar) + _ScrollBar->setX(4 + maxViewW); + + // *** Setup user groups positions + for(k = 0; k < _Lines.size(); ++k) + { + CInterfaceGroup *igr = _Lines[k].UserGroupRight; + CInterfaceGroup *igl = _Lines[k].UserGroupLeft; + if (igr || igl) + { + // get refElm and refElmYReal + GET_REF_ELM(k) + + if (refElm) + { + if (igr) + { + igr->setX(MENU_WIDGET_X + maxUserGroupWidth - igr->getWReal()); + + sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); + if(_GroupList->getMaxH()>=limY && limY>=0) + { + igr->setY(refElmYReal + (refElmHReal - igr->getHReal()) / 2 - _GroupList->getYReal()); + igr->setActive (refElm->getActive()); + } + else + { + igr->setY(0); + igr->setActive(false); + } + } + + if (igl) + { + sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); + if(_GroupList->getMaxH()>=limY && limY>=0) + { + igl->setY(refElmYReal + (refElmHReal - igl->getHReal()) / 2 - this->getYReal()); + igl->setActive(refElm->getActive()); + } + else + { + igl->setY(0); + igl->setActive(false); + } + } + } + } + } + + + sint32 SepLineNb = 0; + // set separator at the right position + for (i = 0; i < _ChildrenGroups.size(); ++i) + { + CInterfaceGroup *pIG = dynamic_cast(_ChildrenGroups[i]); + if (pIG == NULL) continue; + if (pIG->getId() != ID_MENU_SEPARATOR) continue; // is it a separator ? + + // set good width + /*sint32 sw = getW() - _LeftBorder - _RightBorder; + sw = std::max(sw, (sint32) 0); + pIG->setW(sw);*/ + + // Look for the next line of the menu that contains a separator + CInterfaceGroup *sep = NULL; + do + { + nlassert (SepLineNb < (sint32)_Lines.size()); + sep = _Lines[SepLineNb].Separator; + ++SepLineNb; + } + while (sep == NULL); + + // Setup the arrow at the right pos + pIG->setY (sep->getYReal() - getYReal()); + pIG->setActive(sep->getActive()); + } + CGroupFrame::updateCoords(); + + //_SelectionView->setW (this->getW()); + _SelectionView->setH (8); + _SelectionView->setY (4); + + + if (_Selected != -1 && _Lines[_Selected].ViewText != NULL) + { + CRGBA col= _GroupMenu->_HighLightOver; + + _SelectionView->setColor (col); + _SelectionView->setModulateGlobalColor(getModulateGlobalColor()); + + // get refElm and refElmYReal + GET_REF_ELM(_Selected) + + _SelectionView->setH (refElmHReal); + _SelectionView->setY (refElmYReal - this->getYReal()); + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::checkCoords() + { + if (!_Active) return; + if (_GroupMenu == NULL) return; + + // if the mouse goes out the window, unselect all (because handleEvent may not be called) + sint xMouse= CWidgetManager::getInstance()->getPointer()->getX(); + sint yMouse= CWidgetManager::getInstance()->getPointer()->getY(); + if (!((xMouse >= _XReal) && + (xMouse < (_XReal + _WReal))&& + (yMouse > _YReal) && + (yMouse <= (_YReal+ _HReal)))) + _Selected= -1; + + // CViewRenderer &rVR = *CViewRenderer::getInstance(); + + // Highlight (background under the selection) + if (_Selected != -1) + { + // display hightlight + if(_GroupMenu->_HighLightOver.A > 0) + { + _SelectionView->setActive (true); + _SelectionView->invalidateCoords(); + } + else + { + _SelectionView->setActive (false); + } + } + else // no selection + { + _SelectionView->setActive (false); + } + + // Text color if grayed or not + for (sint32 i = 0; i < (sint32)_Lines.size(); ++i) + { + if (_Lines[i].ViewText) + { + if (_Lines[i].ViewText->getGrayed()) // Colors when the text is grayed + { + _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColorGrayed); + _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColorGrayed); + } + else + { + if (i == _Selected) // Colors when the text is selected + { + _Lines[i].ViewText->Over = true; + _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColorOver); + _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColorOver); + } + else // Or finally normal colors + { + _Lines[i].ViewText->Over = false; + _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColor); + _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColor); + } + } + } + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::draw() + { + if (!_Active) return; + if (_GroupMenu == NULL) return; + CGroupFrame::draw(); + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (!_Active) + return false; + + sint32 textDYPos= 0; + if(_GroupList) + textDYPos= -(1+_GroupList->getSpace())/2; + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + _Selected = -1; + + // TODO First check sub menus that can be not in the area of this menu + + if (!((eventDesc.getX() >= _XReal) && + (eventDesc.getX() < (_XReal + _WReal))&& + (eventDesc.getY() > _YReal) && + (eventDesc.getY() <= (_YReal+ _HReal)))) + return false; + + uint32 i = 0; + for (i = 0; i < _Lines.size(); ++i) + { + if (_Lines[i].Selectable) + { + // get refElm and refElmYReal + GET_REF_ELM(i) + + if (refElm) + { + if (refElm->getActive() == true) + if ((eventDesc.getY() > refElmYReal) && + (eventDesc.getY() <= (refElmYReal + refElmHReal + _GroupList->getSpace()))) + { + _Selected = i; + break; + } + } + } + } + + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + // If a line is selected and the line is not grayed + if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed())) + { + + CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHName, + CWidgetManager::getInstance()->getCtrlLaunchingModal(), + _Lines[_Selected].AHParams ); + + if (_SubMenus[_Selected] != NULL) + { + openSubMenu (_Selected); + } + else + { + // if the menu hasn't triggered a new modal window, disable it + if (CWidgetManager::getInstance()->getModalWindow() == _GroupMenu) + { + if(_GroupMenu && _GroupMenu->getCloseSubMenuUsingPopModal()) + CWidgetManager::getInstance()->popModalWindow(); + else + CWidgetManager::getInstance()->disableModalWindow (); + } + } + } + } + + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + // + if (_GroupList && _ScrollBar) + { + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + if (isIn(eventDesc.getX(), eventDesc.getY())) + { + sint32 h = 0; + for (uint32 k = 0; k < _Lines.size(); ++k) + if (_Lines[k].ViewText) + { + // compute max height of widgets on the left of text + sint32 widgetMaxH = 0; + if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); + if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); + if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); + if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); + widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal()); + h = widgetMaxH+_GroupList->getSpace(); + } + if (h == 0) h = 1; + _ScrollBar->moveTargetY(- eventDesc.getWheel() * h); + + hideSubMenus(); + + return true; + } + } + } + } + + return true; + } + return false; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CGroupSubMenu::getElement (const std::string &id) + { + string sTmp = id.substr(0, _GroupMenu->getId().size()); + if (sTmp != _GroupMenu->getId()) return NULL; + + string sRest = id.substr(_GroupMenu->getId().size()+1, id.size()); + + // Iterate through the tree to see if sRest is present + CGroupSubMenu *pCurGSM = this; + while (!sRest.empty()) + { + // Get the first element of the sRest + string::size_type posid = sRest.find (":"); + + if (posid == string::npos) // Is there just one token to test ? + { + for (uint32 i = 0; i < pCurGSM->_Lines.size(); ++i) + if (sRest == pCurGSM->_Lines[i].Id) + return pCurGSM->_Lines[i].ViewText; + sRest = ""; + } + else // no a lot of token left + { + string sTok = sRest.substr (0, posid); + uint32 i = 0; + for (i = 0; i < pCurGSM->_Lines.size(); ++i) + if (sTok == pCurGSM->_Lines[i].Id) + break; + if (i == pCurGSM->_Lines.size()) + return NULL; + + // No sub-menus + if (pCurGSM->_SubMenus[i] == NULL) + { + // Get next token + sRest = sRest.substr (posid+1); + posid = sRest.find (":"); + if (posid == string::npos) + sTok = sRest; + else + sTok = sRest.substr (0, posid); + // Do we want left or right user group ? + if (pCurGSM->_Lines[i].UserGroupRight) + { + string sUGid = pCurGSM->_Lines[i].UserGroupRight->getId(); + sUGid = sUGid.substr(sUGid.rfind(':')+1,sUGid.size()); + if (sUGid == sTok) + { + CInterfaceElement *pIE = pCurGSM->_Lines[i].UserGroupRight->getElement(id); + return pIE; + } + } + if (pCurGSM->_Lines[i].UserGroupLeft) + { + string sUGid = pCurGSM->_Lines[i].UserGroupLeft->getId(); + sUGid = sUGid.substr(sUGid.rfind(':')+1,sUGid.size()); + if (sUGid == sTok) + { + CInterfaceElement *pIE = pCurGSM->_Lines[i].UserGroupLeft->getElement(id); + return pIE; + } + } + + return NULL; + } + else + { + pCurGSM = pCurGSM->_SubMenus[i]; + } + } + sRest = sRest.substr (posid+1); + } + + return NULL; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::addSeparator(const std::string &id) + { + addSeparatorAtIndex((uint)_Lines.size(), id); + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::addSeparatorAtIndex(uint index, const std::string &id) + { + if (index > _Lines.size()) + { + nlwarning("Bad index"); + return; + } + + // create the real separator. It may be larger than the group list, this is why we create a separate group + CInterfaceGroup *separator = CWidgetManager::parser->createGroupInstance("menu_separator", "", NULL, 0); + if (!separator) return; + separator->setId(ID_MENU_SEPARATOR); + addGroup(separator); + separator->setParent(this); + // create place holder group + CInterfaceGroup *ph = CWidgetManager::parser->createGroupInstance("menu_separator_empty", "", NULL, 0); + if (!ph) + { + delGroup(separator); + return; + } + _GroupList->addChildAtIndex(ph, index); + SSubMenuEntry tmp; + tmp.Id = id; + tmp.Separator = ph; + tmp.ViewText = NULL; + tmp.CheckBox = NULL; + tmp.RightArrow = NULL; + _Lines.insert(_Lines.begin() + index, tmp); + _SubMenus.insert(_SubMenus.begin() + index, (CGroupSubMenu*)NULL); + _GroupMenu->invalidateCoords(); + } + + + // ------------------------------------------------------------------------------------------------ + CViewTextMenu* CGroupSubMenu::addLine (const ucstring &name, const std::string &ah, + const std::string ¶ms, const std::string &id, + const std::string &cond, const std::string &texture, + bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ + ) + { + SSubMenuEntry tmp; + + CViewTextMenu *pV = new CViewTextMenu(CViewBase::TCtorParam()); + + + pV->setCaseMode(_GroupMenu->getCaseMode()); + if (formatted) + { + pV->setMultiLine (true); + pV->setMultiLineMaxWOnly (true); + pV->setTextFormatTaged (name); + } + else + { + pV->setText (name); + } + pV->setColor (_GroupMenu->_Color); + pV->setFontSize (_GroupMenu->_FontSize); + pV->setShadow (_GroupMenu->_Shadow); + pV->setCheckable(checkable); + pV->setChecked(checked); + pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); + + pV->OldColor = _GroupMenu->_Color; + pV->OldShadowColor = _GroupMenu->_ShadowColor; + pV->OldColorOver = _GroupMenu->_ColorOver; + pV->OldShadowColorOver = _GroupMenu->_ShadowColorOver; + pV->OldColorGrayed = _GroupMenu->_ColorGrayed; + pV->OldShadowColorGrayed = _GroupMenu->_ShadowColorGrayed; + + _GroupList->addChild (pV); + + CViewBitmap *checkBox = NULL; + + if (checkable) + { + checkBox = createCheckBox(checked); + checkBox->setTexture(texture); + pV->setCheckBox(checkBox); + } + + tmp.ViewText = pV; + tmp.Separator = NULL; + tmp.AHName = ah; + tmp.AHParams = params; + tmp.Cond = cond; + tmp.CheckBox = checkBox; + tmp.RightArrow = NULL; + if (id.empty()) + tmp.Id = NLMISC::toString (_Lines.size()); + else + tmp.Id = id; + + pV->setId(_GroupMenu->getId()+":"+tmp.Id); + + _Lines.push_back (tmp); + + // Add an empty sub menu by default + _SubMenus.push_back (NULL); + + _GroupMenu->invalidateCoords(); + + return pV; + } + + CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + const std::string ¶ms, const std::string &id /*=""*/, + const std::string &cond /*=std::string()*/, const std::string &texture, + bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ + ) + { + if (index > _Lines.size()) + { + nlwarning("Bad index"); + return NULL; + } + SSubMenuEntry tmp; + CViewTextMenu *pV = new CViewTextMenu(CViewBase::TCtorParam()); + + + pV->setCaseMode(_GroupMenu->getCaseMode()); + + + if (formatted) + { + pV->setMultiLine (true); + pV->setMultiLineMaxWOnly (true); + pV->setTextFormatTaged (name); + } + else + { + pV->setText (name); + } + + pV->setColor (_GroupMenu->_Color); + pV->setFontSize (_GroupMenu->_FontSize); + pV->setShadow (_GroupMenu->_Shadow); + pV->setCheckable(checkable); + pV->setChecked(checked); + pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); + + pV->OldColor = _GroupMenu->_Color; + pV->OldShadowColor = _GroupMenu->_ShadowColor; + pV->OldColorOver = _GroupMenu->_ColorOver; + pV->OldShadowColorOver = _GroupMenu->_ShadowColorOver; + pV->OldColorGrayed = _GroupMenu->_ColorGrayed; + pV->OldShadowColorGrayed = _GroupMenu->_ShadowColorGrayed; + + _GroupList->addChildAtIndex(pV, index); + + CViewBitmap *checkBox = NULL; + if (checkable) + { + checkBox = createCheckBox(checked); + checkBox->setTexture(texture); + pV->setCheckBox(checkBox); + } + + tmp.ViewText = pV; + tmp.Separator = NULL; + tmp.AHName = ah; + tmp.AHParams = params; + tmp.Cond = cond; + tmp.CheckBox = checkBox; + tmp.RightArrow = NULL; + + if (id.empty()) + tmp.Id = NLMISC::toString (_Lines.size()); + else + tmp.Id = id; + + pV->setId(getId()+":"+tmp.Id); + + _Lines.insert(_Lines.begin() + index, tmp); + + // Add an empty sub menu by default + _SubMenus.insert(_SubMenus.begin() + index, (CGroupSubMenu*)NULL); + + _GroupMenu->invalidateCoords(); + + return pV; + } + + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::removeLine(uint index) + { + if (index >= _Lines.size()) + { + nlwarning("Bad index"); + return; + } + setUserGroupRight(index, NULL, false); // remove user group + setUserGroupLeft(index, NULL, false); // remove user group + // remove view (right arrow & checkbox) + if (_Lines[index].RightArrow) delView(_Lines[index].RightArrow); + if (_Lines[index].CheckBox) delView(_Lines[index].CheckBox); + if (_Lines[index].Separator) + { + // remove one separator group + for(uint k = 0; k < _ChildrenGroups.size(); ++k) + { + if (_ChildrenGroups[k]->getId() == ID_MENU_SEPARATOR) + { + delGroup(_ChildrenGroups[k]); + break; + } + } + } + // + _GroupList->setDelOnRemove(index, true); + _GroupList->delChild(index); + _Lines.erase(_Lines.begin() + index); + + //invalidate selection + _Selected = -1; + + if(_SubMenus[index]) + { + // reset it and his sons (recurs) + _SubMenus[index]->reset(); + // then delete it + _GroupMenu->delGroup(_SubMenus[index]); + } + _SubMenus.erase(_SubMenus.begin() + index); + _GroupMenu->invalidateCoords(); + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::openSubMenu (sint32 nb) + { + hideSubMenus (); + _SubMenus[nb]->setActive (true); + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::hideSubMenus () + { + for (uint32 i = 0; i < _SubMenus.size(); ++i) + if (_SubMenus[i] != NULL) + { + _SubMenus[i]->setActive (false); + _SubMenus[i]->hideSubMenus (); + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::reset() + { + uint lineCount = (uint)_Lines.size(); + for(sint k = lineCount - 1; k >= 0; --k) + { + removeLine(k); + } + } + + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::removeAllUserGroups() + { + for(uint k = 0; k < _Lines.size(); ++k) + { + setUserGroupRight(k, NULL, false); + setUserGroupLeft(k, NULL, false); + } + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup *CGroupSubMenu::getUserGroupRight(uint line) const + { + if (line >= _Lines.size()) + { + nlwarning("bad index"); + return NULL; + } + return _Lines[line].UserGroupRight; + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceGroup *CGroupSubMenu::getUserGroupLeft(uint line) const + { + if (line >= _Lines.size()) + { + nlwarning("bad index"); + return NULL; + } + return _Lines[line].UserGroupLeft; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership) + { + if (line >= _Lines.size()) + { + nlwarning("bad index"); + return; + } + if (group && isChildGroup(group)) + { + nlwarning("Group inserted twice"); + return; + } + if (_Lines[line].UserGroupRight) + { + delGroup(_Lines[line].UserGroupRight, !_Lines[line].UserGroupRightOwnership); + } + _Lines[line].UserGroupRight = group; + _Lines[line].UserGroupRightOwnership = ownership; + if (group) + { + CViewBase *prevElem = _Lines[line].CheckBox ? _Lines[line].CheckBox : _Lines[line].RightArrow; + if (prevElem) + { + prevElem->setParentPosRef (Hotspot_MR); + prevElem->setPosRef (Hotspot_ML); + prevElem->setParentPos(group); + prevElem->setX(MENU_WIDGET_X); + prevElem->setY(0); + } + sint insertionOrder; + if (prevElem) + { + insertionOrder = getInsertionOrder(prevElem); + } + else + { + insertionOrder = -1; + } + addGroup(group, insertionOrder); + group->setParent(this); + group->setParentPos(_GroupList); + group->setParentPosRef (Hotspot_BR); + group->setPosRef (Hotspot_BL); + } + else + { + // restore all posref.. + CViewBase *prevElem = _Lines[line].CheckBox ? _Lines[line].CheckBox : _Lines[line].RightArrow; + if (prevElem) + { + prevElem->setParent (this); + prevElem->setParentPos (_GroupList); + prevElem->setParentPosRef (Hotspot_BR); + prevElem->setPosRef (Hotspot_BL); + prevElem->setX (MENU_WIDGET_X); + } + } + _GroupMenu->invalidateCoords(); + } + + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership) + { + if (line >= _Lines.size()) + { + nlwarning("bad index"); + return; + } + if (group && isChildGroup(group)) + { + nlwarning("Group inserted twice"); + return; + } + if (_Lines[line].UserGroupLeft) + { + delGroup(_Lines[line].UserGroupLeft, !_Lines[line].UserGroupLeftOwnership); + } + _Lines[line].UserGroupLeft = group; + _Lines[line].UserGroupLeftOwnership = ownership; + if (group) + { + addGroup(group); + group->setParent(this); + group->setParentPos(this); + group->setParentPosRef (Hotspot_BL); + group->setPosRef (Hotspot_BL); + group->setX(LEFT_MENU_WIDGET_X); + } + + _GroupMenu->invalidateCoords(); + } + + + // ------------------------------------------------------------------------------------------------ + CGroupSubMenu *CGroupSubMenu::cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup /* = NULL */) const + { + CGroupSubMenu *copyMenu = appendToMenu ? appendToMenu : new CGroupSubMenu(CViewText::TCtorParam()); + uint startSize = (uint)copyMenu->_Lines.size(); + copyMenu->_GroupMenu = newFather; + copyMenu->initOptions(initGroup); + copyMenu->_Lines.reserve(_Lines.size() + startSize); + copyMenu->_SubMenus.reserve(_SubMenus.size() + startSize); + // copy childrens + for(uint k = 0; k < _Lines.size(); ++k) + { + if (_Lines[k].Separator) + { + copyMenu->addSeparator(_Lines[k].Id); + } + else + { + std::string texture = std::string(); + if(_Lines[k].ViewText->getCheckBox()) + { + texture = _Lines[k].ViewText->getCheckBox()->getTexture(); + } + CViewTextMenu *pV = NULL; + pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, + texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ()); + copyMenu->_Lines[k].Selectable = _Lines[k].Selectable; + pV->setGrayed(_Lines[k].ViewText->getGrayed()); + } + + // sub menu copy if there's one + if (_SubMenus[k] != NULL) + { + + if (copyMenu->_Lines.back().CheckBox) + { + copyMenu->_Lines.back().RightArrow = copyMenu->createRightArrow(copyMenu->_Lines.back().CheckBox, true); + } + else + { + copyMenu->_Lines.back().RightArrow = copyMenu->createRightArrow(copyMenu->_GroupList, false); + } + + + // and create the sub menu + copyMenu->_SubMenus[k + startSize] = _SubMenus[k]->cloneMenu(NULL, newFather, copyMenu); + } + } + if (!appendToMenu) + { + newFather->addGroup(copyMenu); + } + return copyMenu; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setActive(bool state) + { + // check conditions + for(uint k = 0; k < _Lines.size(); ++k) + { + if (!_Lines[k].Cond.empty()) + { + CInterfaceExprValue result; + if (CInterfaceExpr::eval(_Lines[k].Cond, result)) + { + if (result.toBool()) + { + _Lines[k].ViewText->setGrayed(!result.getBool()); + } + } + } + } + + if(_ScrollBar && _GroupList) + _ScrollBar->setTrackPos(_GroupList->getHReal()); + + CGroupFrame::setActive(state); + } + + // ------------------------------------------------------------------------------------------------ + const std::string CGroupSubMenu::getActionHandler(uint lineIndex) const + { + if (lineIndex > _Lines.size()) + { + nlwarning("Bad index"); + return 0; + } + return _Lines[lineIndex].AHName; + } + + // ------------------------------------------------------------------------------------------------ + const std::string CGroupSubMenu::getActionHandlerParam(uint lineIndex) const + { + if (lineIndex > _Lines.size()) + { + nlwarning("Bad index"); + return 0; + } + return _Lines[lineIndex].AHParams; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable) + { + if (lineIndex > _Lines.size()) + { + nlwarning("Bad index"); + return; + } + _Lines[lineIndex].Selectable = selectable; + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupSubMenu::getSelectable(uint lineIndex) const + { + if (lineIndex > _Lines.size()) + { + nlwarning("Bad index"); + return 0; + } + return _Lines[lineIndex].Selectable; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setMaxVisibleLine(sint32 mvl) + { + _MaxVisibleLine = mvl; + } + + // ------------------------------------------------------------------------------------------------ + const std::string &CGroupSubMenu::getLineId(uint index) + { + if(index>=_Lines.size()) + { + static string nullString; + return nullString; + } + else + return _Lines[index].Id; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setGrayedLine(uint line, bool g) + { + if(line<_Lines.size()) + { + if (_Lines[line].ViewText) + { + _Lines[line].ViewText->setGrayed(g); + } + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupSubMenu::setHiddenLine(uint line, bool h) + { + if(line<_Lines.size()) + { + if (_Lines[line].ViewText) + { + _Lines[line].ViewText->setActive(!h); + } + } + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetNumLine(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getNumLine", 0); + ls.push((double) getNumLine()); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetSubMenu(CLuaState &ls) + { + const char *funcName = "getSubMenu"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddSubMenu(CLuaState &ls) + { + const char *funcName = "addSubMenu"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam())); + CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetLineId(CLuaState &ls) + { + const char *funcName = "getLineId"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + std::string id = getLineId((uint) ls.toNumber(1)); + CLuaIHM::push(ls, id); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetLineFromId(CLuaState &ls) + { + const char *funcName = "getLineFromId"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); + ls.push((double) getLineFromId(ls.toString(1))); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaIsSeparator(CLuaState &ls) + { + const char *funcName = "isSeparator"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + ls.push(isSeparator((uint) ls.toNumber(1))); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddLine(CLuaState &ls) + { + const char *funcName = "addLine"; + CLuaIHM::checkArgCount(ls, funcName, 4); + CLuaIHM::checkArgTypeUCString(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + ucstring arg1; + nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); + addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls) + { + const char *funcName = "addLineAtIndex"; + CLuaIHM::checkArgCount(ls, funcName, 5); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CLuaIHM::checkArgTypeUCString(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); + CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); + ucstring arg2; + nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); + addLineAtIndex((uint) ls.toNumber(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddSeparator(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "addSeparator", 0); + addSeparator(); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaAddSeparatorAtIndex(CLuaState &ls) + { + const char *funcName = "addSeparatorAtIndex"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + addSeparatorAtIndex((uint) ls.toNumber(1)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaRemoveLine(CLuaState &ls) + { + const char *funcName = "removeLine"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + removeLine((uint) ls.toNumber(1)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaSetUserGroupRight(CLuaState &ls) + { + const char *funcName = "setUserGroupRight"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) + { + CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); + } + CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); + CInterfaceGroup *group = dynamic_cast(el); + if (el && !group) + { + CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); + } + setUserGroupRight((uint) ls.toNumber(1), group, true); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaSetUserGroupLeft(CLuaState &ls) + { + const char *funcName = "setUserGroupLeft"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) + { + CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); + } + CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); + CInterfaceGroup *group = dynamic_cast(el); + if (el && !group) + { + CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); + } + setUserGroupLeft((uint) ls.toNumber(1), group, true); + return 0; + } + + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetUserGroupRight(CLuaState &ls) + { + const char *funcName = "getUserGroupRight"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); + return 1; + } + + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaGetUserGroupLeft(CLuaState &ls) + { + const char *funcName = "getUserGroupLeft"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1)); + if (pIE) + { + CLuaIHM::pushUIOnStack(ls, pIE); + return 1; + } + else return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaSetMaxVisibleLine(CLuaState &ls) + { + const char *funcName = "setMaxVisibleLine"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + setMaxVisibleLine((uint) ls.toNumber(1)); + return 0; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupSubMenu::luaReset(CLuaState &ls) + { + const char *funcName = "reset"; + CLuaIHM::checkArgCount(ls, funcName, 0); + reset(); + return 0; + } + + + // ------------------------------------------------------------------------------------------------ + // CGroupMenu + // ------------------------------------------------------------------------------------------------ + + NLMISC_REGISTER_OBJECT(CViewBase, CGroupMenu, std::string, "menu"); + + // ------------------------------------------------------------------------------------------------ + CGroupMenu::CGroupMenu(const TCtorParam ¶m) + :CGroupModal(param) + { + _Active = false; + _Color = CRGBA::White; + _ColorOver = CRGBA::White; + _ColorGrayed = CRGBA(128, 128, 128, 255); + _ShadowColor = CRGBA::Black; + _ShadowColorOver = CRGBA::Black; + _ShadowColorGrayed = CRGBA::Black; + _HighLightOver.set(128, 0, 0, 255); + _FontSize = 12; + _Shadow = false; + _ResizeFromChildH = _ResizeFromChildW = true; + _DisplayFrame = false; + _RootMenu = NULL; + _Space = 3; + _CaseMode = CaseUpper; + _Formatted = false; + } + + // ------------------------------------------------------------------------------------------------ + CGroupMenu::~CGroupMenu() + { + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupMenu::parse (xmlNodePtr in, CInterfaceGroup *parentGroup) + { + CXMLAutoPtr prop; + + _FontSize = 12; + + // override source menu options (if there's one) + if (!CGroupModal::parse(in, parentGroup)) + return false; + + + // see if this menu extends another menu + prop= (char*) xmlGetProp( in, (xmlChar*)"extends" ); + CGroupSubMenu *gmExtended = NULL; + if (prop) + { + + CGroupMenu *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); + if (!gm) + { + gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop))); + } + if (gm) + { + gmExtended = gm->_RootMenu; + // copy group frame parameters + CGroupFrame::copyOptionFrom(*gm); + // copy basic datas + _Color = gm->_Color; + _ShadowColor = gm->_ShadowColor; + _Shadow = gm->_Shadow; + _FontSize = gm->_FontSize; + _ColorOver = gm->_ColorOver; + _ShadowColorOver = gm->_ShadowColorOver; + _HighLightOver = gm->_HighLightOver; + _ColorGrayed = gm->_ColorGrayed; + _ShadowColorGrayed = gm->_ShadowColorGrayed; + _Priority = gm->_Priority; + _ModulateGlobalColor = gm->_ModulateGlobalColor; + _Space = gm->_Space; + _CaseMode = gm->_CaseMode; + } + else + { + nlwarning("Can't get menu %s or bad type", (const char *) prop); + } + } + + + // Override the modal behaviour because of sub menus + ExitClickOut = true; + ExitClickL = false; + ExitClickR = false; + ExitKeyPushed = true; + _ResizeFromChildH = _ResizeFromChildW = true; + _DisplayFrame = false; + _Active = false; + _Formatted = false; + + // text colors + prop= (char*) xmlGetProp( in, (xmlChar*)"color" ); + if (prop) _Color = convertColor(prop); + + prop = (char*) xmlGetProp( in, (xmlChar*)"case_mode" ); + if (prop) + { + sint32 caseMode; + fromString((const char*)prop, caseMode); + _CaseMode = (TCaseMode)caseMode; + } + + prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color" ); + if (prop) _ShadowColor = convertColor(prop); + + prop= (char*) xmlGetProp( in, (xmlChar*)"color_over" ); + if (prop) _ColorOver = convertColor(prop); + + prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color_over" ); + if (prop) _ShadowColorOver = convertColor(prop); + + prop= (char*) xmlGetProp( in, (xmlChar*)"highlight_over" ); + if (prop) _HighLightOver = convertColor(prop); + + prop= (char*) xmlGetProp( in, (xmlChar*)"color_grayed" ); + if (prop) _ColorGrayed = convertColor(prop); + + prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color_grayed" ); + if (prop) _ShadowColorGrayed = convertColor(prop); + + prop = (char*) xmlGetProp (in, (xmlChar*)"space"); + if (prop) fromString((const char*)prop, _Space); + + // Text props + prop = (char*) xmlGetProp( in, (xmlChar*)"fontsize" ); + if (prop) fromString((const char*)prop, _FontSize); + + prop = (char*) xmlGetProp( in, (xmlChar*)"shadow" ); + if (prop) + _Shadow = convertBool(prop); + + prop = (char*) xmlGetProp( in, (xmlChar*)"formatted" ); + if (prop) + _Formatted = convertBool(prop); + + + // Read sons + xmlNodePtr cur; + cur = in->children; + if (_RootMenu != NULL) delete _RootMenu; + _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); + _RootMenu->_GroupMenu = this; + _RootMenu->parse (cur); + + prop = (char*) xmlGetProp( in, (xmlChar*)"max_visible_line" ); + if (prop) + { + sint32 maxVisibleLine; + fromString((const char*)prop, maxVisibleLine); + _RootMenu->setMaxVisibleLine(maxVisibleLine); + } + + if (gmExtended) + { + gmExtended->cloneMenu(_RootMenu, this); + } + return true; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::recurseDraw(CGroupSubMenu *pSubMenu) + { + pSubMenu->draw(); + + // const vector &rGroups = pSubMenu->getGroups(); + + for (uint32 i = 0; i < pSubMenu->getNumLines(); i++) + { + CGroupSubMenu *pGSM = pSubMenu->getSubMenu(i); + if (pGSM != NULL) + { + recurseDraw(pGSM); + CViewRenderer::getInstance()->flush(); + } + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::draw () + { + if (!_Active) return; + + // TEMP TEMP + //CViewRenderer &rVR = *CViewRenderer::getInstance(); + //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(255, 0, 0, 255) ); + + _RootMenu->_Active = true; + + if (SpawnOnMousePos) + recurseDraw(_RootMenu); + else + CGroupModal::draw(); + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupMenu::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (!_Active) + return false; + return CGroupModal::handleEvent (event); + } + + // ------------------------------------------------------------------------------------------------ + CInterfaceElement* CGroupMenu::getElement (const std::string &id) + { + if (id == getId()) return this; + CInterfaceElement *pIE = _RootMenu->getElement(id); + if (pIE != NULL) + return pIE; + return CGroupModal::getElement(id); + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setActive (bool state) + { + if (SpawnOnMousePos) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + uint32 w,h; + rVR.getScreenSize(w,h); + setW(w); + setH(h); + setX(0); + setY(0); + _ResizeFromChildH = _ResizeFromChildW = false; + _RootMenu->_PosRef = Hotspot_TL; + _RootMenu->_ParentPosRef = Hotspot_BL; + } + + CGroupFrame::setActive (state); + + // must recompute now the pos of the menu + uint32 i; + for (i = 0; i < _ChildrenGroups.size(); ++i) + { + _ChildrenGroups[i]->setActive (true); + } + + CGroupModal::updateCoords(); + + // hide sub menus + _RootMenu->hideSubMenus(); + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupSubMenu::isSeparator(uint i) const + { + if (i >= _SubMenus.size()) + { + nlassert("bad index"); + return false; + } + return _Lines[i].Separator != NULL; + } + // ------------------------------------------------------------------------------------------------ + bool CGroupMenu::isWindowUnder (sint32 x, sint32 y) + { + for (uint32 i = 0; i < _ChildrenGroups.size(); ++i) + if (_ChildrenGroups[i]->getActive ()) + if (_ChildrenGroups[i]->isWindowUnder(x, y)) + return true; + + return false; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::addLine (const string &name, const string &ah, const string ¶ms, + const std::string &id/*=std::string()*/, + const std::string &cond /*= std::string()*/, const std::string &texture, + bool checkable /*= false*/, bool checked /*= false*/ + ) + { + if (_RootMenu == NULL) + { + _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); + _RootMenu->_GroupMenu = this; + addGroup (_RootMenu); + } + + _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::addLine(const ucstring &name, const std::string &ah, const std::string ¶ms, + const std::string &id /* = std::string()*/, + const std::string &cond /*= std::string()*/, const std::string &texture, + bool checkable /*= false*/, bool checked /*= false*/ + ) + { + if (_RootMenu == NULL) + { + _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); + _RootMenu->_GroupMenu = this; + addGroup (_RootMenu); + } + _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); + } + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, + const std::string ¶ms, const std::string &id /*=std::string()*/, + const std::string &cond /*=std::string()*/, const std::string &texture, + bool checkable /*=false*/, bool checked /*=false*/) + { + if (_RootMenu == NULL) + { + _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); + _RootMenu->_GroupMenu = this; + addGroup (_RootMenu); + } + _RootMenu->addLineAtIndex(index, name, ah, params, id, cond, texture, checkable, checked, _Formatted); + } + + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::reset () + { + if ( _RootMenu ) + { + _RootMenu->reset(); + invalidateCoords(); + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setMinW(sint32 minW) + { + if ( _RootMenu ) + { + _RootMenu->_GroupList->setMinW(minW-_RootMenu->getResizeFromChildWMargin()); + _RootMenu->_GroupList->setW(minW-_RootMenu->getResizeFromChildWMargin()); + _RootMenu->setW(minW-_RootMenu->getResizeFromChildWMargin()); + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setGrayedLine(uint line, bool g) + { + if ( _RootMenu ) + { + _RootMenu->setGrayedLine(line, g); + } + } + + // ------------------------------------------------------------------------------------------------ + uint CGroupMenu::getNumLine() const + { + return _RootMenu ? _RootMenu->getNumLine() : 0; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::deleteLine(uint index) + { + if (index > getNumLine()) + { + nlwarning("bad index"); + return; + } + _RootMenu->removeLine(index); + } + + // ------------------------------------------------------------------------------------------------ + const std::string CGroupMenu::getActionHandler(uint lineIndex) const + { + return _RootMenu ? _RootMenu->getActionHandler(lineIndex) : ""; + } + + // ------------------------------------------------------------------------------------------------ + const std::string CGroupMenu::getActionHandlerParam(uint lineIndex) const + { + return _RootMenu ? _RootMenu->getActionHandlerParam(lineIndex) : ""; + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/) + { + if (_RootMenu) + { + _RootMenu->setUserGroupRight(line, gr, ownerShip); + } + } + + // ------------------------------------------------------------------------------------------------ + void CGroupMenu::setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/) + { + if (_RootMenu) + { + _RootMenu->setUserGroupLeft(line, gr, ownerShip); + } + } + + // ------------------------------------------------------------------------------------------------ + int CGroupMenu::luaGetRootMenu(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "getRootMenu", 0); + CLuaIHM::pushUIOnStack(ls, getRootMenu()); + return 1; + } + + // ------------------------------------------------------------------------------------------------ + int CGroupMenu::luaSetMinW(CLuaState &ls) + { + const char *funcName = "setMinW"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + setMinW((sint32) ls.toNumber(1)); + return 0; + } +} + + diff --git a/code/ryzom/client/src/game_context_menu.cpp b/code/ryzom/client/src/game_context_menu.cpp index 195cf45de..183e691ca 100644 --- a/code/ryzom/client/src/game_context_menu.cpp +++ b/code/ryzom/client/src/game_context_menu.cpp @@ -25,7 +25,7 @@ #include "game_context_menu.h" #include "interface_v3/interface_manager.h" #include "nel/gui/ctrl_text_button.h" -#include "interface_v3/group_menu.h" +#include "nel/gui/group_menu.h" #include "entities.h" #include "interface_v3/bot_chat_manager.h" #include "interface_v3/guild_manager.h" diff --git a/code/ryzom/client/src/game_context_menu.h b/code/ryzom/client/src/game_context_menu.h index 4f325b5c7..1b24330d0 100644 --- a/code/ryzom/client/src/game_context_menu.h +++ b/code/ryzom/client/src/game_context_menu.h @@ -28,10 +28,14 @@ // *************************************************************************** -class CGroupMenu; -class CViewTextMenu; +namespace NLGUI +{ + class CGroupMenu; + class CViewTextMenu; +} + namespace NLMISC{ -class CCDBNodeLeaf; + class CCDBNodeLeaf; } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 91b9add54..e86792b46 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -37,7 +37,7 @@ #include "dbctrl_sheet.h" #include "ctrl_sheet_selection.h" #include "nel/gui/interface_expr.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_item.cpp b/code/ryzom/client/src/interface_v3/action_handler_item.cpp index cfe18adb4..f07dbb018 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_item.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_item.cpp @@ -29,7 +29,7 @@ #include "player_trade.h" #include "../user_entity.h" #include "../net_manager.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "../global.h" #include "group_html.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp index f7d3c7772..99533a720 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_phrase.cpp @@ -45,7 +45,7 @@ #include "../net_manager.h" #include "../entities.h" #include "macrocmd_manager.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/gui/group_tree.h" extern CSheetManager SheetMngr; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index b861cee1d..2a95a0b6c 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -18,7 +18,7 @@ #include "stdpch.h" #include "dbgroup_combo_box.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "interface_manager.h" #include "nel/gui/ctrl_button.h" diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h index 4429c6a13..606d7b430 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h @@ -26,10 +26,9 @@ namespace NLGUI { class CCtrlBaseButton; class CViewText; + class CGroupMenu; } -// *************************************************************************** -class CGroupMenu; // *************************************************************************** #define WIN_COMBO_BOX_SELECT_MENU "ui:interface:combo_box_select_menu" diff --git a/code/ryzom/client/src/interface_v3/group_compas.h b/code/ryzom/client/src/interface_v3/group_compas.h index 33184f301..c5de20471 100644 --- a/code/ryzom/client/src/interface_v3/group_compas.h +++ b/code/ryzom/client/src/interface_v3/group_compas.h @@ -23,7 +23,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/vector_2f.h" #include "nel/gui/group_container.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "animal_position_state.h" class CViewRadar; diff --git a/code/ryzom/client/src/interface_v3/group_in_scene.h b/code/ryzom/client/src/interface_v3/group_in_scene.h index 578d25226..752cf26b0 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene.h +++ b/code/ryzom/client/src/interface_v3/group_in_scene.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_container.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_menu.cpp b/code/ryzom/client/src/interface_v3/group_menu.cpp deleted file mode 100644 index 931571d0b..000000000 --- a/code/ryzom/client/src/interface_v3/group_menu.cpp +++ /dev/null @@ -1,2300 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "nel/gui/interface_options.h" -#include "nel/gui/interface_expr.h" -#include "group_menu.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/action_handler.h" // Just for getAllParams -#include "nel/gui/lua_ihm.h" -#include "nel/misc/i18n.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/group_list.h" -#include "nel/gui/ctrl_scroll.h" -#include "nel/gui/view_pointer_base.h" - - -using namespace NLMISC; -using namespace std; - - -namespace -{ - const std::string ID_MENU_CHECKBOX = "menu_cb"; - const std::string ID_MENU_SEPARATOR = "menu_separator"; - const std::string ID_MENU_SUBMENU = "menu_sb"; - const uint MENU_WIDGET_X = 2; - const uint LEFT_MENU_WIDGET_X = 4; -} - -// ------------------------------------------------------------------------------------------------ -// CGroupSubMenu -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -bool CViewTextMenu::getGrayed() const -{ - return _Grayed; -} - -// ------------------------------------------------------------------------------------------------ -void CViewTextMenu::setGrayed (bool g) -{ - _Grayed = g; -} - -// ------------------------------------------------------------------------------------------------ -void CViewTextMenu::setCheckable(bool c) -{ - if (!c) - { - _Checkable = false; - _CheckBox = NULL; - } - else - { - _Checkable = true; - } -} - -// ------------------------------------------------------------------------------------------------ -void CViewTextMenu::setChecked(bool c) -{ - if (_CheckBox) - { - CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); - if (!pIO) return; - _CheckBox->setTexture(pIO->getValStr(c ? "checked_bitmap" : "unchecked_bitmap")); - } - _Checked = c; -} - -// ------------------------------------------------------------------------------------------------ -sint32 CViewTextMenu::getAlpha() const -{ - if (_Grayed) - { - return OldColorGrayed.A; - } - else - { - if (Over) - return OldColorOver.A; - else - return OldColor.A; - } -} - -// ------------------------------------------------------------------------------------------------ -void CViewTextMenu::setAlpha (sint32 a) -{ - OldShadowColor.A = OldColor.A = (uint8)a; - OldShadowColorOver.A = OldColorOver.A = (uint8)a; - OldShadowColorGrayed.A = OldShadowColorGrayed.A = (uint8)a; -} - -// ------------------------------------------------------------------------------------------------ -// CGroupSubMenu -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -CGroupSubMenu::CGroupSubMenu(const TCtorParam ¶m) -: CGroupSubMenuBase(param) -{ - _SelectionView = NULL; - _GroupList = NULL; - _GroupMenu = NULL; - _Selected = -1; - _MaxVisibleLine = -1; - _ScrollBar = NULL; -} - -// ------------------------------------------------------------------------------------------------ -CGroupSubMenu::~CGroupSubMenu() -{ - removeAllUserGroups(); -} - -// ------------------------------------------------------------------------------------------------ -sint CGroupSubMenu::getLineFromId(const std::string &id) -{ - for (uint k = 0; k < _Lines.size(); ++k) - { - if (_Lines[k].Id == id) - { - return (sint) k; - } - } - return -1; -} - -// ------------------------------------------------------------------------------------------------ -CGroupSubMenu *CGroupSubMenu::getSubMenu(uint index) const -{ - if (index >= _SubMenus.size()) - { - nlassert("bad index"); - return NULL; - } - return _SubMenus[index]; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setSubMenu(uint index, CGroupSubMenu *sub) -{ - nlassert(sub != NULL); - nlassert(index < _SubMenus.size()); - - if (_SubMenus[index] != NULL) - { - // must delete from the group menu (if not found, just delete) - if( !_GroupMenu || !_GroupMenu->delGroup(_SubMenus[index]) ) - delete _SubMenus[index]; - _SubMenus[index] = NULL; - delView(_Lines[index].RightArrow); - } - - if (_Lines[index].CheckBox) - _Lines[index].RightArrow = createRightArrow(_Lines[index].CheckBox, true); - else - _Lines[index].RightArrow = createRightArrow(_GroupList, false); - - sub->_GroupMenu = _GroupMenu; - sub->initOptions(this); - _GroupMenu->addGroup (sub); - sub->_DispType = _GroupMenu->_DispType; - _SubMenus[index] = sub; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::initOptions(CInterfaceGroup *parent) -{ - // Initialization - // me - _Parent = _GroupMenu; - if (parent == NULL) - { - setParentPos (_GroupMenu); - setParentPosRef (Hotspot_TL); - setPosRef (Hotspot_TL); - } - else - { - setParentPos (parent); - setParentPosRef (Hotspot_BR); - setPosRef (Hotspot_BL); - } - _DisplayFrame = true; - _ResizeFromChildH = true; - _ResizeFromChildW = true; - _ResizeFromChildHMargin = 8; - _ResizeFromChildWMargin = 8; - _ModulateGlobalColor = _GroupMenu->_ModulateGlobalColor; - // the selection - if (_SelectionView == NULL) - { - _SelectionView = new CViewBitmap(CViewBase::TCtorParam()); -// CInterfaceManager *pIM = CInterfaceManager::getInstance(); -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - _SelectionView->setParent (this); - _SelectionView->setActive (false); - _SelectionView->setTexture ("blank.tga"); - _SelectionView->setScale (true); - _SelectionView->setX (4); - _SelectionView->setSizeRef(1); // sizeref on W - _SelectionView->setW (-8); - addView (_SelectionView, 0); - } - // the group list - if (_GroupList == NULL) - { - _GroupList = new CGroupList(CViewBase::TCtorParam()); - _GroupList->setParent (this); - _GroupList->setParentPos (this); - _GroupList->setX (4); - _GroupList->setY (4); - _GroupList->setSpace (_GroupMenu->_Space); - addGroup (_GroupList); - } -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupSubMenu::parse (xmlNodePtr cur, CInterfaceGroup *parent) -{ - initOptions(parent); - // the children - while (cur) - { - CViewTextMenu *pV = NULL; - - CXMLAutoPtr id((const char*) xmlGetProp (cur, (xmlChar*)"id")); - - if (stricmp((char*)cur->name, "separator") == 0) - { - if (id) - { - addSeparator((const char *) id); - } - else - { - addSeparator(); - } - } - else - if (stricmp((char*)cur->name, "action") == 0) - { - string strId, strAh, strParams, strCond, strTexture=""; - ucstring ucstrName; - - if (id) strId = (const char*)id; - CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"name")); - - if (name) - { - const char *ptrName = (const char*)name; - ucstrName = ucstring(ptrName); - if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i')) - ucstrName = CI18N::get (ptrName); - } - - CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler")); - if (ah) strAh = (const char*)ah; - CXMLAutoPtr cond((const char*) xmlGetProp (cur, (xmlChar*)"cond")); - if (cond) strCond = (const char*)cond; - CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params")); - if (params) strParams = (const char*)params; - CXMLAutoPtr strCheckable((const char*) xmlGetProp (cur, (xmlChar*)"checkable")); - bool bCheckable = false; - if (strCheckable) bCheckable = convertBool (strCheckable); - CXMLAutoPtr strChecked((const char*) xmlGetProp (cur, (xmlChar*)"checked")); - bool bChecked = false; - if (strChecked) bChecked = convertBool (strChecked); - bool bFormatted = false; - CXMLAutoPtr strFormatted((const char*) xmlGetProp (cur, (xmlChar*)"formatted")); - if (strFormatted) bFormatted = convertBool (strFormatted); - - pV = addLine (ucstrName, strAh, strParams, strId, strCond, strTexture, bCheckable, bChecked, bFormatted); - - CXMLAutoPtr strSelectable((const char*) xmlGetProp (cur, (xmlChar*)"selectable")); - bool bSelectable = true; - if (strSelectable) bSelectable = convertBool (strSelectable); - _Lines.back().Selectable = bSelectable; - - - CXMLAutoPtr grayed((const char*) xmlGetProp (cur, (xmlChar*)"grayed")); - bool bGrayed = false; - if (grayed) bGrayed = convertBool (grayed); - pV->setGrayed(bGrayed); - - // Is this line has a sub menu ? - xmlNodePtr child = cur->children; - if (child != NULL) - { - if (_Lines.back().CheckBox) - { - _Lines.back().RightArrow = createRightArrow(_Lines.back().CheckBox, true); - } - else - { - _Lines.back().RightArrow = createRightArrow(_GroupList, false); - } - // and create the sub menu - CGroupSubMenu *childMenu = new CGroupSubMenu(CViewText::TCtorParam()); - childMenu->_GroupMenu = _GroupMenu; - childMenu->parse (child, this); - - CXMLAutoPtr MVL((const char*) xmlGetProp(cur, (xmlChar*)"max_visible_line")); - if (MVL) - { - sint32 maxVisibleLine; - fromString((const char*)MVL, maxVisibleLine); - childMenu->setMaxVisibleLine(maxVisibleLine); - } - - _SubMenus.back() = childMenu; - } - - // Add user groups - // Left - CXMLAutoPtr usergroup((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_l")); - if (usergroup) - { - vector< pair > vparams; - CXMLAutoPtr ugparams((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_params_l")); - if (ugparams) - { - IActionHandler::getAllParams((const char*)ugparams, vparams); - } - - string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; - CInterfaceGroup *pUGLeft = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); - if (pUGLeft) - setUserGroupLeft((uint)_Lines.size()-1, pUGLeft, true); - } - usergroup = (char*) xmlGetProp (cur, (xmlChar*)"usergroup_r"); - if (usergroup) - { - vector< pair > vparams; - CXMLAutoPtr ugparams((const char*) xmlGetProp (cur, (xmlChar*)"usergroup_params_r")); - if (ugparams) - { - IActionHandler::getAllParams((const char*)ugparams, vparams); - } - - string completeId = _Parent->getId() + ":" + _Lines[_Lines.size()-1].Id; - CInterfaceGroup *pUG = CWidgetManager::parser->createGroupInstance((const char*)usergroup, completeId, vparams); - if (pUG) - setUserGroupRight((uint)_Lines.size()-1, pUG, true); - } - } - cur = cur->next; - } - - _GroupMenu->addGroup (this); - this->_DispType = _GroupMenu->_DispType; - - return true; -} - - -// ------------------------------------------------------------------------------------------------ -CViewBitmap *CGroupSubMenu::createCheckBox(bool checked) -{ - // Put the left arrow to the line - CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); - pVB->setParent (this); - pVB->setParentPos (_GroupList); - pVB->setParentPosRef (Hotspot_BR); - pVB->setPosRef (Hotspot_BL); - CInterfaceOptions *pIO = CWidgetManager::getInstance()->getOptions("menu_checkbox"); - if (pIO) - { - pVB->setTexture(pIO->getValStr(checked ? "checked_bitmap" : "unchecked_bitmap")); - } - pVB->setX (MENU_WIDGET_X); - pVB->setId (ID_MENU_CHECKBOX); // always rescale to parent in update coords - addView (pVB); - return pVB; -} - - -// ------------------------------------------------------------------------------------------------ -CViewBitmap *CGroupSubMenu::createRightArrow(CInterfaceElement *parentPos, bool center) -{ - // Put the left arrow to the line - CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam()); - pVB->setParent (this); - pVB->setParentPos (parentPos); - if (!center) - { - pVB->setParentPosRef (Hotspot_BR); - pVB->setPosRef (Hotspot_BL); - } - else - { - pVB->setParentPosRef (Hotspot_MR); - pVB->setPosRef (Hotspot_ML); - } - pVB->setTexture("w_arrow_right_3.tga"); - pVB->setX (MENU_WIDGET_X); - pVB->setId (ID_MENU_SUBMENU); // rescale to parent in update coords if asked (not needed if there's already on the left a checkbox) - addView (pVB); - return pVB; -} - -// ------------------------------------------------------------------------------------------------ -#define GET_REF_ELM(__index__) \ - CInterfaceElement *refElm; \ - sint32 refElmYReal= 0; \ - sint32 refElmHReal= 0; \ - refElm = _Lines[__index__].ViewText; \ - if(refElm) \ - { \ - refElmYReal= refElm->getYReal() - _Lines[__index__].TextDY; \ - refElmHReal= _Lines[__index__].HReal; \ - } - -void CGroupSubMenu::updateCoords () -{ - if (_ParentPos == _GroupMenu) - { - // Root Menu - setX(_GroupMenu->SpawnMouseX); - setY(_GroupMenu->SpawnMouseY); - CGroupFrame::updateCoords(); - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 screenW, screenH; - rVR.getScreenSize(screenW, screenH); - if ((_XReal+_WReal) > (sint32)screenW) - setX(screenW-_WReal); - if (_YReal < 0) - setY(_HReal); - } - else - // The sub menu may go outside the screen in Y. => clamp it as possible - { - /* X/Y coords have normally been updated before by "parent" sub menus - Why? because setSubMenu() is typically called in "parent first" order (or it is exactly what is done in ::parse()) - => Parent CGroupSubMenu::updateCoords() are called before their sons in CGroupMenu::updateCoords() !!! - => No Need to call _SubMenus[RALineNb]->updateCoords() below ! (else would call too much time because of recursion!!) - */ - - // must udpate correct Real coords - CGroupFrame::updateCoords(); - - // get screen size - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 screenW, screenH; - rVR.getScreenSize(screenW, screenH); - - sint32 hReal= getHReal(); - // If the H is too big, abort.. can't do anything - if(hReal<=(sint32)screenH) - { - sint32 yReal= getYReal(); - - // compute the shift to apply to the Y of the sub menu, to respect (as possible) the screen - sint32 dyClamp= 0; - if(yReal<0) - dyClamp= - yReal; - if(yReal+hReal>(sint32)screenH) - dyClamp= screenH - (yReal+hReal); - // change then the Y - if(dyClamp!=0) - { - setY(getY()+dyClamp); - CGroupFrame::updateCoords(); - } - } - } - - // not yet setuped? - if (!_GroupList) return; - - // get text dy position - sint32 textDYPos= 0; - textDYPos= -(1+_GroupList->getSpace())/2; - - // Set the arrows at the right positions (in _Views we have selection and the right arrows) - sint32 CBLineNb = 0; // check box - sint32 RALineNb = 0; // right arrow - uint32 i; - - sint32 maxUserGroupWidth = 0; - // compute max width of user groups, & adapt max height for each line - uint k; - - // update all left user groups to get their width - sint32 maxLeftUGWidth = 0; - for(k = 0; k < _Lines.size(); ++k) - { - if (_Lines[k].UserGroupLeft) - { - _Lines[k].UserGroupLeft->updateCoords(); - maxLeftUGWidth = std::max(_Lines[k].UserGroupLeft->getWReal(), maxLeftUGWidth); - } - } - - _GroupList->setX(LEFT_MENU_WIDGET_X + maxLeftUGWidth); - - // active separators when needed - bool activeLineSeen = false; - for (i = 0; i < _Lines.size(); ++i) - { - if (_Lines[i].Separator != NULL) - { - if (i == _Lines.size() - 1) - { - _Lines[i].Separator->setActive(false); - break; - } - _Lines[i].Separator->setActive(activeLineSeen); - activeLineSeen = false; - } - else - { - if (_Lines[i].ViewText && _Lines[i].ViewText->getActive()) activeLineSeen = true; - } - } - - CGroupFrame::updateCoords(); - - bool mustUpdate = false; - - if (_MaxVisibleLine > 0 && sint32(_Lines.size())>_MaxVisibleLine) - { - for(k = 0; k < _Lines.size(); ++k) - if (_Lines[k].ViewText) - { - // compute max height of widgets on the left of text - sint32 widgetMaxH = 0; - if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); - if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); - if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); - if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); - widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal()); - _GroupList->setMaxH(widgetMaxH*_MaxVisibleLine+_GroupList->getSpace()*(_MaxVisibleLine-1)); - if (_ScrollBar == NULL) - { - _ScrollBar = new CCtrlScroll(CViewBase::TCtorParam()); - _ScrollBar->setParent (this); - _ScrollBar->setParentPos (_GroupList); - _ScrollBar->setPosRef (Hotspot_BL); - _ScrollBar->setParentPosRef (Hotspot_BR); - _ScrollBar->setX (4); - _ScrollBar->setY (0); - _ScrollBar->setW (8); - _ScrollBar->setTextureBottomOrLeft ("w_scroll_l123_b.tga"); - _ScrollBar->setTextureMiddle ("w_scroll_l123_m.tga"); - _ScrollBar->setTextureTopOrRight ("w_scroll_l123_t.tga"); - _ScrollBar->setTarget(_GroupList); - _SelectionView->setW (-8-8-2); - addCtrl(_ScrollBar); - mustUpdate = true; - } - break; - } - } - else - { - _SelectionView->setW(-8); - } - - - // *** Setup Text - for(k = 0; k < _Lines.size(); ++k) - { - CInterfaceGroup *ig = _Lines[k].UserGroupRight; - if (ig) - { - ig->updateCoords(); - maxUserGroupWidth = std::max(maxUserGroupWidth, ig->getWReal()); - } - if (_Lines[k].ViewText) - { - // compute max height of widgets on the left of text - sint32 widgetMaxH = 0; - if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); - if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); - if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); - if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); - - sint32 textHReal= _Lines[k].ViewText->getHReal(); - _Lines[k].HReal= max(widgetMaxH, textHReal); - _Lines[k].TextDY= textDYPos; - if(widgetMaxH>textHReal) - _Lines[k].TextDY+= (widgetMaxH-textHReal) / 2; - } - } - - - // *** Update Text Positions -// sint32 currX = 0; - for(k = 0; k < _Lines.size(); ++k) - { - if (_Lines[k].ViewText) - { - // Setup Y - _Lines[k].ViewText->setY(_Lines[k].TextDY); - } - } - - - - if (mustUpdate) - { - CGroupFrame::updateCoords(); - } - - - // *** Setup SubMenus and CheckBoxes Positions - sint32 maxViewW = 0; - for (i = 1; i < _Views.size(); ++i) - { - CViewBitmap *pVB = dynamic_cast(_Views[i]); - if (pVB == NULL) continue; - if (pVB->getId() == ID_MENU_SUBMENU) - { - // Look for the next line of the menu that contains a sub menu - for(;;) - { - nlassert (RALineNb < (sint32)_SubMenus.size()); - if (_SubMenus[RALineNb] != NULL) // has a check box or an arrow to indicate submenu ? - { - break; - } - ++RALineNb; - } - - // get refElm and refElmYReal - GET_REF_ELM(RALineNb) - - // if there is a check box, y is 0 - if (_Lines[RALineNb].CheckBox || _Lines[RALineNb].UserGroupRight) - { - pVB->setY(0); - pVB->setX(MENU_WIDGET_X); - } - else - { - sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); - // Setup the arrow at the right pos - if(_GroupList->getMaxH()>=limY && limY>=0) - { - pVB->setY(refElmYReal + (refElmHReal - pVB->getHReal()) / 2 - _GroupList->getYReal()); - pVB->setColor(_Lines[RALineNb].ViewText->getColor()); - pVB->setActive(_Lines[RALineNb].ViewText->getActive()); - pVB->setX(maxUserGroupWidth + MENU_WIDGET_X); - } - else - { - pVB->setY(0); - pVB->setActive(false); - } - } - - if (_GroupMenu->SpawnOnMousePos) - { - _SubMenus[RALineNb]->setParentPos (this); - - // According to mouse position, set the sub menu on the left or right, begin at top or bottom - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 screenW, screenH; - rVR.getScreenSize(screenW, screenH); - if ((_GroupMenu->SpawnMouseX <= ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY <= ((sint32)screenH/2))) - { - _SubMenus[RALineNb]->setParentPosRef(Hotspot_BR); - _SubMenus[RALineNb]->setPosRef(Hotspot_BL); - _SubMenus[RALineNb]->setY (refElmYReal - _GroupList->getYReal()); - } - if ((_GroupMenu->SpawnMouseX <= ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY > ((sint32)screenH/2))) - { - _SubMenus[RALineNb]->setParentPosRef(Hotspot_TR); - _SubMenus[RALineNb]->setPosRef(Hotspot_TL); - _SubMenus[RALineNb]->setY (refElmHReal+(refElmYReal - _GroupList->getYReal()) - _GroupList->getHReal()); - } - if ((_GroupMenu->SpawnMouseX > ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY <= ((sint32)screenH/2))) - { - _SubMenus[RALineNb]->setParentPosRef(Hotspot_BL); - _SubMenus[RALineNb]->setPosRef(Hotspot_BR); - _SubMenus[RALineNb]->setY (refElmYReal - _GroupList->getYReal()); - } - if ((_GroupMenu->SpawnMouseX > ((sint32)screenW/2)) && (_GroupMenu->SpawnMouseY > ((sint32)screenH/2))) - { - _SubMenus[RALineNb]->setParentPosRef(Hotspot_TL); - _SubMenus[RALineNb]->setPosRef(Hotspot_TR); - _SubMenus[RALineNb]->setY (refElmHReal+(refElmYReal - _GroupList->getYReal()) - _GroupList->getHReal()); - } - _SubMenus[RALineNb]->setX(0); - } - else - { - // Setup sub menu - _SubMenus[RALineNb]->setParentPos (this); - _SubMenus[RALineNb]->setParentPosRef (Hotspot_BR); - _SubMenus[RALineNb]->setPosRef (Hotspot_BL); - _SubMenus[RALineNb]->setY (16+refElmYReal - _GroupList->getYReal() - _SubMenus[RALineNb]->getHReal()); - } - - ++RALineNb; - } - else if (pVB->getId() == ID_MENU_CHECKBOX) - { - for(;;) - { - nlassert (CBLineNb < (sint32)_SubMenus.size()); - if (_Lines[CBLineNb].CheckBox != NULL) // has a check box or an arrow to indicate submenu ? - { - break; - } - ++CBLineNb; - } - // Setup the arrow at the right pos - if (!_Lines[CBLineNb].UserGroupRight) - { - // get refElm and refElmYReal - GET_REF_ELM(CBLineNb) - - pVB->setX(maxUserGroupWidth + 2 * MENU_WIDGET_X); - - sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); - // Setup the arrow at the right pos - if(_GroupList->getMaxH()>=limY && limY>=0) - { - pVB->setY(refElmYReal + (refElmHReal - pVB->getHReal()) / 2 - _GroupList->getYReal()); - pVB->setActive(_Lines[CBLineNb].ViewText->getActive()); - } - else - { - pVB->setY(0); - pVB->setActive(false); - } - } - else - { - pVB->setY(0); - pVB->setX(MENU_WIDGET_X); - } - pVB->setColor (_Lines[CBLineNb].ViewText->getColor()); - // - ++CBLineNb; - } - - if (maxViewW<(pVB->getWReal()+pVB->getX())) maxViewW = pVB->getWReal()+pVB->getX(); - } - - // setup scrollbar position in function of views width - if(maxViewW>0 && _ScrollBar) - _ScrollBar->setX(4 + maxViewW); - - // *** Setup user groups positions - for(k = 0; k < _Lines.size(); ++k) - { - CInterfaceGroup *igr = _Lines[k].UserGroupRight; - CInterfaceGroup *igl = _Lines[k].UserGroupLeft; - if (igr || igl) - { - // get refElm and refElmYReal - GET_REF_ELM(k) - - if (refElm) - { - if (igr) - { - igr->setX(MENU_WIDGET_X + maxUserGroupWidth - igr->getWReal()); - - sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); - if(_GroupList->getMaxH()>=limY && limY>=0) - { - igr->setY(refElmYReal + (refElmHReal - igr->getHReal()) / 2 - _GroupList->getYReal()); - igr->setActive (refElm->getActive()); - } - else - { - igr->setY(0); - igr->setActive(false); - } - } - - if (igl) - { - sint32 limY = refElmYReal + refElmHReal/2 - _GroupList->getYReal(); - if(_GroupList->getMaxH()>=limY && limY>=0) - { - igl->setY(refElmYReal + (refElmHReal - igl->getHReal()) / 2 - this->getYReal()); - igl->setActive(refElm->getActive()); - } - else - { - igl->setY(0); - igl->setActive(false); - } - } - } - } - } - - - sint32 SepLineNb = 0; - // set separator at the right position - for (i = 0; i < _ChildrenGroups.size(); ++i) - { - CInterfaceGroup *pIG = dynamic_cast(_ChildrenGroups[i]); - if (pIG == NULL) continue; - if (pIG->getId() != ID_MENU_SEPARATOR) continue; // is it a separator ? - - // set good width - /*sint32 sw = getW() - _LeftBorder - _RightBorder; - sw = std::max(sw, (sint32) 0); - pIG->setW(sw);*/ - - // Look for the next line of the menu that contains a separator - CInterfaceGroup *sep = NULL; - do - { - nlassert (SepLineNb < (sint32)_Lines.size()); - sep = _Lines[SepLineNb].Separator; - ++SepLineNb; - } - while (sep == NULL); - - // Setup the arrow at the right pos - pIG->setY (sep->getYReal() - getYReal()); - pIG->setActive(sep->getActive()); - } - CGroupFrame::updateCoords(); - - //_SelectionView->setW (this->getW()); - _SelectionView->setH (8); - _SelectionView->setY (4); - - - if (_Selected != -1 && _Lines[_Selected].ViewText != NULL) - { - CRGBA col= _GroupMenu->_HighLightOver; - - _SelectionView->setColor (col); - _SelectionView->setModulateGlobalColor(getModulateGlobalColor()); - - // get refElm and refElmYReal - GET_REF_ELM(_Selected) - - _SelectionView->setH (refElmHReal); - _SelectionView->setY (refElmYReal - this->getYReal()); - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::checkCoords() -{ - if (!_Active) return; - if (_GroupMenu == NULL) return; - - // if the mouse goes out the window, unselect all (because handleEvent may not be called) - sint xMouse= CWidgetManager::getInstance()->getPointer()->getX(); - sint yMouse= CWidgetManager::getInstance()->getPointer()->getY(); - if (!((xMouse >= _XReal) && - (xMouse < (_XReal + _WReal))&& - (yMouse > _YReal) && - (yMouse <= (_YReal+ _HReal)))) - _Selected= -1; - -// CViewRenderer &rVR = *CViewRenderer::getInstance(); - - // Highlight (background under the selection) - if (_Selected != -1) - { - // display hightlight - if(_GroupMenu->_HighLightOver.A > 0) - { - _SelectionView->setActive (true); - _SelectionView->invalidateCoords(); - } - else - { - _SelectionView->setActive (false); - } - } - else // no selection - { - _SelectionView->setActive (false); - } - - // Text color if grayed or not - for (sint32 i = 0; i < (sint32)_Lines.size(); ++i) - { - if (_Lines[i].ViewText) - { - if (_Lines[i].ViewText->getGrayed()) // Colors when the text is grayed - { - _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColorGrayed); - _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColorGrayed); - } - else - { - if (i == _Selected) // Colors when the text is selected - { - _Lines[i].ViewText->Over = true; - _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColorOver); - _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColorOver); - } - else // Or finally normal colors - { - _Lines[i].ViewText->Over = false; - _Lines[i].ViewText->setColor (_Lines[i].ViewText->OldColor); - _Lines[i].ViewText->setShadowColor (_Lines[i].ViewText->OldShadowColor); - } - } - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::draw() -{ - if (!_Active) return; - if (_GroupMenu == NULL) return; - CGroupFrame::draw(); -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupSubMenu::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (!_Active) - return false; - - sint32 textDYPos= 0; - if(_GroupList) - textDYPos= -(1+_GroupList->getSpace())/2; - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - _Selected = -1; - - // TODO First check sub menus that can be not in the area of this menu - - if (!((eventDesc.getX() >= _XReal) && - (eventDesc.getX() < (_XReal + _WReal))&& - (eventDesc.getY() > _YReal) && - (eventDesc.getY() <= (_YReal+ _HReal)))) - return false; - - uint32 i = 0; - for (i = 0; i < _Lines.size(); ++i) - { - if (_Lines[i].Selectable) - { - // get refElm and refElmYReal - GET_REF_ELM(i) - - if (refElm) - { - if (refElm->getActive() == true) - if ((eventDesc.getY() > refElmYReal) && - (eventDesc.getY() <= (refElmYReal + refElmHReal + _GroupList->getSpace()))) - { - _Selected = i; - break; - } - } - } - } - - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - // If a line is selected and the line is not grayed - if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed())) - { - - CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHName, - CWidgetManager::getInstance()->getCtrlLaunchingModal(), - _Lines[_Selected].AHParams ); - - if (_SubMenus[_Selected] != NULL) - { - openSubMenu (_Selected); - } - else - { - // if the menu hasn't triggered a new modal window, disable it - if (CWidgetManager::getInstance()->getModalWindow() == _GroupMenu) - { - if(_GroupMenu && _GroupMenu->getCloseSubMenuUsingPopModal()) - CWidgetManager::getInstance()->popModalWindow(); - else - CWidgetManager::getInstance()->disableModalWindow (); - } - } - } - } - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - // - if (_GroupList && _ScrollBar) - { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - if (isIn(eventDesc.getX(), eventDesc.getY())) - { - sint32 h = 0; - for (uint32 k = 0; k < _Lines.size(); ++k) - if (_Lines[k].ViewText) - { - // compute max height of widgets on the left of text - sint32 widgetMaxH = 0; - if (_Lines[k].UserGroupRight) widgetMaxH = _Lines[k].UserGroupRight->getHReal(); - if (_Lines[k].UserGroupLeft) widgetMaxH = std::max(widgetMaxH, _Lines[k].UserGroupLeft->getHReal()); - if (_Lines[k].CheckBox) widgetMaxH = std::max(widgetMaxH, _Lines[k].CheckBox->getHReal()); - if (_Lines[k].RightArrow) widgetMaxH = std::max(widgetMaxH, _Lines[k].RightArrow->getHReal()); - widgetMaxH = std::max(widgetMaxH, _Lines[k].ViewText->getHReal()); - h = widgetMaxH+_GroupList->getSpace(); - } - if (h == 0) h = 1; - _ScrollBar->moveTargetY(- eventDesc.getWheel() * h); - - hideSubMenus(); - - return true; - } - } - } - } - - return true; - } - return false; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CGroupSubMenu::getElement (const std::string &id) -{ - string sTmp = id.substr(0, _GroupMenu->getId().size()); - if (sTmp != _GroupMenu->getId()) return NULL; - - string sRest = id.substr(_GroupMenu->getId().size()+1, id.size()); - - // Iterate through the tree to see if sRest is present - CGroupSubMenu *pCurGSM = this; - while (!sRest.empty()) - { - // Get the first element of the sRest - string::size_type posid = sRest.find (":"); - - if (posid == string::npos) // Is there just one token to test ? - { - for (uint32 i = 0; i < pCurGSM->_Lines.size(); ++i) - if (sRest == pCurGSM->_Lines[i].Id) - return pCurGSM->_Lines[i].ViewText; - sRest = ""; - } - else // no a lot of token left - { - string sTok = sRest.substr (0, posid); - uint32 i = 0; - for (i = 0; i < pCurGSM->_Lines.size(); ++i) - if (sTok == pCurGSM->_Lines[i].Id) - break; - if (i == pCurGSM->_Lines.size()) - return NULL; - - // No sub-menus - if (pCurGSM->_SubMenus[i] == NULL) - { - // Get next token - sRest = sRest.substr (posid+1); - posid = sRest.find (":"); - if (posid == string::npos) - sTok = sRest; - else - sTok = sRest.substr (0, posid); - // Do we want left or right user group ? - if (pCurGSM->_Lines[i].UserGroupRight) - { - string sUGid = pCurGSM->_Lines[i].UserGroupRight->getId(); - sUGid = sUGid.substr(sUGid.rfind(':')+1,sUGid.size()); - if (sUGid == sTok) - { - CInterfaceElement *pIE = pCurGSM->_Lines[i].UserGroupRight->getElement(id); - return pIE; - } - } - if (pCurGSM->_Lines[i].UserGroupLeft) - { - string sUGid = pCurGSM->_Lines[i].UserGroupLeft->getId(); - sUGid = sUGid.substr(sUGid.rfind(':')+1,sUGid.size()); - if (sUGid == sTok) - { - CInterfaceElement *pIE = pCurGSM->_Lines[i].UserGroupLeft->getElement(id); - return pIE; - } - } - - return NULL; - } - else - { - pCurGSM = pCurGSM->_SubMenus[i]; - } - } - sRest = sRest.substr (posid+1); - } - - return NULL; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::addSeparator(const std::string &id) -{ - addSeparatorAtIndex((uint)_Lines.size(), id); -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::addSeparatorAtIndex(uint index, const std::string &id) -{ - if (index > _Lines.size()) - { - nlwarning("Bad index"); - return; - } - - // create the real separator. It may be larger than the group list, this is why we create a separate group - CInterfaceGroup *separator = CWidgetManager::parser->createGroupInstance("menu_separator", "", NULL, 0); - if (!separator) return; - separator->setId(ID_MENU_SEPARATOR); - addGroup(separator); - separator->setParent(this); - // create place holder group - CInterfaceGroup *ph = CWidgetManager::parser->createGroupInstance("menu_separator_empty", "", NULL, 0); - if (!ph) - { - delGroup(separator); - return; - } - _GroupList->addChildAtIndex(ph, index); - SSubMenuEntry tmp; - tmp.Id = id; - tmp.Separator = ph; - tmp.ViewText = NULL; - tmp.CheckBox = NULL; - tmp.RightArrow = NULL; - _Lines.insert(_Lines.begin() + index, tmp); - _SubMenus.insert(_SubMenus.begin() + index, (CGroupSubMenu*)NULL); - _GroupMenu->invalidateCoords(); -} - - -// ------------------------------------------------------------------------------------------------ -CViewTextMenu* CGroupSubMenu::addLine (const ucstring &name, const std::string &ah, - const std::string ¶ms, const std::string &id, - const std::string &cond, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ - ) -{ - SSubMenuEntry tmp; - - CViewTextMenu *pV = new CViewTextMenu(CViewBase::TCtorParam()); - - - pV->setCaseMode(_GroupMenu->getCaseMode()); - if (formatted) - { - pV->setMultiLine (true); - pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name); - } - else - { - pV->setText (name); - } - pV->setColor (_GroupMenu->_Color); - pV->setFontSize (_GroupMenu->_FontSize); - pV->setShadow (_GroupMenu->_Shadow); - pV->setCheckable(checkable); - pV->setChecked(checked); - pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); - - pV->OldColor = _GroupMenu->_Color; - pV->OldShadowColor = _GroupMenu->_ShadowColor; - pV->OldColorOver = _GroupMenu->_ColorOver; - pV->OldShadowColorOver = _GroupMenu->_ShadowColorOver; - pV->OldColorGrayed = _GroupMenu->_ColorGrayed; - pV->OldShadowColorGrayed = _GroupMenu->_ShadowColorGrayed; - - _GroupList->addChild (pV); - - CViewBitmap *checkBox = NULL; - - if (checkable) - { - checkBox = createCheckBox(checked); - checkBox->setTexture(texture); - pV->setCheckBox(checkBox); - } - - tmp.ViewText = pV; - tmp.Separator = NULL; - tmp.AHName = ah; - tmp.AHParams = params; - tmp.Cond = cond; - tmp.CheckBox = checkBox; - tmp.RightArrow = NULL; - if (id.empty()) - tmp.Id = NLMISC::toString (_Lines.size()); - else - tmp.Id = id; - - pV->setId(_GroupMenu->getId()+":"+tmp.Id); - - _Lines.push_back (tmp); - - // Add an empty sub menu by default - _SubMenus.push_back (NULL); - - _GroupMenu->invalidateCoords(); - - return pV; -} - -CViewTextMenu* CGroupSubMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, - const std::string ¶ms, const std::string &id /*=""*/, - const std::string &cond /*=std::string()*/, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/, bool formatted /*= false */ - ) -{ - if (index > _Lines.size()) - { - nlwarning("Bad index"); - return NULL; - } - SSubMenuEntry tmp; - CViewTextMenu *pV = new CViewTextMenu(CViewBase::TCtorParam()); - - - pV->setCaseMode(_GroupMenu->getCaseMode()); - - - if (formatted) - { - pV->setMultiLine (true); - pV->setMultiLineMaxWOnly (true); - pV->setTextFormatTaged (name); - } - else - { - pV->setText (name); - } - - pV->setColor (_GroupMenu->_Color); - pV->setFontSize (_GroupMenu->_FontSize); - pV->setShadow (_GroupMenu->_Shadow); - pV->setCheckable(checkable); - pV->setChecked(checked); - pV->setModulateGlobalColor(_GroupMenu->_ModulateGlobalColor); - - pV->OldColor = _GroupMenu->_Color; - pV->OldShadowColor = _GroupMenu->_ShadowColor; - pV->OldColorOver = _GroupMenu->_ColorOver; - pV->OldShadowColorOver = _GroupMenu->_ShadowColorOver; - pV->OldColorGrayed = _GroupMenu->_ColorGrayed; - pV->OldShadowColorGrayed = _GroupMenu->_ShadowColorGrayed; - - _GroupList->addChildAtIndex(pV, index); - - CViewBitmap *checkBox = NULL; - if (checkable) - { - checkBox = createCheckBox(checked); - checkBox->setTexture(texture); - pV->setCheckBox(checkBox); - } - - tmp.ViewText = pV; - tmp.Separator = NULL; - tmp.AHName = ah; - tmp.AHParams = params; - tmp.Cond = cond; - tmp.CheckBox = checkBox; - tmp.RightArrow = NULL; - - if (id.empty()) - tmp.Id = NLMISC::toString (_Lines.size()); - else - tmp.Id = id; - - pV->setId(getId()+":"+tmp.Id); - - _Lines.insert(_Lines.begin() + index, tmp); - - // Add an empty sub menu by default - _SubMenus.insert(_SubMenus.begin() + index, (CGroupSubMenu*)NULL); - - _GroupMenu->invalidateCoords(); - - return pV; -} - - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::removeLine(uint index) -{ - if (index >= _Lines.size()) - { - nlwarning("Bad index"); - return; - } - setUserGroupRight(index, NULL, false); // remove user group - setUserGroupLeft(index, NULL, false); // remove user group - // remove view (right arrow & checkbox) - if (_Lines[index].RightArrow) delView(_Lines[index].RightArrow); - if (_Lines[index].CheckBox) delView(_Lines[index].CheckBox); - if (_Lines[index].Separator) - { - // remove one separator group - for(uint k = 0; k < _ChildrenGroups.size(); ++k) - { - if (_ChildrenGroups[k]->getId() == ID_MENU_SEPARATOR) - { - delGroup(_ChildrenGroups[k]); - break; - } - } - } - // - _GroupList->setDelOnRemove(index, true); - _GroupList->delChild(index); - _Lines.erase(_Lines.begin() + index); - - //invalidate selection - _Selected = -1; - - if(_SubMenus[index]) - { - // reset it and his sons (recurs) - _SubMenus[index]->reset(); - // then delete it - _GroupMenu->delGroup(_SubMenus[index]); - } - _SubMenus.erase(_SubMenus.begin() + index); - _GroupMenu->invalidateCoords(); -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::openSubMenu (sint32 nb) -{ - hideSubMenus (); - _SubMenus[nb]->setActive (true); -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::hideSubMenus () -{ - for (uint32 i = 0; i < _SubMenus.size(); ++i) - if (_SubMenus[i] != NULL) - { - _SubMenus[i]->setActive (false); - _SubMenus[i]->hideSubMenus (); - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::reset() -{ - uint lineCount = (uint)_Lines.size(); - for(sint k = lineCount - 1; k >= 0; --k) - { - removeLine(k); - } -} - - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::removeAllUserGroups() -{ - for(uint k = 0; k < _Lines.size(); ++k) - { - setUserGroupRight(k, NULL, false); - setUserGroupLeft(k, NULL, false); - } -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup *CGroupSubMenu::getUserGroupRight(uint line) const -{ - if (line >= _Lines.size()) - { - nlwarning("bad index"); - return NULL; - } - return _Lines[line].UserGroupRight; -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceGroup *CGroupSubMenu::getUserGroupLeft(uint line) const -{ - if (line >= _Lines.size()) - { - nlwarning("bad index"); - return NULL; - } - return _Lines[line].UserGroupLeft; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership) -{ - if (line >= _Lines.size()) - { - nlwarning("bad index"); - return; - } - if (group && isChildGroup(group)) - { - nlwarning("Group inserted twice"); - return; - } - if (_Lines[line].UserGroupRight) - { - delGroup(_Lines[line].UserGroupRight, !_Lines[line].UserGroupRightOwnership); - } - _Lines[line].UserGroupRight = group; - _Lines[line].UserGroupRightOwnership = ownership; - if (group) - { - CViewBase *prevElem = _Lines[line].CheckBox ? _Lines[line].CheckBox : _Lines[line].RightArrow; - if (prevElem) - { - prevElem->setParentPosRef (Hotspot_MR); - prevElem->setPosRef (Hotspot_ML); - prevElem->setParentPos(group); - prevElem->setX(MENU_WIDGET_X); - prevElem->setY(0); - } - sint insertionOrder; - if (prevElem) - { - insertionOrder = getInsertionOrder(prevElem); - } - else - { - insertionOrder = -1; - } - addGroup(group, insertionOrder); - group->setParent(this); - group->setParentPos(_GroupList); - group->setParentPosRef (Hotspot_BR); - group->setPosRef (Hotspot_BL); - } - else - { - // restore all posref.. - CViewBase *prevElem = _Lines[line].CheckBox ? _Lines[line].CheckBox : _Lines[line].RightArrow; - if (prevElem) - { - prevElem->setParent (this); - prevElem->setParentPos (_GroupList); - prevElem->setParentPosRef (Hotspot_BR); - prevElem->setPosRef (Hotspot_BL); - prevElem->setX (MENU_WIDGET_X); - } - } - _GroupMenu->invalidateCoords(); -} - - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership) -{ - if (line >= _Lines.size()) - { - nlwarning("bad index"); - return; - } - if (group && isChildGroup(group)) - { - nlwarning("Group inserted twice"); - return; - } - if (_Lines[line].UserGroupLeft) - { - delGroup(_Lines[line].UserGroupLeft, !_Lines[line].UserGroupLeftOwnership); - } - _Lines[line].UserGroupLeft = group; - _Lines[line].UserGroupLeftOwnership = ownership; - if (group) - { - addGroup(group); - group->setParent(this); - group->setParentPos(this); - group->setParentPosRef (Hotspot_BL); - group->setPosRef (Hotspot_BL); - group->setX(LEFT_MENU_WIDGET_X); - } - - _GroupMenu->invalidateCoords(); -} - - -// ------------------------------------------------------------------------------------------------ -CGroupSubMenu *CGroupSubMenu::cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup /* = NULL */) const -{ - CGroupSubMenu *copyMenu = appendToMenu ? appendToMenu : new CGroupSubMenu(CViewText::TCtorParam()); - uint startSize = (uint)copyMenu->_Lines.size(); - copyMenu->_GroupMenu = newFather; - copyMenu->initOptions(initGroup); - copyMenu->_Lines.reserve(_Lines.size() + startSize); - copyMenu->_SubMenus.reserve(_SubMenus.size() + startSize); - // copy childrens - for(uint k = 0; k < _Lines.size(); ++k) - { - if (_Lines[k].Separator) - { - copyMenu->addSeparator(_Lines[k].Id); - } - else - { - std::string texture = std::string(); - if(_Lines[k].ViewText->getCheckBox()) - { - texture = _Lines[k].ViewText->getCheckBox()->getTexture(); - } - CViewTextMenu *pV = NULL; - pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond, - texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ()); - copyMenu->_Lines[k].Selectable = _Lines[k].Selectable; - pV->setGrayed(_Lines[k].ViewText->getGrayed()); - } - - // sub menu copy if there's one - if (_SubMenus[k] != NULL) - { - - if (copyMenu->_Lines.back().CheckBox) - { - copyMenu->_Lines.back().RightArrow = copyMenu->createRightArrow(copyMenu->_Lines.back().CheckBox, true); - } - else - { - copyMenu->_Lines.back().RightArrow = copyMenu->createRightArrow(copyMenu->_GroupList, false); - } - - - // and create the sub menu - copyMenu->_SubMenus[k + startSize] = _SubMenus[k]->cloneMenu(NULL, newFather, copyMenu); - } - } - if (!appendToMenu) - { - newFather->addGroup(copyMenu); - } - return copyMenu; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setActive(bool state) -{ - // check conditions - for(uint k = 0; k < _Lines.size(); ++k) - { - if (!_Lines[k].Cond.empty()) - { - CInterfaceExprValue result; - if (CInterfaceExpr::eval(_Lines[k].Cond, result)) - { - if (result.toBool()) - { - _Lines[k].ViewText->setGrayed(!result.getBool()); - } - } - } - } - - if(_ScrollBar && _GroupList) - _ScrollBar->setTrackPos(_GroupList->getHReal()); - - CGroupFrame::setActive(state); -} - -// ------------------------------------------------------------------------------------------------ -const std::string CGroupSubMenu::getActionHandler(uint lineIndex) const -{ - if (lineIndex > _Lines.size()) - { - nlwarning("Bad index"); - return 0; - } - return _Lines[lineIndex].AHName; -} - -// ------------------------------------------------------------------------------------------------ -const std::string CGroupSubMenu::getActionHandlerParam(uint lineIndex) const -{ - if (lineIndex > _Lines.size()) - { - nlwarning("Bad index"); - return 0; - } - return _Lines[lineIndex].AHParams; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable) -{ - if (lineIndex > _Lines.size()) - { - nlwarning("Bad index"); - return; - } - _Lines[lineIndex].Selectable = selectable; -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupSubMenu::getSelectable(uint lineIndex) const -{ - if (lineIndex > _Lines.size()) - { - nlwarning("Bad index"); - return 0; - } - return _Lines[lineIndex].Selectable; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setMaxVisibleLine(sint32 mvl) -{ - _MaxVisibleLine = mvl; -} - -// ------------------------------------------------------------------------------------------------ -const std::string &CGroupSubMenu::getLineId(uint index) -{ - if(index>=_Lines.size()) - { - static string nullString; - return nullString; - } - else - return _Lines[index].Id; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setGrayedLine(uint line, bool g) -{ - if(line<_Lines.size()) - { - if (_Lines[line].ViewText) - { - _Lines[line].ViewText->setGrayed(g); - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupSubMenu::setHiddenLine(uint line, bool h) -{ - if(line<_Lines.size()) - { - if (_Lines[line].ViewText) - { - _Lines[line].ViewText->setActive(!h); - } - } -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetNumLine(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getNumLine", 0); - ls.push((double) getNumLine()); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetSubMenu(CLuaState &ls) -{ - const char *funcName = "getSubMenu"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaAddSubMenu(CLuaState &ls) -{ - const char *funcName = "addSubMenu"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setSubMenu((uint) ls.toNumber(1), new CGroupSubMenu(CViewText::TCtorParam())); - CLuaIHM::pushUIOnStack(ls, getSubMenu((uint) ls.toNumber(1))); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetLineId(CLuaState &ls) -{ - const char *funcName = "getLineId"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - std::string id = getLineId((uint) ls.toNumber(1)); - CLuaIHM::push(ls, id); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetLineFromId(CLuaState &ls) -{ - const char *funcName = "getLineFromId"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); - ls.push((double) getLineFromId(ls.toString(1))); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaIsSeparator(CLuaState &ls) -{ - const char *funcName = "isSeparator"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - ls.push(isSeparator((uint) ls.toNumber(1))); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaAddLine(CLuaState &ls) -{ - const char *funcName = "addLine"; - CLuaIHM::checkArgCount(ls, funcName, 4); - CLuaIHM::checkArgTypeUCString(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - ucstring arg1; - nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1)); - addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls) -{ - const char *funcName = "addLineAtIndex"; - CLuaIHM::checkArgCount(ls, funcName, 5); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::checkArgTypeUCString(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); - ucstring arg2; - nlverify(CLuaIHM::getUCStringOnStack(ls, 2, arg2)); - addLineAtIndex((uint) ls.toNumber(1), arg2, ls.toString(3), ls.toString(4), ls.toString(5)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaAddSeparator(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "addSeparator", 0); - addSeparator(); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaAddSeparatorAtIndex(CLuaState &ls) -{ - const char *funcName = "addSeparatorAtIndex"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - addSeparatorAtIndex((uint) ls.toNumber(1)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaRemoveLine(CLuaState &ls) -{ - const char *funcName = "removeLine"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - removeLine((uint) ls.toNumber(1)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaSetUserGroupRight(CLuaState &ls) -{ - const char *funcName = "setUserGroupRight"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) - { - CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); - } - CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); - CInterfaceGroup *group = dynamic_cast(el); - if (el && !group) - { - CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); - } - setUserGroupRight((uint) ls.toNumber(1), group, true); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaSetUserGroupLeft(CLuaState &ls) -{ - const char *funcName = "setUserGroupLeft"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - if (!(CLuaIHM::isUIOnStack(ls, 2) || ls.isNil(2))) - { - CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); - } - CInterfaceElement *el = CLuaIHM::getUIOnStack(ls, 2); - CInterfaceGroup *group = dynamic_cast(el); - if (el && !group) - { - CLuaIHM::fails(ls, "%s : Group required as argument 2", funcName); - } - setUserGroupLeft((uint) ls.toNumber(1), group, true); - return 0; -} - - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetUserGroupRight(CLuaState &ls) -{ - const char *funcName = "getUserGroupRight"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CLuaIHM::pushUIOnStack(ls, getUserGroupRight((uint) ls.toNumber(1))); - return 1; -} - - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaGetUserGroupLeft(CLuaState &ls) -{ - const char *funcName = "getUserGroupLeft"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CInterfaceElement *pIE = getUserGroupLeft((uint) ls.toNumber(1)); - if (pIE) - { - CLuaIHM::pushUIOnStack(ls, pIE); - return 1; - } - else return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaSetMaxVisibleLine(CLuaState &ls) -{ - const char *funcName = "setMaxVisibleLine"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setMaxVisibleLine((uint) ls.toNumber(1)); - return 0; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupSubMenu::luaReset(CLuaState &ls) -{ - const char *funcName = "reset"; - CLuaIHM::checkArgCount(ls, funcName, 0); - reset(); - return 0; -} - - -// ------------------------------------------------------------------------------------------------ -// CGroupMenu -// ------------------------------------------------------------------------------------------------ - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupMenu, std::string, "menu"); - -// ------------------------------------------------------------------------------------------------ -CGroupMenu::CGroupMenu(const TCtorParam ¶m) -:CGroupModal(param) -{ - _Active = false; - _Color = CRGBA::White; - _ColorOver = CRGBA::White; - _ColorGrayed = CRGBA(128, 128, 128, 255); - _ShadowColor = CRGBA::Black; - _ShadowColorOver = CRGBA::Black; - _ShadowColorGrayed = CRGBA::Black; - _HighLightOver.set(128, 0, 0, 255); - _FontSize = 12; - _Shadow = false; - _ResizeFromChildH = _ResizeFromChildW = true; - _DisplayFrame = false; - _RootMenu = NULL; - _Space = 3; - _CaseMode = CaseUpper; - _Formatted = false; -} - -// ------------------------------------------------------------------------------------------------ -CGroupMenu::~CGroupMenu() -{ -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupMenu::parse (xmlNodePtr in, CInterfaceGroup *parentGroup) -{ - CXMLAutoPtr prop; - - _FontSize = 12; - - // override source menu options (if there's one) - if (!CGroupModal::parse(in, parentGroup)) - return false; - - - // see if this menu extends another menu - prop= (char*) xmlGetProp( in, (xmlChar*)"extends" ); - CGroupSubMenu *gmExtended = NULL; - if (prop) - { - - CGroupMenu *gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(prop)); - if (!gm) - { - gm = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:" + std::string((const char*)prop))); - } - if (gm) - { - gmExtended = gm->_RootMenu; - // copy group frame parameters - CGroupFrame::copyOptionFrom(*gm); - // copy basic datas - _Color = gm->_Color; - _ShadowColor = gm->_ShadowColor; - _Shadow = gm->_Shadow; - _FontSize = gm->_FontSize; - _ColorOver = gm->_ColorOver; - _ShadowColorOver = gm->_ShadowColorOver; - _HighLightOver = gm->_HighLightOver; - _ColorGrayed = gm->_ColorGrayed; - _ShadowColorGrayed = gm->_ShadowColorGrayed; - _Priority = gm->_Priority; - _ModulateGlobalColor = gm->_ModulateGlobalColor; - _Space = gm->_Space; - _CaseMode = gm->_CaseMode; - } - else - { - nlwarning("Can't get menu %s or bad type", (const char *) prop); - } - } - - - // Override the modal behaviour because of sub menus - ExitClickOut = true; - ExitClickL = false; - ExitClickR = false; - ExitKeyPushed = true; - _ResizeFromChildH = _ResizeFromChildW = true; - _DisplayFrame = false; - _Active = false; - _Formatted = false; - - // text colors - prop= (char*) xmlGetProp( in, (xmlChar*)"color" ); - if (prop) _Color = convertColor(prop); - - prop = (char*) xmlGetProp( in, (xmlChar*)"case_mode" ); - if (prop) - { - sint32 caseMode; - fromString((const char*)prop, caseMode); - _CaseMode = (TCaseMode)caseMode; - } - - prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color" ); - if (prop) _ShadowColor = convertColor(prop); - - prop= (char*) xmlGetProp( in, (xmlChar*)"color_over" ); - if (prop) _ColorOver = convertColor(prop); - - prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color_over" ); - if (prop) _ShadowColorOver = convertColor(prop); - - prop= (char*) xmlGetProp( in, (xmlChar*)"highlight_over" ); - if (prop) _HighLightOver = convertColor(prop); - - prop= (char*) xmlGetProp( in, (xmlChar*)"color_grayed" ); - if (prop) _ColorGrayed = convertColor(prop); - - prop= (char*) xmlGetProp( in, (xmlChar*)"shadow_color_grayed" ); - if (prop) _ShadowColorGrayed = convertColor(prop); - - prop = (char*) xmlGetProp (in, (xmlChar*)"space"); - if (prop) fromString((const char*)prop, _Space); - - // Text props - prop = (char*) xmlGetProp( in, (xmlChar*)"fontsize" ); - if (prop) fromString((const char*)prop, _FontSize); - - prop = (char*) xmlGetProp( in, (xmlChar*)"shadow" ); - if (prop) - _Shadow = convertBool(prop); - - prop = (char*) xmlGetProp( in, (xmlChar*)"formatted" ); - if (prop) - _Formatted = convertBool(prop); - - - // Read sons - xmlNodePtr cur; - cur = in->children; - if (_RootMenu != NULL) delete _RootMenu; - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - _RootMenu->parse (cur); - - prop = (char*) xmlGetProp( in, (xmlChar*)"max_visible_line" ); - if (prop) - { - sint32 maxVisibleLine; - fromString((const char*)prop, maxVisibleLine); - _RootMenu->setMaxVisibleLine(maxVisibleLine); - } - - if (gmExtended) - { - gmExtended->cloneMenu(_RootMenu, this); - } - return true; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::recurseDraw(CGroupSubMenu *pSubMenu) -{ - pSubMenu->draw(); - -// const vector &rGroups = pSubMenu->getGroups(); - - for (uint32 i = 0; i < pSubMenu->getNumLines(); i++) - { - CGroupSubMenu *pGSM = pSubMenu->getSubMenu(i); - if (pGSM != NULL) - { - recurseDraw(pGSM); - CViewRenderer::getInstance()->flush(); - } - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::draw () -{ - if (!_Active) return; - - // TEMP TEMP - //CViewRenderer &rVR = *CViewRenderer::getInstance(); - //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(255, 0, 0, 255) ); - - _RootMenu->_Active = true; - - if (SpawnOnMousePos) - recurseDraw(_RootMenu); - else - CGroupModal::draw(); -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupMenu::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (!_Active) - return false; - return CGroupModal::handleEvent (event); -} - -// ------------------------------------------------------------------------------------------------ -CInterfaceElement* CGroupMenu::getElement (const std::string &id) -{ - if (id == getId()) return this; - CInterfaceElement *pIE = _RootMenu->getElement(id); - if (pIE != NULL) - return pIE; - return CGroupModal::getElement(id); -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::setActive (bool state) -{ - if (SpawnOnMousePos) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - uint32 w,h; - rVR.getScreenSize(w,h); - setW(w); - setH(h); - setX(0); - setY(0); - _ResizeFromChildH = _ResizeFromChildW = false; - _RootMenu->_PosRef = Hotspot_TL; - _RootMenu->_ParentPosRef = Hotspot_BL; - } - - CGroupFrame::setActive (state); - - // must recompute now the pos of the menu - uint32 i; - for (i = 0; i < _ChildrenGroups.size(); ++i) - { - _ChildrenGroups[i]->setActive (true); - } - - CGroupModal::updateCoords(); - - // hide sub menus - _RootMenu->hideSubMenus(); -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupSubMenu::isSeparator(uint i) const -{ - if (i >= _SubMenus.size()) - { - nlassert("bad index"); - return false; - } - return _Lines[i].Separator != NULL; -} -// ------------------------------------------------------------------------------------------------ -bool CGroupMenu::isWindowUnder (sint32 x, sint32 y) -{ - for (uint32 i = 0; i < _ChildrenGroups.size(); ++i) - if (_ChildrenGroups[i]->getActive ()) - if (_ChildrenGroups[i]->isWindowUnder(x, y)) - return true; - - return false; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::addLine (const string &name, const string &ah, const string ¶ms, - const std::string &id/*=std::string()*/, - const std::string &cond /*= std::string()*/, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/ - ) -{ - if (_RootMenu == NULL) - { - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - addGroup (_RootMenu); - } - - _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::addLine(const ucstring &name, const std::string &ah, const std::string ¶ms, - const std::string &id /* = std::string()*/, - const std::string &cond /*= std::string()*/, const std::string &texture, - bool checkable /*= false*/, bool checked /*= false*/ - ) -{ - if (_RootMenu == NULL) - { - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - addGroup (_RootMenu); - } - _RootMenu->addLine (name, ah, params, id, cond, texture, checkable, checked, _Formatted); -} -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::addLineAtIndex(uint index, const ucstring &name, const std::string &ah, - const std::string ¶ms, const std::string &id /*=std::string()*/, - const std::string &cond /*=std::string()*/, const std::string &texture, - bool checkable /*=false*/, bool checked /*=false*/) -{ - if (_RootMenu == NULL) - { - _RootMenu = new CGroupSubMenu(CViewText::TCtorParam()); - _RootMenu->_GroupMenu = this; - addGroup (_RootMenu); - } - _RootMenu->addLineAtIndex(index, name, ah, params, id, cond, texture, checkable, checked, _Formatted); -} - - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::reset () -{ - if ( _RootMenu ) - { - _RootMenu->reset(); - invalidateCoords(); - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::setMinW(sint32 minW) -{ - if ( _RootMenu ) - { - _RootMenu->_GroupList->setMinW(minW-_RootMenu->getResizeFromChildWMargin()); - _RootMenu->_GroupList->setW(minW-_RootMenu->getResizeFromChildWMargin()); - _RootMenu->setW(minW-_RootMenu->getResizeFromChildWMargin()); - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::setGrayedLine(uint line, bool g) -{ - if ( _RootMenu ) - { - _RootMenu->setGrayedLine(line, g); - } -} - -// ------------------------------------------------------------------------------------------------ -uint CGroupMenu::getNumLine() const -{ - return _RootMenu ? _RootMenu->getNumLine() : 0; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::deleteLine(uint index) -{ - if (index > getNumLine()) - { - nlwarning("bad index"); - return; - } - _RootMenu->removeLine(index); -} - -// ------------------------------------------------------------------------------------------------ -const std::string CGroupMenu::getActionHandler(uint lineIndex) const -{ - return _RootMenu ? _RootMenu->getActionHandler(lineIndex) : ""; -} - -// ------------------------------------------------------------------------------------------------ -const std::string CGroupMenu::getActionHandlerParam(uint lineIndex) const -{ - return _RootMenu ? _RootMenu->getActionHandlerParam(lineIndex) : ""; -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/) -{ - if (_RootMenu) - { - _RootMenu->setUserGroupRight(line, gr, ownerShip); - } -} - -// ------------------------------------------------------------------------------------------------ -void CGroupMenu::setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/) -{ - if (_RootMenu) - { - _RootMenu->setUserGroupLeft(line, gr, ownerShip); - } -} - -// ------------------------------------------------------------------------------------------------ -int CGroupMenu::luaGetRootMenu(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "getRootMenu", 0); - CLuaIHM::pushUIOnStack(ls, getRootMenu()); - return 1; -} - -// ------------------------------------------------------------------------------------------------ -int CGroupMenu::luaSetMinW(CLuaState &ls) -{ - const char *funcName = "setMinW"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - setMinW((sint32) ls.toNumber(1)); - return 0; -} - - - - diff --git a/code/ryzom/client/src/interface_v3/group_menu.h b/code/ryzom/client/src/interface_v3/group_menu.h deleted file mode 100644 index 8ab8708e3..000000000 --- a/code/ryzom/client/src/interface_v3/group_menu.h +++ /dev/null @@ -1,396 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_GROUP_MENU_H -#define RZ_GROUP_MENU_H - -#include "nel/gui/interface_group.h" -#include "nel/gui/group_modal.h" -#include "nel/gui/group_submenu_base.h" -#include "nel/gui/view_text.h" -#include "nel/gui/ctrl_text_button.h" - -namespace NLGUI -{ - class CCtrlScroll; - class CViewBitmap; - class CGroupList; -} - -class CGroupMenu; - - -/** - * CViewTextMenu is an element of a sub menu - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CViewTextMenu : public CViewText -{ -public: - - CViewTextMenu(const TCtorParam ¶m) : CViewText(param) - { - _Grayed = false; - _Checked = false; - _Checkable = false; - _CheckBox = NULL; - Over = false; - } - - bool getGrayed() const; - void setGrayed (bool g); - bool getChecked() const { return _Checked; } - void setChecked(bool c); - bool getCheckable() const { return _Checkable; } - void setCheckable(bool c); - void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; } - CViewBitmap * getCheckBox() const { return _CheckBox; } - bool getFormatted () const { return getMultiLine (); } - - virtual sint32 getAlpha() const; - virtual void setAlpha (sint32 a); - - REFLECT_EXPORT_START(CViewTextMenu, CViewText) - REFLECT_BOOL("grayed", getGrayed, setGrayed); - REFLECT_BOOL("checked", getChecked, setChecked); - REFLECT_EXPORT_END - -public: - - bool Over; - NLMISC::CRGBA OldColor; - NLMISC::CRGBA OldShadowColor; - NLMISC::CRGBA OldColorOver; - NLMISC::CRGBA OldShadowColorOver; - NLMISC::CRGBA OldColorGrayed; - NLMISC::CRGBA OldShadowColorGrayed; - -private: - CViewBitmap *_CheckBox; - bool _Grayed; - bool _Checked; - bool _Checkable; -}; - -/** - * CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu) - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ - -class CGroupSubMenu : public CGroupSubMenuBase -{ -public: - - CGroupSubMenu(const TCtorParam ¶m); - virtual ~CGroupSubMenu(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL); - - virtual void checkCoords(); - - virtual void updateCoords (); - - virtual void draw (); - - virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); - - virtual CInterfaceElement* getElement (const std::string &id); - - // retrieve the index of a line from its id (-1 if not found) - sint getLineFromId(const std::string &id); - - CViewTextMenu* addLine (const ucstring &name, const std::string &ah, - const std::string ¶ms, const std::string &id="", - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false, bool formatted = false - ); - CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah, - const std::string ¶ms, const std::string &id="", - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false, bool formatted = false - ); - void addSeparator(const std::string &id = ""); - void addSeparatorAtIndex(uint index, const std::string &id = ""); - - - uint getNumLine() const { return (uint)_Lines.size(); } - void removeLine(uint index); - const std::string getActionHandler(uint lineIndex) const; - const std::string getActionHandlerParam(uint lineIndex) const; - - void openSubMenu (sint32 nb); - - void hideSubMenus (); - - // reset all entries of the sub menu - void reset(); - - virtual void setActive (bool state); - - // Tell if the line is a separator or not - bool isSeparator (uint i) const; - - /** Set a user defined group at the given line - * 'ownership' tells whether this menu should remove the group when it is deleted - * Setting a user group on a line with a separator is illegal - */ - void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership); - CInterfaceGroup *getUserGroupRight(uint line) const; - // - void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership); - CInterfaceGroup *getUserGroupLeft(uint line) const; - - void removeAllUserGroups(); - - uint getNumLines() const { return (uint)_Lines.size(); } - - // return pointer to submenu or NULL if there's none - CGroupSubMenu *getSubMenu(uint index) const; - void setSubMenu(uint index, CGroupSubMenu *sub); - - // if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup) - void setSelectable(uint lineIndex, bool selectable); - bool getSelectable(uint lineIndex) const; - - // Gray a line. - void setGrayedLine(uint line, bool g); - - // Hide a line. - void setHiddenLine(uint line, bool h); - - // Max Visible Line (-1 == no limit) - void setMaxVisibleLine(sint32 mvl); - sint32 getMaxVisibleLine() { return _MaxVisibleLine; } - - // Get the Line Id (not the full Id) - const std::string &getLineId(uint index); - - int luaGetNumLine(CLuaState &ls); - int luaGetSubMenu(CLuaState &ls); - int luaAddSubMenu(CLuaState &ls); - int luaGetLineId(CLuaState &ls); - int luaGetLineFromId(CLuaState &ls); - int luaIsSeparator(CLuaState &ls); - int luaAddLine(CLuaState &ls); - int luaAddLineAtIndex(CLuaState &ls); - int luaAddSeparator(CLuaState &ls); - int luaAddSeparatorAtIndex(CLuaState &ls); - int luaRemoveLine(CLuaState &ls); - int luaSetUserGroupRight(CLuaState &ls); - int luaGetUserGroupRight(CLuaState &ls); - int luaSetUserGroupLeft(CLuaState &ls); - int luaGetUserGroupLeft(CLuaState &ls); - int luaReset(CLuaState &ls); - int luaSetMaxVisibleLine(CLuaState &ls); - // - REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase) - REFLECT_LUA_METHOD("getNumLine", luaGetNumLine); - REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index - REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found - REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu); - REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu); - REFLECT_LUA_METHOD("isSeparator", luaIsSeparator); - REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id - REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id - REFLECT_LUA_METHOD("addSeparator", luaAddSeparator); - REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex); - REFLECT_LUA_METHOD("removeLine", luaRemoveLine); - REFLECT_LUA_METHOD("reset", luaReset); - REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr - REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line - REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr - REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line - REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine); - REFLECT_EXPORT_END - -protected: - - struct SSubMenuEntry - { - CViewTextMenu *ViewText; // Backup of the children that are in grouplist - CInterfaceGroup *Separator; - std::string AHName; - std::string AHParams; - std::string Id; - std::string Cond; // condition to know if the entry is grayed - CViewBitmap *CheckBox; - CViewBitmap *RightArrow; - CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow - CInterfaceGroup *UserGroupLeft; - bool UserGroupRightOwnership; - bool UserGroupLeftOwnership; - bool Selectable; - sint32 HReal; // max H of the view text and the other user group - sint32 TextDY; // Y of the view text to set - SSubMenuEntry() - { - ViewText = NULL; - Separator = NULL; - CheckBox = NULL; - RightArrow = NULL; - UserGroupRight = NULL; - UserGroupLeft = NULL; - UserGroupRightOwnership = false; - Selectable = true; - HReal= 0; - TextDY= 0; - } - }; - -protected: - - CGroupList *_GroupList; - CCtrlScroll *_ScrollBar; - CViewBitmap *_SelectionView; - std::vector _Lines; - std::vector _SubMenus; - - CGroupMenu *_GroupMenu; // Master parent - sint32 _Selected; - - sint32 _MaxVisibleLine; // -1 == no limit - - friend class CGroupMenu; -private: - /** Clone this menu, and set its new father - * If appendToMenu is NULL, the menu is just copied - * otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu. - * NB : user groups are not duplicated - */ - CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const; - void initOptions(CInterfaceGroup *parent); - CViewBitmap *createCheckBox(bool checked); - CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center); -}; - -/** - * class describing a menu composed of one or more CGroupListSubMenu - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CGroupMenu : public CGroupModal -{ - -public: - - CGroupMenu(const TCtorParam ¶m); - virtual ~CGroupMenu(); - - TCaseMode getCaseMode() { return _CaseMode; } - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - virtual void draw (); - - void recurseDraw(CGroupSubMenu *pSubMenu); - - virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); - - virtual CInterfaceElement* getElement (const std::string &id); - - virtual void setActive (bool state); - - virtual bool isWindowUnder (sint32 x, sint32 y); - - // add line with a string, for backward compatibility - void addLine (const std::string &name, const std::string &ah, const std::string ¶ms, - const std::string &id = std::string(), - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false); - uint getNumLine() const; - void deleteLine(uint index); - const std::string getActionHandler(uint lineIndex) const; - const std::string getActionHandlerParam(uint lineIndex) const; - - - void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", - const std::string &id = std::string(), - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false - ); - void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string ¶ms = "", - const std::string &id = std::string(), - const std::string &cond = std::string(), const std::string &texture="", - bool checkable = false, bool checked = false - ); - void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true); - void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true); - - // clear all sub menus - void reset (); - - // set the minW of the RootMenu. - void setMinW(sint32 minW); - - // Gray a line on the RootMenu - void setGrayedLine(uint line, bool g); - - CGroupSubMenu *getRootMenu() const { return _RootMenu; } - - // Max Visible Line (-1 == no limit) - void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); } - sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); } - - // special for menu launched from a modal.... - bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;} - void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;} - - int luaGetRootMenu(CLuaState &ls); - int luaSetMinW(CLuaState &ls); - - REFLECT_EXPORT_START(CGroupMenu, CGroupModal) - REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu); - REFLECT_LUA_METHOD("setMinW", luaSetMinW); - REFLECT_EXPORT_END - -protected: - TCaseMode _CaseMode; - - CGroupSubMenu *_RootMenu; - - // Text lookup - NLMISC::CRGBA _Color; - NLMISC::CRGBA _ShadowColor; - - bool _CloseSubMenuUsingPopModal; - bool _Shadow; - bool _Formatted; - uint8 _Space; - sint32 _FontSize; - - NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it - NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it - NLMISC::CRGBA _HighLightOver; // Background color of the selection - - NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable - NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable - - friend class CGroupSubMenu; -}; - - -#endif // RZ_GROUP_MENU_H - -/* End of group_menu.h */ - - diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 16a323fa4..63a120944 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -25,7 +25,7 @@ #include "nel/gui/view_text.h" #include "dbctrl_sheet.h" #include "nel/gui/group_container.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "group_html.h" #include "../init_main_loop.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 80991490e..10ca54ea3 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -61,7 +61,7 @@ #include "dbctrl_sheet.h" // Group #include "nel/gui/group_list.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/gui/group_container.h" #include "nel/gui/group_modal.h" #include "nel/gui/group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 5bd8c98f8..d43629bb7 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -70,10 +70,10 @@ namespace NLGUI { class CInterfaceOptions; class CGroupContainer; + class CGroupMenu; } class CInterfaceAnim; -class CGroupMenu; /** * class managing the interface diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp index 11cdc1a91..f4e0fe5cd 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp @@ -21,7 +21,7 @@ #include "nel/gui/interface_options.h" #include "interface_manager.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/misc/xml_auto_ptr.h" #include "../net_manager.h" #include "../sheet_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index c896d1538..be160de5d 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -67,7 +67,7 @@ #include "group_modal_get_key.h" #include "nel/gui/group_list.h" #include "nel/gui/group_tree.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/gui/group_container.h" #include "nel/gui/group_scrolltext.h" #include "nel/gui/group_editbox.h" diff --git a/code/ryzom/client/src/interface_v3/interface_pointer.h b/code/ryzom/client/src/interface_v3/interface_pointer.h index cc057c235..33aeea4e8 100644 --- a/code/ryzom/client/src/interface_v3/interface_pointer.h +++ b/code/ryzom/client/src/interface_v3/interface_pointer.h @@ -28,6 +28,7 @@ namespace NLGUI class CCtrlBaseButton; class CInterfaceGroup; class CViewText; + class CViewTextMenu; class CCtrlTextButton; class CGroupContainer; } @@ -64,7 +65,7 @@ typedef CInterfacePtr::TInterfacePtr CInterfaceElementPtr; typedef CInterfacePtr::TInterfacePtr CInterfaceGroupPtr; typedef CInterfacePtr::TInterfacePtr CCtrlTextButtonPtr; typedef CInterfacePtr::TInterfacePtr CViewTextPtr; -typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; +typedef CInterfacePtr::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr::TInterfacePtr CCtrlBasePtr; typedef CInterfacePtr::TInterfacePtr CCtrlBaseButtonPtr; typedef CInterfacePtr::TInterfacePtr CGroupContainerPtr; diff --git a/code/ryzom/client/src/interface_v3/inventory_manager.cpp b/code/ryzom/client/src/interface_v3/inventory_manager.cpp index dd3664d1f..e97e30716 100644 --- a/code/ryzom/client/src/interface_v3/inventory_manager.cpp +++ b/code/ryzom/client/src/interface_v3/inventory_manager.cpp @@ -24,7 +24,7 @@ #include "bot_chat_page_trade.h" #include "bot_chat_page_all.h" #include "nel/gui/group_container.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/misc/cdb_leaf.h" #include "nel/misc/cdb_branch.h" #include "list_sheet_base.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index 1a7593031..c682ee824 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -27,7 +27,7 @@ #include "chat_window.h" #include "../entity_animation_manager.h" #include "nel/gui/group_editbox.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "../client_chat_manager.h" #include "../string_manager_client.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index b6d5a8ba8..b2c526b6b 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -25,7 +25,7 @@ #include "nel/gui/view_bitmap.h" #include "view_radar.h" #include "nel/gui/group_submenu_base.h" -#include "group_menu.h" +#include "nel/gui/group_menu.h" #include "nel/gui/ctrl_base.h" #include "nel/gui/interface_group.h" #include "nel/gui/group_frame.h" From 59c52c713c63152438a6e041191dfe497326fc5c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 03:29:20 +0200 Subject: [PATCH 102/339] CHANGED: #1471 CGroupTab no longer depends on CInterfaceManager and the Ryzom game client time data. --- .../client/src/interface_v3/group_tab.cpp | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp index e9fe48a2e..c91b2f217 100644 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ b/code/ryzom/client/src/interface_v3/group_tab.cpp @@ -14,18 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "group_tab.h" #include "nel/misc/xml_auto_ptr.h" -#include "../time_client.h" -#include "interface_manager.h" - #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" - +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/view_text.h" using namespace std; using namespace NLMISC; @@ -131,10 +125,8 @@ void CGroupTab::addTab(CCtrlTabButton * tabB) selectFromCtrl(tabB); if(_HideOutTabs && !_AHOnChange.empty()) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } + } // *************************************************************************** @@ -225,10 +217,8 @@ void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) updateCoords(); if(_HideOutTabs && !_AHOnChange.empty()) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } + } // *************************************************************************** @@ -245,10 +235,8 @@ int CGroupTab::luaAddTab(CLuaState &ls) updateCoords(); if(_HideOutTabs && !_AHOnChange.empty()) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } + } return 0; } @@ -332,10 +320,7 @@ void CGroupTab::removeTab(sint index) select(_FirstTabIndex); if(!_AHOnChange.empty()) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } } } @@ -503,10 +488,8 @@ void CGroupTab::updateFirstTabButton() } if(!_AHOnChange.empty() && ((oldFirstTabIndex!=_FirstTabIndex) || (oldLastTabIndex!=_LastTabIndex))) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } + } // *************************************************************************** @@ -797,9 +780,10 @@ bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) if (_Blinking) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); - if ((T1 - _BlinkDate) > dbclickDelay) + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + if (( times.thisFrameMs - _BlinkDate) > dbclickDelay) { if (_BlinkState) { @@ -812,7 +796,7 @@ bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); } _BlinkState = !_BlinkState; - _BlinkDate = T1; + _BlinkDate = times.thisFrameMs; } } } @@ -822,7 +806,6 @@ bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) // *************************************************************************** void CCtrlTabButton::setBlink (bool b) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (b) { if (!_Blinking) From 308fa1d0ea212a7faa2101d108763193722235aa Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 03:53:15 +0200 Subject: [PATCH 103/339] CHANGED: CGroupTab and CCtrlTabButton are now part of the NELGUI library and are under the NLGUI namespace. --- code/nel/include/nel/gui/group_tab.h | 180 ++++ code/nel/src/gui/group_tab.cpp | 852 ++++++++++++++++++ code/ryzom/client/src/client_chat_manager.cpp | 2 +- .../src/interface_v3/bot_chat_page_trade.cpp | 2 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../client/src/interface_v3/chat_window.h | 3 +- .../client/src/interface_v3/group_tab.cpp | 847 ----------------- .../ryzom/client/src/interface_v3/group_tab.h | 177 ---- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 2 +- .../register_interface_elements.cpp | 2 +- 11 files changed, 1040 insertions(+), 1031 deletions(-) create mode 100644 code/nel/include/nel/gui/group_tab.h create mode 100644 code/nel/src/gui/group_tab.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_tab.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_tab.h diff --git a/code/nel/include/nel/gui/group_tab.h b/code/nel/include/nel/gui/group_tab.h new file mode 100644 index 000000000..1836ed797 --- /dev/null +++ b/code/nel/include/nel/gui/group_tab.h @@ -0,0 +1,180 @@ +// Ryzom - MMORPG Framework +// 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 NL_GROUP_TAB_H +#define NL_GROUP_TAB_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/ctrl_text_button.h" + +namespace NLGUI +{ + class CCtrlTabButton; + + + + // *************************************************************************** + /** + * Group handling Ctrl Tab, to easily simulate Tab ctrl. + * NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order: + * - in this group + * - in the parent group + * - in global + * \author Lionel Berenguier + * \author Nevrax France + * \date 2003 + */ + class CGroupTab : public CInterfaceGroup + { + public: + + /// Constructor + CGroupTab(const TCtorParam ¶m); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + + // select the ctrl tab. -1 will invalidate all. + void select(sint index); + sint getSelection() const; + + // select with a CCtrlTabButton ptr + void selectFromCtrl(CCtrlTabButton *button); + + // select a default activated tab, if the current is a special ctrlTab + void selectDefault(CCtrlTabButton *ifSelectionIs); + + // select a default activated tab, if the current is hid + void selectDefaultIfCurrentHid(); + + // add new tab + void addTab(CCtrlTabButton *tabB); + void addTab(CCtrlTabButton *tabB, sint index); + int luaAddTab(CLuaState &ls); + int luaAddTabWithOrder(CLuaState &ls); + + // remove selected tab + void removeTab(sint index); + int luaRemoveTab(CLuaState &ls); + + // remove all tabs + void removeAll(); + int luaRemoveAll(CLuaState &ls); + + // tab number + void setTabButtonNb(sint32 /* val */){} + sint32 getTabButtonNb() const {return (sint32)_Buttons.size();} + + // selection index + void setIndexSelection(sint32 val){select((sint)val);} + sint32 getIndexSelection() const {return (sint32)_NextSelection;} + + // selection index + void setAssociatedGroupSelection(const std::string & /* assG */){} + std::string getAssociatedGroupSelection() const; + + // get group from index + CInterfaceGroup* getGroup(sint index); + int luaGetGroup(CLuaState &ls); + + // get tab from index + CCtrlTabButton* getTabButton(sint index); + int luaGetTabButton(CLuaState &ls); + + // first showed tab button + sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;} + + // last showed tab button + sint32 getLastTabButton() const {return (sint32)_LastTabIndex;} + + // update showed tab buttons on function of GroupTab width + void updateFirstTabButton(); + int luaShowTabButton(CLuaState &ls); + + void dummySet(sint32 /* value */){} + + REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup) + REFLECT_LUA_METHOD("addTab", luaAddTab) + REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder) + REFLECT_LUA_METHOD("removeTab", luaRemoveTab) + REFLECT_LUA_METHOD("removeAll", luaRemoveAll) + REFLECT_LUA_METHOD("getGroup", luaGetGroup) + REFLECT_LUA_METHOD("getTabButton", luaGetTabButton) + REFLECT_LUA_METHOD("showTabButton", luaShowTabButton) + REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb) + REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection) + REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet) + REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet) + REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection) + REFLECT_EXPORT_END + + private: + + std::vector _Buttons; // can't be NULL. + std::vector _Groups; // may be NULL + sint _Selection; + sint _NextSelection; + sint _BaseRenderLayer; + bool _Setuped; + bool _HideOutTabs; + sint _FirstTabIndex; + sint _LastTabIndex; + + std::string _AHOnChange; + std::string _ParamsOnChange; + + void setup(); + }; + + // *************************************************************************** + /** + * Used with CGroupTab + */ + class CCtrlTabButton : public CCtrlTextButton + { + public: + + CCtrlTabButton(const TCtorParam ¶m); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + virtual void setActive(bool state); + + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + void setBlink (bool b); + + std::string _AssociatedGroup; + IActionHandler *_AHOnLeftClick2; + + private: + + sint32 _DefaultX; + bool _Blinking; + NLMISC::CRGBA _TextColorNormalBlink; + bool _TextModulateGlobalColorNormalBlink; + sint64 _BlinkDate; + bool _BlinkState; + }; + +} + +#endif // NL_GROUP_TAB_H + +/* End of group_tab.h */ diff --git a/code/nel/src/gui/group_tab.cpp b/code/nel/src/gui/group_tab.cpp new file mode 100644 index 000000000..a286d661f --- /dev/null +++ b/code/nel/src/gui/group_tab.cpp @@ -0,0 +1,852 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_tab.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/view_text.h" + +using namespace std; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CGroupTab, std::string, "tab"); + +namespace NLGUI +{ + + // *************************************************************************** + CGroupTab::CGroupTab(const TCtorParam ¶m) + : CInterfaceGroup(param) + { + _Selection= -1; + _NextSelection = -1; + _BaseRenderLayer= 0; + _Setuped= false; + _HideOutTabs = false; + _FirstTabIndex = -1; + _LastTabIndex = -1; + } + + + // *************************************************************************** + bool CGroupTab::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if( !CInterfaceGroup::parse(cur, parentGroup) ) + return false; + + CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"hide_out_tabs")); + if (prop) + { + _HideOutTabs = convertBool(prop); + } + + prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange" ); + if (prop) _AHOnChange = (const char *) prop; + prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange_params" ); + if (prop) _ParamsOnChange = (const char *) prop; + + return true; + } + + // *************************************************************************** + void CGroupTab::setup() + { + if(_Setuped) + return; + _Setuped= true; + + _Buttons.clear(); + _Groups.clear(); + + /* Buttons must be named tab0,tab1,tab2... + and tab_array0_0, tab_array0_1 .... (for vector of tab) + Only 10 tab array are allowed + */ + for(sint tabArrayIndex= -1;tabArrayIndex<10;tabArrayIndex++) + { + // prefix according to array or not + string prefix; + if(tabArrayIndex==-1) + prefix= "tab"; + else + prefix= toString("tab_array%d_", tabArrayIndex); + + // for all tab of this type (standard tab or array of tab), find the Buttons and groups. + uint tabIndex=0; + for(;;) + { + // find the ctrl named "tab0" + CCtrlTabButton *but= dynamic_cast(getCtrl(toString("%s%d", prefix.c_str(), tabIndex))); + if(!but) + break; + + // find the associated group + CInterfaceGroup *pGroup = NULL; + CInterfaceGroup *pFather = this; + + while ((pGroup == NULL) && (pFather != NULL)) + { + pGroup = pFather->getGroup(but->_AssociatedGroup); + pFather = pFather->getParent(); + } + + // add to the button and group list + _Buttons.push_back(but); + _Groups.push_back(pGroup); + + // try next + tabIndex++; + } + } + + // at the first setup, select by default the 1st + if(_Selection<0) + select(0); + } + + // *************************************************************************** + void CGroupTab::addTab(CCtrlTabButton * tabB) + { + addCtrl(tabB); + _Setuped = false; + updateCoords(); + selectFromCtrl(tabB); + + if(_HideOutTabs && !_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + + } + + // *************************************************************************** + void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) + { + if(index<(sint)_Buttons.size() && index>=0) + { + vector buttons = _Buttons; + + for(sint i=0;i<(sint)_Buttons.size();i++) + delCtrl(_Buttons[i], true); + + _Setuped = false; + updateCoords(); + + uint count=0; + CCtrlTabButton* lastTab=NULL; + for(sint i=0;i<(sint)buttons.size();i++) + { + if(i==index) + { + tabB->setId("tab" + NLMISC::toString(count)); + tabB->setParentPos(lastTab); + if(i==0) + tabB->setParentPosRef(Hotspot_TL); + else + tabB->setParentPosRef(Hotspot_TR); + tabB->setPosRef(Hotspot_TL); + + addCtrl(tabB); + lastTab = tabB; + count++; + } + + buttons[i]->setId("tab" + NLMISC::toString(count)); + buttons[i]->setParentPos(lastTab); + if(i==0 && index!=0) + buttons[i]->setParentPosRef(Hotspot_TL); + else + buttons[i]->setParentPosRef(Hotspot_TR); + buttons[i]->setPosRef(Hotspot_TL); + + addCtrl(buttons[i]); + + lastTab = buttons[i]; + count++; + } + + _Setuped = false; + updateCoords(); + + // we have added a new button in first position + // then it must recover the reference + if(index==0) + { + CCtrlTabButton * tab0 = _Buttons[0]; + for(uint i=0; i<_Buttons.size(); ++i) + _Buttons[i]->initRBRefFromRadioButton(tab0); + + select(_Selection); + } + else + { + CCtrlTabButton * tab0 = _Buttons[0]; + _Buttons[index]->initRBRefFromRadioButton(tab0); + } + } + else + { + tabB->setId(string("tab") + NLMISC::toString(_Buttons.size())); + + if(_Buttons.size()==0) + { + tabB->setParentPos(NULL); + tabB->setParentPosRef(Hotspot_TL); + } + else + { + tabB->setParentPos(_Buttons[_Buttons.size()-1]); + tabB->setParentPosRef(Hotspot_TR); + } + tabB->setPosRef(Hotspot_TL); + + addCtrl(tabB); + } + + _Setuped = false; + updateCoords(); + + if(_HideOutTabs && !_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + + } + + // *************************************************************************** + int CGroupTab::luaAddTab(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CGroupTab::addTab", 1); + CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (tabB) + { + // don't use addTab to avoid selection of new tab + addCtrl(tabB); + + _Setuped = false; + updateCoords(); + + if(_HideOutTabs && !_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + + } + return 0; + } + + // *************************************************************************** + int CGroupTab::luaAddTabWithOrder(CLuaState &ls) + { + const char *funcName = "addTabWithOrder"; + CLuaIHM::checkArgCount(ls, funcName, 2); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + + CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); + if (tabB) + { + // don't use addTab to avoid selection of new tab + addTab(tabB, (sint) ls.toNumber(2)); + } + return 0; + } + + // *************************************************************************** + void CGroupTab::removeTab(sint index) + { + if(!(index>=0 && index<(sint)_Buttons.size())) + return; + + vector buttons = _Buttons; + + for(sint i=0;i<(sint)_Buttons.size();i++) + { + bool deleteElt = (i!=index); + CViewText* tabVT = _Buttons[i]->getViewText(); + if(tabVT && !deleteElt) + delView(tabVT, deleteElt); + + delCtrl(_Buttons[i], deleteElt); + + if(!deleteElt) + (_Groups[i]->getParent())->delGroup(_Groups[i], deleteElt); + } + _Setuped = false; + updateCoords(); + + uint count=0; + CCtrlTabButton* lastTab = NULL; + for(sint i=0;i<(sint)buttons.size();i++) + { + if(i!=index) + { + buttons[i]->setId("tab"+NLMISC::toString(count)); + buttons[i]->setParentPos(lastTab); + if((i==0) || (index==0 && i==1)) + buttons[i]->setParentPosRef(Hotspot_TL); + else + _Buttons[i]->setParentPosRef(Hotspot_TR); + + buttons[i]->setPosRef(Hotspot_TL); + + lastTab = buttons[i]; + addCtrl(buttons[i]); + count++; + } + } + + _Setuped = false; + updateCoords(); + + // we have removed the first button which is the only one to own the reference + // then the new first button recovers the reference + if(index==0) + { + CCtrlTabButton * tab0 = _Buttons[0]; + for(uint i=0; i<_Buttons.size(); ++i) + _Buttons[i]->initRBRefFromRadioButton(tab0); + + select(_Selection); + } + + if(_HideOutTabs) + { + select(_FirstTabIndex); + + if(!_AHOnChange.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + } + } + + // *************************************************************************** + + int CGroupTab::luaRemoveTab(CLuaState &ls) + { + const char *funcName = "removeTab"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + removeTab((uint) ls.toNumber(1)); + return 0; + } + + // *************************************************************************** + void CGroupTab::removeAll() + { + for(sint i=0;i<(sint)_Buttons.size();i++) + { + CViewText* tabVT = _Buttons[i]->getViewText(); + if(tabVT) + delView(tabVT, false); + + delCtrl(_Buttons[i], false); + (_Groups[i]->getParent())->delGroup(_Groups[i], false); + } + + _Setuped = false; + updateCoords(); + } + + // *************************************************************************** + + int CGroupTab::luaRemoveAll(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "CGroupTab::removeAll", 0); + removeAll(); + return 0; + } + + // *************************************************************************** + CCtrlTabButton* CGroupTab::getTabButton(sint index) + { + if(index>=0 && index<(sint)_Buttons.size()) + { + return _Buttons[index]; + } + return NULL; + } + + // *************************************************************************** + int CGroupTab::luaGetTabButton(CLuaState &ls) + { + const char *funcName = "getTabButton"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1)); + if(tab != NULL) + { + CLuaIHM::pushUIOnStack(ls, tab); + return 1; + } + return 0; + } + + // *************************************************************************** + void CGroupTab::updateFirstTabButton() + { + if(!_HideOutTabs || (_Selection<0) || (_Buttons.size()==0) || (_Parent->getWReal()<0) + || _FirstTabIndex>=(sint)_Buttons.size()) + return; + + sint oldFirstTabIndex = _FirstTabIndex; + sint oldLastTabIndex = _LastTabIndex; + + if(_FirstTabIndex<0) + { + for(uint i=0; i<_Buttons.size(); i++) + { + CCtrlTabButton * tab = _Buttons[i]; + if(tab->getActive()) + { + _FirstTabIndex = i; + break; + } + } + } + + sint selection = _Selection; + if(selection>=(sint)_Buttons.size()) + selection = _FirstTabIndex; + + if(selection < _FirstTabIndex) + _FirstTabIndex = selection; + + sint32 maxWidth = _Parent->getWReal(); + sint32 buttonsWidth = 0; + _LastTabIndex = 0; + + // desactive first tabs + for(uint i=0; i<(uint)_FirstTabIndex; i++) + { + CCtrlTabButton * tab = _Buttons[i]; + if(tab->getActive()) + tab->setActive(false); + } + + + // active tabs from _FirstTabIndex and search for last showed tab + for(uint i=_FirstTabIndex; i<_Buttons.size(); i++) + { + CCtrlTabButton * tab = _Buttons[i]; + sint32 tabWidth = tab->getWMax(); + if(buttonsWidth+tabWidth <= maxWidth) + { + buttonsWidth += tabWidth; + if(!tab->getActive()) + tab->setActive(true); + _LastTabIndex = i; + } + else + break; + } + + // check if selected tab is in showed tabs + if(_LastTabIndex < selection) + { + for(uint i=_LastTabIndex+1; i<=(uint)selection; i++) + { + CCtrlTabButton * tab = _Buttons[i]; + buttonsWidth += tab->getWMax(); + if(!tab->getActive()) + tab->setActive(true); + } + + while(buttonsWidth>maxWidth) + { + CCtrlTabButton * tab = _Buttons[_FirstTabIndex]; + buttonsWidth -= tab->getWMax(); + _FirstTabIndex++; + if(tab->getActive()) + tab->setActive(false); + } + } + + // add tabs before the "_FirstTabIndex" one if it remains place + while(buttonsWidth0) + { + CCtrlTabButton * tab = _Buttons[_FirstTabIndex-1]; + buttonsWidth += tab->getWMax(); + if(buttonsWidth<=maxWidth) + { + _FirstTabIndex--; + if(!tab->getActive()) + tab->setActive(true); + } + } + + // desactive last tabs + for(uint i=_LastTabIndex+1; i<_Buttons.size(); i++) + { + CCtrlTabButton * tab = _Buttons[i]; + if(tab->getActive()) + tab->setActive(false); + } + + if(!_AHOnChange.empty() && ((oldFirstTabIndex!=_FirstTabIndex) || (oldLastTabIndex!=_LastTabIndex))) + CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); + + } + + // *************************************************************************** + int CGroupTab::luaShowTabButton(CLuaState &ls) + { + const char *funcName = "showTabButton"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + sint showTab = (sint)ls.toNumber(1); + + if(showTab>=0 && showTab<(sint)_Buttons.size()) + { + sint32 maxWidth = _Parent->getWReal(); + sint32 buttonsWidth = 0; + + if(showTab<_FirstTabIndex) + { + _FirstTabIndex = showTab; + sint lastTabIndex = _FirstTabIndex; + for(uint i=_FirstTabIndex; i<_Buttons.size(); i++) + { + CCtrlTabButton * tab = _Buttons[i]; + sint32 tabWidth = tab->getWMax(); + if(buttonsWidth+tabWidth <= maxWidth) + { + buttonsWidth += tabWidth; + if(!tab->getActive()) + tab->setActive(true); + lastTabIndex = i; + } + else + break; + } + + if(lastTabIndex <_Selection) + select(lastTabIndex); + else + updateFirstTabButton(); + } + else if(showTab>_LastTabIndex) + { + for(uint i=_FirstTabIndex; i<=(uint)showTab; i++) + buttonsWidth += _Buttons[i]->getWMax(); + + while(buttonsWidth>maxWidth) + { + buttonsWidth -= _Buttons[_FirstTabIndex]->getWMax(); + _FirstTabIndex++; + } + + if(_Selection<_FirstTabIndex) + select(_FirstTabIndex); + else + updateFirstTabButton(); + } + } + + return 0; + } + + // *************************************************************************** + void CGroupTab::updateCoords () + { + if(!_Setuped) + setup(); + + // special for groupTab. Because the ctrl may overlap each other from left to right, they are inserted in reverse + // order. BUT, for correct TR/TL coord handling, must updtae in the reverse sens too! + + // **** just basis + CInterfaceGroup::doUpdateCoords(); + + // **** update in reverse order + _XReal += _OffsetX; + _YReal += _OffsetY; + vector::reverse_iterator ite; + for (ite = _EltOrder.rbegin() ; ite != _EltOrder.rend(); ite++) + { + CViewBase *pIE = *ite; + pIE->updateCoords(); + } + _XReal -= _OffsetX; + _YReal -= _OffsetY; + + // **** complete with child resize + CInterfaceGroup::updateCoords(); + + updateFirstTabButton(); + } + + // *************************************************************************** + void CGroupTab::select(sint index) + { + if(index<0) + index= -1; + + if(index<(sint)_Buttons.size()) + { + sint i; + + // validate this radio button. + if(index>=0) + _Buttons[index]->setPushed(true); + else + for(i=0;i<(sint)_Buttons.size();i++) + _Buttons[i]->setPushed(false); + + _NextSelection = index; + + // set all render layer to their correct state + for(i=0;i<(sint)_Buttons.size();i++) + { + // set the selected one +1, so it will be over + _Buttons[i]->setRenderLayer(_BaseRenderLayer + (i==index?1:0) ); + if (i==index) + { + _Buttons[i]->setBlink(false); + if (_Buttons[i]->_AHOnLeftClick2 != NULL) + // call like if press on it + _Buttons[i]->_AHOnLeftClick2->execute(_Buttons[i], _Buttons[i]->getParamsOnLeftClick()); + } + } + + // show/hide all the associated groups + for(i=0;i<(sint)_Groups.size();i++) + { + if(_Groups[i]) + _Groups[i]->setActive(i==index); + } + + // ok! + _Selection= index; + + updateFirstTabButton(); + } + } + + // *************************************************************************** + void CGroupTab::selectFromCtrl(CCtrlTabButton *button) + { + // search in all buttons + for(uint i=0;i<_Buttons.size();i++) + { + // found? + if(_Buttons[i]==button) + { + select(i); + return; + } + } + } + + // *************************************************************************** + void CGroupTab::selectDefault(CCtrlTabButton *ifSelectionIs) + { + if(!_HideOutTabs && _Selection>=0 && _Selection<(sint)_Buttons.size() && _Buttons[_Selection]==ifSelectionIs) + { + // parse all active button + for(uint i=0;i<_Buttons.size();i++) + { + if(_Buttons[i]->getActive()) + { + select(i); + return; + } + } + + // default: unselect + select(-1); + } + } + + // *************************************************************************** + void CGroupTab::selectDefaultIfCurrentHid() + { + if(_Selection>=0 && _Selection<(sint)_Buttons.size() && + _Buttons[_Selection]!=NULL && _Buttons[_Selection]->getActive()==false) + { + selectDefault(_Buttons[_Selection]); + } + } + + // *************************************************************************** + sint CGroupTab::getSelection() const + { + return _Selection; + } + + NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTabButton, std::string, "tab_button"); + + // *************************************************************************** + std::string CGroupTab::getAssociatedGroupSelection() const + { + if(_Selection>=0 && _Selection<(sint)_Buttons.size()) + { + return _Buttons[_Selection]->_AssociatedGroup; + } + return ""; + } + + // *************************************************************************** + CInterfaceGroup* CGroupTab::getGroup(sint index) + { + if(index>=0 && index<(sint)_Groups.size()) + { + return _Groups[index]; + } + return NULL; + } + + // *************************************************************************** + int CGroupTab::luaGetGroup(CLuaState &ls) + { + const char *funcName = "getGroup"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CInterfaceGroup* group = getGroup((uint) ls.toNumber(1)); + if(group != NULL) + { + CLuaIHM::pushUIOnStack(ls, group); + return 1; + } + return 0; + } + + // *************************************************************************** + CCtrlTabButton::CCtrlTabButton(const TCtorParam ¶m) + : CCtrlTextButton(param) + { + _DefaultX= 0; + _AHOnLeftClick2 = NULL; + _BlinkDate = 0; + _Blinking = false; + _BlinkState = false; + } + + // *************************************************************************** + bool CCtrlTabButton::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if(!CCtrlTextButton::parse(cur, parentGroup)) + return false; + + // if left click not setuped, set default + _AHOnLeftClick2 = _AHOnLeftClick; + string dummy; + _AHOnLeftClick= CAHManager::getInstance()->getAH("tab_select", dummy); + + // read the associated group to show/hide + CXMLAutoPtr prop; + prop = (char*) xmlGetProp( cur, (xmlChar*)"group" ); + if(prop) _AssociatedGroup= (const char*)prop; + + // backup the x + _DefaultX= _X; + + return true; + } + + // *************************************************************************** + void CCtrlTabButton::setActive(bool state) + { + if(state!=getActive()) + { + CCtrlTextButton::setActive(state); + + // special for correct display of textbuttons. reset to 0 when the button is hid + if(state) + setX(_DefaultX); + else + setX(0); + + // if hide, and I was the selected tab, select a default active one + if(state==false) + { + CGroupTab *parent= dynamic_cast(getParent()); + if(parent) + parent->selectDefault(this); + } + } + } + + // *************************************************************************** + bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; + if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) + if (_Blinking) + { + uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + if (( times.thisFrameMs - _BlinkDate) > dbclickDelay) + { + if (_BlinkState) + { + setTextColorNormal(CRGBA::White); + setTextModulateGlobalColorNormal(false); + } + else + { + setTextColorNormal(_TextColorNormalBlink); + setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); + } + _BlinkState = !_BlinkState; + _BlinkDate = times.thisFrameMs; + } + } + } + return CCtrlTextButton::handleEvent(event); + } + + // *************************************************************************** + void CCtrlTabButton::setBlink (bool b) + { + if (b) + { + if (!_Blinking) + { + _TextColorNormalBlink = getTextColorNormal(); + _TextModulateGlobalColorNormalBlink = getTextModulateGlobalColorNormal(); + CWidgetManager::getInstance()->registerClockMsgTarget(this); + } + _Blinking = true; + } + else + { + if (_Blinking) + { + CWidgetManager::getInstance()->unregisterClockMsgTarget(this); + setTextColorNormal(_TextColorNormalBlink); + setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); + } + _Blinking = false; + } + } + + // *************************************************************************** + // Action handler for Tab selection + class CHandlerTabSelect : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const string &/* Params */) + { + CCtrlTabButton *but= dynamic_cast(pCaller); + + // get the parent TabGroup + CGroupTab *parent= dynamic_cast(but->getParent()); + if(parent) + parent->selectFromCtrl(but); + } + }; + REGISTER_ACTION_HANDLER(CHandlerTabSelect, "tab_select" ); + +} + diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index bbb52e524..8f12a17a6 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -34,7 +34,7 @@ #include "permanent_ban.h" #include "global.h" #include "nel/gui/ctrl_text_button.h" -#include "interface_v3/group_tab.h" +#include "nel/gui/group_tab.h" #include "string_manager_client.h" #include "game_share/generic_xml_msg_mngr.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp index d329d8f04..af540da96 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp @@ -35,7 +35,7 @@ #include "bot_chat_manager.h" #include "dbctrl_sheet.h" #include "nel/gui/group_editbox.h" -#include "group_tab.h" +#include "nel/gui/group_tab.h" #include "nel/gui/group_container.h" #include "action_handler_help.h" #include "../string_manager_client.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index fe5d12cf4..9ecbbd630 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -32,7 +32,7 @@ // #include "nel/gui/group_container.h" #include "nel/gui/group_editbox.h" -#include "group_tab.h" +#include "nel/gui/group_tab.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "../client_chat_manager.h" diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index add950b54..ee8aafce3 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -32,6 +32,7 @@ namespace NLGUI class CGroupList; class CGroupEditBox; class CGroupContainer; + class CCtrlTabButton; } class CChatWindow; @@ -207,7 +208,7 @@ protected: std::vector _FreeTellers; - void getAssociatedSubWindow(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, NLGUI::CGroupList *&gl, class CCtrlTabButton *&tab); + void getAssociatedSubWindow(CChatGroup::TGroupType gt, uint32 dynamicChatDbIndex, NLGUI::CGroupList *&gl, NLGUI::CCtrlTabButton *&tab); void updateFreeTellerHeader(NLGUI::CGroupContainer &ft); private: diff --git a/code/ryzom/client/src/interface_v3/group_tab.cpp b/code/ryzom/client/src/interface_v3/group_tab.cpp deleted file mode 100644 index c91b2f217..000000000 --- a/code/ryzom/client/src/interface_v3/group_tab.cpp +++ /dev/null @@ -1,847 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_tab.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_group.h" -#include "nel/gui/view_text.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupTab, std::string, "tab"); - -// *************************************************************************** -CGroupTab::CGroupTab(const TCtorParam ¶m) - : CInterfaceGroup(param) -{ - _Selection= -1; - _NextSelection = -1; - _BaseRenderLayer= 0; - _Setuped= false; - _HideOutTabs = false; - _FirstTabIndex = -1; - _LastTabIndex = -1; -} - - -// *************************************************************************** -bool CGroupTab::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if( !CInterfaceGroup::parse(cur, parentGroup) ) - return false; - - CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"hide_out_tabs")); - if (prop) - { - _HideOutTabs = convertBool(prop); - } - - prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange" ); - if (prop) _AHOnChange = (const char *) prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"onchange_params" ); - if (prop) _ParamsOnChange = (const char *) prop; - - return true; -} - -// *************************************************************************** -void CGroupTab::setup() -{ - if(_Setuped) - return; - _Setuped= true; - - _Buttons.clear(); - _Groups.clear(); - - /* Buttons must be named tab0,tab1,tab2... - and tab_array0_0, tab_array0_1 .... (for vector of tab) - Only 10 tab array are allowed - */ - for(sint tabArrayIndex= -1;tabArrayIndex<10;tabArrayIndex++) - { - // prefix according to array or not - string prefix; - if(tabArrayIndex==-1) - prefix= "tab"; - else - prefix= toString("tab_array%d_", tabArrayIndex); - - // for all tab of this type (standard tab or array of tab), find the Buttons and groups. - uint tabIndex=0; - for(;;) - { - // find the ctrl named "tab0" - CCtrlTabButton *but= dynamic_cast(getCtrl(toString("%s%d", prefix.c_str(), tabIndex))); - if(!but) - break; - - // find the associated group - CInterfaceGroup *pGroup = NULL; - CInterfaceGroup *pFather = this; - - while ((pGroup == NULL) && (pFather != NULL)) - { - pGroup = pFather->getGroup(but->_AssociatedGroup); - pFather = pFather->getParent(); - } - - // add to the button and group list - _Buttons.push_back(but); - _Groups.push_back(pGroup); - - // try next - tabIndex++; - } - } - - // at the first setup, select by default the 1st - if(_Selection<0) - select(0); -} - -// *************************************************************************** -void CGroupTab::addTab(CCtrlTabButton * tabB) -{ - addCtrl(tabB); - _Setuped = false; - updateCoords(); - selectFromCtrl(tabB); - - if(_HideOutTabs && !_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - -} - -// *************************************************************************** -void CGroupTab::addTab(CCtrlTabButton * tabB, sint index) -{ - if(index<(sint)_Buttons.size() && index>=0) - { - vector buttons = _Buttons; - - for(sint i=0;i<(sint)_Buttons.size();i++) - delCtrl(_Buttons[i], true); - - _Setuped = false; - updateCoords(); - - uint count=0; - CCtrlTabButton* lastTab=NULL; - for(sint i=0;i<(sint)buttons.size();i++) - { - if(i==index) - { - tabB->setId("tab" + NLMISC::toString(count)); - tabB->setParentPos(lastTab); - if(i==0) - tabB->setParentPosRef(Hotspot_TL); - else - tabB->setParentPosRef(Hotspot_TR); - tabB->setPosRef(Hotspot_TL); - - addCtrl(tabB); - lastTab = tabB; - count++; - } - - buttons[i]->setId("tab" + NLMISC::toString(count)); - buttons[i]->setParentPos(lastTab); - if(i==0 && index!=0) - buttons[i]->setParentPosRef(Hotspot_TL); - else - buttons[i]->setParentPosRef(Hotspot_TR); - buttons[i]->setPosRef(Hotspot_TL); - - addCtrl(buttons[i]); - - lastTab = buttons[i]; - count++; - } - - _Setuped = false; - updateCoords(); - - // we have added a new button in first position - // then it must recover the reference - if(index==0) - { - CCtrlTabButton * tab0 = _Buttons[0]; - for(uint i=0; i<_Buttons.size(); ++i) - _Buttons[i]->initRBRefFromRadioButton(tab0); - - select(_Selection); - } - else - { - CCtrlTabButton * tab0 = _Buttons[0]; - _Buttons[index]->initRBRefFromRadioButton(tab0); - } - } - else - { - tabB->setId(string("tab") + NLMISC::toString(_Buttons.size())); - - if(_Buttons.size()==0) - { - tabB->setParentPos(NULL); - tabB->setParentPosRef(Hotspot_TL); - } - else - { - tabB->setParentPos(_Buttons[_Buttons.size()-1]); - tabB->setParentPosRef(Hotspot_TR); - } - tabB->setPosRef(Hotspot_TL); - - addCtrl(tabB); - } - - _Setuped = false; - updateCoords(); - - if(_HideOutTabs && !_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - -} - -// *************************************************************************** -int CGroupTab::luaAddTab(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CGroupTab::addTab", 1); - CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (tabB) - { - // don't use addTab to avoid selection of new tab - addCtrl(tabB); - - _Setuped = false; - updateCoords(); - - if(_HideOutTabs && !_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - - } - return 0; -} - -// *************************************************************************** -int CGroupTab::luaAddTabWithOrder(CLuaState &ls) -{ - const char *funcName = "addTabWithOrder"; - CLuaIHM::checkArgCount(ls, funcName, 2); - CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - - CCtrlTabButton *tabB = dynamic_cast(CLuaIHM::getUIOnStack(ls, 1)); - if (tabB) - { - // don't use addTab to avoid selection of new tab - addTab(tabB, (sint) ls.toNumber(2)); - } - return 0; -} - -// *************************************************************************** -void CGroupTab::removeTab(sint index) -{ - if(!(index>=0 && index<(sint)_Buttons.size())) - return; - - vector buttons = _Buttons; - - for(sint i=0;i<(sint)_Buttons.size();i++) - { - bool deleteElt = (i!=index); - CViewText* tabVT = _Buttons[i]->getViewText(); - if(tabVT && !deleteElt) - delView(tabVT, deleteElt); - - delCtrl(_Buttons[i], deleteElt); - - if(!deleteElt) - (_Groups[i]->getParent())->delGroup(_Groups[i], deleteElt); - } - _Setuped = false; - updateCoords(); - - uint count=0; - CCtrlTabButton* lastTab = NULL; - for(sint i=0;i<(sint)buttons.size();i++) - { - if(i!=index) - { - buttons[i]->setId("tab"+NLMISC::toString(count)); - buttons[i]->setParentPos(lastTab); - if((i==0) || (index==0 && i==1)) - buttons[i]->setParentPosRef(Hotspot_TL); - else - _Buttons[i]->setParentPosRef(Hotspot_TR); - - buttons[i]->setPosRef(Hotspot_TL); - - lastTab = buttons[i]; - addCtrl(buttons[i]); - count++; - } - } - - _Setuped = false; - updateCoords(); - - // we have removed the first button which is the only one to own the reference - // then the new first button recovers the reference - if(index==0) - { - CCtrlTabButton * tab0 = _Buttons[0]; - for(uint i=0; i<_Buttons.size(); ++i) - _Buttons[i]->initRBRefFromRadioButton(tab0); - - select(_Selection); - } - - if(_HideOutTabs) - { - select(_FirstTabIndex); - - if(!_AHOnChange.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - } -} - -// *************************************************************************** - -int CGroupTab::luaRemoveTab(CLuaState &ls) -{ - const char *funcName = "removeTab"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - removeTab((uint) ls.toNumber(1)); - return 0; -} - -// *************************************************************************** -void CGroupTab::removeAll() -{ - for(sint i=0;i<(sint)_Buttons.size();i++) - { - CViewText* tabVT = _Buttons[i]->getViewText(); - if(tabVT) - delView(tabVT, false); - - delCtrl(_Buttons[i], false); - (_Groups[i]->getParent())->delGroup(_Groups[i], false); - } - - _Setuped = false; - updateCoords(); -} - -// *************************************************************************** - -int CGroupTab::luaRemoveAll(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "CGroupTab::removeAll", 0); - removeAll(); - return 0; -} - -// *************************************************************************** -CCtrlTabButton* CGroupTab::getTabButton(sint index) -{ - if(index>=0 && index<(sint)_Buttons.size()) - { - return _Buttons[index]; - } - return NULL; -} - -// *************************************************************************** -int CGroupTab::luaGetTabButton(CLuaState &ls) -{ - const char *funcName = "getTabButton"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CCtrlTabButton* tab = getTabButton((uint) ls.toNumber(1)); - if(tab != NULL) - { - CLuaIHM::pushUIOnStack(ls, tab); - return 1; - } - return 0; -} - -// *************************************************************************** -void CGroupTab::updateFirstTabButton() -{ - if(!_HideOutTabs || (_Selection<0) || (_Buttons.size()==0) || (_Parent->getWReal()<0) - || _FirstTabIndex>=(sint)_Buttons.size()) - return; - - sint oldFirstTabIndex = _FirstTabIndex; - sint oldLastTabIndex = _LastTabIndex; - - if(_FirstTabIndex<0) - { - for(uint i=0; i<_Buttons.size(); i++) - { - CCtrlTabButton * tab = _Buttons[i]; - if(tab->getActive()) - { - _FirstTabIndex = i; - break; - } - } - } - - sint selection = _Selection; - if(selection>=(sint)_Buttons.size()) - selection = _FirstTabIndex; - - if(selection < _FirstTabIndex) - _FirstTabIndex = selection; - - sint32 maxWidth = _Parent->getWReal(); - sint32 buttonsWidth = 0; - _LastTabIndex = 0; - - // desactive first tabs - for(uint i=0; i<(uint)_FirstTabIndex; i++) - { - CCtrlTabButton * tab = _Buttons[i]; - if(tab->getActive()) - tab->setActive(false); - } - - - // active tabs from _FirstTabIndex and search for last showed tab - for(uint i=_FirstTabIndex; i<_Buttons.size(); i++) - { - CCtrlTabButton * tab = _Buttons[i]; - sint32 tabWidth = tab->getWMax(); - if(buttonsWidth+tabWidth <= maxWidth) - { - buttonsWidth += tabWidth; - if(!tab->getActive()) - tab->setActive(true); - _LastTabIndex = i; - } - else - break; - } - - // check if selected tab is in showed tabs - if(_LastTabIndex < selection) - { - for(uint i=_LastTabIndex+1; i<=(uint)selection; i++) - { - CCtrlTabButton * tab = _Buttons[i]; - buttonsWidth += tab->getWMax(); - if(!tab->getActive()) - tab->setActive(true); - } - - while(buttonsWidth>maxWidth) - { - CCtrlTabButton * tab = _Buttons[_FirstTabIndex]; - buttonsWidth -= tab->getWMax(); - _FirstTabIndex++; - if(tab->getActive()) - tab->setActive(false); - } - } - - // add tabs before the "_FirstTabIndex" one if it remains place - while(buttonsWidth0) - { - CCtrlTabButton * tab = _Buttons[_FirstTabIndex-1]; - buttonsWidth += tab->getWMax(); - if(buttonsWidth<=maxWidth) - { - _FirstTabIndex--; - if(!tab->getActive()) - tab->setActive(true); - } - } - - // desactive last tabs - for(uint i=_LastTabIndex+1; i<_Buttons.size(); i++) - { - CCtrlTabButton * tab = _Buttons[i]; - if(tab->getActive()) - tab->setActive(false); - } - - if(!_AHOnChange.empty() && ((oldFirstTabIndex!=_FirstTabIndex) || (oldLastTabIndex!=_LastTabIndex))) - CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); - -} - -// *************************************************************************** -int CGroupTab::luaShowTabButton(CLuaState &ls) -{ - const char *funcName = "showTabButton"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - sint showTab = (sint)ls.toNumber(1); - - if(showTab>=0 && showTab<(sint)_Buttons.size()) - { - sint32 maxWidth = _Parent->getWReal(); - sint32 buttonsWidth = 0; - - if(showTab<_FirstTabIndex) - { - _FirstTabIndex = showTab; - sint lastTabIndex = _FirstTabIndex; - for(uint i=_FirstTabIndex; i<_Buttons.size(); i++) - { - CCtrlTabButton * tab = _Buttons[i]; - sint32 tabWidth = tab->getWMax(); - if(buttonsWidth+tabWidth <= maxWidth) - { - buttonsWidth += tabWidth; - if(!tab->getActive()) - tab->setActive(true); - lastTabIndex = i; - } - else - break; - } - - if(lastTabIndex <_Selection) - select(lastTabIndex); - else - updateFirstTabButton(); - } - else if(showTab>_LastTabIndex) - { - for(uint i=_FirstTabIndex; i<=(uint)showTab; i++) - buttonsWidth += _Buttons[i]->getWMax(); - - while(buttonsWidth>maxWidth) - { - buttonsWidth -= _Buttons[_FirstTabIndex]->getWMax(); - _FirstTabIndex++; - } - - if(_Selection<_FirstTabIndex) - select(_FirstTabIndex); - else - updateFirstTabButton(); - } - } - - return 0; -} - -// *************************************************************************** -void CGroupTab::updateCoords () -{ - if(!_Setuped) - setup(); - - // special for groupTab. Because the ctrl may overlap each other from left to right, they are inserted in reverse - // order. BUT, for correct TR/TL coord handling, must updtae in the reverse sens too! - - // **** just basis - CInterfaceGroup::doUpdateCoords(); - - // **** update in reverse order - _XReal += _OffsetX; - _YReal += _OffsetY; - vector::reverse_iterator ite; - for (ite = _EltOrder.rbegin() ; ite != _EltOrder.rend(); ite++) - { - CViewBase *pIE = *ite; - pIE->updateCoords(); - } - _XReal -= _OffsetX; - _YReal -= _OffsetY; - - // **** complete with child resize - CInterfaceGroup::updateCoords(); - - updateFirstTabButton(); -} - -// *************************************************************************** -void CGroupTab::select(sint index) -{ - if(index<0) - index= -1; - - if(index<(sint)_Buttons.size()) - { - sint i; - - // validate this radio button. - if(index>=0) - _Buttons[index]->setPushed(true); - else - for(i=0;i<(sint)_Buttons.size();i++) - _Buttons[i]->setPushed(false); - - _NextSelection = index; - - // set all render layer to their correct state - for(i=0;i<(sint)_Buttons.size();i++) - { - // set the selected one +1, so it will be over - _Buttons[i]->setRenderLayer(_BaseRenderLayer + (i==index?1:0) ); - if (i==index) - { - _Buttons[i]->setBlink(false); - if (_Buttons[i]->_AHOnLeftClick2 != NULL) - // call like if press on it - _Buttons[i]->_AHOnLeftClick2->execute(_Buttons[i], _Buttons[i]->getParamsOnLeftClick()); - } - } - - // show/hide all the associated groups - for(i=0;i<(sint)_Groups.size();i++) - { - if(_Groups[i]) - _Groups[i]->setActive(i==index); - } - - // ok! - _Selection= index; - - updateFirstTabButton(); - } -} - -// *************************************************************************** -void CGroupTab::selectFromCtrl(CCtrlTabButton *button) -{ - // search in all buttons - for(uint i=0;i<_Buttons.size();i++) - { - // found? - if(_Buttons[i]==button) - { - select(i); - return; - } - } -} - -// *************************************************************************** -void CGroupTab::selectDefault(CCtrlTabButton *ifSelectionIs) -{ - if(!_HideOutTabs && _Selection>=0 && _Selection<(sint)_Buttons.size() && _Buttons[_Selection]==ifSelectionIs) - { - // parse all active button - for(uint i=0;i<_Buttons.size();i++) - { - if(_Buttons[i]->getActive()) - { - select(i); - return; - } - } - - // default: unselect - select(-1); - } -} - -// *************************************************************************** -void CGroupTab::selectDefaultIfCurrentHid() -{ - if(_Selection>=0 && _Selection<(sint)_Buttons.size() && - _Buttons[_Selection]!=NULL && _Buttons[_Selection]->getActive()==false) - { - selectDefault(_Buttons[_Selection]); - } -} - -// *************************************************************************** -sint CGroupTab::getSelection() const -{ - return _Selection; -} - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlTabButton, std::string, "tab_button"); - -// *************************************************************************** -std::string CGroupTab::getAssociatedGroupSelection() const -{ - if(_Selection>=0 && _Selection<(sint)_Buttons.size()) - { - return _Buttons[_Selection]->_AssociatedGroup; - } - return ""; -} - -// *************************************************************************** -CInterfaceGroup* CGroupTab::getGroup(sint index) -{ - if(index>=0 && index<(sint)_Groups.size()) - { - return _Groups[index]; - } - return NULL; -} - -// *************************************************************************** -int CGroupTab::luaGetGroup(CLuaState &ls) -{ - const char *funcName = "getGroup"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - CInterfaceGroup* group = getGroup((uint) ls.toNumber(1)); - if(group != NULL) - { - CLuaIHM::pushUIOnStack(ls, group); - return 1; - } - return 0; -} - -// *************************************************************************** -CCtrlTabButton::CCtrlTabButton(const TCtorParam ¶m) -: CCtrlTextButton(param) -{ - _DefaultX= 0; - _AHOnLeftClick2 = NULL; - _BlinkDate = 0; - _Blinking = false; - _BlinkState = false; -} - -// *************************************************************************** -bool CCtrlTabButton::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if(!CCtrlTextButton::parse(cur, parentGroup)) - return false; - - // if left click not setuped, set default - _AHOnLeftClick2 = _AHOnLeftClick; - string dummy; - _AHOnLeftClick= CAHManager::getInstance()->getAH("tab_select", dummy); - - // read the associated group to show/hide - CXMLAutoPtr prop; - prop = (char*) xmlGetProp( cur, (xmlChar*)"group" ); - if(prop) _AssociatedGroup= (const char*)prop; - - // backup the x - _DefaultX= _X; - - return true; -} - -// *************************************************************************** -void CCtrlTabButton::setActive(bool state) -{ - if(state!=getActive()) - { - CCtrlTextButton::setActive(state); - - // special for correct display of textbuttons. reset to 0 when the button is hid - if(state) - setX(_DefaultX); - else - setX(0); - - // if hide, and I was the selected tab, select a default active one - if(state==false) - { - CGroupTab *parent= dynamic_cast(getParent()); - if(parent) - parent->selectDefault(this); - } - } -} - -// *************************************************************************** -bool CCtrlTabButton::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event; - if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick) - if (_Blinking) - { - uint dbclickDelay = CWidgetManager::getInstance()->getUserDblClickDelay(); - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - if (( times.thisFrameMs - _BlinkDate) > dbclickDelay) - { - if (_BlinkState) - { - setTextColorNormal(CRGBA::White); - setTextModulateGlobalColorNormal(false); - } - else - { - setTextColorNormal(_TextColorNormalBlink); - setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); - } - _BlinkState = !_BlinkState; - _BlinkDate = times.thisFrameMs; - } - } - } - return CCtrlTextButton::handleEvent(event); -} - -// *************************************************************************** -void CCtrlTabButton::setBlink (bool b) -{ - if (b) - { - if (!_Blinking) - { - _TextColorNormalBlink = getTextColorNormal(); - _TextModulateGlobalColorNormalBlink = getTextModulateGlobalColorNormal(); - CWidgetManager::getInstance()->registerClockMsgTarget(this); - } - _Blinking = true; - } - else - { - if (_Blinking) - { - CWidgetManager::getInstance()->unregisterClockMsgTarget(this); - setTextColorNormal(_TextColorNormalBlink); - setTextModulateGlobalColorNormal(_TextModulateGlobalColorNormalBlink); - } - _Blinking = false; - } -} - -// *************************************************************************** -// Action handler for Tab selection -class CHandlerTabSelect : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const string &/* Params */) - { - CCtrlTabButton *but= dynamic_cast(pCaller); - - // get the parent TabGroup - CGroupTab *parent= dynamic_cast(but->getParent()); - if(parent) - parent->selectFromCtrl(but); - } -}; -REGISTER_ACTION_HANDLER(CHandlerTabSelect, "tab_select" ); - diff --git a/code/ryzom/client/src/interface_v3/group_tab.h b/code/ryzom/client/src/interface_v3/group_tab.h deleted file mode 100644 index 46cc241ab..000000000 --- a/code/ryzom/client/src/interface_v3/group_tab.h +++ /dev/null @@ -1,177 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_GROUP_TAB_H -#define NL_GROUP_TAB_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/interface_group.h" -#include "nel/gui/ctrl_text_button.h" - - -// *************************************************************************** -class CCtrlTabButton; - - -// *************************************************************************** -/** - * Group handling Ctrl Tab, to easily simulate Tab ctrl. - * NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order: - * - in this group - * - in the parent group - * - in global - * \author Lionel Berenguier - * \author Nevrax France - * \date 2003 - */ -class CGroupTab : public CInterfaceGroup -{ -public: - - /// Constructor - CGroupTab(const TCtorParam ¶m); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void updateCoords (); - - // select the ctrl tab. -1 will invalidate all. - void select(sint index); - sint getSelection() const; - - // select with a CCtrlTabButton ptr - void selectFromCtrl(CCtrlTabButton *button); - - // select a default activated tab, if the current is a special ctrlTab - void selectDefault(CCtrlTabButton *ifSelectionIs); - - // select a default activated tab, if the current is hid - void selectDefaultIfCurrentHid(); - - // add new tab - void addTab(CCtrlTabButton *tabB); - void addTab(CCtrlTabButton *tabB, sint index); - int luaAddTab(CLuaState &ls); - int luaAddTabWithOrder(CLuaState &ls); - - // remove selected tab - void removeTab(sint index); - int luaRemoveTab(CLuaState &ls); - - // remove all tabs - void removeAll(); - int luaRemoveAll(CLuaState &ls); - - // tab number - void setTabButtonNb(sint32 /* val */){} - sint32 getTabButtonNb() const {return (sint32)_Buttons.size();} - - // selection index - void setIndexSelection(sint32 val){select((sint)val);} - sint32 getIndexSelection() const {return (sint32)_NextSelection;} - - // selection index - void setAssociatedGroupSelection(const std::string & /* assG */){} - std::string getAssociatedGroupSelection() const; - - // get group from index - CInterfaceGroup* getGroup(sint index); - int luaGetGroup(CLuaState &ls); - - // get tab from index - CCtrlTabButton* getTabButton(sint index); - int luaGetTabButton(CLuaState &ls); - - // first showed tab button - sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;} - - // last showed tab button - sint32 getLastTabButton() const {return (sint32)_LastTabIndex;} - - // update showed tab buttons on function of GroupTab width - void updateFirstTabButton(); - int luaShowTabButton(CLuaState &ls); - - void dummySet(sint32 /* value */){} - - REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup) - REFLECT_LUA_METHOD("addTab", luaAddTab) - REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder) - REFLECT_LUA_METHOD("removeTab", luaRemoveTab) - REFLECT_LUA_METHOD("removeAll", luaRemoveAll) - REFLECT_LUA_METHOD("getGroup", luaGetGroup) - REFLECT_LUA_METHOD("getTabButton", luaGetTabButton) - REFLECT_LUA_METHOD("showTabButton", luaShowTabButton) - REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb) - REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection) - REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet) - REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet) - REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection) - REFLECT_EXPORT_END - -private: - - std::vector _Buttons; // can't be NULL. - std::vector _Groups; // may be NULL - sint _Selection; - sint _NextSelection; - sint _BaseRenderLayer; - bool _Setuped; - bool _HideOutTabs; - sint _FirstTabIndex; - sint _LastTabIndex; - - std::string _AHOnChange; - std::string _ParamsOnChange; - - void setup(); -}; - -// *************************************************************************** -/** - * Used with CGroupTab - */ -class CCtrlTabButton : public CCtrlTextButton -{ -public: - - CCtrlTabButton(const TCtorParam ¶m); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - virtual void setActive(bool state); - - virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - - void setBlink (bool b); - - std::string _AssociatedGroup; - IActionHandler *_AHOnLeftClick2; - -private: - - sint32 _DefaultX; - bool _Blinking; - NLMISC::CRGBA _TextColorNormalBlink; - bool _TextModulateGlobalColorNormalBlink; - sint64 _BlinkDate; - bool _BlinkState; -}; - -#endif // NL_GROUP_TAB_H - -/* End of group_tab.h */ diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index be160de5d..5f27cf92e 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -82,7 +82,7 @@ #include "group_in_scene_user_info.h" #include "group_in_scene_bubble.h" #include "group_phrase_skill_filter.h" -#include "group_tab.h" +#include "nel/gui/group_tab.h" #include "group_table.h" // DBGroup #include "dbgroup_select_number.h" diff --git a/code/ryzom/client/src/interface_v3/people_interraction.cpp b/code/ryzom/client/src/interface_v3/people_interraction.cpp index c682ee824..1efed593b 100644 --- a/code/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/code/ryzom/client/src/interface_v3/people_interraction.cpp @@ -39,7 +39,7 @@ #include "../entities.h" #include "../net_manager.h" #include "../connection.h" -#include "group_tab.h" +#include "nel/gui/group_tab.h" #include "guild_manager.h" // Game share #include "game_share/entity_types.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index b2c526b6b..a8c8b35e4 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -48,7 +48,7 @@ #include "nel/gui/ctrl_scroll_base.h" #include "nel/gui/ctrl_scroll.h" #include "dbgroup_combo_box.h" -#include "group_tab.h" +#include "nel/gui/group_tab.h" #include "group_html.h" #include "group_header.h" #include "sphrase_manager.h" From 0532f7a01a14712fc03b9f54e7b2469be72ebc21 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:00:45 +0200 Subject: [PATCH 104/339] CHANGED: CGroupHeader no longer depends on CInterfaceManager. --- code/ryzom/client/src/interface_v3/group_header.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp index d1ac6fff6..b907595a5 100644 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ b/code/ryzom/client/src/interface_v3/group_header.cpp @@ -15,13 +15,10 @@ // along with this program. If not, see . - -#include "stdpch.h" -// -#include "interface_manager.h" #include "nel/gui/group_container.h" #include "group_header.h" #include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" using namespace NLMISC; @@ -240,7 +237,6 @@ public: {} void release() { - CInterfaceManager *im = CInterfaceManager::getInstance(); if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) { _Moving = false; @@ -257,7 +253,6 @@ public: } bool handleEvent (const NLGUI::CEventDescriptor &event) { - CInterfaceManager *im = CInterfaceManager::getInstance(); if (_Parent) { if (event.getType() == NLGUI::CEventDescriptor::system) @@ -417,7 +412,6 @@ bool CGroupHeaderEntry::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) // ***************************************************************************************************************** CInterfaceGroup *CGroupHeaderEntry::getTargetColumn() const { - CInterfaceManager *im = CInterfaceManager::getInstance(); return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_TargetColumnId)); } From 854e269ae6d7d537100e7e535228bcc395a65d3d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:08:15 +0200 Subject: [PATCH 105/339] CHANGED: CGroupHeader is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/group_header.h | 86 ++++ code/nel/src/gui/group_header.cpp | 441 ++++++++++++++++++ .../client/src/interface_v3/group_header.cpp | 435 ----------------- .../client/src/interface_v3/group_header.h | 85 ---- .../register_interface_elements.cpp | 2 +- 5 files changed, 528 insertions(+), 521 deletions(-) create mode 100644 code/nel/include/nel/gui/group_header.h create mode 100644 code/nel/src/gui/group_header.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_header.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_header.h diff --git a/code/nel/include/nel/gui/group_header.h b/code/nel/include/nel/gui/group_header.h new file mode 100644 index 000000000..81d5d20be --- /dev/null +++ b/code/nel/include/nel/gui/group_header.h @@ -0,0 +1,86 @@ +// Ryzom - MMORPG Framework +// 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 CL_GROUP_HEADER_H +#define CL_GROUP_HEADER_H + +#include "nel/gui/group_list.h" + +namespace NLGUI +{ + + class CGroupHeaderEntry; + + // ***************************************************************************************************************** + /** Display a header with movable entries. + * Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode) + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2006 + */ + class CGroupHeader : public CGroupList + { + public: + REFLECT_EXPORT_START(CGroupHeader, CGroupList) + REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns); + REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer); + REFLECT_EXPORT_END + + CGroupHeader(const TCtorParam ¶m); + // from CInterfaceGroup + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + sint32 getHeaderMaxSize() const { return _HeaderMaxSize; } + // get the entries in this header + void getEntries(std::vector &dest); + // ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()' + void enlargeColumns(sint32 margin); + // ensure that content of each column is visible + void resizeColumnsAndContainer(sint32 margin); + private: + sint32 _HeaderMaxSize; + int luaEnlargeColumns(CLuaState &ls); + int luaResizeColumnsAndContainer(CLuaState &ls); + }; + + // ***************************************************************************************************************** + // an entry in a header, includes a "mover control" to move it inside its parent header + // NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size' + class CGroupHeaderEntry : public CInterfaceGroup + { + public: + CGroupHeaderEntry(const TCtorParam ¶m); + // from CInterfaceGroup + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + sint32 getMinSize() const { return _MinSize; } + virtual void updateCoords(); + CInterfaceGroup *getTargetColumn() const; + + const std::string &getAHOnResize() const { return _AHOnResize; } + const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } + + private: + sint32 _MinSize; + std::string _TargetColumnId; + std::string _AHOnResize; + std::string _AHOnResizeParams; + }; + + +} + +#endif + diff --git a/code/nel/src/gui/group_header.cpp b/code/nel/src/gui/group_header.cpp new file mode 100644 index 000000000..48ae85776 --- /dev/null +++ b/code/nel/src/gui/group_header.cpp @@ -0,0 +1,441 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_container.h" +#include "nel/gui/group_header.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" + + +using namespace NLMISC; + +namespace NLGUI +{ + + ////////////////// + // CGroupHeader // + ////////////////// + + // ***************************************************************************************************************** + CGroupHeader::CGroupHeader(const TCtorParam ¶m) : CGroupList(param), _HeaderMaxSize(32767) + { + } + + // ***************************************************************************************************************** + void CGroupHeader::enlargeColumns(sint32 margin) + { + std::vector entries; + getEntries(entries); + sint32 totalWidth = 0; + for (uint k = 0; k < entries.size(); ++k) + { + CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn(); + if (colEnclosing && !colEnclosing->getGroups().empty()) + { + CInterfaceGroup *col = colEnclosing->getGroups()[0]; + if (col) + { + // enlarge to the max to be able to measure the sub text (they may clamp themselves based + // on their first non-"child resizing" parent (see CViewText::updateCoords) + colEnclosing->setW(16384); + colEnclosing->invalidateCoords(); + colEnclosing->updateCoords(); + + // assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList) + entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin)); + entries[k]->invalidateCoords(); + totalWidth += entries[k]->getW(); + } + } + } + // if total width bigger than allowed, reduce proportionnally + if (totalWidth > _HeaderMaxSize) + { + while (totalWidth > _HeaderMaxSize) + { + bool adjusted = false; + // stupid algo here, but ponctual ... + for (uint k = 0; k < entries.size() && totalWidth > _HeaderMaxSize; ++k) + { + if (entries[k]->getW() > entries[k]->getMinSize()) + { + entries[k]->setW(entries[k]->getW() - 1); + entries[k]->invalidateCoords(); + --totalWidth; + adjusted = true; + } + } + // if all at min size, just exit ... + if (!adjusted) break; + } + } + else + { + // search first parent that limit size, if it is larger then enlarge to fit size + CInterfaceGroup *limitingParent = getParent(); + while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast(limitingParent))) + { + // NB nico : the dynamic_cast for CGroupList is bad!! + // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords + // ... + limitingParent = limitingParent->getParent(); + } + if (limitingParent && limitingParent->getWReal() > totalWidth) + { + while (limitingParent->getWReal() > totalWidth && totalWidth < _HeaderMaxSize) + { + // enlarge to matche parent size + // stupid algo here, but ponctual ... + for (uint k = 0; k < entries.size(); ++k) + { + entries[k]->setW(entries[k]->getW() + 1); + entries[k]->invalidateCoords(); + ++totalWidth; + if (limitingParent->getWReal() <= totalWidth || totalWidth >= _HeaderMaxSize) break; + } + } + } + } + invalidateCoords(); + } + + // ***************************************************************************************************************** + void CGroupHeader::resizeColumnsAndContainer(sint32 margin) + { + std::vector entries; + getEntries(entries); + sint32 totalWidth = 0; + for (uint k = 0; k < entries.size(); ++k) + { + CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn(); + if (colEnclosing && !colEnclosing->getGroups().empty()) + { + CInterfaceGroup *col = colEnclosing->getGroups()[0]; + if (col) + { + // enlarge to the max to be able to measure the sub text (they may clamp themselves based + // on their first non-"child resizing" parent (see CViewText::updateCoords) + colEnclosing->setW(16384); + colEnclosing->invalidateCoords(); + colEnclosing->updateCoords(); + + // assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList) + entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin)); + entries[k]->invalidateCoords(); + totalWidth += entries[k]->getW(); + } + } + } + + // resize W + if (totalWidth <= _HeaderMaxSize) + { + // search first parent that limit size, if it is larger then enlarge to fit size + CInterfaceGroup *limitingParent = getParent(); + while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast(limitingParent))) + { + // NB nico : the dynamic_cast for CGroupList is bad!! + // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords + // ... + limitingParent = limitingParent->getParent(); + } + + getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal()); + } + + // resize H + if(entries.size()>0) + { + CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn(); + if (colEnclosing && !colEnclosing->getGroups().empty()) + { + CInterfaceGroup *col = colEnclosing->getGroups()[0]; + if (col) + { + // search first parent that limit size, if it is larger then enlarge to fit size + CInterfaceGroup *limitingParent = colEnclosing->getParent(); + while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast(limitingParent))) + limitingParent = limitingParent->getParent(); + + getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); + } + } + } + + + invalidateCoords(); + } + + // ***************************************************************************************************************** + void CGroupHeader::getEntries(std::vector &dest) + { + dest.clear(); + const std::vector &groups = getGroups(); + for (uint k = 0; k < groups.size(); ++k) + { + CGroupHeaderEntry *entry = dynamic_cast(groups[k]); + if (entry) + { + dest.push_back(entry); + } + } + } + + // ***************************************************************************************************************** + int CGroupHeader::luaEnlargeColumns(CLuaState &ls) + { + const char *funcName = "enlargeColumns"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + enlargeColumns((sint32) ls.toNumber(1)); + return 0; + } + + // ***************************************************************************************************************** + int CGroupHeader::luaResizeColumnsAndContainer(CLuaState &ls) + { + const char *funcName = "resizeColumnsAndContainer"; + CLuaIHM::checkArgCount(ls, funcName, 1); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + resizeColumnsAndContainer((sint32) ls.toNumber(1)); + return 0; + } + + // ***************************************************************************************************************** + bool CGroupHeader::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CGroupList::parse(cur, parentGroup)) return false; + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"header_max_size" )); + if (prop) fromString((const char*)prop, _HeaderMaxSize); + return true; + } + + ///////////////////////// + // CHeaderEntryResizer // + ///////////////////////// + + class CHeaderEntryResizer : public CCtrlBase + { + public: + CHeaderEntryResizer(bool rightSide, sint32 wMin) : CCtrlBase(TCtorParam()), + _RightSide(rightSide), + _Moving(false), + _StartX(0), + _OffsetX(0), + _WMin(wMin) + {} + void release() + { + if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) + { + _Moving = false; + CWidgetManager::getInstance()->setCapturePointerLeft(NULL); + } + } + virtual uint getDeltaDepth() const { return 100; } + CInterfaceGroup *getTargetGroup() + { + if (_RightSide) return _Parent; + + if (getParent()->getParent() == _Parent->getParentPos()) return NULL; // leftmost header + return dynamic_cast(getParent()->getParentPos()); + } + bool handleEvent (const NLGUI::CEventDescriptor &event) + { + if (_Parent) + { + if (event.getType() == NLGUI::CEventDescriptor::system) + { + const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; + if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) + { + const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; + if (edsf.hasFocus() == false) + { + release(); + return CCtrlBase::handleEvent(event); + } + } + } + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) + { + if (!this->isIn(eventDesc.getX(), eventDesc.getY())) return false; + _TargetGroup = getTargetGroup(); + if (!_TargetGroup) return false; + CWidgetManager::getInstance()->setCapturePointerLeft(this); + _Moving = true; + _OffsetX = _TargetGroup->getW() - eventDesc.getX(); + return true; + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) + { + release(); + } + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) + { + if (_Moving && CWidgetManager::getInstance()->getCapturePointerLeft() == this) + { + if (!_TargetGroup) + { + release(); + return false; + } + sint32 newW = eventDesc.getX() + _OffsetX; + // compute width of all header entries but this one + CGroupHeader *header = dynamic_cast(getParent()->getParent()); + if (header) + { + sint32 w = 0; + for (uint k = 0; k < header->getNumChildren(); ++k) + { + if (header->getChild(k) != _TargetGroup) + { + w += header->getChild(k)->getW(); + } + } + sint32 excess = w + newW - header->getHeaderMaxSize(); + if (excess) + { + // try to diminish the size of all headers starting from the last + for (sint k = header->getNumChildren() - 1; k >= 0 && excess > 0; --k) + { + if (header->getChild(k) == _TargetGroup) break; + CGroupHeaderEntry *ghe = dynamic_cast(header->getChild(k)); + sint32 wGain = std::min(excess, std::max((sint32) 0, ghe->getW() - ghe->getMinSize())); + if (wGain > 0) + { + ghe->setW(ghe->getW() - wGain); + ghe->invalidateCoords(); + excess -= wGain; + } + } + } + newW -= std::max((sint32) 0, excess); + } + _TargetGroup->setW(std::max(_WMin, newW)); + _TargetGroup->invalidateCoords(); + CGroupHeaderEntry *ghe = dynamic_cast((CInterfaceGroup *) _TargetGroup); + if (ghe) + { + ghe->setW(_TargetGroup->getW()); + ghe->invalidateCoords(); + CAHManager::getInstance()->runActionHandler(ghe->getAHOnResize(), ghe, ghe->getAHOnResizeParams()); + } + return true; + } + _Moving = false; + } + } + } + return CCtrlBase::handleEvent(event); + } + virtual void draw () + { + // no-op + } + virtual bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col) + { + + if (!getTargetGroup()) return false; + texName = "curs_resize_LR.tga"; + rot = 0; + col = CRGBA::White; + return true; + } + + private: + NLMISC::CRefPtr _TargetGroup; // group for which w is modified + bool _RightSide; // right or left side mover ? + bool _Moving; + sint32 _StartX; // value to add to mouse to get local x pos of target group + sint32 _OffsetX; + sint32 _WMin; + }; + + // ***************************************************************************************************************** + CGroupHeaderEntry::CGroupHeaderEntry(const TCtorParam ¶m) : CInterfaceGroup(param) + { + _MinSize = 4; + } + + // ***************************************************************************************************************** + bool CGroupHeaderEntry::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur, parentGroup)) return false; + // left mover + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"wmin" )); + if (prop) fromString((const char*)prop, _MinSize); + sint32 resizerSize = 4; + prop = (char*) xmlGetProp( cur, (xmlChar*)"resizer_size" ); + if (prop) fromString((const char*)prop, resizerSize); + prop = (char*) xmlGetProp(cur, (xmlChar*) "target"); + if (prop) _TargetColumnId = (const char *) prop; + + prop = (char*) xmlGetProp(cur, (xmlChar*) "on_resize"); + if (prop) _AHOnResize = (const char *) prop; + prop = (char*) xmlGetProp(cur, (xmlChar*) "on_resize_params"); + if (prop) _AHOnResizeParams = (const char *) prop; + + CHeaderEntryResizer *hm = new CHeaderEntryResizer(false, _MinSize); + addCtrl(hm); + hm->setW(resizerSize); + hm->setSizeRef(2); + hm->setParent(this); + hm->setParentPosRef(Hotspot_TL); + hm->setPosRef(Hotspot_TL); + // right mover + hm = new CHeaderEntryResizer(true, _MinSize); + addCtrl(hm); + hm->setW(resizerSize); + hm->setSizeRef(2); + hm->setParent(this); + hm->setParentPosRef(Hotspot_TR); + hm->setPosRef(Hotspot_TR); + // + return true; + } + + // ***************************************************************************************************************** + CInterfaceGroup *CGroupHeaderEntry::getTargetColumn() const + { + return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_TargetColumnId)); + } + + // ***************************************************************************************************************** + void CGroupHeaderEntry::updateCoords() + { + CInterfaceGroup::updateCoords(); + CInterfaceGroup *targetColumn = getTargetColumn(); + if (targetColumn) + { + if (targetColumn->getW() != getW()) + { + targetColumn->setW(getW()); + targetColumn->invalidateCoords(); + } + } + } + + + NLMISC_REGISTER_OBJECT(CViewBase, CGroupHeader, std::string, "header"); + NLMISC_REGISTER_OBJECT(CViewBase, CGroupHeaderEntry, std::string, "header_entry"); + +} + diff --git a/code/ryzom/client/src/interface_v3/group_header.cpp b/code/ryzom/client/src/interface_v3/group_header.cpp deleted file mode 100644 index b907595a5..000000000 --- a/code/ryzom/client/src/interface_v3/group_header.cpp +++ /dev/null @@ -1,435 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "nel/gui/group_container.h" -#include "group_header.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/widget_manager.h" - - -using namespace NLMISC; - -////////////////// -// CGroupHeader // -////////////////// - -// ***************************************************************************************************************** -CGroupHeader::CGroupHeader(const TCtorParam ¶m) : CGroupList(param), _HeaderMaxSize(32767) -{ -} - -// ***************************************************************************************************************** -void CGroupHeader::enlargeColumns(sint32 margin) -{ - std::vector entries; - getEntries(entries); - sint32 totalWidth = 0; - for (uint k = 0; k < entries.size(); ++k) - { - CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn(); - if (colEnclosing && !colEnclosing->getGroups().empty()) - { - CInterfaceGroup *col = colEnclosing->getGroups()[0]; - if (col) - { - // enlarge to the max to be able to measure the sub text (they may clamp themselves based - // on their first non-"child resizing" parent (see CViewText::updateCoords) - colEnclosing->setW(16384); - colEnclosing->invalidateCoords(); - colEnclosing->updateCoords(); - - // assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList) - entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin)); - entries[k]->invalidateCoords(); - totalWidth += entries[k]->getW(); - } - } - } - // if total width bigger than allowed, reduce proportionnally - if (totalWidth > _HeaderMaxSize) - { - while (totalWidth > _HeaderMaxSize) - { - bool adjusted = false; - // stupid algo here, but ponctual ... - for (uint k = 0; k < entries.size() && totalWidth > _HeaderMaxSize; ++k) - { - if (entries[k]->getW() > entries[k]->getMinSize()) - { - entries[k]->setW(entries[k]->getW() - 1); - entries[k]->invalidateCoords(); - --totalWidth; - adjusted = true; - } - } - // if all at min size, just exit ... - if (!adjusted) break; - } - } - else - { - // search first parent that limit size, if it is larger then enlarge to fit size - CInterfaceGroup *limitingParent = getParent(); - while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast(limitingParent))) - { - // NB nico : the dynamic_cast for CGroupList is bad!! - // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords - // ... - limitingParent = limitingParent->getParent(); - } - if (limitingParent && limitingParent->getWReal() > totalWidth) - { - while (limitingParent->getWReal() > totalWidth && totalWidth < _HeaderMaxSize) - { - // enlarge to matche parent size - // stupid algo here, but ponctual ... - for (uint k = 0; k < entries.size(); ++k) - { - entries[k]->setW(entries[k]->getW() + 1); - entries[k]->invalidateCoords(); - ++totalWidth; - if (limitingParent->getWReal() <= totalWidth || totalWidth >= _HeaderMaxSize) break; - } - } - } - } - invalidateCoords(); -} - -// ***************************************************************************************************************** -void CGroupHeader::resizeColumnsAndContainer(sint32 margin) -{ - std::vector entries; - getEntries(entries); - sint32 totalWidth = 0; - for (uint k = 0; k < entries.size(); ++k) - { - CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn(); - if (colEnclosing && !colEnclosing->getGroups().empty()) - { - CInterfaceGroup *col = colEnclosing->getGroups()[0]; - if (col) - { - // enlarge to the max to be able to measure the sub text (they may clamp themselves based - // on their first non-"child resizing" parent (see CViewText::updateCoords) - colEnclosing->setW(16384); - colEnclosing->invalidateCoords(); - colEnclosing->updateCoords(); - - // assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList) - entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin)); - entries[k]->invalidateCoords(); - totalWidth += entries[k]->getW(); - } - } - } - - // resize W - if (totalWidth <= _HeaderMaxSize) - { - // search first parent that limit size, if it is larger then enlarge to fit size - CInterfaceGroup *limitingParent = getParent(); - while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast(limitingParent))) - { - // NB nico : the dynamic_cast for CGroupList is bad!! - // can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords - // ... - limitingParent = limitingParent->getParent(); - } - - getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal()); - } - - // resize H - if(entries.size()>0) - { - CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn(); - if (colEnclosing && !colEnclosing->getGroups().empty()) - { - CInterfaceGroup *col = colEnclosing->getGroups()[0]; - if (col) - { - // search first parent that limit size, if it is larger then enlarge to fit size - CInterfaceGroup *limitingParent = colEnclosing->getParent(); - while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast(limitingParent))) - limitingParent = limitingParent->getParent(); - - getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); - } - } - } - - - invalidateCoords(); -} - -// ***************************************************************************************************************** -void CGroupHeader::getEntries(std::vector &dest) -{ - dest.clear(); - const std::vector &groups = getGroups(); - for (uint k = 0; k < groups.size(); ++k) - { - CGroupHeaderEntry *entry = dynamic_cast(groups[k]); - if (entry) - { - dest.push_back(entry); - } - } -} - -// ***************************************************************************************************************** -int CGroupHeader::luaEnlargeColumns(CLuaState &ls) -{ - const char *funcName = "enlargeColumns"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - enlargeColumns((sint32) ls.toNumber(1)); - return 0; -} - -// ***************************************************************************************************************** -int CGroupHeader::luaResizeColumnsAndContainer(CLuaState &ls) -{ - const char *funcName = "resizeColumnsAndContainer"; - CLuaIHM::checkArgCount(ls, funcName, 1); - CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - resizeColumnsAndContainer((sint32) ls.toNumber(1)); - return 0; -} - -// ***************************************************************************************************************** -bool CGroupHeader::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CGroupList::parse(cur, parentGroup)) return false; - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"header_max_size" )); - if (prop) fromString((const char*)prop, _HeaderMaxSize); - return true; -} - -///////////////////////// -// CHeaderEntryResizer // -///////////////////////// - -class CHeaderEntryResizer : public CCtrlBase -{ -public: - CHeaderEntryResizer(bool rightSide, sint32 wMin) : CCtrlBase(TCtorParam()), - _RightSide(rightSide), - _Moving(false), - _StartX(0), - _OffsetX(0), - _WMin(wMin) - {} - void release() - { - if (CWidgetManager::getInstance()->getCapturePointerLeft() == this) - { - _Moving = false; - CWidgetManager::getInstance()->setCapturePointerLeft(NULL); - } - } - virtual uint getDeltaDepth() const { return 100; } - CInterfaceGroup *getTargetGroup() - { - if (_RightSide) return _Parent; - - if (getParent()->getParent() == _Parent->getParentPos()) return NULL; // leftmost header - return dynamic_cast(getParent()->getParentPos()); - } - bool handleEvent (const NLGUI::CEventDescriptor &event) - { - if (_Parent) - { - if (event.getType() == NLGUI::CEventDescriptor::system) - { - const NLGUI::CEventDescriptorSystem &eds = (const NLGUI::CEventDescriptorSystem &) event; - if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus) - { - const NLGUI::CEventDescriptorSetFocus &edsf = (const NLGUI::CEventDescriptorSetFocus &) eds; - if (edsf.hasFocus() == false) - { - release(); - return CCtrlBase::handleEvent(event); - } - } - } - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) - { - if (!this->isIn(eventDesc.getX(), eventDesc.getY())) return false; - _TargetGroup = getTargetGroup(); - if (!_TargetGroup) return false; - CWidgetManager::getInstance()->setCapturePointerLeft(this); - _Moving = true; - _OffsetX = _TargetGroup->getW() - eventDesc.getX(); - return true; - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) - { - release(); - } - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove) - { - if (_Moving && CWidgetManager::getInstance()->getCapturePointerLeft() == this) - { - if (!_TargetGroup) - { - release(); - return false; - } - sint32 newW = eventDesc.getX() + _OffsetX; - // compute width of all header entries but this one - CGroupHeader *header = dynamic_cast(getParent()->getParent()); - if (header) - { - sint32 w = 0; - for (uint k = 0; k < header->getNumChildren(); ++k) - { - if (header->getChild(k) != _TargetGroup) - { - w += header->getChild(k)->getW(); - } - } - sint32 excess = w + newW - header->getHeaderMaxSize(); - if (excess) - { - // try to diminish the size of all headers starting from the last - for (sint k = header->getNumChildren() - 1; k >= 0 && excess > 0; --k) - { - if (header->getChild(k) == _TargetGroup) break; - CGroupHeaderEntry *ghe = dynamic_cast(header->getChild(k)); - sint32 wGain = std::min(excess, std::max((sint32) 0, ghe->getW() - ghe->getMinSize())); - if (wGain > 0) - { - ghe->setW(ghe->getW() - wGain); - ghe->invalidateCoords(); - excess -= wGain; - } - } - } - newW -= std::max((sint32) 0, excess); - } - _TargetGroup->setW(std::max(_WMin, newW)); - _TargetGroup->invalidateCoords(); - CGroupHeaderEntry *ghe = dynamic_cast((CInterfaceGroup *) _TargetGroup); - if (ghe) - { - ghe->setW(_TargetGroup->getW()); - ghe->invalidateCoords(); - CAHManager::getInstance()->runActionHandler(ghe->getAHOnResize(), ghe, ghe->getAHOnResizeParams()); - } - return true; - } - _Moving = false; - } - } - } - return CCtrlBase::handleEvent(event); - } - virtual void draw () - { - // no-op - } - virtual bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col) - { - - if (!getTargetGroup()) return false; - texName = "curs_resize_LR.tga"; - rot = 0; - col = CRGBA::White; - return true; - } - -private: - NLMISC::CRefPtr _TargetGroup; // group for which w is modified - bool _RightSide; // right or left side mover ? - bool _Moving; - sint32 _StartX; // value to add to mouse to get local x pos of target group - sint32 _OffsetX; - sint32 _WMin; -}; - -// ***************************************************************************************************************** -CGroupHeaderEntry::CGroupHeaderEntry(const TCtorParam ¶m) : CInterfaceGroup(param) -{ - _MinSize = 4; -} - -// ***************************************************************************************************************** -bool CGroupHeaderEntry::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur, parentGroup)) return false; - // left mover - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"wmin" )); - if (prop) fromString((const char*)prop, _MinSize); - sint32 resizerSize = 4; - prop = (char*) xmlGetProp( cur, (xmlChar*)"resizer_size" ); - if (prop) fromString((const char*)prop, resizerSize); - prop = (char*) xmlGetProp(cur, (xmlChar*) "target"); - if (prop) _TargetColumnId = (const char *) prop; - - prop = (char*) xmlGetProp(cur, (xmlChar*) "on_resize"); - if (prop) _AHOnResize = (const char *) prop; - prop = (char*) xmlGetProp(cur, (xmlChar*) "on_resize_params"); - if (prop) _AHOnResizeParams = (const char *) prop; - - CHeaderEntryResizer *hm = new CHeaderEntryResizer(false, _MinSize); - addCtrl(hm); - hm->setW(resizerSize); - hm->setSizeRef(2); - hm->setParent(this); - hm->setParentPosRef(Hotspot_TL); - hm->setPosRef(Hotspot_TL); - // right mover - hm = new CHeaderEntryResizer(true, _MinSize); - addCtrl(hm); - hm->setW(resizerSize); - hm->setSizeRef(2); - hm->setParent(this); - hm->setParentPosRef(Hotspot_TR); - hm->setPosRef(Hotspot_TR); - // - return true; -} - -// ***************************************************************************************************************** -CInterfaceGroup *CGroupHeaderEntry::getTargetColumn() const -{ - return dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_TargetColumnId)); -} - -// ***************************************************************************************************************** -void CGroupHeaderEntry::updateCoords() -{ - CInterfaceGroup::updateCoords(); - CInterfaceGroup *targetColumn = getTargetColumn(); - if (targetColumn) - { - if (targetColumn->getW() != getW()) - { - targetColumn->setW(getW()); - targetColumn->invalidateCoords(); - } - } -} - - -NLMISC_REGISTER_OBJECT(CViewBase, CGroupHeader, std::string, "header"); -NLMISC_REGISTER_OBJECT(CViewBase, CGroupHeaderEntry, std::string, "header_entry"); diff --git a/code/ryzom/client/src/interface_v3/group_header.h b/code/ryzom/client/src/interface_v3/group_header.h deleted file mode 100644 index 113130d1d..000000000 --- a/code/ryzom/client/src/interface_v3/group_header.h +++ /dev/null @@ -1,85 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_GROUP_HEADER_H -#define CL_GROUP_HEADER_H - - -#include "nel/gui/group_list.h" - - -class CGroupHeaderEntry; - -// ***************************************************************************************************************** -/** Display a header with movable entries. - * Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode) - * - * \author Nicolas Vizerie - * \author Nevrax France - * \date 2006 - */ -class CGroupHeader : public CGroupList -{ -public: - REFLECT_EXPORT_START(CGroupHeader, CGroupList) - REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns); - REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer); - REFLECT_EXPORT_END - CGroupHeader(const TCtorParam ¶m); - // from CInterfaceGroup - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - sint32 getHeaderMaxSize() const { return _HeaderMaxSize; } - // get the entries in this header - void getEntries(std::vector &dest); - // ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()' - void enlargeColumns(sint32 margin); - // ensure that content of each column is visible - void resizeColumnsAndContainer(sint32 margin); -private: - sint32 _HeaderMaxSize; - int luaEnlargeColumns(CLuaState &ls); - int luaResizeColumnsAndContainer(CLuaState &ls); -}; - -// ***************************************************************************************************************** -// an entry in a header, includes a "mover control" to move it inside its parent header -// NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size' -class CGroupHeaderEntry : public CInterfaceGroup -{ -public: - CGroupHeaderEntry(const TCtorParam ¶m); - // from CInterfaceGroup - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - sint32 getMinSize() const { return _MinSize; } - virtual void updateCoords(); - CInterfaceGroup *getTargetColumn() const; - - const std::string &getAHOnResize() const { return _AHOnResize; } - const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } - -private: - sint32 _MinSize; - std::string _TargetColumnId; - - std::string _AHOnResize; - std::string _AHOnResizeParams; -}; - - - - -#endif - diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index a8c8b35e4..f71ccb5a2 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -50,7 +50,7 @@ #include "dbgroup_combo_box.h" #include "nel/gui/group_tab.h" #include "group_html.h" -#include "group_header.h" +#include "nel/gui/group_header.h" #include "sphrase_manager.h" // #include "../r2/displayer_visual.h" From 2b2eb5cb783efd2681c80e7ba63456fb9ca732f7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:14:36 +0200 Subject: [PATCH 106/339] CHANGED: CDBViewBar no longer depends on CInterfaceManager. --- code/ryzom/client/src/interface_v3/dbview_bar.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp index 53984d0d1..08975b4fc 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar.cpp @@ -15,14 +15,11 @@ // along with this program. If not, see . - -// ---------------------------------------------------------------------------- -#include "stdpch.h" - #include "dbview_bar.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" - +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/db_manager.h" using namespace std; using namespace NL3D; @@ -118,7 +115,6 @@ void CDBViewBar::setType (TViewBar vb) } // Get the Height Size. - CInterfaceManager *pIM= CInterfaceManager::getInstance(); sint32 wBar; CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, wBar, _HBar); } @@ -179,7 +175,6 @@ void CDBViewBar::draw () _Slot.draw(); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); color.A = (uint8)(((sint32)color.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); From cdb0c5b6c5a69447968ee74627b491a993b0db65 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:30:12 +0200 Subject: [PATCH 107/339] CHANGED: #1471 CDBViewBar is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/dbview_bar.h | 112 +++++++++ code/nel/src/gui/dbview_bar.cpp | 233 ++++++++++++++++++ .../src/interface_v3/action_handler_help.cpp | 2 +- .../src/interface_v3/action_phrase_faber.cpp | 2 +- .../client/src/interface_v3/dbview_bar.cpp | 227 ----------------- .../client/src/interface_v3/dbview_bar.h | 108 -------- .../client/src/interface_v3/group_skills.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- 9 files changed, 350 insertions(+), 340 deletions(-) create mode 100644 code/nel/include/nel/gui/dbview_bar.h create mode 100644 code/nel/src/gui/dbview_bar.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_bar.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_bar.h diff --git a/code/nel/include/nel/gui/dbview_bar.h b/code/nel/include/nel/gui/dbview_bar.h new file mode 100644 index 000000000..ae322060e --- /dev/null +++ b/code/nel/include/nel/gui/dbview_bar.h @@ -0,0 +1,112 @@ +// Ryzom - MMORPG Framework +// 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 RZ_DBVIEW_BAR_H +#define RZ_DBVIEW_BAR_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + + /** + * class implementing a bitmap used as the front texture of a progress bar + * the bitmap is drawn from _X to _W * _Range/_RangeMax + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CDBViewBar : public CViewBitmap + { + public: + enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick }; + public: + + /// Constructor + CDBViewBar(const TCtorParam ¶m) + : CViewBitmap(param), + _Slot(TCtorParam()) + { + _Color= NLMISC::CRGBA::White; + _ValueInt= 0; + _RangeInt = 255; + _ReferenceInt= 0; + _Type = ViewBar_Normal; + } + + void setType (TViewBar vb); + + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords (); + virtual void draw (); + + /// Nbs: Values by Int are not used if the Links are setuped + void setValue (sint32 r) { _ValueInt = r; } + void setRange (sint32 r) { _RangeInt = r; } + void setReference (sint32 r) { _ReferenceInt = r; } + sint32 getValue () const { return _ValueInt; } + sint32 getRange () const { return _RangeInt; } + sint32 getReference () const { return _ReferenceInt; } + + void setValueDbLink (const std::string &r); + void setRangeDbLink (const std::string &r); + void setReferenceDbLink (const std::string &r); + std::string getValueDbLink () const; + std::string getRangeDbLink () const; + std::string getReferenceDbLink () const; + + // Reflect ValueInt (ie not used if the link is setuped) + REFLECT_EXPORT_START(CDBViewBar, CViewBitmap) + REFLECT_SINT32 ("value", getValue, setValue); + REFLECT_SINT32 ("range", getRange, setRange); + REFLECT_SINT32 ("reference", getReference, setReference); + REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink); + REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink); + REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink); + REFLECT_EXPORT_END + + protected: + + CViewBitmap _Slot; + TViewBar _Type; + sint32 _HBar; + NLMISC::CRGBA _ColorNegative; + + // Value of the progression in arbitrary units. should be integer + CInterfaceProperty _Value; + // Max range of the progression in arbitrary units. should be integer + CInterfaceProperty _Range; + // Reference of the progression (substracted from value and range). + CInterfaceProperty _Reference; + + /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links + sint32 _ValueInt; + sint32 _RangeInt; + sint32 _ReferenceInt; + + void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); + sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); + }; + +} + +#endif // RZ_DBVIEW_BAR_H + +/* End of dbview_bar.h */ diff --git a/code/nel/src/gui/dbview_bar.cpp b/code/nel/src/gui/dbview_bar.cpp new file mode 100644 index 000000000..dce0f70fb --- /dev/null +++ b/code/nel/src/gui/dbview_bar.cpp @@ -0,0 +1,233 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbview_bar.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/db_manager.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar, std::string, "bar"); + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + void CDBViewBar::parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name) + { + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)name )); + if (prop) + { + if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') + fromString((const char*)prop, intProp); + else + dbProp.link(prop); + } + } + + + // ---------------------------------------------------------------------------- + bool CDBViewBar::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CViewBitmap::parse(cur, parentGroup)) + { + string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + return false; + } + + CXMLAutoPtr prop; + + // read value, range and reference + parseValProp(cur, _Value, _ValueInt, "value"); + parseValProp(cur, _Range, _RangeInt, "range"); + parseValProp(cur, _Reference, _ReferenceInt, "reference"); + + // Get Visual props + prop= (char*) xmlGetProp( cur, (xmlChar*)"color_negative" ); + _ColorNegative = CRGBA(0,0,0,0); + if (prop) + _ColorNegative = convertColor (prop); + + // Bar Type + _Type = ViewBar_Normal; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"mini" ); + if (prop) + if (convertBool(prop)) + setType(ViewBar_Mini); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"ultra_mini" ); + if (prop) + if (convertBool(prop)) + setType(ViewBar_UltraMini); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"mini_thick" ); + if (prop) + if (convertBool(prop)) + setType(ViewBar_MiniThick); + + if (_Type == ViewBar_Normal) + setType(ViewBar_Normal); + + return true; + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::setType (TViewBar vb) + { + _Type = vb; + switch(_Type) + { + case ViewBar_Normal: _Slot.setTexture ("w_slot_jauge_1.tga"); break; + case ViewBar_Mini: _Slot.setTexture ("w_slot_jauge_1_mini.tga"); break; + case ViewBar_UltraMini: _Slot.setTexture ("w_slot_jauge_1_umin.tga"); break; + case ViewBar_MiniThick: _Slot.setTexture ("w_slot_jauge_1_tmin.tga"); break; + } + + _Slot.setPosRef (_PosRef); + _Slot.setParentPosRef (_ParentPosRef); + _Slot.setX (_X); + _Slot.setY (_Y); + + _Scale = true; + switch(_Type) + { + case ViewBar_Normal: setTexture ("w_jauge_fill.tga"); break; + case ViewBar_Mini: setTexture ("w_jauge_fill_mini.tga"); break; + case ViewBar_UltraMini: setTexture ("w_jauge_fill_umin.tga"); break; + case ViewBar_MiniThick: setTexture ("w_jauge_fill_tmin.tga"); break; + } + + // Get the Height Size. + sint32 wBar; + CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, wBar, _HBar); + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::updateCoords () + { + if (_ParentPos == NULL) + _Slot.setParentPos (_Parent); + else + _Slot.setParentPos (_ParentPos); + _Slot.updateCoords(); + _W = _Slot.getW(); + _H = _Slot.getH(); + CViewBitmap::updateCoords(); + } + + // ---------------------------------------------------------------------------- + sint64 CDBViewBar::getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp) + { + if(dbProp.getNodePtr()) + return dbProp.getSInt64(); + else + return intProp; + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::draw () + { + float wBar = (float)(_Slot.getWReal()-4); + + sint64 value= getCurrentValProp(_Value, _ValueInt); + sint64 range= getCurrentValProp(_Range, _RangeInt); + sint64 reference= getCurrentValProp(_Reference, _ReferenceInt); + + // remove the reference + value-= reference; + range-= reference; + + // draw the bar + CRGBA color = _Color; + + if (range > 0) + { + float ratio= (float)value / range; + if (_ColorNegative.A != 0 && ratio < 0.0f) + { + ratio = - ratio; + color = _ColorNegative; + } + NLMISC::clamp(ratio, 0.f, 1.f); + wBar *= ratio; + } + else + wBar = 0; + + _WReal = (sint32)wBar; + + _Slot.draw(); + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + color.A = (uint8)(((sint32)color.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); + + // compute the DeltaY: mean of dif. + sint32 deltaY= (_H-_HBar)/2; + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+2, _YReal+deltaY, _WReal, _HBar, 0, false, _TextureId, color); + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::setValueDbLink (const std::string &r) + { + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); + if (pNL != NULL) _Value.setNodePtr(pNL); + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::setRangeDbLink (const std::string &r) + { + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); + if (pNL != NULL) _Range.setNodePtr(pNL); + } + + // ---------------------------------------------------------------------------- + void CDBViewBar::setReferenceDbLink (const std::string &r) + { + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); + if (pNL != NULL) _Reference.setNodePtr(pNL); + } + + // ---------------------------------------------------------------------------- + string CDBViewBar::getValueDbLink () const + { + if (_Value.getNodePtr() == NULL) return ""; + return _Value.getNodePtr()->getFullName(); + } + + // ---------------------------------------------------------------------------- + string CDBViewBar::getRangeDbLink () const + { + if (_Range.getNodePtr() == NULL) return ""; + return _Range.getNodePtr()->getFullName(); + } + + // ---------------------------------------------------------------------------- + string CDBViewBar::getReferenceDbLink () const + { + if (_Reference.getNodePtr() == NULL) return ""; + return _Reference.getNodePtr()->getFullName(); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 987a6d1b4..b8573e74d 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -33,7 +33,7 @@ #include "../user_entity.h" #include "../entities.h" #include "dbgroup_combo_box.h" -#include "dbview_bar.h" +#include "nel/gui/dbview_bar.h" #include "../debug_client.h" #include "interface_3d_scene.h" #include "character_3d.h" diff --git a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp index dd981f0b4..cfd442deb 100644 --- a/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp +++ b/code/ryzom/client/src/interface_v3/action_phrase_faber.cpp @@ -31,7 +31,7 @@ #include "sbrick_manager.h" #include "sphrase_manager.h" #include "nel/gui/group_editbox.h" -#include "dbview_bar.h" +#include "nel/gui/dbview_bar.h" #include "skill_manager.h" #include "game_share/bot_chat_types.h" diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.cpp b/code/ryzom/client/src/interface_v3/dbview_bar.cpp deleted file mode 100644 index 08975b4fc..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_bar.cpp +++ /dev/null @@ -1,227 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbview_bar.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/interface_group.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/db_manager.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar, std::string, "bar"); - -// ---------------------------------------------------------------------------- -void CDBViewBar::parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name) -{ - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)name )); - if (prop) - { - if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') - fromString((const char*)prop, intProp); - else - dbProp.link(prop); - } -} - - -// ---------------------------------------------------------------------------- -bool CDBViewBar::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CViewBitmap::parse(cur, parentGroup)) - { - string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - return false; - } - - CXMLAutoPtr prop; - - // read value, range and reference - parseValProp(cur, _Value, _ValueInt, "value"); - parseValProp(cur, _Range, _RangeInt, "range"); - parseValProp(cur, _Reference, _ReferenceInt, "reference"); - - // Get Visual props - prop= (char*) xmlGetProp( cur, (xmlChar*)"color_negative" ); - _ColorNegative = CRGBA(0,0,0,0); - if (prop) - _ColorNegative = convertColor (prop); - - // Bar Type - _Type = ViewBar_Normal; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"mini" ); - if (prop) - if (convertBool(prop)) - setType(ViewBar_Mini); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"ultra_mini" ); - if (prop) - if (convertBool(prop)) - setType(ViewBar_UltraMini); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"mini_thick" ); - if (prop) - if (convertBool(prop)) - setType(ViewBar_MiniThick); - - if (_Type == ViewBar_Normal) - setType(ViewBar_Normal); - - return true; -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::setType (TViewBar vb) -{ - _Type = vb; - switch(_Type) - { - case ViewBar_Normal: _Slot.setTexture ("w_slot_jauge_1.tga"); break; - case ViewBar_Mini: _Slot.setTexture ("w_slot_jauge_1_mini.tga"); break; - case ViewBar_UltraMini: _Slot.setTexture ("w_slot_jauge_1_umin.tga"); break; - case ViewBar_MiniThick: _Slot.setTexture ("w_slot_jauge_1_tmin.tga"); break; - } - - _Slot.setPosRef (_PosRef); - _Slot.setParentPosRef (_ParentPosRef); - _Slot.setX (_X); - _Slot.setY (_Y); - - _Scale = true; - switch(_Type) - { - case ViewBar_Normal: setTexture ("w_jauge_fill.tga"); break; - case ViewBar_Mini: setTexture ("w_jauge_fill_mini.tga"); break; - case ViewBar_UltraMini: setTexture ("w_jauge_fill_umin.tga"); break; - case ViewBar_MiniThick: setTexture ("w_jauge_fill_tmin.tga"); break; - } - - // Get the Height Size. - sint32 wBar; - CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, wBar, _HBar); -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::updateCoords () -{ - if (_ParentPos == NULL) - _Slot.setParentPos (_Parent); - else - _Slot.setParentPos (_ParentPos); - _Slot.updateCoords(); - _W = _Slot.getW(); - _H = _Slot.getH(); - CViewBitmap::updateCoords(); -} - -// ---------------------------------------------------------------------------- -sint64 CDBViewBar::getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp) -{ - if(dbProp.getNodePtr()) - return dbProp.getSInt64(); - else - return intProp; -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::draw () -{ - float wBar = (float)(_Slot.getWReal()-4); - - sint64 value= getCurrentValProp(_Value, _ValueInt); - sint64 range= getCurrentValProp(_Range, _RangeInt); - sint64 reference= getCurrentValProp(_Reference, _ReferenceInt); - - // remove the reference - value-= reference; - range-= reference; - - // draw the bar - CRGBA color = _Color; - - if (range > 0) - { - float ratio= (float)value / range; - if (_ColorNegative.A != 0 && ratio < 0.0f) - { - ratio = - ratio; - color = _ColorNegative; - } - NLMISC::clamp(ratio, 0.f, 1.f); - wBar *= ratio; - } - else - wBar = 0; - - _WReal = (sint32)wBar; - - _Slot.draw(); - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - color.A = (uint8)(((sint32)color.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - - // compute the DeltaY: mean of dif. - sint32 deltaY= (_H-_HBar)/2; - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+2, _YReal+deltaY, _WReal, _HBar, 0, false, _TextureId, color); -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::setValueDbLink (const std::string &r) -{ - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); - if (pNL != NULL) _Value.setNodePtr(pNL); -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::setRangeDbLink (const std::string &r) -{ - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); - if (pNL != NULL) _Range.setNodePtr(pNL); -} - -// ---------------------------------------------------------------------------- -void CDBViewBar::setReferenceDbLink (const std::string &r) -{ - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(r,false); - if (pNL != NULL) _Reference.setNodePtr(pNL); -} - -// ---------------------------------------------------------------------------- -string CDBViewBar::getValueDbLink () const -{ - if (_Value.getNodePtr() == NULL) return ""; - return _Value.getNodePtr()->getFullName(); -} - -// ---------------------------------------------------------------------------- -string CDBViewBar::getRangeDbLink () const -{ - if (_Range.getNodePtr() == NULL) return ""; - return _Range.getNodePtr()->getFullName(); -} - -// ---------------------------------------------------------------------------- -string CDBViewBar::getReferenceDbLink () const -{ - if (_Reference.getNodePtr() == NULL) return ""; - return _Reference.getNodePtr()->getFullName(); -} diff --git a/code/ryzom/client/src/interface_v3/dbview_bar.h b/code/ryzom/client/src/interface_v3/dbview_bar.h deleted file mode 100644 index f3ee02129..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_bar.h +++ /dev/null @@ -1,108 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_DBVIEW_BAR_H -#define RZ_DBVIEW_BAR_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/view_bitmap.h" - -/** - * class implementing a bitmap used as the front texture of a progress bar - * the bitmap is drawn from _X to _W * _Range/_RangeMax - * \author Nicolas Brigand - * \author Nevrax France - * \date 2002 - */ -class CDBViewBar : public CViewBitmap -{ -public: - enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick }; -public: - - /// Constructor - CDBViewBar(const TCtorParam ¶m) - : CViewBitmap(param), - _Slot(TCtorParam()) - { - _Color= NLMISC::CRGBA::White; - _ValueInt= 0; - _RangeInt = 255; - _ReferenceInt= 0; - _Type = ViewBar_Normal; - } - - void setType (TViewBar vb); - - bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - virtual void updateCoords (); - virtual void draw (); - - /// Nbs: Values by Int are not used if the Links are setuped - void setValue (sint32 r) { _ValueInt = r; } - void setRange (sint32 r) { _RangeInt = r; } - void setReference (sint32 r) { _ReferenceInt = r; } - sint32 getValue () const { return _ValueInt; } - sint32 getRange () const { return _RangeInt; } - sint32 getReference () const { return _ReferenceInt; } - - void setValueDbLink (const std::string &r); - void setRangeDbLink (const std::string &r); - void setReferenceDbLink (const std::string &r); - std::string getValueDbLink () const; - std::string getRangeDbLink () const; - std::string getReferenceDbLink () const; - - // Reflect ValueInt (ie not used if the link is setuped) - REFLECT_EXPORT_START(CDBViewBar, CViewBitmap) - REFLECT_SINT32 ("value", getValue, setValue); - REFLECT_SINT32 ("range", getRange, setRange); - REFLECT_SINT32 ("reference", getReference, setReference); - REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink); - REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink); - REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink); - REFLECT_EXPORT_END - -protected: - - CViewBitmap _Slot; - TViewBar _Type; - sint32 _HBar; - NLMISC::CRGBA _ColorNegative; - - // Value of the progression in arbitrary units. should be integer - CInterfaceProperty _Value; - // Max range of the progression in arbitrary units. should be integer - CInterfaceProperty _Range; - // Reference of the progression (substracted from value and range). - CInterfaceProperty _Reference; - - /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links - sint32 _ValueInt; - sint32 _RangeInt; - sint32 _ReferenceInt; - - void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); - sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); -}; - - -#endif // RZ_DBVIEW_BAR_H - -/* End of dbview_bar.h */ diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index c73082c1e..d24e1afc5 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -26,7 +26,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/view_bitmap.h" #include "dbview_number.h" -#include "dbview_bar.h" +#include "nel/gui/dbview_bar.h" #include "game_share/skills.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 5f27cf92e..484d46bea 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -46,7 +46,7 @@ #include "view_radar.h" #include "view_pointer.h" // DBView (View linked to the database) -#include "dbview_bar.h" +#include "nel/gui/dbview_bar.h" #include "dbview_bar3.h" #include "dbview_number.h" #include "dbview_quantity.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index f71ccb5a2..e2375447c 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -43,7 +43,7 @@ #include "nel/gui/group_editbox.h" #include "nel/gui/group_tree.h" #include "nel/gui/reflect.h" -#include "dbview_bar.h" +#include "nel/gui/dbview_bar.h" #include "dbview_bar3.h" #include "nel/gui/ctrl_scroll_base.h" #include "nel/gui/ctrl_scroll.h" From f14ca72e58f689f48dc00658ec3270efe5740cd8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:33:55 +0200 Subject: [PATCH 108/339] CHANGED: #1471 CDBViewBar3 no longer depends on CInterfaceManager. --- code/ryzom/client/src/interface_v3/dbview_bar3.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp index 9b40ba06d..543ed12a9 100644 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp @@ -15,13 +15,11 @@ // along with this program. If not, see . - -// ---------------------------------------------------------------------------- -#include "stdpch.h" - #include "dbview_bar3.h" -#include "interface_manager.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/db_manager.h" +#include "nel/gui/interface_group.h" using namespace std; using namespace NL3D; @@ -161,7 +159,6 @@ void CDBViewBar3::draw () { _Slot.draw(); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); CRGBA gColor = CWidgetManager::getInstance()->getGlobalColorForContent(); From 2f0a724cd709a27ed5b6809a62bad23cad226cd8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 24 Jun 2012 04:51:30 +0200 Subject: [PATCH 109/339] CHANGED: #1471 CDBViewBar3 is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/dbview_bar3.h | 103 ++++++++ code/nel/src/gui/dbview_bar3.cpp | 239 ++++++++++++++++++ .../client/src/interface_v3/dbview_bar3.cpp | 235 ----------------- .../client/src/interface_v3/dbview_bar3.h | 99 -------- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- 6 files changed, 344 insertions(+), 336 deletions(-) create mode 100644 code/nel/include/nel/gui/dbview_bar3.h create mode 100644 code/nel/src/gui/dbview_bar3.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_bar3.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_bar3.h diff --git a/code/nel/include/nel/gui/dbview_bar3.h b/code/nel/include/nel/gui/dbview_bar3.h new file mode 100644 index 000000000..40301f1e2 --- /dev/null +++ b/code/nel/include/nel/gui/dbview_bar3.h @@ -0,0 +1,103 @@ +// Ryzom - MMORPG Framework +// 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 RZ_DBVIEW_BAR3_H +#define RZ_DBVIEW_BAR3_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + + /** + * class implementing a 3 Bar widget + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CDBViewBar3 : public CViewBitmap + { + public: + + /// Constructor + CDBViewBar3(const TCtorParam ¶m); + + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords (); + + void setMini (bool mini); + + virtual void draw (); + + /// Nbs: Values by Int are not used if the Links are setuped + void setValue0 (sint32 r) { _ValueInt[0] = r; } + void setValue1 (sint32 r) { _ValueInt[1] = r; } + void setValue2 (sint32 r) { _ValueInt[2] = r; } + void setRange0 (sint32 r) { _RangeInt[0] = r; } + void setRange1 (sint32 r) { _RangeInt[1] = r; } + void setRange2 (sint32 r) { _RangeInt[2] = r; } + sint32 getValue0 () const { return _ValueInt[0]; } + sint32 getValue1 () const { return _ValueInt[1]; } + sint32 getValue2 () const { return _ValueInt[2]; } + sint32 getRange0 () const { return _RangeInt[0]; } + sint32 getRange1 () const { return _RangeInt[1]; } + sint32 getRange2 () const { return _RangeInt[2]; } + + // Reflect ValueInt (ie not used if the link is setuped) + REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap) + REFLECT_SINT32 ("value1", getValue0, setValue0); + REFLECT_SINT32 ("value2", getValue1, setValue1); + REFLECT_SINT32 ("value3", getValue2, setValue2); + REFLECT_SINT32 ("range1", getRange0, setRange0); + REFLECT_SINT32 ("range2", getRange1, setRange1); + REFLECT_SINT32 ("range3", getRange2, setRange2); + REFLECT_EXPORT_END + + protected: + + CViewBitmap _Slot; + + // Value of the progression in arbitrary units. should be integer + CInterfaceProperty _Value[3]; + // Max range of the progression in arbitrary units. should be integer + CInterfaceProperty _Range[3]; + + /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links + sint32 _ValueInt[3]; + sint32 _RangeInt[3]; + + + NLMISC::CRGBA _Colors[3]; + NLMISC::CRGBA _ColorsNegative[3]; + + bool _Mini; + + // Height of the bitmap + sint32 _BarH; + + void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); + sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); + }; + +} + +#endif // RZ_DBVIEW_BAR3_H + +/* End of dbview_bar3.h */ diff --git a/code/nel/src/gui/dbview_bar3.cpp b/code/nel/src/gui/dbview_bar3.cpp new file mode 100644 index 000000000..03eda066d --- /dev/null +++ b/code/nel/src/gui/dbview_bar3.cpp @@ -0,0 +1,239 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbview_bar3.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/db_manager.h" +#include "nel/gui/interface_group.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +namespace NLGUI +{ + + NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar3, std::string, "bar3"); + + // ---------------------------------------------------------------------------- + CDBViewBar3::CDBViewBar3(const TCtorParam ¶m) + : CViewBitmap(param), + _Slot(TCtorParam()) + { + _Mini = false; + _ColorsNegative[0] = _ColorsNegative[1] = _ColorsNegative[2] = NLMISC::CRGBA(0,0,0,0); + _ValueInt[0] = _ValueInt[1] = _ValueInt[2] = 0; + _RangeInt[0] = _RangeInt[1] = _RangeInt[2] = 255; + } + + + // ---------------------------------------------------------------------------- + void CDBViewBar3::parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name) + { + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)name )); + if (prop) + { + if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') + fromString((const char*)prop, intProp); + else + dbProp.link(prop); + } + } + + + // ---------------------------------------------------------------------------- + bool CDBViewBar3::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CViewBitmap::parse(cur, parentGroup)) + { + string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); + nlinfo(tmp.c_str()); + return false; + } + + // read values + parseValProp(cur, _Value[0], _ValueInt[0], "value1" ); + parseValProp(cur, _Value[1], _ValueInt[1], "value2" ); + parseValProp(cur, _Value[2], _ValueInt[2], "value3" ); + + // read ranges + parseValProp(cur, _Range[0], _RangeInt[0], "range1" ); + parseValProp(cur, _Range[1], _RangeInt[1], "range2" ); + parseValProp(cur, _Range[2], _RangeInt[2], "range3" ); + + + // Read colors etc.... + CXMLAutoPtr prop; + + prop = (char*) xmlGetProp( cur, (xmlChar*)"color1" ); + _Colors[0] = convertColor(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"color2" ); + _Colors[1] = convertColor(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"color3" ); + _Colors[2] = convertColor(prop); + + prop = (char*) xmlGetProp( cur, (xmlChar*)"color1_negative" ); + _ColorsNegative[0] = convertColor(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"color2_negative" ); + _ColorsNegative[1] = convertColor(prop); + prop = (char*) xmlGetProp( cur, (xmlChar*)"color3_negative" ); + _ColorsNegative[2] = convertColor(prop); + + + _Mini = false; + prop = (char*) xmlGetProp( cur, (xmlChar*)"mini" ); + if (prop) + if (convertBool(prop)) + setMini(true); + + if (_Mini == false) + setMini(false); + + return true; + } + + // ---------------------------------------------------------------------------- + void CDBViewBar3::setMini(bool b) + { + _Mini = b; + if (_Mini) + _Slot.setTexture ("w_slot_jauge_3_mini.tga"); + else + _Slot.setTexture ("w_slot_jauge_3.tga"); + + _Slot.setPosRef (_PosRef); + _Slot.setParentPosRef (_ParentPosRef); + _Slot.setX (_X); + _Slot.setY (_Y); + + _Scale = true; + if (_Mini) + setTexture ("w_jauge_fill_mini.tga"); + else + setTexture ("w_jauge_fill.tga"); + } + + // ---------------------------------------------------------------------------- + void CDBViewBar3::updateCoords () + { + if (_ParentPos == NULL) + _Slot.setParentPos (_Parent); + else + _Slot.setParentPos (_ParentPos); + _Slot.updateCoords(); + _W = _Slot.getW(); + _H = _Slot.getH(); + + // get the height of the texture + sint32 dummy; + CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, dummy, _BarH); + + CViewBitmap::updateCoords(); + } + + // ---------------------------------------------------------------------------- + sint32 CDBViewBar3::getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp) + { + if(dbProp.getNodePtr()) + return dbProp.getSInt32(); + else + return intProp; + } + + + // ---------------------------------------------------------------------------- + void CDBViewBar3::draw () + { + _Slot.draw(); + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + CRGBA gColor = CWidgetManager::getInstance()->getGlobalColorForContent(); + + if (_Mini) + { + for (uint32 i = 0; i < 3; ++i) + { + float factor; + CRGBA color; + + sint32 value= getCurrentValProp(_Value[i], _ValueInt[i]); + sint32 range= getCurrentValProp(_Range[i], _RangeInt[i]); + + if (range > 0) + factor = ( (float)value / (float)range ); + else + factor = 0; + + if (factor < 0) + { + factor = -factor; + color = _ColorsNegative[i]; + } + else + { + color = _Colors[i]; + } + + // clamp the factor to 0/1 + clamp(factor, 0, 1); + float wBar= factor * (float)(_Slot.getWReal()-2); + + color.A = (uint8)(((sint32)color.A*((sint32)gColor.A+1))>>8); + _WReal = (sint32)wBar; + + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+1, _YReal+i*3+2, _WReal, _BarH, 0, false, _TextureId, color); + } + } + else + { + for (uint32 i = 0; i < 3; ++i) + { + float factor; + CRGBA color; + + sint32 value= getCurrentValProp(_Value[i], _ValueInt[i]); + sint32 range= getCurrentValProp(_Range[i], _RangeInt[i]); + + if (range > 0) + factor = ( (float)value / (float)range ); + else + factor = 0; + + if (factor < 0) + { + factor = -factor; + color = _ColorsNegative[i]; + } + else + { + color = _Colors[i]; + } + + // clamp the factor to 0/1 + clamp(factor, 0, 1); + float wBar= factor * (float)(_Slot.getWReal()-4); + + color.A = (uint8)(((sint32)color.A*((sint32)gColor.A+1))>>8); + _WReal = (sint32)wBar; + + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+2, _YReal+i*7+4, _WReal, _BarH, 0, false, _TextureId, color); + } + } + } +} + diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp b/code/ryzom/client/src/interface_v3/dbview_bar3.cpp deleted file mode 100644 index 543ed12a9..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbview_bar3.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/db_manager.h" -#include "nel/gui/interface_group.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar3, std::string, "bar3"); - -// ---------------------------------------------------------------------------- -CDBViewBar3::CDBViewBar3(const TCtorParam ¶m) -: CViewBitmap(param), - _Slot(TCtorParam()) -{ - _Mini = false; - _ColorsNegative[0] = _ColorsNegative[1] = _ColorsNegative[2] = NLMISC::CRGBA(0,0,0,0); - _ValueInt[0] = _ValueInt[1] = _ValueInt[2] = 0; - _RangeInt[0] = _RangeInt[1] = _RangeInt[2] = 255; -} - - -// ---------------------------------------------------------------------------- -void CDBViewBar3::parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name) -{ - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)name )); - if (prop) - { - if ( isdigit(*prop.getDatas()) || *(prop.getDatas())=='-') - fromString((const char*)prop, intProp); - else - dbProp.link(prop); - } -} - - -// ---------------------------------------------------------------------------- -bool CDBViewBar3::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CViewBitmap::parse(cur, parentGroup)) - { - string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId(); - nlinfo(tmp.c_str()); - return false; - } - - // read values - parseValProp(cur, _Value[0], _ValueInt[0], "value1" ); - parseValProp(cur, _Value[1], _ValueInt[1], "value2" ); - parseValProp(cur, _Value[2], _ValueInt[2], "value3" ); - - // read ranges - parseValProp(cur, _Range[0], _RangeInt[0], "range1" ); - parseValProp(cur, _Range[1], _RangeInt[1], "range2" ); - parseValProp(cur, _Range[2], _RangeInt[2], "range3" ); - - - // Read colors etc.... - CXMLAutoPtr prop; - - prop = (char*) xmlGetProp( cur, (xmlChar*)"color1" ); - _Colors[0] = convertColor(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"color2" ); - _Colors[1] = convertColor(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"color3" ); - _Colors[2] = convertColor(prop); - - prop = (char*) xmlGetProp( cur, (xmlChar*)"color1_negative" ); - _ColorsNegative[0] = convertColor(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"color2_negative" ); - _ColorsNegative[1] = convertColor(prop); - prop = (char*) xmlGetProp( cur, (xmlChar*)"color3_negative" ); - _ColorsNegative[2] = convertColor(prop); - - - _Mini = false; - prop = (char*) xmlGetProp( cur, (xmlChar*)"mini" ); - if (prop) - if (convertBool(prop)) - setMini(true); - - if (_Mini == false) - setMini(false); - - return true; -} - -// ---------------------------------------------------------------------------- -void CDBViewBar3::setMini(bool b) -{ - _Mini = b; - if (_Mini) - _Slot.setTexture ("w_slot_jauge_3_mini.tga"); - else - _Slot.setTexture ("w_slot_jauge_3.tga"); - - _Slot.setPosRef (_PosRef); - _Slot.setParentPosRef (_ParentPosRef); - _Slot.setX (_X); - _Slot.setY (_Y); - - _Scale = true; - if (_Mini) - setTexture ("w_jauge_fill_mini.tga"); - else - setTexture ("w_jauge_fill.tga"); -} - -// ---------------------------------------------------------------------------- -void CDBViewBar3::updateCoords () -{ - if (_ParentPos == NULL) - _Slot.setParentPos (_Parent); - else - _Slot.setParentPos (_ParentPos); - _Slot.updateCoords(); - _W = _Slot.getW(); - _H = _Slot.getH(); - - // get the height of the texture - sint32 dummy; - CViewRenderer::getInstance()->getTextureSizeFromId(_TextureId, dummy, _BarH); - - CViewBitmap::updateCoords(); -} - -// ---------------------------------------------------------------------------- -sint32 CDBViewBar3::getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp) -{ - if(dbProp.getNodePtr()) - return dbProp.getSInt32(); - else - return intProp; -} - - -// ---------------------------------------------------------------------------- -void CDBViewBar3::draw () -{ - _Slot.draw(); - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - CRGBA gColor = CWidgetManager::getInstance()->getGlobalColorForContent(); - - if (_Mini) - { - for (uint32 i = 0; i < 3; ++i) - { - float factor; - CRGBA color; - - sint32 value= getCurrentValProp(_Value[i], _ValueInt[i]); - sint32 range= getCurrentValProp(_Range[i], _RangeInt[i]); - - if (range > 0) - factor = ( (float)value / (float)range ); - else - factor = 0; - - if (factor < 0) - { - factor = -factor; - color = _ColorsNegative[i]; - } - else - { - color = _Colors[i]; - } - - // clamp the factor to 0/1 - clamp(factor, 0, 1); - float wBar= factor * (float)(_Slot.getWReal()-2); - - color.A = (uint8)(((sint32)color.A*((sint32)gColor.A+1))>>8); - _WReal = (sint32)wBar; - - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+1, _YReal+i*3+2, _WReal, _BarH, 0, false, _TextureId, color); - } - } - else - { - for (uint32 i = 0; i < 3; ++i) - { - float factor; - CRGBA color; - - sint32 value= getCurrentValProp(_Value[i], _ValueInt[i]); - sint32 range= getCurrentValProp(_Range[i], _RangeInt[i]); - - if (range > 0) - factor = ( (float)value / (float)range ); - else - factor = 0; - - if (factor < 0) - { - factor = -factor; - color = _ColorsNegative[i]; - } - else - { - color = _Colors[i]; - } - - // clamp the factor to 0/1 - clamp(factor, 0, 1); - float wBar= factor * (float)(_Slot.getWReal()-4); - - color.A = (uint8)(((sint32)color.A*((sint32)gColor.A+1))>>8); - _WReal = (sint32)wBar; - - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+2, _YReal+i*7+4, _WReal, _BarH, 0, false, _TextureId, color); - } - } -} diff --git a/code/ryzom/client/src/interface_v3/dbview_bar3.h b/code/ryzom/client/src/interface_v3/dbview_bar3.h deleted file mode 100644 index f745564c3..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_bar3.h +++ /dev/null @@ -1,99 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_DBVIEW_BAR3_H -#define RZ_DBVIEW_BAR3_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/view_bitmap.h" - -/** - * class implementing a 3 Bar widget - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2002 - */ -class CDBViewBar3 : public CViewBitmap -{ -public: - - /// Constructor - CDBViewBar3(const TCtorParam ¶m); - - bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); - virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } - virtual void updateCoords (); - - void setMini (bool mini); - - virtual void draw (); - - /// Nbs: Values by Int are not used if the Links are setuped - void setValue0 (sint32 r) { _ValueInt[0] = r; } - void setValue1 (sint32 r) { _ValueInt[1] = r; } - void setValue2 (sint32 r) { _ValueInt[2] = r; } - void setRange0 (sint32 r) { _RangeInt[0] = r; } - void setRange1 (sint32 r) { _RangeInt[1] = r; } - void setRange2 (sint32 r) { _RangeInt[2] = r; } - sint32 getValue0 () const { return _ValueInt[0]; } - sint32 getValue1 () const { return _ValueInt[1]; } - sint32 getValue2 () const { return _ValueInt[2]; } - sint32 getRange0 () const { return _RangeInt[0]; } - sint32 getRange1 () const { return _RangeInt[1]; } - sint32 getRange2 () const { return _RangeInt[2]; } - - // Reflect ValueInt (ie not used if the link is setuped) - REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap) - REFLECT_SINT32 ("value1", getValue0, setValue0); - REFLECT_SINT32 ("value2", getValue1, setValue1); - REFLECT_SINT32 ("value3", getValue2, setValue2); - REFLECT_SINT32 ("range1", getRange0, setRange0); - REFLECT_SINT32 ("range2", getRange1, setRange1); - REFLECT_SINT32 ("range3", getRange2, setRange2); - REFLECT_EXPORT_END - -protected: - - CViewBitmap _Slot; - - // Value of the progression in arbitrary units. should be integer - CInterfaceProperty _Value[3]; - // Max range of the progression in arbitrary units. should be integer - CInterfaceProperty _Range[3]; - - /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links - sint32 _ValueInt[3]; - sint32 _RangeInt[3]; - - - NLMISC::CRGBA _Colors[3]; - NLMISC::CRGBA _ColorsNegative[3]; - - bool _Mini; - - // Height of the bitmap - sint32 _BarH; - - void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); - sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); -}; - - -#endif // RZ_DBVIEW_BAR3_H - -/* End of dbview_bar3.h */ diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 484d46bea..33a5e4dd4 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -47,7 +47,7 @@ #include "view_pointer.h" // DBView (View linked to the database) #include "nel/gui/dbview_bar.h" -#include "dbview_bar3.h" +#include "nel/gui/dbview_bar3.h" #include "dbview_number.h" #include "dbview_quantity.h" #include "dbview_digit.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index e2375447c..bfca22dd5 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -44,7 +44,7 @@ #include "nel/gui/group_tree.h" #include "nel/gui/reflect.h" #include "nel/gui/dbview_bar.h" -#include "dbview_bar3.h" +#include "nel/gui/dbview_bar3.h" #include "nel/gui/ctrl_scroll_base.h" #include "nel/gui/ctrl_scroll.h" #include "dbgroup_combo_box.h" From 5afbf1615acf4a6ed1fb2b40224d8a58a1940d77 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 28 Jun 2012 07:07:44 +0200 Subject: [PATCH 110/339] CHANGED: CDBViewDigit is now part of the NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/dbview_digit.h | 57 +++---- code/nel/src/gui/dbview_digit.cpp | 142 ++++++++++++++++++ .../client/src/interface_v3/dbview_digit.cpp | 141 ----------------- .../src/interface_v3/interface_parser.cpp | 2 +- 4 files changed, 172 insertions(+), 170 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/dbview_digit.h (55%) create mode 100644 code/nel/src/gui/dbview_digit.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_digit.cpp diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.h b/code/nel/include/nel/gui/dbview_digit.h similarity index 55% rename from code/ryzom/client/src/interface_v3/dbview_digit.h rename to code/nel/include/nel/gui/dbview_digit.h index 0589e38d8..05a5db6b2 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.h +++ b/code/nel/include/nel/gui/dbview_digit.h @@ -15,47 +15,48 @@ // along with this program. If not, see . - #ifndef NL_DBVIEW_DIGIT_H #define NL_DBVIEW_DIGIT_H #include "nel/misc/types_nl.h" - #include "nel/gui/view_base.h" - -// *************************************************************************** -/** - * A number displayed with special bitmaps - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBViewDigit : public CViewBase +namespace NLGUI { -public: - /// Constructor - CDBViewDigit(const TCtorParam ¶m); + // *************************************************************************** + /** + * A number displayed with special bitmaps + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewDigit : public CViewBase + { + public: - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void draw (); - virtual void updateCoords(); + /// Constructor + CDBViewDigit(const TCtorParam ¶m); -protected: - CInterfaceProperty _Number; - sint32 _Cache; - sint32 _NumDigit; - NLMISC::CRGBA _Color; - // space between each digit - sint32 _WSpace; - // The texture digit for the current number - sint32 _DigitId[10]; - uint _DivBase; + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void draw (); + virtual void updateCoords(); + + protected: + CInterfaceProperty _Number; + sint32 _Cache; + sint32 _NumDigit; + NLMISC::CRGBA _Color; + // space between each digit + sint32 _WSpace; + // The texture digit for the current number + sint32 _DigitId[10]; + uint _DivBase; -}; + }; +} #endif // NL_DBVIEW_DIGIT_H diff --git a/code/nel/src/gui/dbview_digit.cpp b/code/nel/src/gui/dbview_digit.cpp new file mode 100644 index 000000000..f8affb858 --- /dev/null +++ b/code/nel/src/gui/dbview_digit.cpp @@ -0,0 +1,142 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbview_digit.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_renderer.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CDBViewDigit, std::string, "digit"); + +namespace NLGUI +{ + + // *************************************************************************** + CDBViewDigit::CDBViewDigit(const TCtorParam ¶m) + : CViewBase(param) + { + _NumDigit= 2; + _WSpace= -1; + _DivBase= 1; + } + + + // *************************************************************************** + bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CViewBase::parse(cur, parentGroup)) + return false; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + // link to the db + CXMLAutoPtr ptr; + ptr = xmlGetProp (cur, (xmlChar*)"value"); + if ( ptr ) + _Number.link ( ptr ); + else + { + nlinfo ("no value in %s", _Id.c_str()); + return false; + } + + // read options + ptr = xmlGetProp (cur, (xmlChar*)"numdigit"); + if(ptr) fromString((const char*)ptr, _NumDigit); + clamp(_NumDigit, 1, 10); + + ptr = xmlGetProp (cur, (xmlChar*)"wspace"); + if(ptr) fromString((const char*)ptr, _WSpace); + + ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _Color = CRGBA(255,255,255,255); + if (ptr) + _Color = convertColor (ptr); + + // compute window size. Remove one space. + sint32 wDigit= rVR.getFigurTextureW(); + sint32 hDigit= rVR.getFigurTextureH(); + setW((wDigit+_WSpace)*_NumDigit - _WSpace); + setH(hDigit); + + // some init + // For _NumDigit=2; set the divBase to 100, etc... + _DivBase= 1; + for(uint i= 0;i<(uint)_NumDigit;i++) + { + _DivBase*= 10; + } + + // init cache. + _Cache= -1; + + return true; + } + + + // *************************************************************************** + void CDBViewDigit::updateCoords() + { + CViewBase::updateCoords(); + } + + + // *************************************************************************** + void CDBViewDigit::draw () + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 wDigit= rVR.getFigurTextureW(); + sint32 hDigit= rVR.getFigurTextureH(); + + // change bitmap ids + sint32 val= _Number.getSInt32(); + val= max(val, sint32(0)); + if(_Cache!=val) + { + _Cache= val; + // clamp the value to max possible (eg:99) + if(val>(sint32)_DivBase-1) + val=(sint32)_DivBase-1; + // compute each digit id + uint divisor= _DivBase/10; + for(sint i=0;i<_NumDigit;i++) + { + sint digitVal= (val/divisor)%10; + // set the digit text id + _DigitId[i]= rVR.getFigurTextureId(digitVal); + // next divisor + divisor/= 10; + } + } + + // Display bitmaps + sint32 x= _XReal; + sint32 y= _YReal; + for(sint i=0;i<_NumDigit;i++) + { + rVR.drawRotFlipBitmap ( _RenderLayer, x, y, wDigit, hDigit, 0, false, _DigitId[i], _Color ); + // next digit + x+= wDigit+_WSpace; + } + + } + +} + diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.cpp b/code/ryzom/client/src/interface_v3/dbview_digit.cpp deleted file mode 100644 index 683662fef..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_digit.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbview_digit.h" -#include "interface_manager.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewDigit, std::string, "digit"); - -// *************************************************************************** -CDBViewDigit::CDBViewDigit(const TCtorParam ¶m) -: CViewBase(param) -{ - _NumDigit= 2; - _WSpace= -1; - _DivBase= 1; -} - - -// *************************************************************************** -bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CViewBase::parse(cur, parentGroup)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - // link to the db - CXMLAutoPtr ptr; - ptr = xmlGetProp (cur, (xmlChar*)"value"); - if ( ptr ) - _Number.link ( ptr ); - else - { - nlinfo ("no value in %s", _Id.c_str()); - return false; - } - - // read options - ptr = xmlGetProp (cur, (xmlChar*)"numdigit"); - if(ptr) fromString((const char*)ptr, _NumDigit); - clamp(_NumDigit, 1, 10); - - ptr = xmlGetProp (cur, (xmlChar*)"wspace"); - if(ptr) fromString((const char*)ptr, _WSpace); - - ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _Color = CRGBA(255,255,255,255); - if (ptr) - _Color = convertColor (ptr); - - // compute window size. Remove one space. - sint32 wDigit= rVR.getFigurTextureW(); - sint32 hDigit= rVR.getFigurTextureH(); - setW((wDigit+_WSpace)*_NumDigit - _WSpace); - setH(hDigit); - - // some init - // For _NumDigit=2; set the divBase to 100, etc... - _DivBase= 1; - for(uint i= 0;i<(uint)_NumDigit;i++) - { - _DivBase*= 10; - } - - // init cache. - _Cache= -1; - - return true; -} - - -// *************************************************************************** -void CDBViewDigit::updateCoords() -{ - CViewBase::updateCoords(); -} - - -// *************************************************************************** -void CDBViewDigit::draw () -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 wDigit= rVR.getFigurTextureW(); - sint32 hDigit= rVR.getFigurTextureH(); - - // change bitmap ids - sint32 val= _Number.getSInt32(); - val= max(val, sint32(0)); - if(_Cache!=val) - { - _Cache= val; - // clamp the value to max possible (eg:99) - if(val>(sint32)_DivBase-1) - val=(sint32)_DivBase-1; - // compute each digit id - uint divisor= _DivBase/10; - for(sint i=0;i<_NumDigit;i++) - { - sint digitVal= (val/divisor)%10; - // set the digit text id - _DigitId[i]= rVR.getFigurTextureId(digitVal); - // next divisor - divisor/= 10; - } - } - - // Display bitmaps - sint32 x= _XReal; - sint32 y= _YReal; - for(sint i=0;i<_NumDigit;i++) - { - rVR.drawRotFlipBitmap ( _RenderLayer, x, y, wDigit, hDigit, 0, false, _DigitId[i], _Color ); - // next digit - x+= wDigit+_WSpace; - } - -} diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 33a5e4dd4..97d152d1d 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -50,7 +50,7 @@ #include "nel/gui/dbview_bar3.h" #include "dbview_number.h" #include "dbview_quantity.h" -#include "dbview_digit.h" +#include "nel/gui/dbview_digit.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" From c1f7df59d750e0a602b726733004c00ecab4af39 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 28 Jun 2012 07:16:15 +0200 Subject: [PATCH 111/339] CHANGED: #1471 CDBViewNumber is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/dbview_number.h | 72 ++++++++++ code/nel/src/gui/dbview_number.cpp | 128 ++++++++++++++++++ .../client/src/interface_v3/dbview_number.cpp | 126 ----------------- .../client/src/interface_v3/dbview_number.h | 70 ---------- .../client/src/interface_v3/group_skills.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- 6 files changed, 202 insertions(+), 198 deletions(-) create mode 100644 code/nel/include/nel/gui/dbview_number.h create mode 100644 code/nel/src/gui/dbview_number.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_number.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_number.h diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h new file mode 100644 index 000000000..9f288805f --- /dev/null +++ b/code/nel/include/nel/gui/dbview_number.h @@ -0,0 +1,72 @@ +// Ryzom - MMORPG Framework +// 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 NL_DBVIEW_NUMBER_H +#define NL_DBVIEW_NUMBER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_text.h" + +namespace NLGUI +{ + + // *************************************************************************** + /** + * Display a text from a database number + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewNumber : public CViewText + { + public: + + /// Constructor + CDBViewNumber(const TCtorParam ¶m); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + virtual void draw (); + + void link (const std::string &dbprop) + { + _Number.link (dbprop.c_str()); + } + + protected: + + sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); + else return (_Number.getSInt64() / _Divisor)%_Modulo; } + + protected: + + CInterfaceProperty _Number; + sint64 _Cache; + bool _Positive; // only positive values are displayed + bool _Format; // the number will be formatted (like "1,000,000") if >= 10k + sint64 _Divisor, _Modulo; + // string to append to the value (eg: meters) + CStringShared _Suffix; + CStringShared _Prefix; + }; + +} + +#endif // NL_DBVIEW_NUMBER_H + +/* End of dbview_number.h */ diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp new file mode 100644 index 000000000..ee6f762c7 --- /dev/null +++ b/code/nel/src/gui/dbview_number.cpp @@ -0,0 +1,128 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbview_number.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/common.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + + +NLMISC_REGISTER_OBJECT(CViewBase, CDBViewNumber, std::string, "text_number"); + +// *************************************************************************** + +namespace NLGUI +{ + + CDBViewNumber::CDBViewNumber(const TCtorParam ¶m) + :CViewText(param) + { + _Positive = false; + _Cache= 0; + setText(ucstring("0")); + _Divisor = 1; + _Modulo = 0; + } + + + // *************************************************************************** + bool CDBViewNumber::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CViewText::parse(cur, parentGroup)) + return false; + + // link to the db + CXMLAutoPtr ptr; + ptr = xmlGetProp (cur, (xmlChar*)"value"); + if ( ptr ) + { + // Yoyo: verify doesn't entered a direct number :). MUST BE A CORRECT DATABASE ENTRY + const char *serverDb= "SERVER:"; + const char *localDb= "LOCAL:"; + const char *uiDb= "UI:"; + if( strncmp((const char*)ptr, serverDb, strlen(serverDb))==0 || + strncmp((const char*)ptr, localDb, strlen(localDb))==0 || + strncmp((const char*)ptr, uiDb, strlen(uiDb))==0 ) + { + // OK? => Link. + _Number.link ( ptr ); + } + else + { + nlinfo ("bad value in %s", _Id.c_str()); + return false; + } + } + else + { + nlinfo ("no value in %s", _Id.c_str()); + return false; + } + + ptr = xmlGetProp (cur, (xmlChar*)"positive"); + if (ptr) _Positive = convertBool(ptr); + else _Positive = false; + + ptr = xmlGetProp (cur, (xmlChar*)"format"); + if (ptr) _Format = convertBool(ptr); + else _Format = false; + + ptr = xmlGetProp (cur, (xmlChar*)"divisor"); + if (ptr) fromString((const char*)ptr, _Divisor); + + ptr = xmlGetProp (cur, (xmlChar*)"modulo"); + if (ptr) fromString((const char*)ptr, _Modulo); + + ptr = xmlGetProp (cur, (xmlChar*)"suffix"); + if (ptr) _Suffix = (const char*)ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"prefix"); + if (ptr) _Prefix = (const char*)ptr; + + // init cache. + _Cache= 0; + setText(ucstring("0")); + + return true; + } + + // *************************************************************************** + void CDBViewNumber::checkCoords() + { + // change text + sint64 val = getVal(); + if (_Cache != val) + { + _Cache= val; + ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); + if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?")); + else setText( ucstring(_Prefix) + value + ucstring(_Suffix) ); + } + } + + // *************************************************************************** + void CDBViewNumber::draw () + { + // parent call + CViewText::draw(); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/dbview_number.cpp b/code/ryzom/client/src/interface_v3/dbview_number.cpp deleted file mode 100644 index 4b1ebc5ef..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_number.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbview_number.h" -#include "interface_manager.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/misc/common.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewNumber, std::string, "text_number"); - -// *************************************************************************** -CDBViewNumber::CDBViewNumber(const TCtorParam ¶m) - :CViewText(param) -{ - _Positive = false; - _Cache= 0; - setText(ucstring("0")); - _Divisor = 1; - _Modulo = 0; -} - - -// *************************************************************************** -bool CDBViewNumber::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CViewText::parse(cur, parentGroup)) - return false; - - // link to the db - CXMLAutoPtr ptr; - ptr = xmlGetProp (cur, (xmlChar*)"value"); - if ( ptr ) - { - // Yoyo: verify doesn't entered a direct number :). MUST BE A CORRECT DATABASE ENTRY - const char *serverDb= "SERVER:"; - const char *localDb= "LOCAL:"; - const char *uiDb= "UI:"; - if( strncmp((const char*)ptr, serverDb, strlen(serverDb))==0 || - strncmp((const char*)ptr, localDb, strlen(localDb))==0 || - strncmp((const char*)ptr, uiDb, strlen(uiDb))==0 ) - { - // OK? => Link. - _Number.link ( ptr ); - } - else - { - nlinfo ("bad value in %s", _Id.c_str()); - return false; - } - } - else - { - nlinfo ("no value in %s", _Id.c_str()); - return false; - } - - ptr = xmlGetProp (cur, (xmlChar*)"positive"); - if (ptr) _Positive = convertBool(ptr); - else _Positive = false; - - ptr = xmlGetProp (cur, (xmlChar*)"format"); - if (ptr) _Format = convertBool(ptr); - else _Format = false; - - ptr = xmlGetProp (cur, (xmlChar*)"divisor"); - if (ptr) fromString((const char*)ptr, _Divisor); - - ptr = xmlGetProp (cur, (xmlChar*)"modulo"); - if (ptr) fromString((const char*)ptr, _Modulo); - - ptr = xmlGetProp (cur, (xmlChar*)"suffix"); - if (ptr) _Suffix = (const char*)ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"prefix"); - if (ptr) _Prefix = (const char*)ptr; - - // init cache. - _Cache= 0; - setText(ucstring("0")); - - return true; -} - -// *************************************************************************** -void CDBViewNumber::checkCoords() -{ - // change text - sint64 val = getVal(); - if (_Cache != val) - { - _Cache= val; - ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val); - if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?")); - else setText( ucstring(_Prefix) + value + ucstring(_Suffix) ); - } -} - -// *************************************************************************** -void CDBViewNumber::draw () -{ - // parent call - CViewText::draw(); -} - diff --git a/code/ryzom/client/src/interface_v3/dbview_number.h b/code/ryzom/client/src/interface_v3/dbview_number.h deleted file mode 100644 index 602f0e3b9..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_number.h +++ /dev/null @@ -1,70 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_DBVIEW_NUMBER_H -#define NL_DBVIEW_NUMBER_H - -#include "nel/misc/types_nl.h" - -#include "nel/gui/view_text.h" - - -// *************************************************************************** -/** - * Display a text from a database number - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBViewNumber : public CViewText -{ -public: - - /// Constructor - CDBViewNumber(const TCtorParam ¶m); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void checkCoords(); - virtual void draw (); - - void link (const std::string &dbprop) - { - _Number.link (dbprop.c_str()); - } - -protected: - - sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); - else return (_Number.getSInt64() / _Divisor)%_Modulo; } - -protected: - - CInterfaceProperty _Number; - sint64 _Cache; - bool _Positive; // only positive values are displayed - bool _Format; // the number will be formatted (like "1,000,000") if >= 10k - sint64 _Divisor, _Modulo; - // string to append to the value (eg: meters) - CStringShared _Suffix; - CStringShared _Prefix; -}; - - -#endif // NL_DBVIEW_NUMBER_H - -/* End of dbview_number.h */ diff --git a/code/ryzom/client/src/interface_v3/group_skills.cpp b/code/ryzom/client/src/interface_v3/group_skills.cpp index d24e1afc5..ea7d88a75 100644 --- a/code/ryzom/client/src/interface_v3/group_skills.cpp +++ b/code/ryzom/client/src/interface_v3/group_skills.cpp @@ -25,7 +25,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/view_bitmap.h" -#include "dbview_number.h" +#include "nel/gui/dbview_number.h" #include "nel/gui/dbview_bar.h" #include "game_share/skills.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 97d152d1d..b8f36ea00 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -48,7 +48,7 @@ // DBView (View linked to the database) #include "nel/gui/dbview_bar.h" #include "nel/gui/dbview_bar3.h" -#include "dbview_number.h" +#include "nel/gui/dbview_number.h" #include "dbview_quantity.h" #include "nel/gui/dbview_digit.h" // Ctrl From b5c4ad14da4339f0e11175ab78a3609588271c80 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 28 Jun 2012 07:35:11 +0200 Subject: [PATCH 112/339] CHANGED: #1471 CDBViewQuantity is now part of the NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/dbview_quantity.h | 48 ++--- code/nel/src/gui/dbview_quantity.cpp | 114 +++++++++++ .../src/interface_v3/dbview_quantity.cpp | 114 ----------- .../src/interface_v3/interface_parser.cpp | 190 +----------------- 4 files changed, 141 insertions(+), 325 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/dbview_quantity.h (59%) create mode 100644 code/nel/src/gui/dbview_quantity.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_quantity.cpp diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.h b/code/nel/include/nel/gui/dbview_quantity.h similarity index 59% rename from code/ryzom/client/src/interface_v3/dbview_quantity.h rename to code/nel/include/nel/gui/dbview_quantity.h index a693a46d3..d692f0785 100644 --- a/code/ryzom/client/src/interface_v3/dbview_quantity.h +++ b/code/nel/include/nel/gui/dbview_quantity.h @@ -20,38 +20,40 @@ #define NL_DBVIEW_QUANTITY_H #include "nel/misc/types_nl.h" - #include "nel/gui/view_text.h" - -// *************************************************************************** -/** - * Display a text in the form of val / max or "empty" - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBViewQuantity : public CViewText +namespace NLGUI { -public: - /// Constructor - CDBViewQuantity(const TCtorParam ¶m); + // *************************************************************************** + /** + * Display a text in the form of val / max or "empty" + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewQuantity : public CViewText + { + public: - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void draw (); + /// Constructor + CDBViewQuantity(const TCtorParam ¶m); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void draw (); -protected: - CInterfaceProperty _Number; - CInterfaceProperty _NumberMax; - sint32 _Cache; - sint32 _CacheMax; - ucstring _EmptyText; + protected: + CInterfaceProperty _Number; + CInterfaceProperty _NumberMax; + sint32 _Cache; + sint32 _CacheMax; + ucstring _EmptyText; - void buildTextFromCache(); -}; + void buildTextFromCache(); + }; +} #endif // NL_DBVIEW_QUANTITY_H diff --git a/code/nel/src/gui/dbview_quantity.cpp b/code/nel/src/gui/dbview_quantity.cpp new file mode 100644 index 000000000..fb6241339 --- /dev/null +++ b/code/nel/src/gui/dbview_quantity.cpp @@ -0,0 +1,114 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbview_quantity.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/i18n.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + + +NLMISC_REGISTER_OBJECT(CViewBase, CDBViewQuantity, std::string, "text_quantity"); + +namespace NLGUI +{ + + // *************************************************************************** + CDBViewQuantity::CDBViewQuantity(const TCtorParam ¶m) + : CViewText(param) + { + } + + + + // *************************************************************************** + bool CDBViewQuantity::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CViewText::parse(cur, parentGroup)) + return false; + + // link to the db + CXMLAutoPtr ptr; + ptr = xmlGetProp (cur, (xmlChar*)"value"); + if ( ptr ) + _Number.link ( ptr ); + else + { + nlinfo ("no value in %s", _Id.c_str()); + return false; + } + ptr = xmlGetProp (cur, (xmlChar*)"valuemax"); + if ( ptr ) + _NumberMax.link ( ptr ); + else + { + nlinfo ("no max value in %s", _Id.c_str()); + return false; + } + + // empty opt + ptr = xmlGetProp (cur, (xmlChar*)"emptytext"); + if(ptr) + { + const char *propPtr = ptr; + _EmptyText = ucstring(propPtr); + if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) + _EmptyText = CI18N::get (propPtr); + } + + // init cache. + _Cache= 0; + _CacheMax= 0; + buildTextFromCache(); + + return true; + } + + // *************************************************************************** + void CDBViewQuantity::draw () + { + // change text + sint32 val= _Number.getSInt32(); + sint32 valMax= _NumberMax.getSInt32(); + if(_Cache!=val || _CacheMax!=valMax) + { + _Cache= val; + _CacheMax=valMax; + buildTextFromCache(); + } + + // parent call + CViewText::draw(); + } + + // *************************************************************************** + void CDBViewQuantity::buildTextFromCache() + { + if(_Cache==0 && !_EmptyText.empty()) + { + setText(_EmptyText); + } + else + { + char buf[256]; + smprintf(buf, 256, "%d/%d", _Cache, _CacheMax); + setText(toString((const char*)buf)); + } + } +} diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp b/code/ryzom/client/src/interface_v3/dbview_quantity.cpp deleted file mode 100644 index 6f95ddbc9..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_quantity.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbview_quantity.h" -#include "interface_manager.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewQuantity, std::string, "text_quantity"); - -// *************************************************************************** -CDBViewQuantity::CDBViewQuantity(const TCtorParam ¶m) - : CViewText(param) -{ -} - - - -// *************************************************************************** -bool CDBViewQuantity::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CViewText::parse(cur, parentGroup)) - return false; - - // link to the db - CXMLAutoPtr ptr; - ptr = xmlGetProp (cur, (xmlChar*)"value"); - if ( ptr ) - _Number.link ( ptr ); - else - { - nlinfo ("no value in %s", _Id.c_str()); - return false; - } - ptr = xmlGetProp (cur, (xmlChar*)"valuemax"); - if ( ptr ) - _NumberMax.link ( ptr ); - else - { - nlinfo ("no max value in %s", _Id.c_str()); - return false; - } - - // empty opt - ptr = xmlGetProp (cur, (xmlChar*)"emptytext"); - if(ptr) - { - const char *propPtr = ptr; - _EmptyText = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - _EmptyText = CI18N::get (propPtr); - } - - // init cache. - _Cache= 0; - _CacheMax= 0; - buildTextFromCache(); - - return true; -} - -// *************************************************************************** -void CDBViewQuantity::draw () -{ - // change text - sint32 val= _Number.getSInt32(); - sint32 valMax= _NumberMax.getSInt32(); - if(_Cache!=val || _CacheMax!=valMax) - { - _Cache= val; - _CacheMax=valMax; - buildTextFromCache(); - } - - // parent call - CViewText::draw(); -} - -// *************************************************************************** -void CDBViewQuantity::buildTextFromCache() -{ - if(_Cache==0 && !_EmptyText.empty()) - { - setText(_EmptyText); - } - else - { - char buf[256]; - smprintf(buf, 256, "%d/%d", _Cache, _CacheMax); - setText(toString((const char*)buf)); - } -} diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index b8f36ea00..d07a8f154 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -49,7 +49,7 @@ #include "nel/gui/dbview_bar.h" #include "nel/gui/dbview_bar3.h" #include "nel/gui/dbview_number.h" -#include "dbview_quantity.h" +#include "nel/gui/dbview_quantity.h" #include "nel/gui/dbview_digit.h" // Ctrl #include "nel/gui/ctrl_scroll.h" @@ -1405,106 +1405,10 @@ bool CInterfaceParser::parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup { group = dynamic_cast(NLMISC_GET_FACTORY(CViewBase, std::string).createObject("interface_group", CViewBase::TCtorParam())); } -// if (stricmp(ptr, "list") == 0) -// group = new CGroupList; -// else if (stricmp(ptr, "container") == 0) -// group = new CGroupContainer; -// else if (stricmp(ptr, "frame") == 0) -// group = new CGroupFrame; -// else if (stricmp(ptr, "modal") == 0) -// group = new CGroupModal; -// else if (stricmp(ptr, "modal_get_key") == 0) -// group = new CGroupModalGetKey; -// else if (stricmp(ptr, "menu") == 0) -// group = new CGroupMenu; -// else if (stricmp(ptr, "select_number") == 0) -// group = new CDBGroupSelectNumber; -// else if (stricmp(ptr, "tree") == 0) -// group = new CGroupTree; -// else if (stricmp(ptr, "list_sheet") == 0) -// group = new CDBGroupListSheet; -// else if (stricmp(ptr, "scroll_text") == 0) -// group = new CGroupScrollText; -// else if (stricmp(ptr, "html") == 0) -// group = new CGroupHTML; -// else if (stricmp(ptr, "html_input_offset") == 0) -// group = new CGroupHTMLInputOffset; -// else if (stricmp(ptr, "forum_html") == 0) -// group = new CGroupHTMLForum; -// else if (stricmp(ptr, "mail_html") == 0) -// group = new CGroupHTMLMail; -// else if (stricmp(ptr, "qcm_html") == 0) -// group = new CGroupHTMLQCM; -// else if (stricmp(ptr, "quick_help") == 0) -// group = new CGroupQuickHelp; -// else if (stricmp(ptr, "cs_html") == 0) -// group = new CGroupHTMLCS; -// else if (stricmp(ptr, "compas") == 0) -// group = new CGroupCompas; -// else if (stricmp(ptr, "menu_compas") == 0) -// group = new CGroupCompasMenu; -// else if (stricmp(ptr, "in_scene") == 0) -// group = new CGroupInScene; -// else if (stricmp(ptr, "in_scene_user_info") == 0) -// group = new CGroupInSceneUserInfo; -// else if (stricmp(ptr, "in_scene_bubble") == 0) -// group = new CGroupInSceneBubble; -// else if (stricmp(ptr, "edit_box") == 0) -// group = new CGroupEditBox; -// else if (stricmp(ptr, "career") == 0) -// group = new CGroupCareer; -// else if (stricmp(ptr, "job") == 0) -// group = new CGroupJob; -// else if (stricmp(ptr, "skills_displayer") == 0) -// group = new CGroupSkills; -// else if (stricmp(ptr, "combo_box") == 0) -// group = new CDBGroupComboBox; -// else if (stricmp(ptr, "list_sheet_text") == 0) -// group = new CDBGroupListSheetText; -// else if (stricmp(ptr, "list_sheet_trade") == 0) -// group = new CDBGroupListSheetTrade; -// else if (stricmp(ptr, "list_sheet_mission") == 0) -// group = new CDBGroupListSheetMission; -// else if (stricmp(ptr, "list_sheet_guild") == 0) -// group = new CDBGroupListAscensor; -// else if (stricmp(ptr, "list_sheet_bag") == 0) -// group = new CDBGroupListSheetBag; -// else if (stricmp(ptr, "list_icon_bag") == 0) -// group = new CDBGroupIconListBag; -// else if (stricmp(ptr, "list_sheet_filter_clm_slot") == 0) -// group = new CDBGroupListSheetFilterCLMSlot; -// else if (stricmp(ptr, "list_sheet_filter_exchangeable") == 0) -// group = new CDBGroupListSheetFilterExchangeable; -// else if (stricmp(ptr, "build_phrase") == 0) -// group = new CDBGroupBuildPhrase; -// else if (stricmp(ptr, "list_sheet_phraseid") == 0) -// group = new CDBGroupListSheetTextPhraseId; -// else if (stricmp(ptr, "list_sheet_compo_brick") == 0) -// group = new CDBGroupListSheetTextBrickComposition; -// else if (stricmp(ptr, "list_sheet_share") == 0) -// group = new CDBGroupListSheetTextShare; -// else if (stricmp(ptr, "map") == 0) -// group = new CGroupMap; -// else if (stricmp(ptr, "container_windows") == 0) -// group = new CGroupContainerWindows; -// else if (stricmp(ptr, "phrase_skill_filter") == 0) -// group = new CGroupPhraseSkillFilter; -// else if (stricmp(ptr, "list_sheet_bonus_malus") == 0) -// group = new CDBGroupListSheetBonusMalus; -// else if (stricmp(ptr, "tab") == 0) -// group = new CGroupTab; -// else if (stricmp(ptr, "list_sheet_text_phrase") == 0) -// group = new CDBGroupListSheetTextPhrase; -// else if (stricmp(ptr, "list_sheet_icon_phrase") == 0) -// group = new CDBGroupListSheetIconPhrase; -// else if (stricmp(ptr, "table") == 0) -// group = new CGroupTable; -// else -// group = new CInterfaceGroup; + } else group = dynamic_cast(NLMISC_GET_FACTORY(CViewBase, std::string).createObject("interface_group", CViewBase::TCtorParam())); -// group = new CInterfaceGroup; // parse the group attributes if (!group->parse(cur,parentGroup)) @@ -1608,40 +1512,6 @@ bool CInterfaceParser::parseControl (xmlNodePtr cur, CInterfaceGroup * parentGro ctrl = dynamic_cast(NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam())); -// if (!strcmp(ptr,"button")) -// { -// ctrl = new CCtrlButton; -// } -// else if (stricmp(ptr, "scroll") == 0) -// { -// ctrl = new CCtrlScroll; -// } -// else if (stricmp(ptr, "colpick") == 0) -// { -// ctrl = new CCtrlColPick; -// } -// else if (stricmp(ptr, "tooltip") == 0) -// { -// ctrl = new CCtrlToolTip; -// } - // DB CTRL -// else if ( !strcmp(ptr,"sheet")) -// { -// ctrl = new CDBCtrlSheet; -// } -// else if ( !strcmp(ptr,"text_button")) -// { -// ctrl = new CCtrlTextButton; -// } -// else if ( !strcmp(ptr,"button_link")) -// { -// ctrl = new CCtrlLink; -// } -// else if ( !strcmp(ptr,"tab_button")) -// { -// ctrl = new CCtrlTabButton; -// } - if (ctrl) { if (!ctrl->parse(cur,parentGroup)) @@ -1684,62 +1554,6 @@ bool CInterfaceParser::parseView(xmlNodePtr cur, CInterfaceGroup * parentGroup, } view = NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam()); -// if ( !strcmp(ptr,"text")) -// { -// view = new CViewText; -// } -// else if ( !strcmp(ptr,"text_formated")) -// { -// view = new CViewTextFormated; -// } -// else if ( !strcmp(ptr,"text_id")) -// { -// view = new CViewTextID; -// } -// else if ( !strcmp(ptr,"text_id_formated")) -// { -// view = new CViewTextIDFormated; -// } -// else if ( !strcmp(ptr,"text_number")) -// { -// view = new CDBViewNumber; -// } -// else if ( !strcmp(ptr,"text_quantity")) -// { -// view = new CDBViewQuantity; -// } -// else if ( !strcmp(ptr,"digit")) -// { -// view = new CDBViewDigit; -// } -// else if ( !strcmp(ptr,"bitmap")) -// { -// view = new CViewBitmap; -// } -// else if ( !strcmp(ptr,"bar")) -// { -// view = new CDBViewBar; -// } -// else if ( !strcmp(ptr,"bar3")) -// { -// view = new CDBViewBar3; -// } -// else if ( !strcmp(ptr,"bitmap_faber_mp")) -// { -// view = new CViewBitmapFaberMp; -// } -// else if (!strcmp(ptr, "bitmap_combo")) -// { -// view = new CViewBitmapCombo; -// } -// else if (!strcmp(ptr, "radar")) -// { -// view = new CViewRadar; -// } -// else if ( !strcmp(ptr,"pointer")) -// { -// view = _Pointer = new CViewPointer; -// } if ( !strcmp(ptr,"pointer")) { From 17c499ef176813ee1dfb0c3a41411b6f31c0c810 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 28 Jun 2012 11:06:36 +0200 Subject: [PATCH 113/339] CHANGED: #1471 CDBGroupSelectNumber is now part of the NELGUI library and is under the NLGUI namespace. Also had to add a workaround so that the linker doesn't drop the seemingly unused code from the library. Thanks goes to Kaetami for that! --- .../include/nel/gui/dbgroup_select_number.h | 96 +++++++ code/nel/include/nel/gui/dbview_bar3.h | 2 + code/nel/include/nel/gui/dbview_number.h | 2 + code/nel/src/gui/dbgroup_select_number.cpp | 234 +++++++++++++++++ code/nel/src/gui/dbview_bar3.cpp | 7 +- code/nel/src/gui/dbview_number.cpp | 4 + code/nel/src/gui/link_hack.cpp | 12 + code/nel/src/gui/widget_manager.cpp | 11 +- .../interface_v3/dbgroup_select_number.cpp | 237 ------------------ .../src/interface_v3/dbgroup_select_number.h | 98 -------- .../src/interface_v3/interface_parser.cpp | 2 +- .../register_interface_elements.cpp | 2 +- 12 files changed, 367 insertions(+), 340 deletions(-) create mode 100644 code/nel/include/nel/gui/dbgroup_select_number.h create mode 100644 code/nel/src/gui/dbgroup_select_number.cpp create mode 100644 code/nel/src/gui/link_hack.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbgroup_select_number.h diff --git a/code/nel/include/nel/gui/dbgroup_select_number.h b/code/nel/include/nel/gui/dbgroup_select_number.h new file mode 100644 index 000000000..1e12caaa3 --- /dev/null +++ b/code/nel/include/nel/gui/dbgroup_select_number.h @@ -0,0 +1,96 @@ +// Ryzom - MMORPG Framework +// 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 NL_DBGROUP_SELECT_NUMBER_H +#define NL_DBGROUP_SELECT_NUMBER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + + +namespace NLGUI +{ + class CCtrlBaseButton; + class CViewText; + class CViewBitmap; + + // *************************************************************************** + /** + * Widget to select a number + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBGroupSelectNumber : public CInterfaceGroup + { + public: + + /// Constructor + CDBGroupSelectNumber(const TCtorParam ¶m); + ~CDBGroupSelectNumber(); + + /// CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + virtual void checkCoords(); + virtual void draw (); + virtual void clearViews (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + // mod interface + void changeValue(sint delta); + + sint32 getMinValue () const { return _MinValue; } + void setMinValue (sint32 m) { _MinValue = m; } + sint32 getMaxValue () const { return _MaxValue; } + void setMaxValue (sint32 m) { _MaxValue = m; } + + sint32 getCurrentValue () const { return _Number.getSInt32(); } + void setCurrentValue (sint32 val) { _Number.setSInt32(val); } + + REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup) + REFLECT_SINT32("min", getMinValue, setMinValue); + REFLECT_SINT32("max", getMaxValue, setMaxValue); + REFLECT_EXPORT_END + + protected: + + // sint32 + CInterfaceProperty _Number; + bool _LoopMode; + sint _MinValue; + sint _MaxValue; + sint _DeltaMultiplier; + + // Children + CViewBitmap *_SlotNumber; + CViewText *_TextNumber; + CCtrlBaseButton *_ButtonUp; + CCtrlBaseButton *_ButtonDown; + + private: + + void setup(); + + }; + +} + +#endif // NL_DBGROUP_SELECT_NUMBER_H + +/* End of dbgroup_select_number.h */ diff --git a/code/nel/include/nel/gui/dbview_bar3.h b/code/nel/include/nel/gui/dbview_bar3.h index 40301f1e2..ad931b304 100644 --- a/code/nel/include/nel/gui/dbview_bar3.h +++ b/code/nel/include/nel/gui/dbview_bar3.h @@ -70,6 +70,8 @@ namespace NLGUI REFLECT_SINT32 ("range3", getRange2, setRange2); REFLECT_EXPORT_END + static void forceLink(); + protected: CViewBitmap _Slot; diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h index 9f288805f..9f40e97c1 100644 --- a/code/nel/include/nel/gui/dbview_number.h +++ b/code/nel/include/nel/gui/dbview_number.h @@ -48,6 +48,8 @@ namespace NLGUI _Number.link (dbprop.c_str()); } + static void forceLink(); + protected: sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); diff --git a/code/nel/src/gui/dbgroup_select_number.cpp b/code/nel/src/gui/dbgroup_select_number.cpp new file mode 100644 index 000000000..6b3dccd8c --- /dev/null +++ b/code/nel/src/gui/dbgroup_select_number.cpp @@ -0,0 +1,234 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbgroup_select_number.h" +#include "nel/gui/view_text.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/interface_property.h" +#include "nel/gui/action_handler.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +namespace NLGUI +{ + NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number"); + + // *************************************************************************** + CDBGroupSelectNumber::CDBGroupSelectNumber(const TCtorParam ¶m) : + CInterfaceGroup(param) + { + _SlotNumber= NULL; + _TextNumber= NULL; + _ButtonUp= NULL; + _ButtonDown= NULL; + _LoopMode= true; + _MinValue= 0; + _MaxValue= 9; + _DeltaMultiplier= 1; + } + + // *************************************************************************** + CDBGroupSelectNumber::~CDBGroupSelectNumber() + { + } + + // *************************************************************************** + bool CDBGroupSelectNumber::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if(!CInterfaceGroup::parse(cur, parentGroup)) + return false; + + // read params + CXMLAutoPtr ptr; + ptr = xmlGetProp (cur, (xmlChar*)"value"); + if ( ptr ) + _Number.link ( ptr ); + else + { + nlinfo ("no value in %s", _Id.c_str()); + return false; + } + + // Loop, min and max + _LoopMode= false; + ptr= xmlGetProp (cur, (xmlChar*)"loop"); + if(ptr) _LoopMode= convertBool(ptr); + _MinValue = 0; + ptr= xmlGetProp (cur, (xmlChar*)"min"); + if(ptr) fromString((const char*)ptr, _MinValue); + _MaxValue = 0; + ptr= xmlGetProp (cur, (xmlChar*)"max"); + if(ptr) fromString((const char*)ptr, _MaxValue); + ptr= xmlGetProp (cur, (xmlChar*)"delta"); + if(ptr) fromString((const char*)ptr, _DeltaMultiplier); + + // set min val in DB + _Number.setSInt32(_MinValue); + + return true; + } + + // *************************************************************************** + void CDBGroupSelectNumber::setup() + { + if (_SlotNumber != NULL) + return; + + // bind to the controls. + _SlotNumber= dynamic_cast(CInterfaceGroup::getView("slot_number")); + _TextNumber= dynamic_cast(CInterfaceGroup::getView("number")); + _ButtonUp= dynamic_cast(CInterfaceGroup::getCtrl("arrow_up")); + _ButtonDown= dynamic_cast(CInterfaceGroup::getCtrl("arrow_down")); + + // checks + if(_SlotNumber==NULL) + nlwarning("Interface: SelectNumberGroup: bitmap 'slot_number' missing or bad type"); + if(_TextNumber==NULL) + nlwarning("Interface: SelectNumberGroup: text view 'number' missing or bad type"); + if(_ButtonUp==NULL) + nlwarning("Interface: SelectNumberGroup: button 'arrow_up' missing or bad type"); + if(_ButtonDown==NULL) + nlwarning("Interface: SelectNumberGroup: button 'arrow_down' missing or bad type"); + if(_SlotNumber==NULL || _TextNumber==NULL || _ButtonUp==NULL || _ButtonDown==NULL) + return; + + // actions + _ButtonUp->setActionOnLeftClick("sn_up"); + _ButtonDown->setActionOnLeftClick("sn_down"); + } + + + // *************************************************************************** + void CDBGroupSelectNumber::updateCoords () + { + setup(); + CInterfaceGroup::updateCoords(); + } + + + + void CDBGroupSelectNumber::checkCoords() + { + if(_TextNumber) + _TextNumber->setText( toString(_Number.getSInt32()) ); + CInterfaceGroup::checkCoords(); + } + + // *************************************************************************** + void CDBGroupSelectNumber::draw () + { + CInterfaceGroup::draw(); + } + + // *************************************************************************** + void CDBGroupSelectNumber::clearViews () + { + CInterfaceGroup::clearViews(); + } + + // *************************************************************************** + bool CDBGroupSelectNumber::handleEvent (const NLGUI::CEventDescriptor &event) + { + if (event.getType() == NLGUI::CEventDescriptor::mouse) + { + const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; + if (isIn(eventDesc.getX(), eventDesc.getY())) + { + if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) + { + changeValue (eventDesc.getWheel()); + return true; + } + } + } + if (CInterfaceGroup::handleEvent(event)) return true; + return false; + } + + + // *************************************************************************** + void CDBGroupSelectNumber::changeValue(sint delta) + { + delta*= _DeltaMultiplier; + + // get DB and add + sint32 val= _Number.getSInt32(); + val+= delta; + + // Loop or clamp + if(_LoopMode) + { + sint32 dval= _MaxValue+1 - _MinValue; + if (dval <= 0) + { + val = 0; + return; + } + val -= _MinValue; + val = val% dval; val = (val+dval)% dval; + val += _MinValue; + } + else + { + clamp(val, _MinValue, _MaxValue); + } + + // set in DB + _Number.setSInt32(val); + if(_TextNumber) + _TextNumber->setText( toString(_Number.getSInt32()) ); + } + + + // *************************************************************************** + // *************************************************************************** + // Actions Handlers + // *************************************************************************** + // *************************************************************************** + + + // *************************************************************************** + class CSNUp : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CDBGroupSelectNumber *pSN = dynamic_cast(pCaller->getParent()); + if (pSN == NULL) return; + pSN->changeValue(+1); + } + }; + REGISTER_ACTION_HANDLER (CSNUp, "sn_up"); + + // *************************************************************************** + class CSNDown : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CDBGroupSelectNumber *pSN = dynamic_cast(pCaller->getParent()); + if (pSN == NULL) return; + pSN->changeValue(-1); + } + }; + REGISTER_ACTION_HANDLER (CSNDown, "sn_down"); + +} + diff --git a/code/nel/src/gui/dbview_bar3.cpp b/code/nel/src/gui/dbview_bar3.cpp index 03eda066d..4a1911e8c 100644 --- a/code/nel/src/gui/dbview_bar3.cpp +++ b/code/nel/src/gui/dbview_bar3.cpp @@ -17,9 +17,9 @@ #include "nel/gui/dbview_bar3.h" #include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/interface_group.h" #include "nel/gui/widget_manager.h" #include "nel/gui/db_manager.h" -#include "nel/gui/interface_group.h" using namespace std; using namespace NL3D; @@ -27,7 +27,6 @@ using namespace NLMISC; namespace NLGUI { - NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar3, std::string, "bar3"); // ---------------------------------------------------------------------------- @@ -235,5 +234,9 @@ namespace NLGUI } } } + + void CDBViewBar3::forceLink() + { + } } diff --git a/code/nel/src/gui/dbview_number.cpp b/code/nel/src/gui/dbview_number.cpp index ee6f762c7..74df94f42 100644 --- a/code/nel/src/gui/dbview_number.cpp +++ b/code/nel/src/gui/dbview_number.cpp @@ -124,5 +124,9 @@ namespace NLGUI CViewText::draw(); } + void CDBViewNumber::forceLink() + { + } + } diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp new file mode 100644 index 000000000..a813014fd --- /dev/null +++ b/code/nel/src/gui/link_hack.cpp @@ -0,0 +1,12 @@ +#include "nel/gui/dbview_bar3.h" +#include "nel/gui/dbview_number.h" + +namespace NLGUI +{ + /// Necessary so the linker doesn't drop the code of these classes from the library + void LinkHack() + { + CDBViewBar3::forceLink(); + CDBViewNumber::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 f60349a69..da9870352 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -25,17 +25,26 @@ #include "nel/gui/group_editbox_base.h" #include "nel/gui/interface_options.h" +namespace NLGUI +{ + void LinkHack(); +} + namespace { const uint DOUBLE_CLICK_MIN = 50; const uint DOUBLE_CLICK_MAX = 750; const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f; const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f; + + void Hack() + { + NLGUI::LinkHack(); + } } namespace NLGUI { - CWidgetManager* CWidgetManager::instance = NULL; std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal"; IParser* CWidgetManager::parser = NULL; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp b/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp deleted file mode 100644 index 1b7e7a0e5..000000000 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.cpp +++ /dev/null @@ -1,237 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbgroup_select_number.h" -#include "nel/gui/view_text.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/ctrl_button.h" -#include "nel/gui/interface_property.h" -#include "interface_manager.h" -#include "nel/gui/action_handler.h" - - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number"); - -// *************************************************************************** -CDBGroupSelectNumber::CDBGroupSelectNumber(const TCtorParam ¶m) -: CInterfaceGroup(param) -{ - _SlotNumber= NULL; - _TextNumber= NULL; - _ButtonUp= NULL; - _ButtonDown= NULL; - _LoopMode= true; - _MinValue= 0; - _MaxValue= 9; - _DeltaMultiplier= 1; -} - -// *************************************************************************** -CDBGroupSelectNumber::~CDBGroupSelectNumber() -{ -} - -// *************************************************************************** -bool CDBGroupSelectNumber::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if(!CInterfaceGroup::parse(cur, parentGroup)) - return false; - - // read params - CXMLAutoPtr ptr; - ptr = xmlGetProp (cur, (xmlChar*)"value"); - if ( ptr ) - _Number.link ( ptr ); - else - { - nlinfo ("no value in %s", _Id.c_str()); - return false; - } - - // Loop, min and max - _LoopMode= false; - ptr= xmlGetProp (cur, (xmlChar*)"loop"); - if(ptr) _LoopMode= convertBool(ptr); - _MinValue = 0; - ptr= xmlGetProp (cur, (xmlChar*)"min"); - if(ptr) fromString((const char*)ptr, _MinValue); - _MaxValue = 0; - ptr= xmlGetProp (cur, (xmlChar*)"max"); - if(ptr) fromString((const char*)ptr, _MaxValue); - ptr= xmlGetProp (cur, (xmlChar*)"delta"); - if(ptr) fromString((const char*)ptr, _DeltaMultiplier); - - // set min val in DB - _Number.setSInt32(_MinValue); - - return true; -} - -// *************************************************************************** -void CDBGroupSelectNumber::setup() -{ - if (_SlotNumber != NULL) - return; - - // bind to the controls. - _SlotNumber= dynamic_cast(CInterfaceGroup::getView("slot_number")); - _TextNumber= dynamic_cast(CInterfaceGroup::getView("number")); - _ButtonUp= dynamic_cast(CInterfaceGroup::getCtrl("arrow_up")); - _ButtonDown= dynamic_cast(CInterfaceGroup::getCtrl("arrow_down")); - - // checks - if(_SlotNumber==NULL) - nlwarning("Interface: SelectNumberGroup: bitmap 'slot_number' missing or bad type"); - if(_TextNumber==NULL) - nlwarning("Interface: SelectNumberGroup: text view 'number' missing or bad type"); - if(_ButtonUp==NULL) - nlwarning("Interface: SelectNumberGroup: button 'arrow_up' missing or bad type"); - if(_ButtonDown==NULL) - nlwarning("Interface: SelectNumberGroup: button 'arrow_down' missing or bad type"); - if(_SlotNumber==NULL || _TextNumber==NULL || _ButtonUp==NULL || _ButtonDown==NULL) - return; - - // actions - _ButtonUp->setActionOnLeftClick("sn_up"); - _ButtonDown->setActionOnLeftClick("sn_down"); -} - - -// *************************************************************************** -void CDBGroupSelectNumber::updateCoords () -{ - setup(); - CInterfaceGroup::updateCoords(); -} - - - -void CDBGroupSelectNumber::checkCoords() -{ - if(_TextNumber) - _TextNumber->setText( toString(_Number.getSInt32()) ); - CInterfaceGroup::checkCoords(); -} - -// *************************************************************************** -void CDBGroupSelectNumber::draw () -{ - CInterfaceGroup::draw(); -} - -// *************************************************************************** -void CDBGroupSelectNumber::clearViews () -{ - CInterfaceGroup::clearViews(); -} - -// *************************************************************************** -bool CDBGroupSelectNumber::handleEvent (const NLGUI::CEventDescriptor &event) -{ - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - if (isIn(eventDesc.getX(), eventDesc.getY())) - { - if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel) - { - changeValue (eventDesc.getWheel()); - return true; - } - } - } - if (CInterfaceGroup::handleEvent(event)) return true; - return false; -} - - -// *************************************************************************** -void CDBGroupSelectNumber::changeValue(sint delta) -{ - delta*= _DeltaMultiplier; - - // get DB and add - sint32 val= _Number.getSInt32(); - val+= delta; - - // Loop or clamp - if(_LoopMode) - { - sint32 dval= _MaxValue+1 - _MinValue; - if (dval <= 0) - { - val = 0; - return; - } - val -= _MinValue; - val = val% dval; val = (val+dval)% dval; - val += _MinValue; - } - else - { - clamp(val, _MinValue, _MaxValue); - } - - // set in DB - _Number.setSInt32(val); - if(_TextNumber) - _TextNumber->setText( toString(_Number.getSInt32()) ); -} - - -// *************************************************************************** -// *************************************************************************** -// Actions Handlers -// *************************************************************************** -// *************************************************************************** - - -// *************************************************************************** -class CSNUp : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CDBGroupSelectNumber *pSN = dynamic_cast(pCaller->getParent()); - if (pSN == NULL) return; - pSN->changeValue(+1); - } -}; -REGISTER_ACTION_HANDLER (CSNUp, "sn_up"); - -// *************************************************************************** -class CSNDown : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CDBGroupSelectNumber *pSN = dynamic_cast(pCaller->getParent()); - if (pSN == NULL) return; - pSN->changeValue(-1); - } -}; -REGISTER_ACTION_HANDLER (CSNDown, "sn_down"); - diff --git a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h b/code/ryzom/client/src/interface_v3/dbgroup_select_number.h deleted file mode 100644 index 0b3b1a530..000000000 --- a/code/ryzom/client/src/interface_v3/dbgroup_select_number.h +++ /dev/null @@ -1,98 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_DBGROUP_SELECT_NUMBER_H -#define NL_DBGROUP_SELECT_NUMBER_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/interface_group.h" - - -namespace NLGUI -{ - class CCtrlBaseButton; - class CViewText; - class CViewBitmap; -} - - - -// *************************************************************************** -/** - * Widget to select a number - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBGroupSelectNumber : public CInterfaceGroup -{ -public: - - /// Constructor - CDBGroupSelectNumber(const TCtorParam ¶m); - ~CDBGroupSelectNumber(); - - /// CInterfaceGroup Interface - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void updateCoords (); - virtual void checkCoords(); - virtual void draw (); - virtual void clearViews (); - virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); - - // mod interface - void changeValue(sint delta); - - sint32 getMinValue () const { return _MinValue; } - void setMinValue (sint32 m) { _MinValue = m; } - sint32 getMaxValue () const { return _MaxValue; } - void setMaxValue (sint32 m) { _MaxValue = m; } - - sint32 getCurrentValue () const { return _Number.getSInt32(); } - void setCurrentValue (sint32 val) { _Number.setSInt32(val); } - - REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup) - REFLECT_SINT32("min", getMinValue, setMinValue); - REFLECT_SINT32("max", getMaxValue, setMaxValue); - REFLECT_EXPORT_END - -protected: - - // sint32 - CInterfaceProperty _Number; - bool _LoopMode; - sint _MinValue; - sint _MaxValue; - sint _DeltaMultiplier; - - // Children - CViewBitmap *_SlotNumber; - CViewText *_TextNumber; - CCtrlBaseButton *_ButtonUp; - CCtrlBaseButton *_ButtonDown; - -private: - - void setup(); - -}; - - -#endif // NL_DBGROUP_SELECT_NUMBER_H - -/* End of dbgroup_select_number.h */ diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index d07a8f154..1e59ad6fc 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -85,7 +85,7 @@ #include "nel/gui/group_tab.h" #include "group_table.h" // DBGroup -#include "dbgroup_select_number.h" +#include "nel/gui/dbgroup_select_number.h" #include "dbgroup_list_sheet.h" #include "dbgroup_combo_box.h" #include "dbgroup_list_sheet_trade.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index bfca22dd5..bad3da747 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -32,7 +32,7 @@ #include "nel/gui/group_container_base.h" #include "nel/gui/group_container.h" #include "nel/gui/group_list.h" -#include "dbgroup_select_number.h" +#include "nel/gui/dbgroup_select_number.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_text_button.h" #include "nel/gui/ctrl_col_pick.h" From 02ba7f66f9ac80caf8997723e024b76880a9e773 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 29 Jun 2012 00:30:27 +0200 Subject: [PATCH 114/339] CHANGED: #1471 CDBGroupComboBox no longer depends on the isLoggedin global Ryzom game variable. --- code/ryzom/client/src/far_tp.cpp | 3 +- .../src/interface_v3/dbgroup_combo_box.cpp | 19 +++----- .../src/interface_v3/dbgroup_combo_box.h | 17 +++---- .../src/interface_v3/interface_manager.cpp | 3 +- code/ryzom/client/src/login.cpp | 44 ++++++++++++++++--- 5 files changed, 53 insertions(+), 33 deletions(-) diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index 5b4b28c99..1b15b63c2 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -1351,6 +1351,7 @@ void CFarTP::onDssDown(bool forceReturn) } extern bool loginFinished; +void setLoginFinished( bool f ); extern bool loginOK; void CFarTP::joinSessionResult(uint32 /* userId */, TSessionId /* sessionId */, uint32 /* result */, const std::string &/* shardAddr */, const std::string &/* participantStatus */) @@ -1365,7 +1366,7 @@ void CFarTP::joinSessionResult(uint32 /* userId */, TSessionId /* sessionId */, // // FSAddr = shardAddr; // -// loginFinished = true; +// setLoginFinished( true ); // loginOK = true; // // LoginSM.pushEvent(CLoginStateMachine::ev_connect); diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp index 2a95a0b6c..e35f1e159 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp @@ -15,24 +15,22 @@ // along with this program. If not, see . - -#include "stdpch.h" #include "dbgroup_combo_box.h" #include "nel/gui/group_menu.h" #include "nel/misc/xml_auto_ptr.h" -#include "interface_manager.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/action_handler.h" #include "nel/gui/lua_ihm.h" - -#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" using namespace std; using namespace NLMISC; NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); -extern bool loginFinished; +std::string CDBGroupComboBox::measureMenu; +std::string CDBGroupComboBox::selectMenu; +std::string CDBGroupComboBox::selectMenuOut; // *************************************************************************** CDBGroupComboBox::CDBGroupComboBox(const TCtorParam ¶m) @@ -56,9 +54,8 @@ CDBGroupComboBox::~CDBGroupComboBox() // *************************************************************************** sint32 CDBGroupComboBox::evalContentWidth() const { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( loginFinished ? WIN_COMBO_BOX_MEASURE_MENU : WIN_COMBO_BOX_MEASURE_MENU_LOGIN )); + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::measureMenu )); if( !groupMenu ) { return 0; @@ -543,7 +540,6 @@ class CHandlerComboBoxSelectStart : public IActionHandler public: virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CDBGroupComboBox *pCB = dynamic_cast(pCaller->getParent()); if (pCB == NULL) return; // if no choice, return. @@ -551,10 +547,10 @@ public: return; // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(loginFinished ? WIN_COMBO_BOX_SELECT_MENU: WIN_COMBO_BOX_SELECT_MENU_LOGIN )); + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenu )); if( !groupMenu ) { - groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WIN_COMBO_BOX_SELECT_MENU_OUTGAME)); + groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenuOut )); } if( !groupMenu ) return; @@ -606,7 +602,6 @@ class CHandlerComboBoxSelectEnd : public IActionHandler public: virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); if (pCB == NULL) return; diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h index 606d7b430..bf2a44c12 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h @@ -30,17 +30,6 @@ namespace NLGUI } -// *************************************************************************** -#define WIN_COMBO_BOX_SELECT_MENU "ui:interface:combo_box_select_menu" -#define WIN_COMBO_BOX_MEASURE_MENU "ui:interface:combo_box_measure_menu" - -#define WIN_COMBO_BOX_SELECT_MENU_OUTGAME "ui:outgame:combo_box_select_menu" - -#define WIN_COMBO_BOX_SELECT_MENU_LOGIN "ui:login:combo_box_select_menu" -#define WIN_COMBO_BOX_MEASURE_MENU_LOGIN "ui:login:combo_box_measure_menu" - - - // *************************************************************************** /** * Widget: ComboBox of text @@ -155,12 +144,16 @@ protected: private: - void setup(); void dirt(); public: // private : fill a menu with current content void fillMenu(CGroupMenu *groupMenu) const; + + + static std::string measureMenu; + static std::string selectMenu; + static std::string selectMenuOut; }; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 10ca54ea3..a3d87f447 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -174,6 +174,7 @@ using namespace NLNET; // ------------------------------------------------------------------------------------------------ extern bool loginFinished; +void setLoginFinished( bool f ); // Edit actions CActionsManager EditActions; @@ -788,7 +789,7 @@ void badXMLParseMessageBox() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::initInGame() { - loginFinished = true; + setLoginFinished( true ); _LogState = false; // Whole initInGame profile diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 5d37d7c54..ad9631f69 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -40,6 +40,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_text_button.h" +#include "interface_v3/dbgroup_combo_box.h" #include "sound_manager.h" #include "far_tp.h" @@ -143,6 +144,33 @@ uint32 TotalPatchSize; CLoginStateMachine LoginSM; +// *************************************************************************** +#define WIN_COMBO_BOX_SELECT_MENU "ui:interface:combo_box_select_menu" +#define WIN_COMBO_BOX_MEASURE_MENU "ui:interface:combo_box_measure_menu" +#define WIN_COMBO_BOX_SELECT_MENU_OUTGAME "ui:outgame:combo_box_select_menu" +#define WIN_COMBO_BOX_SELECT_MENU_LOGIN "ui:login:combo_box_select_menu" +#define WIN_COMBO_BOX_MEASURE_MENU_LOGIN "ui:login:combo_box_measure_menu" + +bool isLoginFinished() +{ + return loginFinished; +} + +void setLoginFinished( bool f ) +{ + loginFinished = f; + if( loginFinished ) + { + CDBGroupComboBox::measureMenu.assign( WIN_COMBO_BOX_MEASURE_MENU ); + CDBGroupComboBox::selectMenu.assign( WIN_COMBO_BOX_SELECT_MENU ); + } + else + { + CDBGroupComboBox::measureMenu.assign( WIN_COMBO_BOX_MEASURE_MENU_LOGIN ); + CDBGroupComboBox::selectMenu.assign( WIN_COMBO_BOX_SELECT_MENU_LOGIN ); + } +} + // *************************************************************************** // Pop a fatal error message box, giving the option to 'quit' the client, plus a help button @@ -349,6 +377,7 @@ static void updatePatchingInfoText(const std::string &baseUIPath) // Main loop of the login step void loginMainLoop() { + CDBGroupComboBox::selectMenuOut.assign( WIN_COMBO_BOX_SELECT_MENU_OUTGAME ); CInterfaceManager *pIM = CInterfaceManager::getInstance(); CPatchManager *pPM = CPatchManager::getInstance(); @@ -757,7 +786,7 @@ void initLoginScreen() CCtrlTextButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CONNECT)); if (pCB != NULL) pCB->setActive(false); - loginFinished = false; + setLoginFinished( false ); loginOK = false; } @@ -882,6 +911,7 @@ bool login() // CCtrlTextButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_BUTTON_CONNECT)); // if (pCB != NULL) pCB->setActive(false); // +// setLoginFinished( false ); // loginFinished = false; // loginOK = false; @@ -1280,7 +1310,7 @@ class CAHOnGameConfiguration : public IActionHandler { // launch the ryzom configurator launchProgram(Configurator, ""); - loginFinished = true; + setLoginFinished( true ); loginOK = false; LoginSM.pushEvent(CLoginStateMachine::ev_quit); @@ -1301,7 +1331,7 @@ class CAHLoginQuit : public IActionHandler { nlinfo("CAHLoginQuit called"); - loginFinished = true; + setLoginFinished( true ); loginOK = false; LoginSM.pushEvent(CLoginStateMachine::ev_quit); @@ -1400,7 +1430,7 @@ void ConnectToShard() if (ClientCfg.R2Mode) { // r2 mode - loginFinished = true; + setLoginFinished( true ); loginOK = true; LoginSM.pushEvent(CLoginStateMachine::ev_enter_game); @@ -1414,7 +1444,7 @@ void ConnectToShard() if(res.empty()) { - loginFinished = true; + setLoginFinished( true ); loginOK = true; LoginSM.pushEvent(CLoginStateMachine::ev_enter_game); @@ -2625,7 +2655,7 @@ class CAHOnConnectToShard: public IActionHandler Cookie[i] = '|'; } - loginFinished = true; + setLoginFinished( true ); loginOK = true; LoginSM.pushEvent(CLoginStateMachine::ev_connect); @@ -2639,7 +2669,7 @@ class CAHOnBackToLogin: public IActionHandler { virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - loginFinished = false; + setLoginFinished( false ); loginOK = false; LoginSM.pushEvent(CLoginStateMachine::ev_relog); From 0c8698d7f0cbd4d5d4e608b561708226038c0851 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 29 Jun 2012 02:57:29 +0200 Subject: [PATCH 115/339] CHANGED: #1471 CDBGroupComboBox is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/dbgroup_combo_box.h | 162 +++++ code/nel/include/nel/gui/dbview_quantity.h | 2 + code/nel/src/gui/dbgroup_combo_box.cpp | 622 ++++++++++++++++++ code/nel/src/gui/dbview_quantity.cpp | 4 + code/nel/src/gui/link_hack.cpp | 2 + code/ryzom/client/src/connection.cpp | 2 +- .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/action_handler_help.cpp | 2 +- .../bot_chat_page_dynamic_mission.cpp | 2 +- .../bot_chat_page_dynamic_mission.h | 7 +- .../src/interface_v3/dbgroup_combo_box.cpp | 616 ----------------- .../src/interface_v3/dbgroup_combo_box.h | 162 ----- .../client/src/interface_v3/group_html.cpp | 2 +- .../client/src/interface_v3/group_html.h | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/macrocmd_key.cpp | 2 +- .../src/interface_v3/macrocmd_manager.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/skill_manager.cpp | 2 +- code/ryzom/client/src/login.cpp | 2 +- code/ryzom/client/src/r2/npc_editor.cpp | 2 +- 21 files changed, 810 insertions(+), 793 deletions(-) create mode 100644 code/nel/include/nel/gui/dbgroup_combo_box.h create mode 100644 code/nel/src/gui/dbgroup_combo_box.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbgroup_combo_box.h diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h new file mode 100644 index 000000000..e7a808f13 --- /dev/null +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -0,0 +1,162 @@ +// Ryzom - MMORPG Framework +// 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 NL_DBGROUP_COMBO_BOX_H +#define NL_DBGROUP_COMBO_BOX_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + +namespace NLGUI +{ + class CCtrlBaseButton; + class CViewText; + class CGroupMenu; + + + // *************************************************************************** + /** + * Widget: ComboBox of text + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBGroupComboBox : public CInterfaceGroup + { + public: + + /// Constructor + CDBGroupComboBox(const TCtorParam ¶m); + ~CDBGroupComboBox(); + + /// CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + virtual void checkCoords (); + + // Combo Texts + void resetTexts(); + void addText(const ucstring &text); + void setText(uint i, const ucstring &text); + void insertText(uint i, const ucstring &text); + const ucstring &getText(uint i) const; + const ucstring &getTexture(uint i) const; + void removeText(uint i); + uint getNumTexts() const {return (uint)_Texts.size();} + + // selection + void setSelection(sint32 val); + void setSelectionNoTrigger(sint32 val); + sint32 getSelection() const; + + // selection number + void setSelectionNb(sint32 /* val */){} + sint32 getSelectionNb() const {return (sint32)_Texts.size();} + + // selection text + void setSelectionText(const std::string & val); + std::string getSelectionText() const; + + // view text + void setViewText(const ucstring & text); + ucstring getViewText() const; + + void setTexture(uint i, const ucstring &texture); + + sint32 evalContentWidth() const; + + + int luaAddText(CLuaState &ls); + int luaRemoveSelection(CLuaState &ls); + int luaRemoveText(CLuaState &ls); + int luaRemoveTextByIndex(CLuaState &ls); + int luaResetTexts(CLuaState &ls); + int luaSetText(CLuaState &ls); + int luaInsertText(CLuaState &ls); + int luaGetText(CLuaState &ls); + int luaGetNumTexts(CLuaState &ls); + int luaSetTexture(CLuaState &ls); + + + REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup) + REFLECT_SINT32("selection", getSelection, setSelection) + REFLECT_LUA_METHOD("addText", luaAddText) + REFLECT_LUA_METHOD("setText", luaSetText) + REFLECT_LUA_METHOD("insertText", luaInsertText) + REFLECT_LUA_METHOD("setTexture", luaSetTexture) + REFLECT_LUA_METHOD("getText", luaGetText) + REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts) + REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection) + REFLECT_LUA_METHOD("removeText", luaRemoveText) + REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex) + REFLECT_LUA_METHOD("resetTexts", luaResetTexts) + REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) + REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) + REFLECT_UCSTRING ("view_text", getViewText, setViewText) + REFLECT_EXPORT_END + + + protected: + friend class CHandlerComboBoxSelectStart; + + bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead + bool _Setuped; + bool _DirtySelection; + sint32 _CacheSelection; + + // sint32 + CInterfaceProperty _Selection; + sint32 _NotLinkedToDBSelection; + std::vector _Texts; + std::vector _Textures; + + // Action Handler called on combo click + std::string _AHOnSelectStart; + + // Action handler called when the content is changed + std::string _AHOnChange; + std::string _AHOnChangeParams; + bool _CallingOnChangeActionHandler; // avoid infinite loop here + + + // Children + CViewText *_ViewText; + CCtrlBaseButton *_SelectButton; + + bool _IsExternViewText; + ucstring _ExternViewText; + + + private: + void setup(); + void dirt(); + public: + // private : fill a menu with current content + void fillMenu(CGroupMenu *groupMenu) const; + + + static std::string measureMenu; + static std::string selectMenu; + static std::string selectMenuOut; + }; + +} + +#endif // NL_DBGROUP_COMBO_BOX_H + +/* End of dbgroup_combo_box.h */ diff --git a/code/nel/include/nel/gui/dbview_quantity.h b/code/nel/include/nel/gui/dbview_quantity.h index d692f0785..da6c2e933 100644 --- a/code/nel/include/nel/gui/dbview_quantity.h +++ b/code/nel/include/nel/gui/dbview_quantity.h @@ -42,6 +42,8 @@ namespace NLGUI virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual void draw (); + static void forceLink(); + protected: CInterfaceProperty _Number; diff --git a/code/nel/src/gui/dbgroup_combo_box.cpp b/code/nel/src/gui/dbgroup_combo_box.cpp new file mode 100644 index 000000000..5191e1f68 --- /dev/null +++ b/code/nel/src/gui/dbgroup_combo_box.cpp @@ -0,0 +1,622 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/dbgroup_combo_box.h" +#include "nel/gui/group_menu.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/action_handler.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/widget_manager.h" +#include "nel/misc/i18n.h" + +using namespace std; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); + +namespace NLGUI +{ + + std::string CDBGroupComboBox::measureMenu; + std::string CDBGroupComboBox::selectMenu; + std::string CDBGroupComboBox::selectMenuOut; + + // *************************************************************************** + CDBGroupComboBox::CDBGroupComboBox(const TCtorParam ¶m) + : CInterfaceGroup(param) + { + _Setuped= false; + _ViewText= NULL; + _SelectButton= NULL; + _LinkedToDB = true; + _NotLinkedToDBSelection = 0; + _CallingOnChangeActionHandler = false; + _IsExternViewText = false; + dirt(); + } + + // *************************************************************************** + CDBGroupComboBox::~CDBGroupComboBox() + { + } + + // *************************************************************************** + sint32 CDBGroupComboBox::evalContentWidth() const + { + // get the menu to open. + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::measureMenu )); + if( !groupMenu ) + { + return 0; + } + fillMenu(groupMenu); + groupMenu->setActive(true); + groupMenu->updateCoords(); + sint32 width = groupMenu->getWReal(); + groupMenu->setActive(false); + groupMenu->reset(); + // add width for the selection arrow + return width; + } + + + // *************************************************************************** + bool CDBGroupComboBox::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + if( !CInterfaceGroup::parse(cur, parentGroup) ) + return false; + + CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"linked_to_db")); + if (prop) + { + _LinkedToDB = convertBool(prop); + } + + if (_LinkedToDB) + { + // read the selection value + CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"value")); + if(!prop) + { + nlwarning("'value' not found in %s", _Id.c_str()); + return false; + } + else + { + _Selection.link((const char*)prop); + } + } + + // read the sons text + xmlNodePtr child; + child = cur->children; + while (child) + { + if (stricmp((char*)child->name,"combo_text") == 0) + { + CXMLAutoPtr name((const char*) xmlGetProp (child, (xmlChar*)"name")); + if (name) + { + const char *propPtr = name; + ucstring Text = ucstring::makeFromUtf8(propPtr); + if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) + Text = CI18N::get (propPtr); + addText(Text); + } + } + child = child->next; + } + + // optional ActionHandler on click + prop= xmlGetProp(cur, (xmlChar*)"on_select_start"); + if(prop) _AHOnSelectStart= (const char*)prop; + + // optional ActionHandler on change + prop= xmlGetProp(cur, (xmlChar*)"on_change"); + if(prop) _AHOnChange= (const char*)prop; + + prop= xmlGetProp(cur, (xmlChar*)"on_change_params"); + if(prop) _AHOnChangeParams= (const char*)prop; + + + return true; + } + + // *************************************************************************** + void CDBGroupComboBox::checkCoords () + { + if(!_ViewText) + return; + bool mustUpdate = false; + if (_LinkedToDB) + { + // if some change in texts/selection + if(_DirtySelection || _CacheSelection!=_Selection.getSInt32()) + { + _CacheSelection= _Selection.getSInt32(); + mustUpdate = true; + } + } + else + { + // if some change in texts/selection + if(_DirtySelection || _CacheSelection != _NotLinkedToDBSelection) + { + _CacheSelection= _NotLinkedToDBSelection; + mustUpdate = true; + } + } + if (mustUpdate) + { + // change selected text + if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() ) + { + _ViewText->setText(ucstring()); + } + else if(_IsExternViewText) + { + _ViewText->setText(_ExternViewText); + } + else + { + _ViewText->setText(_Texts[_CacheSelection]); + } + } + } + + // *************************************************************************** + void CDBGroupComboBox::updateCoords () + { + if(!_Setuped) + setup(); + CInterfaceGroup::updateCoords(); + } + + + // *************************************************************************** + void CDBGroupComboBox::dirt() + { + _DirtySelection= true; + } + + // *************************************************************************** + void CDBGroupComboBox::resetTexts() + { + dirt(); + _Texts.clear(); + _Textures.clear(); + } + + // *************************************************************************** + void CDBGroupComboBox::addText(const ucstring &text) + { + dirt(); + _Texts.push_back(text); + _Textures.push_back(std::string()); + } + + // *************************************************************************** + void CDBGroupComboBox::setText(uint i, const ucstring &text) + { + dirt(); + if(i<_Texts.size()) + _Texts[i]= text; + } + + // *************************************************************************** + void CDBGroupComboBox::insertText(uint i, const ucstring &text) + { + dirt(); + if(i<_Texts.size()) + { + addText(_Texts[_Texts.size()-1]); + + for(uint t=i; t<_Texts.size()-1; t++) + { + _Texts[t+1] = _Texts[t]; + _Textures[t+1] = _Textures[t]; + } + _Texts[i]= text; + _Textures[i] = std::string(); + } + else if(i==_Texts.size()) + addText(text); + } + + // *************************************************************************** + void CDBGroupComboBox::setTexture(uint i, const ucstring &texture) + { + dirt(); + if(i<_Textures.size()) + _Textures[i]= texture; + } + + // *************************************************************************** + void CDBGroupComboBox::removeText(uint i) + { + dirt(); + if(i<_Texts.size()) + { + _Texts.erase( _Texts.begin()+i ); + _Textures.erase( _Textures.begin()+i ); + } + } + + // *************************************************************************** + const ucstring &CDBGroupComboBox::getText(uint i) const + { + static ucstring null; + if(i<_Texts.size()) + return _Texts[i]; + else + return null; + } + + // *************************************************************************** + const ucstring &CDBGroupComboBox::getTexture(uint i) const + { + static ucstring null; + if(i<_Textures.size()) + return _Textures[i]; + else + return null; + } + + + // *************************************************************************** + void CDBGroupComboBox::setSelection(sint32 val) + { + _IsExternViewText = false; + + if (_LinkedToDB) + { + _Selection.setSInt32(val); + } + else + { + _NotLinkedToDBSelection = val; + } + if (!_AHOnChange.empty()) + { + if (!_CallingOnChangeActionHandler) + { + _CallingOnChangeActionHandler = true; + CAHManager::getInstance()->runActionHandler (_AHOnChange, this, _AHOnChangeParams); + _CallingOnChangeActionHandler = false; + } + } + } + + // *************************************************************************** + void CDBGroupComboBox::setSelectionNoTrigger(sint32 val) + { + if (_LinkedToDB) + { + _Selection.setSInt32(val); + } + else + { + _NotLinkedToDBSelection = val; + } + } + + // *************************************************************************** + sint32 CDBGroupComboBox::getSelection() const + { + if (_LinkedToDB) + { + return _Selection.getSInt32(); + } + else + { + return _NotLinkedToDBSelection; + } + } + + // *************************************************************************** + void CDBGroupComboBox::setSelectionText(const std::string & val) + { + sint32 value; + for(uint i=0; isetText(_ExternViewText); + } + + // *************************************************************************** + ucstring CDBGroupComboBox::getViewText() const + { + return _ViewText->getText(); + } + + // *************************************************************************** + std::string CDBGroupComboBox::getSelectionText() const + { + ucstring text; + if (_LinkedToDB) + { + text = getText(_Selection.getSInt32()); + } + else + { + text = getText(_NotLinkedToDBSelection); + } + std::string texteS; + text.toString(texteS); + return texteS; + } + + // *************************************************************************** + void CDBGroupComboBox::setup() + { + _Setuped= true; + + // get the viewText + _ViewText= dynamic_cast(CInterfaceGroup::getView("text")); + // get the button + _SelectButton= dynamic_cast(CInterfaceGroup::getCtrl("select")); + + // force the action handler + if( _SelectButton ) + _SelectButton->setActionOnLeftClick("combo_box_select_start"); + } + + + + // *************************************************************************** + int CDBGroupComboBox::luaRemoveSelection(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "removeSelection", 1); + sint32 value; + if(CLuaIHM::popSINT32(ls, value)) + { + removeText(value); + } + return 0; + } + + // *************************************************************************** + int CDBGroupComboBox::luaRemoveText(CLuaState &ls) + { + CLuaIHM::checkArgCount(ls, "removeText", 1); + CLuaIHM::checkArgType(ls, "removeText", 1, LUA_TSTRING); + std::string text = ls.toString(1); + sint32 value; + for(uint i=0; ireset(); + for(uint i=0; iaddLine(getText(i), "combo_box_select_end", toString(i), + "", std::string(), getTexture(i).toString(), checkable); + } + + + } + + + + // *************************************************************************** + class CHandlerComboBoxSelectStart : public IActionHandler + { + public: + virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) + { + CDBGroupComboBox *pCB = dynamic_cast(pCaller->getParent()); + if (pCB == NULL) return; + // if no choice, return. + if( pCB->getNumTexts()==0 ) + return; + + // get the menu to open. + CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenu )); + if( !groupMenu ) + { + groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenuOut )); + } + if( !groupMenu ) + return; + + pCB->fillMenu(groupMenu); + + groupMenu->setMaxVisibleLine(8); + + // pos and size wisely the menu. + groupMenu->setMinW(pCB->getWReal()); + groupMenu->setX(pCB->getXReal()); + groupMenu->setBaseX(pCB->getXReal()); + groupMenu->setY(pCB->getYReal()); + groupMenu->setBaseY(pCB->getYReal()); + + // Must ensure the combo menu has same windows priority than the combo box window + CInterfaceGroup *rootWin= pCB->getRootWindow(); + if(rootWin) + groupMenu->setPriority(rootWin->getPriority()); + + // After menu init, Call user activation method + if( !pCB->_AHOnSelectStart.empty() ) + { + CAHManager::getInstance()->runActionHandler(pCB->_AHOnSelectStart, pCB); + } + + // launch the menu + // if the combo box is in a modal, must do a push, else just replace + if(dynamic_cast(pCB->getRootWindow())) + { + groupMenu->setCloseSubMenuUsingPopModal(true); + CWidgetManager::getInstance()->pushModalWindow(pCB, groupMenu); + } + else + { + groupMenu->setCloseSubMenuUsingPopModal(false); + CWidgetManager::getInstance()->enableModalWindow (pCB, groupMenu); + } + } + }; + REGISTER_ACTION_HANDLER (CHandlerComboBoxSelectStart, "combo_box_select_start"); + + + + + // *************************************************************************** + class CHandlerComboBoxSelectEnd : public IActionHandler + { + public: + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + { + CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); + if (pCB == NULL) return; + + // set the selection + sint32 selection; + fromString(Params, selection); + pCB->setSelection(selection); + } + }; + REGISTER_ACTION_HANDLER (CHandlerComboBoxSelectEnd, "combo_box_select_end"); + +} + + diff --git a/code/nel/src/gui/dbview_quantity.cpp b/code/nel/src/gui/dbview_quantity.cpp index fb6241339..8291d5cc2 100644 --- a/code/nel/src/gui/dbview_quantity.cpp +++ b/code/nel/src/gui/dbview_quantity.cpp @@ -111,4 +111,8 @@ namespace NLGUI setText(toString((const char*)buf)); } } + + void CDBViewQuantity::forceLink() + { + } } diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index a813014fd..2b1a59676 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -1,5 +1,6 @@ #include "nel/gui/dbview_bar3.h" #include "nel/gui/dbview_number.h" +#include "nel/gui/dbview_quantity.h" namespace NLGUI { @@ -8,5 +9,6 @@ namespace NLGUI { CDBViewBar3::forceLink(); CDBViewNumber::forceLink(); + CDBViewQuantity::forceLink(); } } \ No newline at end of file diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 9ef633596..9e058b6b0 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -71,7 +71,7 @@ #include "init_main_loop.h" #include "continent_manager.h" #include "interface_v3/group_quick_help.h" -#include "interface_v3/dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "r2/dmc/client_edition_module.h" #include "r2/editor.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index e86792b46..4eb3a6cd7 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -82,7 +82,7 @@ #include "game_share/scores.h" // Game Config -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/ctrl_button.h" #include "../global.h" diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index b8573e74d..290598b95 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -32,7 +32,7 @@ #include "nel/gui/view_text_id.h" #include "../user_entity.h" #include "../entities.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/dbview_bar.h" #include "../debug_client.h" #include "interface_3d_scene.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp index 2d744f4ad..30e67b46a 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.cpp @@ -22,7 +22,7 @@ #include "nel/gui/interface_group.h" #include "../string_manager_client.h" #include "nel/gui/action_handler.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "bot_chat_page_all.h" #include "bot_chat_manager.h" #include "../client_cfg.h" diff --git a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.h b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.h index 048267066..f6a320d90 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.h +++ b/code/ryzom/client/src/interface_v3/bot_chat_page_dynamic_mission.h @@ -21,7 +21,10 @@ #include "bot_chat_page.h" -class CDBGroupComboBox; +namespace NLGUI +{ + class CDBGroupComboBox; +} // number of choices that the player must make to create a dynamic mission const uint DYNAMIC_MISSION_NUM_CHOICES = 3; @@ -51,7 +54,7 @@ public: void regen(); private: // The control for each choice list - CDBGroupComboBox *_ChoiceCB[DYNAMIC_MISSION_NUM_CHOICES]; + NLGUI::CDBGroupComboBox *_ChoiceCB[DYNAMIC_MISSION_NUM_CHOICES]; // current choice for each group (-1 means that choice has not been made) sint _Choice[DYNAMIC_MISSION_NUM_CHOICES]; // For each text ID, true if the text has been received diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp deleted file mode 100644 index e35f1e159..000000000 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.cpp +++ /dev/null @@ -1,616 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "dbgroup_combo_box.h" -#include "nel/gui/group_menu.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/ctrl_button.h" -#include "nel/gui/action_handler.h" -#include "nel/gui/lua_ihm.h" -#include "nel/gui/widget_manager.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupComboBox, std::string, "combo_box"); - -std::string CDBGroupComboBox::measureMenu; -std::string CDBGroupComboBox::selectMenu; -std::string CDBGroupComboBox::selectMenuOut; - -// *************************************************************************** -CDBGroupComboBox::CDBGroupComboBox(const TCtorParam ¶m) -: CInterfaceGroup(param) -{ - _Setuped= false; - _ViewText= NULL; - _SelectButton= NULL; - _LinkedToDB = true; - _NotLinkedToDBSelection = 0; - _CallingOnChangeActionHandler = false; - _IsExternViewText = false; - dirt(); -} - -// *************************************************************************** -CDBGroupComboBox::~CDBGroupComboBox() -{ -} - -// *************************************************************************** -sint32 CDBGroupComboBox::evalContentWidth() const -{ - // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::measureMenu )); - if( !groupMenu ) - { - return 0; - } - fillMenu(groupMenu); - groupMenu->setActive(true); - groupMenu->updateCoords(); - sint32 width = groupMenu->getWReal(); - groupMenu->setActive(false); - groupMenu->reset(); - // add width for the selection arrow - return width; -} - - -// *************************************************************************** -bool CDBGroupComboBox::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - if( !CInterfaceGroup::parse(cur, parentGroup) ) - return false; - - CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"linked_to_db")); - if (prop) - { - _LinkedToDB = convertBool(prop); - } - - if (_LinkedToDB) - { - // read the selection value - CXMLAutoPtr prop((const char*)xmlGetProp(cur, (xmlChar*)"value")); - if(!prop) - { - nlwarning("'value' not found in %s", _Id.c_str()); - return false; - } - else - { - _Selection.link((const char*)prop); - } - } - - // read the sons text - xmlNodePtr child; - child = cur->children; - while (child) - { - if (stricmp((char*)child->name,"combo_text") == 0) - { - CXMLAutoPtr name((const char*) xmlGetProp (child, (xmlChar*)"name")); - if (name) - { - const char *propPtr = name; - ucstring Text = ucstring::makeFromUtf8(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - addText(Text); - } - } - child = child->next; - } - - // optional ActionHandler on click - prop= xmlGetProp(cur, (xmlChar*)"on_select_start"); - if(prop) _AHOnSelectStart= (const char*)prop; - - // optional ActionHandler on change - prop= xmlGetProp(cur, (xmlChar*)"on_change"); - if(prop) _AHOnChange= (const char*)prop; - - prop= xmlGetProp(cur, (xmlChar*)"on_change_params"); - if(prop) _AHOnChangeParams= (const char*)prop; - - - return true; -} - -// *************************************************************************** -void CDBGroupComboBox::checkCoords () -{ - if(!_ViewText) - return; - bool mustUpdate = false; - if (_LinkedToDB) - { - // if some change in texts/selection - if(_DirtySelection || _CacheSelection!=_Selection.getSInt32()) - { - _CacheSelection= _Selection.getSInt32(); - mustUpdate = true; - } - } - else - { - // if some change in texts/selection - if(_DirtySelection || _CacheSelection != _NotLinkedToDBSelection) - { - _CacheSelection= _NotLinkedToDBSelection; - mustUpdate = true; - } - } - if (mustUpdate) - { - // change selected text - if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() ) - { - _ViewText->setText(ucstring()); - } - else if(_IsExternViewText) - { - _ViewText->setText(_ExternViewText); - } - else - { - _ViewText->setText(_Texts[_CacheSelection]); - } - } -} - -// *************************************************************************** -void CDBGroupComboBox::updateCoords () -{ - if(!_Setuped) - setup(); - CInterfaceGroup::updateCoords(); -} - - -// *************************************************************************** -void CDBGroupComboBox::dirt() -{ - _DirtySelection= true; -} - -// *************************************************************************** -void CDBGroupComboBox::resetTexts() -{ - dirt(); - _Texts.clear(); - _Textures.clear(); -} - -// *************************************************************************** -void CDBGroupComboBox::addText(const ucstring &text) -{ - dirt(); - _Texts.push_back(text); - _Textures.push_back(std::string()); -} - -// *************************************************************************** -void CDBGroupComboBox::setText(uint i, const ucstring &text) -{ - dirt(); - if(i<_Texts.size()) - _Texts[i]= text; -} - -// *************************************************************************** -void CDBGroupComboBox::insertText(uint i, const ucstring &text) -{ - dirt(); - if(i<_Texts.size()) - { - addText(_Texts[_Texts.size()-1]); - - for(uint t=i; t<_Texts.size()-1; t++) - { - _Texts[t+1] = _Texts[t]; - _Textures[t+1] = _Textures[t]; - } - _Texts[i]= text; - _Textures[i] = std::string(); - } - else if(i==_Texts.size()) - addText(text); -} - -// *************************************************************************** -void CDBGroupComboBox::setTexture(uint i, const ucstring &texture) -{ - dirt(); - if(i<_Textures.size()) - _Textures[i]= texture; -} - -// *************************************************************************** -void CDBGroupComboBox::removeText(uint i) -{ - dirt(); - if(i<_Texts.size()) - { - _Texts.erase( _Texts.begin()+i ); - _Textures.erase( _Textures.begin()+i ); - } -} - -// *************************************************************************** -const ucstring &CDBGroupComboBox::getText(uint i) const -{ - static ucstring null; - if(i<_Texts.size()) - return _Texts[i]; - else - return null; -} - -// *************************************************************************** -const ucstring &CDBGroupComboBox::getTexture(uint i) const -{ - static ucstring null; - if(i<_Textures.size()) - return _Textures[i]; - else - return null; -} - - -// *************************************************************************** -void CDBGroupComboBox::setSelection(sint32 val) -{ - _IsExternViewText = false; - - if (_LinkedToDB) - { - _Selection.setSInt32(val); - } - else - { - _NotLinkedToDBSelection = val; - } - if (!_AHOnChange.empty()) - { - if (!_CallingOnChangeActionHandler) - { - _CallingOnChangeActionHandler = true; - CAHManager::getInstance()->runActionHandler (_AHOnChange, this, _AHOnChangeParams); - _CallingOnChangeActionHandler = false; - } - } -} - -// *************************************************************************** -void CDBGroupComboBox::setSelectionNoTrigger(sint32 val) -{ - if (_LinkedToDB) - { - _Selection.setSInt32(val); - } - else - { - _NotLinkedToDBSelection = val; - } -} - -// *************************************************************************** -sint32 CDBGroupComboBox::getSelection() const -{ - if (_LinkedToDB) - { - return _Selection.getSInt32(); - } - else - { - return _NotLinkedToDBSelection; - } -} - -// *************************************************************************** -void CDBGroupComboBox::setSelectionText(const std::string & val) -{ - sint32 value; - for(uint i=0; isetText(_ExternViewText); -} - -// *************************************************************************** -ucstring CDBGroupComboBox::getViewText() const -{ - return _ViewText->getText(); -} - -// *************************************************************************** -std::string CDBGroupComboBox::getSelectionText() const -{ - ucstring text; - if (_LinkedToDB) - { - text = getText(_Selection.getSInt32()); - } - else - { - text = getText(_NotLinkedToDBSelection); - } - std::string texteS; - text.toString(texteS); - return texteS; -} - -// *************************************************************************** -void CDBGroupComboBox::setup() -{ - _Setuped= true; - - // get the viewText - _ViewText= dynamic_cast(CInterfaceGroup::getView("text")); - // get the button - _SelectButton= dynamic_cast(CInterfaceGroup::getCtrl("select")); - - // force the action handler - if( _SelectButton ) - _SelectButton->setActionOnLeftClick("combo_box_select_start"); -} - - - -// *************************************************************************** -int CDBGroupComboBox::luaRemoveSelection(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "removeSelection", 1); - sint32 value; - if(CLuaIHM::popSINT32(ls, value)) - { - removeText(value); - } - return 0; -} - -// *************************************************************************** -int CDBGroupComboBox::luaRemoveText(CLuaState &ls) -{ - CLuaIHM::checkArgCount(ls, "removeText", 1); - CLuaIHM::checkArgType(ls, "removeText", 1, LUA_TSTRING); - std::string text = ls.toString(1); - sint32 value; - for(uint i=0; ireset(); - for(uint i=0; iaddLine(getText(i), "combo_box_select_end", toString(i), - "", std::string(), getTexture(i).toString(), checkable); - } - - -} - - - -// *************************************************************************** -class CHandlerComboBoxSelectStart : public IActionHandler -{ -public: - virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */) - { - CDBGroupComboBox *pCB = dynamic_cast(pCaller->getParent()); - if (pCB == NULL) return; - // if no choice, return. - if( pCB->getNumTexts()==0 ) - return; - - // get the menu to open. - CGroupMenu *groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenu )); - if( !groupMenu ) - { - groupMenu= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( CDBGroupComboBox::selectMenuOut )); - } - if( !groupMenu ) - return; - - pCB->fillMenu(groupMenu); - - groupMenu->setMaxVisibleLine(8); - - // pos and size wisely the menu. - groupMenu->setMinW(pCB->getWReal()); - groupMenu->setX(pCB->getXReal()); - groupMenu->setBaseX(pCB->getXReal()); - groupMenu->setY(pCB->getYReal()); - groupMenu->setBaseY(pCB->getYReal()); - - // Must ensure the combo menu has same windows priority than the combo box window - CInterfaceGroup *rootWin= pCB->getRootWindow(); - if(rootWin) - groupMenu->setPriority(rootWin->getPriority()); - - // After menu init, Call user activation method - if( !pCB->_AHOnSelectStart.empty() ) - { - CAHManager::getInstance()->runActionHandler(pCB->_AHOnSelectStart, pCB); - } - - // launch the menu - // if the combo box is in a modal, must do a push, else just replace - if(dynamic_cast(pCB->getRootWindow())) - { - groupMenu->setCloseSubMenuUsingPopModal(true); - CWidgetManager::getInstance()->pushModalWindow(pCB, groupMenu); - } - else - { - groupMenu->setCloseSubMenuUsingPopModal(false); - CWidgetManager::getInstance()->enableModalWindow (pCB, groupMenu); - } - } -}; -REGISTER_ACTION_HANDLER (CHandlerComboBoxSelectStart, "combo_box_select_start"); - - - - -// *************************************************************************** -class CHandlerComboBoxSelectEnd : public IActionHandler -{ -public: - virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) - { - CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getCtrlLaunchingModal()); - if (pCB == NULL) return; - - // set the selection - sint32 selection; - fromString(Params, selection); - pCB->setSelection(selection); - } -}; -REGISTER_ACTION_HANDLER (CHandlerComboBoxSelectEnd, "combo_box_select_end"); - - diff --git a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h b/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h deleted file mode 100644 index bf2a44c12..000000000 --- a/code/ryzom/client/src/interface_v3/dbgroup_combo_box.h +++ /dev/null @@ -1,162 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_DBGROUP_COMBO_BOX_H -#define NL_DBGROUP_COMBO_BOX_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/interface_group.h" - -namespace NLGUI -{ - class CCtrlBaseButton; - class CViewText; - class CGroupMenu; -} - - -// *************************************************************************** -/** - * Widget: ComboBox of text - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBGroupComboBox : public CInterfaceGroup -{ -public: - - /// Constructor - CDBGroupComboBox(const TCtorParam ¶m); - ~CDBGroupComboBox(); - - /// CInterfaceGroup Interface - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - virtual void updateCoords (); - virtual void checkCoords (); - - // Combo Texts - void resetTexts(); - void addText(const ucstring &text); - void setText(uint i, const ucstring &text); - void insertText(uint i, const ucstring &text); - const ucstring &getText(uint i) const; - const ucstring &getTexture(uint i) const; - void removeText(uint i); - uint getNumTexts() const {return (uint)_Texts.size();} - - // selection - void setSelection(sint32 val); - void setSelectionNoTrigger(sint32 val); - sint32 getSelection() const; - - // selection number - void setSelectionNb(sint32 /* val */){} - sint32 getSelectionNb() const {return (sint32)_Texts.size();} - - // selection text - void setSelectionText(const std::string & val); - std::string getSelectionText() const; - - // view text - void setViewText(const ucstring & text); - ucstring getViewText() const; - - void setTexture(uint i, const ucstring &texture); - - sint32 evalContentWidth() const; - - - int luaAddText(CLuaState &ls); - int luaRemoveSelection(CLuaState &ls); - int luaRemoveText(CLuaState &ls); - int luaRemoveTextByIndex(CLuaState &ls); - int luaResetTexts(CLuaState &ls); - int luaSetText(CLuaState &ls); - int luaInsertText(CLuaState &ls); - int luaGetText(CLuaState &ls); - int luaGetNumTexts(CLuaState &ls); - int luaSetTexture(CLuaState &ls); - - - REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup) - REFLECT_SINT32("selection", getSelection, setSelection) - REFLECT_LUA_METHOD("addText", luaAddText) - REFLECT_LUA_METHOD("setText", luaSetText) - REFLECT_LUA_METHOD("insertText", luaInsertText) - REFLECT_LUA_METHOD("setTexture", luaSetTexture) - REFLECT_LUA_METHOD("getText", luaGetText) - REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts) - REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection) - REFLECT_LUA_METHOD("removeText", luaRemoveText) - REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex) - REFLECT_LUA_METHOD("resetTexts", luaResetTexts) - REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) - REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) - REFLECT_UCSTRING ("view_text", getViewText, setViewText) - REFLECT_EXPORT_END - - -protected: - friend class CHandlerComboBoxSelectStart; - - bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead - bool _Setuped; - bool _DirtySelection; - sint32 _CacheSelection; - - // sint32 - CInterfaceProperty _Selection; - sint32 _NotLinkedToDBSelection; - std::vector _Texts; - std::vector _Textures; - - // Action Handler called on combo click - std::string _AHOnSelectStart; - - // Action handler called when the content is changed - std::string _AHOnChange; - std::string _AHOnChangeParams; - bool _CallingOnChangeActionHandler; // avoid infinite loop here - - - // Children - CViewText *_ViewText; - CCtrlBaseButton *_SelectButton; - - bool _IsExternViewText; - ucstring _ExternViewText; - - -private: - void setup(); - void dirt(); -public: - // private : fill a menu with current content - void fillMenu(CGroupMenu *groupMenu) const; - - - static std::string measureMenu; - static std::string selectMenu; - static std::string selectMenuOut; -}; - - -#endif // NL_DBGROUP_COMBO_BOX_H - -/* End of dbgroup_combo_box.h */ diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 9e40cadb7..bb90cef39 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -42,7 +42,7 @@ extern "C" #include "interface_manager.h" #include "nel/gui/view_bitmap.h" #include "../actions.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/lua_ihm.h" #include "../time_client.h" diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 9f03ab050..9b21f01ed 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -42,9 +42,9 @@ namespace NLGUI class CCtrlButton; class CCtrlScroll; class CGroupList; + class CDBGroupComboBox; } -class CDBGroupComboBox; class CGroupParagraph; // HTML group diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 1e59ad6fc..6dacf841a 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -87,7 +87,7 @@ // DBGroup #include "nel/gui/dbgroup_select_number.h" #include "dbgroup_list_sheet.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "dbgroup_list_sheet_trade.h" #include "dbgroup_list_sheet_mission.h" #include "guild_manager.h" // for CDBGroupListAscensor diff --git a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp index 00abdaf88..a03ac010b 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_key.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_key.cpp @@ -27,7 +27,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/group_container.h" #include "group_modal_get_key.h" #include "nel/gui/interface_expr.h" diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index 52c7ae45a..ab7c67073 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -28,7 +28,7 @@ #include "nel/gui/ctrl_button.h" #include "nel/gui/group_editbox.h" #include "nel/gui/group_list.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/group_container.h" #include "group_modal_get_key.h" #include "task_bar_manager.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index bad3da747..436e492e1 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -47,7 +47,7 @@ #include "nel/gui/dbview_bar3.h" #include "nel/gui/ctrl_scroll_base.h" #include "nel/gui/ctrl_scroll.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/group_tab.h" #include "group_html.h" #include "nel/gui/group_header.h" diff --git a/code/ryzom/client/src/interface_v3/skill_manager.cpp b/code/ryzom/client/src/interface_v3/skill_manager.cpp index 1f849522b..176a53e1f 100644 --- a/code/ryzom/client/src/interface_v3/skill_manager.cpp +++ b/code/ryzom/client/src/interface_v3/skill_manager.cpp @@ -27,7 +27,7 @@ #include "nel/misc/cdb_leaf.h" #include "nel/gui/action_handler.h" #include "sbrick_manager.h" -#include "dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/view_bitmap.h" #include "../net_manager.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index ad9631f69..7d1b8a3fa 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -40,7 +40,7 @@ #include "nel/gui/view_text.h" #include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_text_button.h" -#include "interface_v3/dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "sound_manager.h" #include "far_tp.h" diff --git a/code/ryzom/client/src/r2/npc_editor.cpp b/code/ryzom/client/src/r2/npc_editor.cpp index e24f6d900..11cb94b38 100644 --- a/code/ryzom/client/src/r2/npc_editor.cpp +++ b/code/ryzom/client/src/r2/npc_editor.cpp @@ -23,7 +23,7 @@ #include "../interface_v3/interface_manager.h" #include "nel/gui/group_container.h" #include "displayer_visual_entity.h" -#include "../interface_v3/dbgroup_combo_box.h" +#include "nel/gui/dbgroup_combo_box.h" #include "../sheet_manager.h" From e209a6c77d85e8db3a07d70be92859a7dbd68371 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 29 Jun 2012 06:15:56 +0200 Subject: [PATCH 116/339] CHANGED: #1471 CGroupTable and CGroupCell no longer depend on CInterfaceManager, and a Ryzom game global. --- code/nel/include/nel/gui/widget_manager.h | 1 + .../client/src/interface_v3/group_table.cpp | 20 ++++++------------- .../client/src/interface_v3/group_table.h | 5 ++++- code/ryzom/client/src/main_loop.cpp | 7 ++++--- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 98fae80d6..0083e20c0 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -51,6 +51,7 @@ namespace NLGUI virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; + virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ); }; /// Manages the GUI widgets diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index bdb37b895..4711ed4ca 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -15,27 +15,21 @@ // along with this program. If not, see . - -#include "stdpch.h" - #include "group_table.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.h" #include "nel/gui/interface_element.h" -#include "../client_chat_manager.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" #include "nel/gui/group_container.h" - #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" - #include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; -extern CClientChatManager ChatMngr; -extern bool DebugUICell; + +bool CGroupCell::DebugUICell = false; // ---------------------------------------------------------------------------- CGroupCell::CGroupCell(const TCtorParam ¶m) @@ -91,7 +85,7 @@ bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint colum Group->setId(parentGroup->getId() + Group->getId()); setEnclosedGroupDefaultParams(); // parse the children - bool ok = CInterfaceManager::getInstance()->parseGroupChildren(cur, Group, false); + bool ok = CWidgetManager::parser->parseGroupChildren(cur, Group, false); if (!ok) return false; // align ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); @@ -191,8 +185,7 @@ bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint colum // ---------------------------------------------------------------------------- void CGroupCell::draw () { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (DebugUICell) + if ( CGroupCell::DebugUICell ) { // Draw cell CViewRenderer &rVR = *CViewRenderer::getInstance(); @@ -791,7 +784,7 @@ void CGroupTable::checkCoords () } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { @@ -944,7 +937,6 @@ void CGroupTable::draw () sint32 border = Border + CellSpacing + CellPadding; if (border) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CRGBA finalColor; finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); finalColor.A = CurrentAlpha; diff --git a/code/ryzom/client/src/interface_v3/group_table.h b/code/ryzom/client/src/interface_v3/group_table.h index ba14e7039..77c3e507c 100644 --- a/code/ryzom/client/src/interface_v3/group_table.h +++ b/code/ryzom/client/src/interface_v3/group_table.h @@ -22,7 +22,6 @@ #include "nel/misc/types_nl.h" #include "nel/gui/group_frame.h" #include "nel/gui/view_text.h" -#include "view_link.h" #include "nel/gui/ctrl_button.h" /** @@ -101,8 +100,12 @@ public: void setTextureTile(bool tiled); void setTextureScale(bool scaled); + static void setDebugUICell( bool d ){ DebugUICell = d; } + static bool getDebugUICell(){ return DebugUICell; } + private: void setEnclosedGroupDefaultParams(); + static bool DebugUICell; }; /** diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 61dda28bd..1300de86d 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -146,6 +146,7 @@ #include "string_manager_client.h" #include "nel/gui/lua_manager.h" +#include "interface_v3/group_table.h" /////////// @@ -317,7 +318,6 @@ uint32 OldWidth; // Last Width of the window. uint32 OldHeight; // Last Height of the window. bool ShowInterface = true; // Do the Chat OSD have to be displayed. -bool DebugUICell = false; bool DebugUIView = false; bool DebugUICtrl = false; bool DebugUIGroup = false; @@ -4394,7 +4394,8 @@ NLMISC_COMMAND(debugUI, "Debug the ui : show/hide quads of bboxs and hotspots", else fromString(args[0], on); } - DebugUICell = on; + + CGroupCell::setDebugUICell( on ); DebugUIView = on; DebugUICtrl = on; DebugUIGroup = on; @@ -4426,7 +4427,7 @@ NLMISC_COMMAND(debugUIGroup, "Debug the ui : show/hide quads of bboxs and hotspo // show hide the debuging of cells NLMISC_COMMAND(debugUICell, "Debug the ui : show/hide quads of bboxs for cells", "") { - DebugUICell = !DebugUICell; + CGroupCell::setDebugUICell( !CGroupCell::getDebugUICell() ) return true; } From 215f7124d259fb15cf4ae60367c07e2f5fe22de9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 29 Jun 2012 06:58:14 +0200 Subject: [PATCH 117/339] CHANGED: #1471 CGroupTable and CGroupCell are now part of the NELGUI library and are under the NLGUI namespace. --- code/nel/include/nel/gui/group_table.h | 216 ++++ code/nel/include/nel/gui/widget_manager.h | 2 +- code/nel/src/gui/group_table.cpp | 1078 +++++++++++++++++ .../client/src/interface_v3/group_html.h | 2 +- .../client/src/interface_v3/group_table.cpp | 1074 ---------------- .../client/src/interface_v3/group_table.h | 212 ---- .../src/interface_v3/interface_parser.cpp | 2 +- code/ryzom/client/src/main_loop.cpp | 4 +- 8 files changed, 1299 insertions(+), 1291 deletions(-) create mode 100644 code/nel/include/nel/gui/group_table.h create mode 100644 code/nel/src/gui/group_table.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_table.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_table.h diff --git a/code/nel/include/nel/gui/group_table.h b/code/nel/include/nel/gui/group_table.h new file mode 100644 index 000000000..4fd0f86e0 --- /dev/null +++ b/code/nel/include/nel/gui/group_table.h @@ -0,0 +1,216 @@ +// Ryzom - MMORPG Framework +// 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 NL_GROUP_TABLE_H +#define NL_GROUP_TABLE_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/group_frame.h" +#include "nel/gui/view_text.h" +#include "nel/gui/ctrl_button.h" + +namespace NLGUI +{ + + /** + * This group is used to simulate HTML cells. + * They have specific parameters to be aligned like HTML cells. + * (Percent of the table size + */ + class CGroupCell: public CInterfaceGroup + { + friend class CGroupTable; + public: + CGroupCell(const TCtorParam ¶m); + + enum TAlign + { + Left, + Center, + Right + }; + + enum TVAlign + { + Top, + Middle, + Bottom + }; + + /// \from CInterfaceElement + virtual void draw(); + virtual sint32 getMaxUsedW() const; + virtual sint32 getMinUsedW() const; + + // to be called by CGroupTable + bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); + + // If the cell is a new line. This is the first + bool NewLine; + bool IgnoreMaxWidth; + bool IgnoreMinWidth; + bool AddChildW; + + // The table width cell ratio. This is the
after a
parameter + float TableRatio; + + // The Width you want in pixel. This is the parameter + sint32 WidthWanted; + + + // The min height of the cell + sint32 Height; + + // Memorize max width + sint32 WidthMax; + + // The cell color + NLMISC::CRGBA BgColor; + + // Texture + CViewRenderer::CTextureId _TextureId; /// Accelerator + bool _UserTexture; + bool _TextureTiled; + bool _TextureScaled; + + // Alignment + TAlign Align; + TVAlign VAlign; + sint32 LeftMargin; + + // The cell group + CInterfaceGroup *Group; + + // The cell is nowrap + bool NoWrap; + + void setTexture(const std::string & TxName); + void setTextureTile(bool tiled); + void setTextureScale(bool scaled); + + static void setDebugUICell( bool d ){ DebugUICell = d; } + static bool getDebugUICell(){ return DebugUICell; } + + private: + void setEnclosedGroupDefaultParams(); + static bool DebugUICell; + }; + + /** + * This group is used to simulate HTML table. Support "percent of the parent width" sizeRef mode. + */ + class CGroupTable : public CInterfaceGroup + { + public: + + ///constructor + CGroupTable(const TCtorParam ¶m); + + // dtor + ~CGroupTable(); + + // Add a cell in the table + void addChild (CGroupCell* child); + + // The ratio you want [0 ~1]. This is the parameter + float TableRatio; + + // The Width you want in pixel. This is the
parameter + sint32 ForceWidthMin; + + // Table borders + sint32 Border; + sint32 CellPadding; + sint32 CellSpacing; + + // The table color + NLMISC::CRGBA BgColor; + uint8 CurrentAlpha; + + bool ContinuousUpdate; + + protected: + + /// \from CInterfaceElement + void onInvalidateContent(); + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + void draw (); + + /** + * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here + */ + virtual void updateCoords(); + + virtual void checkCoords(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + + // Content validated + bool _ContentValidated; + + // Last parent width + sint32 _LastParentW; + + // Children + std::vector _Cells; + + // Table column + class CColumn + { + public: + CColumn() + { + Width = 0; + WidthMax = 0; + WidthWanted = 0; + TableRatio = 0; + Height = 0; + } + sint32 Width; + sint32 Height; + sint32 WidthWanted; + sint32 WidthMax; + float TableRatio; + }; + + // Table row + class CRow + { + public: + CRow() + { + Height = 0; + } + sint32 Height; + }; + + // Column table + std::vector _Columns; + + // Column table + std::vector _Rows; + }; + +} + +#endif // NL_GROUP_TABLE_H + +/* End of group_table.h */ + + diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 0083e20c0..df5fd5540 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -51,7 +51,7 @@ namespace NLGUI virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; - virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ); + virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0; }; /// Manages the GUI widgets diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp new file mode 100644 index 000000000..4baa32ab1 --- /dev/null +++ b/code/nel/src/gui/group_table.cpp @@ -0,0 +1,1078 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/group_table.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_element.h" +#include "nel/gui/view_bitmap.h" +#include "nel/gui/view_text_id.h" +#include "nel/gui/group_container.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/i18n.h" +#include "nel/misc/xml_auto_ptr.h" + +using namespace std; +using namespace NLMISC; + +namespace NLGUI +{ + + bool CGroupCell::DebugUICell = false; + + // ---------------------------------------------------------------------------- + CGroupCell::CGroupCell(const TCtorParam ¶m) + : CInterfaceGroup(param), + BgColor (0,0,0,0) + + { + NewLine = false; + TableRatio = 0.f; + WidthWanted = 0; + Height = 0; + Group = new CInterfaceGroup(CViewBase::TCtorParam()); + Align = Left; + VAlign = Top; + LeftMargin = 0; + NoWrap = false; + IgnoreMaxWidth = false; + IgnoreMinWidth = false; + AddChildW = false; + _UserTexture = false; + _TextureTiled = false; + _TextureScaled = false; + setEnclosedGroupDefaultParams(); + addGroup (Group); + } + + // ---------------------------------------------------------------------------- + void CGroupCell::setEnclosedGroupDefaultParams() + { + nlassert(Group); + // Cells are moved and resized by the table + Group->setParent(this); + Group->setParentPos(this); + Group->setPosRef(Hotspot_TL); + Group->setParentPosRef(Hotspot_TL); + Group->setResizeFromChildW(false); + Group->setResizeFromChildH(true); + } + + // ---------------------------------------------------------------------------- + bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) + { + CXMLAutoPtr ptr; + ptr = (char*) xmlGetProp( cur, (xmlChar*)"id"); + if (!ptr) + { + // no id was given, so create one + std::string newId = NLMISC::toString("cell_%d_%d", (int) columnIndex, (int) rowIndex); + xmlSetProp(cur, (const xmlChar*) "id", (const xmlChar*) newId.c_str()); + } + // parse enclosed group + if (!Group->parse(cur, this)) return false; + Group->setId(parentGroup->getId() + Group->getId()); + setEnclosedGroupDefaultParams(); + // parse the children + bool ok = CWidgetManager::parser->parseGroupChildren(cur, Group, false); + if (!ok) return false; + // align + ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); + if (ptr) + { + if (strcmp((const char *) ptr, "left") == 0) + { + Align = Left; + } + else if (strcmp((const char *) ptr, "right") == 0) + { + Align = Right; + } + else if (strcmp((const char *) ptr, "center") == 0) + { + Align = Center; + } + else + { + nlwarning(" Unknwown or unsupported align mode : %s", (const char *) ptr); + } + } + // v-align + ptr = (char*) xmlGetProp( cur, (xmlChar*)"valign" ); + if (ptr) + { + if (strcmp((const char *) ptr, "top") == 0) + { + VAlign = Top; + } + else if (strcmp((const char *) ptr, "middle") == 0) + { + VAlign = Middle; + } + else if (strcmp((const char *) ptr, "bottom") == 0) + { + VAlign = Bottom; + } + else + { + nlwarning(" Unknwown or unsupported valign mode : %s", (const char *) ptr); + } + } + // left margin + ptr = (char*) xmlGetProp( cur, (xmlChar*)"left_margin" ); + if (ptr) + { + fromString((const char*)ptr, LeftMargin); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"nowrap" ); + if (ptr) + { + NoWrap = convertBool(ptr); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"bgcolor" ); + if (ptr) + { + BgColor = convertColor(ptr); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"width" ); + if (ptr) + { + convertPixelsOrRatio((const char *) ptr, WidthWanted, TableRatio); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"height" ); + if (ptr) + { + fromString((const char*)ptr, Height); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"ignore_max_width" ); + if (ptr) + { + IgnoreMaxWidth = convertBool(ptr); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"ignore_min_width" ); + if (ptr) + { + IgnoreMinWidth = convertBool(ptr); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"add_child_w" ); + if (ptr) + { + AddChildW = convertBool(ptr); + } + + return true; + } + + + // ---------------------------------------------------------------------------- + void CGroupCell::draw () + { + if ( CGroupCell::DebugUICell ) + { + // Draw cell + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal-1, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-1, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); + } + + // Draw the background + if (_UserTexture || BgColor.A != 0) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + if (_UserTexture) + { + CRGBA col; + if (BgColor.A == 0 ) + col = CRGBA(255,255,255,255); + else + col = BgColor; + + + if (_TextureScaled && !_TextureTiled) + { + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, + _WReal, _HReal, + 0, false, + _TextureId, + col ); + } + else + { + if (!_TextureTiled) + { + rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, + 0, false, + _TextureId, + col); + } + else + { + rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal, + _WReal, _HReal, + 0, false, + _TextureId, + 0, + col); + } + } + + } + else + { + CRGBA finalColor; + finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); + + // Get the parent table + if (getParent ()) + { + CGroupTable *table = static_cast (getParent ()); + finalColor.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) finalColor.A) >> 8); + } + + //nlinfo("Blank Texture"); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor); + } + } + + CInterfaceGroup::draw (); + } + + // ---------------------------------------------------------------------------- + sint32 CGroupCell::getMaxUsedW() const + { + return Group->getMaxUsedW(); + } + + // ------------------------------------------------------------------------------------------------ + sint32 CGroupCell::getMinUsedW() const + { + return Group->getMinUsedW(); + } + + + // ---------------------------------------------------------------------------- + void CGroupCell::setTexture(const std::string & TxName) + { + if (TxName.empty() || TxName == "none") + { + _UserTexture = false; + nlinfo("Set no texture"); + } + else + { + nlinfo("Set texture to cell : %s", TxName.c_str()); + _UserTexture = true; + _TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false); + } + } + + // ---------------------------------------------------------------------------- + void CGroupCell::setTextureTile(bool tiled) + { + if (tiled) + nlinfo("Set texture is Tiled"); + _TextureTiled = tiled; + } + + // ---------------------------------------------------------------------------- + void CGroupCell::setTextureScale(bool scaled) + { + if (scaled) + nlinfo("Set texture is Scaled : %s"); + _TextureScaled = scaled; + } + + + // ---------------------------------------------------------------------------- + NLMISC_REGISTER_OBJECT(CViewBase, CGroupTable, std::string, "table"); + + CGroupTable::CGroupTable(const TCtorParam ¶m) + : CInterfaceGroup(param), + BgColor(0,0,0,255) + { + _ContentValidated = false; + TableRatio = 0.f; + ForceWidthMin = 0; + Border=0; + CellPadding=0; + CellSpacing=0; + ContinuousUpdate = false; + } + + // ---------------------------------------------------------------------------- + void CGroupTable::addChild (CGroupCell* child) + { + // Cell empty ? + if (_Cells.empty()) + // New line + child->NewLine = true; + + // Cells are moved and resized by the table + child->setParent(this); + child->setParentPos(this); + child->setPosRef(Hotspot_TL); + child->setParentPosRef(Hotspot_TL); + child->setResizeFromChildW(false); + + // Child resize H for cells + child->setResizeFromChildH(false); + + /* // New line ? + if (child->NewLine) + { + // First element + if (_Cells.empty()) + { + child->setParentPos(NULL); + child->setPosRef(Hotspot_TL); + child->setParentPosRef(Hotspot_TL); + } + // New line + else + { + // Look for previous new line + uint i; + for (i=_Cells.size()-1; i>0; i--) + if (_Cells[i]->NewLine) + break; + + child->setParentPos(_Cells[i]); + child->setPosRef(Hotspot_TL); + child->setParentPosRef(Hotspot_BL); + } + } + else + { + nlassert(!_Cells.empty()); + child->setParentPos(_Cells.back()); + child->setPosRef(Hotspot_TL); + child->setParentPosRef(Hotspot_TR); + }*/ + + // Add the child + addGroup(child); + _Cells.push_back(child); + invalidateContent(); + } + + // ---------------------------------------------------------------------------- + CGroupTable::~CGroupTable() + { + /* uint i; + for (i=0; i<_Cells.size(); i++) + delete _Cells[i]; + _Cells.clear ();*/ + } + + + + // ---------------------------------------------------------------------------- + void CGroupTable::updateCoords() + { + if (_Parent) + { + if (ContinuousUpdate) + { + sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + if (_LastParentW != (sint) parentWidth) + { + _LastParentW = parentWidth; + _ContentValidated = false; + } + } + if (!_ContentValidated) + { + // Update W and XReal + CInterfaceElement::updateCoords(); + + // *** For each children, update coords, gets min and max values + // *** Get the column sizes, we need to know min for the table + + uint i; + uint column = 0; + _Columns.clear (); + for (i=0; i<_Cells.size(); i++) + { + // Update coords to get XReal + CGroupCell *cell = _Cells[i]; + cell->checkCoords(); + cell->updateCoords(); + + sint32 additionnalWidth = 0; + if (cell->AddChildW) + { + sint width, height; + cell->Group->evalChildrenBBox(true, false, width, height); + additionnalWidth = (sint32) width; + } + + // Get width min and max + if( !cell->IgnoreMaxWidth) + { + cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin; + } + else + { + cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin; + } + sint32 cellWidth; + if(!cell->IgnoreMinWidth) + { + cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin; + } + else + { + cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin; + } + + // New cell ? + if (cell->NewLine) + column = 0; + + // Resize the array + if (column>=_Columns.size()) + _Columns.resize(column+1); + + // Update sizes + if (cellWidth > _Columns[column].Width) + _Columns[column].Width = cellWidth; + if (cell->WidthMax > _Columns[column].WidthMax) + _Columns[column].WidthMax = cell->WidthMax; + if (cell->TableRatio > _Columns[column].TableRatio) + _Columns[column].TableRatio = cell->TableRatio; + if (cell->WidthWanted + additionnalWidth > _Columns[column].WidthWanted) + _Columns[column].WidthWanted = cell->WidthWanted + additionnalWidth; + if (cell->Height > _Columns[column].Height) + _Columns[column].Height = cell->Height; + + if (_Columns[column].WidthWanted + additionnalWidth) + _Columns[column].WidthMax = _Columns[column].WidthWanted + additionnalWidth; + if (_Columns[column].WidthWanted > _Columns[column].Width) + _Columns[column].Width = _Columns[column].WidthWanted; + + // Next column + column++; + } + + // Width of cells and table borders + sint32 borderWidth = 2*Border + ((sint32)_Columns.size()+1) * CellSpacing + ((sint32)_Columns.size()*2) * CellPadding; + + // Get the width + sint32 tableWidthMax = ForceWidthMin?ForceWidthMin:_LastParentW; // getWReal(); + sint32 tableWidthMin = std::max(ForceWidthMin, (sint32)((float)tableWidthMax*TableRatio)); + tableWidthMax = std::max ((sint32)0, tableWidthMax-borderWidth); + tableWidthMin = std::max ((sint32)0, tableWidthMin-borderWidth); + + // Get the width of the table and normalize percent of the cell (sum of TableRatio must == 1) + sint32 tableWidth = 0; + sint32 tableMaxContentWidth = 0; + float ratio = 1; + for (i=0; i<_Columns.size(); i++) + { + tableWidth += _Columns[i].Width; + tableMaxContentWidth += _Columns[i].WidthMax; + _Columns[i].TableRatio = std::min(_Columns[i].TableRatio, ratio); + ratio -= _Columns[i].TableRatio; + } + + // Eval table size with all percent cells resized + sint32 tableWidthSizeAfterPercent = tableWidth; + for (i=0; i<_Columns.size(); i++) + { + if (_Columns[i].TableRatio > 0) + { + // Size of the cell with its percent + sint32 me = (sint32)((float)_Columns[i].Width / _Columns[i].TableRatio); + + tableWidthSizeAfterPercent = std::min(tableWidthMax, std::max(tableWidthSizeAfterPercent, me)); + } + } + for (i=0; i<_Columns.size(); i++) + { + if (_Columns[i].TableRatio > 0) + { + // Size of the other cells + sint32 cellSize; + if (_Columns[i].TableRatio < 1.f) + cellSize = (sint32)((float)tableWidthSizeAfterPercent*_Columns[i].TableRatio) + 1; + else + cellSize = 10000; + + sint32 diff = std::min(tableWidthMax, (std::max(_Columns[i].Width, cellSize) - _Columns[i].Width)+tableWidth) - tableWidth; + tableWidth += diff; + _Columns[i].Width += diff; + // tableMaxContentWidth = std::max(tableMaxContentWidth, (sint32)((float)_Columns[i].WidthMax / _Columns[i].TableRatio)); + } + } + sint32 space = tableWidthMax - tableWidth; + + // Normalize percent window + for (i=0; i<_Columns.size(); i++) + { + // Width for the cell + sint32 diff = (sint32)((float)tableWidth*_Columns[i].TableRatio) - _Columns[i].Width; + diff = std::min(diff, space); + if (diff > 0) + { + _Columns[i].Width += diff; + tableWidth += diff; + space -= diff; + } + } + + // Ok, now percent window are nomralized + // Evaluate space to put in windows + sint32 finalWidth = std::max(tableWidthMin, std::min(std::max(tableWidth, tableMaxContentWidth), tableWidthMax)); + space = finalWidth - tableWidth; + if (space > 0) + { + // First give to percent cells + for (i=0; i<_Columns.size(); i++) + { + // Width for the cell + sint32 dif = (sint32)((float)space*_Columns[i].TableRatio); + _Columns[i].Width += dif; + tableWidth += dif; + } + + // Some space ? + space = finalWidth - tableWidth; + + if (space > 0) + { + // Then add in wanted Width cells + for (i=0; i<_Columns.size(); i++) + { + // Width for the cell + if (_Columns[i].Width < _Columns[i].WidthWanted) + { + sint32 dif = std::min(space, _Columns[i].WidthWanted-_Columns[i].Width); + _Columns[i].Width += dif; + space -= dif; + } + } + + if (space > 0) + { + // All cells with sizewanted are full + // Distribute remaining space in resizable cells that have a WidthMax + sint32 sumDeltaWidth = 0; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) + sumDeltaWidth += std::max ((sint32)0, _Columns[i].WidthMax - _Columns[i].Width); + } + if (sumDeltaWidth) + { + sint32 toDistribute = space; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) + { + sint32 marge = std::max ((sint32)0, _Columns[i].WidthMax - _Columns[i].Width); + sint32 cellPart = std::min(marge, std::min(space, 1 + marge * toDistribute / sumDeltaWidth)); + if (cellPart) + { + _Columns[i].Width += cellPart; + space -= cellPart; + } + } + } + } + + if (space > 0) + { + // All cells with sizemax are full + // Distribute remaining space in others resizable cells + sumDeltaWidth = 0; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) + sumDeltaWidth++; + } + if (sumDeltaWidth) + { + sint32 toDistribute = space; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) + { + sint32 cellPart = std::min(space, 1 + toDistribute / sumDeltaWidth); + _Columns[i].Width += cellPart; + space -= cellPart; + } + } + } + + if (space > 0) + { + // No cells with sizemax not sizewanted, resize size wanted + // Distribute remaining space in others resizable cells + sumDeltaWidth = 0; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted != 0)) + sumDeltaWidth++; + } + if (sumDeltaWidth) + { + sint32 toDistribute = space; + for (i=0; i<_Columns.size(); i++) + { + if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted != 0)) + { + sint32 cellPart = std::min(space, 1 + toDistribute / sumDeltaWidth); + _Columns[i].Width += cellPart; + space -= cellPart; + } + } + } + } + } + } + } + } + + // *** Now we know each column width, resize cells and get the height for each row + + column = 0; + sint32 row = 0; + sint32 currentX = Border + CellSpacing + CellPadding; + _Rows.clear (); + for (i=0; i<_Cells.size(); i++) + { + CGroupCell *cell = _Cells[i]; + // New cell ? + if (cell->NewLine) + { + column = 0; + currentX = Border + CellSpacing + CellPadding; + _Rows.push_back(CRow()); + } + + // Set the x and width + + // Check align + sint32 alignmentX = 0; + sint32 widthReduceX = 0; + if (cell->WidthMax < _Columns[column].Width) + { + switch (cell->Align) + { + case CGroupCell::Center: + alignmentX = (_Columns[column].Width - cell->WidthMax) / 2; + widthReduceX = alignmentX * 2; + break; + case CGroupCell::Right: + alignmentX = _Columns[column].Width - cell->WidthMax; + widthReduceX = alignmentX; + break; + default: + break; + } + } + + cell->setX(currentX); + cell->setW(_Columns[column].Width); + + cell->Group->setX(alignmentX+cell->LeftMargin); + cell->Group->setW(_Columns[column].Width - widthReduceX); + cell->Group->CInterfaceElement::updateCoords(); + + // Update coords to get H + cell->Group->checkCoords(); + cell->Group->updateCoords(); + + // Resize the row array + _Rows.back().Height = std::max(cell->Height, std::max(_Rows.back().Height, (sint32)cell->Group->getH())); + + // Next column + currentX += _Columns[column].Width + 2*CellPadding + CellSpacing; + column ++; + } + + // Set cell Y + row = 0; + sint32 currentY = -(Border + CellSpacing + CellPadding); + for (i=0; i<_Cells.size(); i++) + { + // New cell ? + CGroupCell *cell = _Cells[i]; + if ((i != 0) && (cell->NewLine)) + { + if (_Rows[row].Height != 0) + { + currentY -= _Rows[row].Height + 2*CellPadding + CellSpacing; + } + row++; + } + + // Check align + sint32 alignmentY = 0; + if ((sint32)cell->Group->getH() < _Rows[row].Height) + { + switch (cell->VAlign) + { + case CGroupCell::Middle: + alignmentY = (_Rows[row].Height - (sint32)cell->Group->getH()) / 2; + break; + case CGroupCell::Bottom: + alignmentY = _Rows[row].Height - (sint32)cell->Group->getH(); + break; + default: + break; + } + } + + cell->setY(currentY); + cell->setH (_Rows[row].Height); + cell->Group->setY(-alignmentY); + } + + // Resize the table + setW(finalWidth+borderWidth-_LastParentW); + if (!_Rows.empty()) + currentY -= _Rows[row].Height + CellPadding + CellSpacing + Border; + setH(-currentY); + + // All done + } + } + + + CInterfaceGroup::updateCoords(); + + + + + // Validated + _ContentValidated = true; + } + + // ---------------------------------------------------------------------------- + void CGroupTable::checkCoords () + { + if (_Parent != NULL) + { + sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); + if (_LastParentW != (sint) parentWidth) + { + if (ContinuousUpdate) + { + _LastParentW = parentWidth; + invalidateContent(); + } + else + { + + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); + if (pCB != NULL) + { + CCtrlResizer *pCR = dynamic_cast(pCB); + if (pCR != NULL) + { + // We are resizing !!!! + } + else + { + _LastParentW = parentWidth; + invalidateContent(); + } + } + else + { + _LastParentW = parentWidth; + invalidateContent(); + } + } + } + } + CInterfaceGroup::checkCoords(); + } + + // ---------------------------------------------------------------------------- + void CGroupTable::onInvalidateContent() + { + _ContentValidated = false; + invalidateCoords(); + } + + // ---------------------------------------------------------------------------- + sint32 CGroupTable::getMaxUsedW() const + { + uint i; + uint column = 0; + vector columns; + columns.clear (); + for (i=0; i<_Cells.size(); i++) + { + // Update coords to get XReal + CGroupCell *cell = _Cells[i]; + cell->checkCoords(); + cell->updateCoords(); + + // Get width min and max + sint32 cellWidthMax = cell->getMaxUsedW(); + + // New cell ? + if (cell->NewLine) + column = 0; + + // Resize the array + if (column>=columns.size()) + columns.resize(column+1, 0); + + // Update sizes + if (cellWidthMax > columns[column]) + columns[column] = cellWidthMax; + if (cell->WidthWanted) + columns[column] = cell->WidthWanted; + + // Hack to force a table with ratio to be large + sint32 cellRatio = (sint32)ceil(cell->TableRatio * 1024.f); + if (cellRatio > columns[column]) + columns[column] = cellRatio; + + // Next column + column++; + } + + // Sum + sint32 maxWidth = 0; + for (i=0; i columns; + columns.clear (); + for (i=0; i<_Cells.size(); i++) + { + // Update coords to get XReal + CGroupCell *cell = _Cells[i]; + cell->checkCoords(); + cell->updateCoords(); + + // Get width min and max + sint32 cellWidthMin = cell->getMinUsedW(); + + // New cell ? + if (cell->NewLine) + column = 0; + + // Resize the array + if (column>=columns.size()) + columns.resize(column+1, 0); + + // Update sizes + if (cellWidthMin > columns[column]) + columns[column] = cellWidthMin; + if (cell->WidthWanted) + columns[column] = cell->WidthWanted; + + // Next column + column++; + } + + // Sum + sint32 maxWidth = 0; + for (i=0; iisGroupContainer()) + { + CGroupContainer *gc = static_cast(gr); + CurrentAlpha = gc->getCurrentContainerAlpha(); + break; + } + gr = gr->getParent(); + } + + // Not found ? + if (gr == NULL) + CurrentAlpha = 255; + + if (!_Columns.empty() && !_Rows.empty() && BgColor.A) + { + sint32 border = Border + CellSpacing + CellPadding; + if (border) + { + CRGBA finalColor; + finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); + finalColor.A = CurrentAlpha; + + // Draw the top and bottom lines + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal-border+_HReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); + + // Draw the left and right lines + sint32 insideHeight = std::max((sint32)0, (sint32)_HReal - (sint32)2*border); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+border, border, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); + rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-border, _YReal+border, border, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); + + // Draw the inside borders + sint32 insideWidth = 2*CellPadding + CellSpacing; + if (insideWidth) + { + // Draw the inside verticals + uint i; + sint32 x = _XReal + _Columns[0].Width + border; + for (i=1; i<_Columns.size(); i++) + { + rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal+border, insideWidth, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); + x += _Columns[i].Width + insideWidth; + } + + // Draw the inside horizontals + sint32 y = _YReal + _HReal - border - _Rows[0].Height; + if (_Rows[0].Height != 0) + { + y -= insideWidth; + } + for (i=1; i<_Rows.size(); i++) + { + uint j; + x = _XReal + border; + if (_Rows[i].Height != 0) + { + for (j=0; j<_Columns.size(); j++) + { + rVR.drawRotFlipBitmap (_RenderLayer, x, y, _Columns[j].Width, insideWidth, 0, false, rVR.getBlankTextureId(), finalColor); + x += _Columns[j].Width + insideWidth; + } + y -= _Rows[i].Height+ insideWidth; + } + } + } + } + } + + CInterfaceGroup::draw (); + } + + // ------------------------------------------------------------------------------------------------ + bool CGroupTable::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if (!CInterfaceGroup::parse(cur, parentGroup)) return false; + // + CXMLAutoPtr ptr; + ptr = (char*) xmlGetProp( cur, (xmlChar*)"border" ); + if (ptr) + { + fromString((const char*)ptr, Border); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellpadding" ); + if (ptr) + { + fromString((const char*)ptr, CellPadding); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellspacing" ); + if (ptr) + { + fromString((const char*)ptr, CellSpacing); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"bgcolor" ); + if (ptr) + { + BgColor = convertColor((const char *) ptr); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"width" ); + if (ptr) + { + convertPixelsOrRatio(ptr, ForceWidthMin, TableRatio); + } + // + ptr = (char*) xmlGetProp( cur, (xmlChar*)"continuous_update" ); + if (ptr) + { + ContinuousUpdate = convertBool(ptr); + } + // parse cells + uint row = 0; + xmlNodePtr currRow = cur->children; + while (currRow != NULL) + { + // look for 'TR' markup + if (strcmp((char*)currRow->name,"TR") == 0) + { + // found a row, parse cells inside + xmlNodePtr currCol = currRow->children; + bool newLine = true; + uint column = 0; + while (currCol != NULL) + { + // look for 'TR' markup + if (strcmp((char*)currCol->name,"TD") == 0) + { + CGroupCell *cell = new CGroupCell(CViewBase::TCtorParam()); + if (cell->parse(currCol, this, column, row)) + { + cell->NewLine = newLine; + newLine = false; + addChild(cell); + } + else + { + delete cell; + } + ++ column; + } + currCol = currCol->next; + } + ++ row; + } + currRow = currRow->next; + } + + return true; + } + +} + diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index 9b21f01ed..d5c30cf1f 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -28,7 +28,7 @@ #include "nel/gui/group_scrolltext.h" #include "nel/gui/group_tree.h" #include "nel/gui/ctrl_button.h" -#include "group_table.h" +#include "nel/gui/group_table.h" typedef std::map TStyle; diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp deleted file mode 100644 index 4711ed4ca..000000000 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ /dev/null @@ -1,1074 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_table.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_element.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/group_container.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/i18n.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NLMISC; - - -bool CGroupCell::DebugUICell = false; - -// ---------------------------------------------------------------------------- -CGroupCell::CGroupCell(const TCtorParam ¶m) -: CInterfaceGroup(param), - BgColor (0,0,0,0) - -{ - NewLine = false; - TableRatio = 0.f; - WidthWanted = 0; - Height = 0; - Group = new CInterfaceGroup(CViewBase::TCtorParam()); - Align = Left; - VAlign = Top; - LeftMargin = 0; - NoWrap = false; - IgnoreMaxWidth = false; - IgnoreMinWidth = false; - AddChildW = false; - _UserTexture = false; - _TextureTiled = false; - _TextureScaled = false; - setEnclosedGroupDefaultParams(); - addGroup (Group); -} - -// ---------------------------------------------------------------------------- -void CGroupCell::setEnclosedGroupDefaultParams() -{ - nlassert(Group); - // Cells are moved and resized by the table - Group->setParent(this); - Group->setParentPos(this); - Group->setPosRef(Hotspot_TL); - Group->setParentPosRef(Hotspot_TL); - Group->setResizeFromChildW(false); - Group->setResizeFromChildH(true); -} - -// ---------------------------------------------------------------------------- -bool CGroupCell::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex) -{ - CXMLAutoPtr ptr; - ptr = (char*) xmlGetProp( cur, (xmlChar*)"id"); - if (!ptr) - { - // no id was given, so create one - std::string newId = NLMISC::toString("cell_%d_%d", (int) columnIndex, (int) rowIndex); - xmlSetProp(cur, (const xmlChar*) "id", (const xmlChar*) newId.c_str()); - } - // parse enclosed group - if (!Group->parse(cur, this)) return false; - Group->setId(parentGroup->getId() + Group->getId()); - setEnclosedGroupDefaultParams(); - // parse the children - bool ok = CWidgetManager::parser->parseGroupChildren(cur, Group, false); - if (!ok) return false; - // align - ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); - if (ptr) - { - if (strcmp((const char *) ptr, "left") == 0) - { - Align = Left; - } - else if (strcmp((const char *) ptr, "right") == 0) - { - Align = Right; - } - else if (strcmp((const char *) ptr, "center") == 0) - { - Align = Center; - } - else - { - nlwarning(" Unknwown or unsupported align mode : %s", (const char *) ptr); - } - } - // v-align - ptr = (char*) xmlGetProp( cur, (xmlChar*)"valign" ); - if (ptr) - { - if (strcmp((const char *) ptr, "top") == 0) - { - VAlign = Top; - } - else if (strcmp((const char *) ptr, "middle") == 0) - { - VAlign = Middle; - } - else if (strcmp((const char *) ptr, "bottom") == 0) - { - VAlign = Bottom; - } - else - { - nlwarning(" Unknwown or unsupported valign mode : %s", (const char *) ptr); - } - } - // left margin - ptr = (char*) xmlGetProp( cur, (xmlChar*)"left_margin" ); - if (ptr) - { - fromString((const char*)ptr, LeftMargin); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"nowrap" ); - if (ptr) - { - NoWrap = convertBool(ptr); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"bgcolor" ); - if (ptr) - { - BgColor = convertColor(ptr); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"width" ); - if (ptr) - { - convertPixelsOrRatio((const char *) ptr, WidthWanted, TableRatio); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"height" ); - if (ptr) - { - fromString((const char*)ptr, Height); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"ignore_max_width" ); - if (ptr) - { - IgnoreMaxWidth = convertBool(ptr); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"ignore_min_width" ); - if (ptr) - { - IgnoreMinWidth = convertBool(ptr); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"add_child_w" ); - if (ptr) - { - AddChildW = convertBool(ptr); - } - - return true; -} - - -// ---------------------------------------------------------------------------- -void CGroupCell::draw () -{ - if ( CGroupCell::DebugUICell ) - { - // Draw cell - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal-1, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-1, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); - } - - // Draw the background - if (_UserTexture || BgColor.A != 0) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - if (_UserTexture) - { - CRGBA col; - if (BgColor.A == 0 ) - col = CRGBA(255,255,255,255); - else - col = BgColor; - - - if (_TextureScaled && !_TextureTiled) - { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - 0, false, - _TextureId, - col ); - } - else - { - if (!_TextureTiled) - { - rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, - 0, false, - _TextureId, - col); - } - else - { - rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - 0, false, - _TextureId, - 0, - col); - } - } - - } - else - { - CRGBA finalColor; - finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); - - // Get the parent table - if (getParent ()) - { - CGroupTable *table = static_cast (getParent ()); - finalColor.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) finalColor.A) >> 8); - } - - //nlinfo("Blank Texture"); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor); - } - } - - CInterfaceGroup::draw (); -} - -// ---------------------------------------------------------------------------- -sint32 CGroupCell::getMaxUsedW() const -{ - return Group->getMaxUsedW(); -} - -// ------------------------------------------------------------------------------------------------ -sint32 CGroupCell::getMinUsedW() const -{ - return Group->getMinUsedW(); -} - - -// ---------------------------------------------------------------------------- -void CGroupCell::setTexture(const std::string & TxName) -{ - if (TxName.empty() || TxName == "none") - { - _UserTexture = false; - nlinfo("Set no texture"); - } - else - { - nlinfo("Set texture to cell : %s", TxName.c_str()); - _UserTexture = true; - _TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false); - } -} - -// ---------------------------------------------------------------------------- -void CGroupCell::setTextureTile(bool tiled) -{ - if (tiled) - nlinfo("Set texture is Tiled"); - _TextureTiled = tiled; -} - -// ---------------------------------------------------------------------------- -void CGroupCell::setTextureScale(bool scaled) -{ - if (scaled) - nlinfo("Set texture is Scaled : %s"); - _TextureScaled = scaled; -} - - -// ---------------------------------------------------------------------------- -NLMISC_REGISTER_OBJECT(CViewBase, CGroupTable, std::string, "table"); - -CGroupTable::CGroupTable(const TCtorParam ¶m) -: CInterfaceGroup(param), - BgColor(0,0,0,255) -{ - _ContentValidated = false; - TableRatio = 0.f; - ForceWidthMin = 0; - Border=0; - CellPadding=0; - CellSpacing=0; - ContinuousUpdate = false; -} - -// ---------------------------------------------------------------------------- -void CGroupTable::addChild (CGroupCell* child) -{ - // Cell empty ? - if (_Cells.empty()) - // New line - child->NewLine = true; - - // Cells are moved and resized by the table - child->setParent(this); - child->setParentPos(this); - child->setPosRef(Hotspot_TL); - child->setParentPosRef(Hotspot_TL); - child->setResizeFromChildW(false); - - // Child resize H for cells - child->setResizeFromChildH(false); - -/* // New line ? - if (child->NewLine) - { - // First element - if (_Cells.empty()) - { - child->setParentPos(NULL); - child->setPosRef(Hotspot_TL); - child->setParentPosRef(Hotspot_TL); - } - // New line - else - { - // Look for previous new line - uint i; - for (i=_Cells.size()-1; i>0; i--) - if (_Cells[i]->NewLine) - break; - - child->setParentPos(_Cells[i]); - child->setPosRef(Hotspot_TL); - child->setParentPosRef(Hotspot_BL); - } - } - else - { - nlassert(!_Cells.empty()); - child->setParentPos(_Cells.back()); - child->setPosRef(Hotspot_TL); - child->setParentPosRef(Hotspot_TR); - }*/ - - // Add the child - addGroup(child); - _Cells.push_back(child); - invalidateContent(); -} - -// ---------------------------------------------------------------------------- -CGroupTable::~CGroupTable() -{ -/* uint i; - for (i=0; i<_Cells.size(); i++) - delete _Cells[i]; - _Cells.clear ();*/ -} - - - -// ---------------------------------------------------------------------------- -void CGroupTable::updateCoords() -{ - if (_Parent) - { - if (ContinuousUpdate) - { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - if (_LastParentW != (sint) parentWidth) - { - _LastParentW = parentWidth; - _ContentValidated = false; - } - } - if (!_ContentValidated) - { - // Update W and XReal - CInterfaceElement::updateCoords(); - - // *** For each children, update coords, gets min and max values - // *** Get the column sizes, we need to know min for the table - - uint i; - uint column = 0; - _Columns.clear (); - for (i=0; i<_Cells.size(); i++) - { - // Update coords to get XReal - CGroupCell *cell = _Cells[i]; - cell->checkCoords(); - cell->updateCoords(); - - sint32 additionnalWidth = 0; - if (cell->AddChildW) - { - sint width, height; - cell->Group->evalChildrenBBox(true, false, width, height); - additionnalWidth = (sint32) width; - } - - // Get width min and max - if( !cell->IgnoreMaxWidth) - { - cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin; - } - else - { - cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin; - } - sint32 cellWidth; - if(!cell->IgnoreMinWidth) - { - cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin; - } - else - { - cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin; - } - - // New cell ? - if (cell->NewLine) - column = 0; - - // Resize the array - if (column>=_Columns.size()) - _Columns.resize(column+1); - - // Update sizes - if (cellWidth > _Columns[column].Width) - _Columns[column].Width = cellWidth; - if (cell->WidthMax > _Columns[column].WidthMax) - _Columns[column].WidthMax = cell->WidthMax; - if (cell->TableRatio > _Columns[column].TableRatio) - _Columns[column].TableRatio = cell->TableRatio; - if (cell->WidthWanted + additionnalWidth > _Columns[column].WidthWanted) - _Columns[column].WidthWanted = cell->WidthWanted + additionnalWidth; - if (cell->Height > _Columns[column].Height) - _Columns[column].Height = cell->Height; - - if (_Columns[column].WidthWanted + additionnalWidth) - _Columns[column].WidthMax = _Columns[column].WidthWanted + additionnalWidth; - if (_Columns[column].WidthWanted > _Columns[column].Width) - _Columns[column].Width = _Columns[column].WidthWanted; - - // Next column - column++; - } - - // Width of cells and table borders - sint32 borderWidth = 2*Border + ((sint32)_Columns.size()+1) * CellSpacing + ((sint32)_Columns.size()*2) * CellPadding; - - // Get the width - sint32 tableWidthMax = ForceWidthMin?ForceWidthMin:_LastParentW; // getWReal(); - sint32 tableWidthMin = std::max(ForceWidthMin, (sint32)((float)tableWidthMax*TableRatio)); - tableWidthMax = std::max ((sint32)0, tableWidthMax-borderWidth); - tableWidthMin = std::max ((sint32)0, tableWidthMin-borderWidth); - - // Get the width of the table and normalize percent of the cell (sum of TableRatio must == 1) - sint32 tableWidth = 0; - sint32 tableMaxContentWidth = 0; - float ratio = 1; - for (i=0; i<_Columns.size(); i++) - { - tableWidth += _Columns[i].Width; - tableMaxContentWidth += _Columns[i].WidthMax; - _Columns[i].TableRatio = std::min(_Columns[i].TableRatio, ratio); - ratio -= _Columns[i].TableRatio; - } - - // Eval table size with all percent cells resized - sint32 tableWidthSizeAfterPercent = tableWidth; - for (i=0; i<_Columns.size(); i++) - { - if (_Columns[i].TableRatio > 0) - { - // Size of the cell with its percent - sint32 me = (sint32)((float)_Columns[i].Width / _Columns[i].TableRatio); - - tableWidthSizeAfterPercent = std::min(tableWidthMax, std::max(tableWidthSizeAfterPercent, me)); - } - } - for (i=0; i<_Columns.size(); i++) - { - if (_Columns[i].TableRatio > 0) - { - // Size of the other cells - sint32 cellSize; - if (_Columns[i].TableRatio < 1.f) - cellSize = (sint32)((float)tableWidthSizeAfterPercent*_Columns[i].TableRatio) + 1; - else - cellSize = 10000; - - sint32 diff = std::min(tableWidthMax, (std::max(_Columns[i].Width, cellSize) - _Columns[i].Width)+tableWidth) - tableWidth; - tableWidth += diff; - _Columns[i].Width += diff; - // tableMaxContentWidth = std::max(tableMaxContentWidth, (sint32)((float)_Columns[i].WidthMax / _Columns[i].TableRatio)); - } - } - sint32 space = tableWidthMax - tableWidth; - - // Normalize percent window - for (i=0; i<_Columns.size(); i++) - { - // Width for the cell - sint32 diff = (sint32)((float)tableWidth*_Columns[i].TableRatio) - _Columns[i].Width; - diff = std::min(diff, space); - if (diff > 0) - { - _Columns[i].Width += diff; - tableWidth += diff; - space -= diff; - } - } - - // Ok, now percent window are nomralized - // Evaluate space to put in windows - sint32 finalWidth = std::max(tableWidthMin, std::min(std::max(tableWidth, tableMaxContentWidth), tableWidthMax)); - space = finalWidth - tableWidth; - if (space > 0) - { - // First give to percent cells - for (i=0; i<_Columns.size(); i++) - { - // Width for the cell - sint32 dif = (sint32)((float)space*_Columns[i].TableRatio); - _Columns[i].Width += dif; - tableWidth += dif; - } - - // Some space ? - space = finalWidth - tableWidth; - - if (space > 0) - { - // Then add in wanted Width cells - for (i=0; i<_Columns.size(); i++) - { - // Width for the cell - if (_Columns[i].Width < _Columns[i].WidthWanted) - { - sint32 dif = std::min(space, _Columns[i].WidthWanted-_Columns[i].Width); - _Columns[i].Width += dif; - space -= dif; - } - } - - if (space > 0) - { - // All cells with sizewanted are full - // Distribute remaining space in resizable cells that have a WidthMax - sint32 sumDeltaWidth = 0; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) - sumDeltaWidth += std::max ((sint32)0, _Columns[i].WidthMax - _Columns[i].Width); - } - if (sumDeltaWidth) - { - sint32 toDistribute = space; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) - { - sint32 marge = std::max ((sint32)0, _Columns[i].WidthMax - _Columns[i].Width); - sint32 cellPart = std::min(marge, std::min(space, 1 + marge * toDistribute / sumDeltaWidth)); - if (cellPart) - { - _Columns[i].Width += cellPart; - space -= cellPart; - } - } - } - } - - if (space > 0) - { - // All cells with sizemax are full - // Distribute remaining space in others resizable cells - sumDeltaWidth = 0; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) - sumDeltaWidth++; - } - if (sumDeltaWidth) - { - sint32 toDistribute = space; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted == 0)) - { - sint32 cellPart = std::min(space, 1 + toDistribute / sumDeltaWidth); - _Columns[i].Width += cellPart; - space -= cellPart; - } - } - } - - if (space > 0) - { - // No cells with sizemax not sizewanted, resize size wanted - // Distribute remaining space in others resizable cells - sumDeltaWidth = 0; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted != 0)) - sumDeltaWidth++; - } - if (sumDeltaWidth) - { - sint32 toDistribute = space; - for (i=0; i<_Columns.size(); i++) - { - if ((_Columns[i].TableRatio == 0) && (_Columns[i].WidthWanted != 0)) - { - sint32 cellPart = std::min(space, 1 + toDistribute / sumDeltaWidth); - _Columns[i].Width += cellPart; - space -= cellPart; - } - } - } - } - } - } - } - } - - // *** Now we know each column width, resize cells and get the height for each row - - column = 0; - sint32 row = 0; - sint32 currentX = Border + CellSpacing + CellPadding; - _Rows.clear (); - for (i=0; i<_Cells.size(); i++) - { - CGroupCell *cell = _Cells[i]; - // New cell ? - if (cell->NewLine) - { - column = 0; - currentX = Border + CellSpacing + CellPadding; - _Rows.push_back(CRow()); - } - - // Set the x and width - - // Check align - sint32 alignmentX = 0; - sint32 widthReduceX = 0; - if (cell->WidthMax < _Columns[column].Width) - { - switch (cell->Align) - { - case CGroupCell::Center: - alignmentX = (_Columns[column].Width - cell->WidthMax) / 2; - widthReduceX = alignmentX * 2; - break; - case CGroupCell::Right: - alignmentX = _Columns[column].Width - cell->WidthMax; - widthReduceX = alignmentX; - break; - default: - break; - } - } - - cell->setX(currentX); - cell->setW(_Columns[column].Width); - - cell->Group->setX(alignmentX+cell->LeftMargin); - cell->Group->setW(_Columns[column].Width - widthReduceX); - cell->Group->CInterfaceElement::updateCoords(); - - // Update coords to get H - cell->Group->checkCoords(); - cell->Group->updateCoords(); - - // Resize the row array - _Rows.back().Height = std::max(cell->Height, std::max(_Rows.back().Height, (sint32)cell->Group->getH())); - - // Next column - currentX += _Columns[column].Width + 2*CellPadding + CellSpacing; - column ++; - } - - // Set cell Y - row = 0; - sint32 currentY = -(Border + CellSpacing + CellPadding); - for (i=0; i<_Cells.size(); i++) - { - // New cell ? - CGroupCell *cell = _Cells[i]; - if ((i != 0) && (cell->NewLine)) - { - if (_Rows[row].Height != 0) - { - currentY -= _Rows[row].Height + 2*CellPadding + CellSpacing; - } - row++; - } - - // Check align - sint32 alignmentY = 0; - if ((sint32)cell->Group->getH() < _Rows[row].Height) - { - switch (cell->VAlign) - { - case CGroupCell::Middle: - alignmentY = (_Rows[row].Height - (sint32)cell->Group->getH()) / 2; - break; - case CGroupCell::Bottom: - alignmentY = _Rows[row].Height - (sint32)cell->Group->getH(); - break; - default: - break; - } - } - - cell->setY(currentY); - cell->setH (_Rows[row].Height); - cell->Group->setY(-alignmentY); - } - - // Resize the table - setW(finalWidth+borderWidth-_LastParentW); - if (!_Rows.empty()) - currentY -= _Rows[row].Height + CellPadding + CellSpacing + Border; - setH(-currentY); - - // All done - } - } - - - CInterfaceGroup::updateCoords(); - - - - - // Validated - _ContentValidated = true; -} - -// ---------------------------------------------------------------------------- -void CGroupTable::checkCoords () -{ - if (_Parent != NULL) - { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - if (_LastParentW != (sint) parentWidth) - { - if (ContinuousUpdate) - { - _LastParentW = parentWidth; - invalidateContent(); - } - else - { - - CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); - if (pCB != NULL) - { - CCtrlResizer *pCR = dynamic_cast(pCB); - if (pCR != NULL) - { - // We are resizing !!!! - } - else - { - _LastParentW = parentWidth; - invalidateContent(); - } - } - else - { - _LastParentW = parentWidth; - invalidateContent(); - } - } - } - } - CInterfaceGroup::checkCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupTable::onInvalidateContent() -{ - _ContentValidated = false; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -sint32 CGroupTable::getMaxUsedW() const -{ - uint i; - uint column = 0; - vector columns; - columns.clear (); - for (i=0; i<_Cells.size(); i++) - { - // Update coords to get XReal - CGroupCell *cell = _Cells[i]; - cell->checkCoords(); - cell->updateCoords(); - - // Get width min and max - sint32 cellWidthMax = cell->getMaxUsedW(); - - // New cell ? - if (cell->NewLine) - column = 0; - - // Resize the array - if (column>=columns.size()) - columns.resize(column+1, 0); - - // Update sizes - if (cellWidthMax > columns[column]) - columns[column] = cellWidthMax; - if (cell->WidthWanted) - columns[column] = cell->WidthWanted; - - // Hack to force a table with ratio to be large - sint32 cellRatio = (sint32)ceil(cell->TableRatio * 1024.f); - if (cellRatio > columns[column]) - columns[column] = cellRatio; - - // Next column - column++; - } - - // Sum - sint32 maxWidth = 0; - for (i=0; i columns; - columns.clear (); - for (i=0; i<_Cells.size(); i++) - { - // Update coords to get XReal - CGroupCell *cell = _Cells[i]; - cell->checkCoords(); - cell->updateCoords(); - - // Get width min and max - sint32 cellWidthMin = cell->getMinUsedW(); - - // New cell ? - if (cell->NewLine) - column = 0; - - // Resize the array - if (column>=columns.size()) - columns.resize(column+1, 0); - - // Update sizes - if (cellWidthMin > columns[column]) - columns[column] = cellWidthMin; - if (cell->WidthWanted) - columns[column] = cell->WidthWanted; - - // Next column - column++; - } - - // Sum - sint32 maxWidth = 0; - for (i=0; iisGroupContainer()) - { - CGroupContainer *gc = static_cast(gr); - CurrentAlpha = gc->getCurrentContainerAlpha(); - break; - } - gr = gr->getParent(); - } - - // Not found ? - if (gr == NULL) - CurrentAlpha = 255; - - if (!_Columns.empty() && !_Rows.empty() && BgColor.A) - { - sint32 border = Border + CellSpacing + CellPadding; - if (border) - { - CRGBA finalColor; - finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); - finalColor.A = CurrentAlpha; - - // Draw the top and bottom lines - CViewRenderer &rVR = *CViewRenderer::getInstance(); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal-border+_HReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor); - - // Draw the left and right lines - sint32 insideHeight = std::max((sint32)0, (sint32)_HReal - (sint32)2*border); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+border, border, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); - rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-border, _YReal+border, border, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); - - // Draw the inside borders - sint32 insideWidth = 2*CellPadding + CellSpacing; - if (insideWidth) - { - // Draw the inside verticals - uint i; - sint32 x = _XReal + _Columns[0].Width + border; - for (i=1; i<_Columns.size(); i++) - { - rVR.drawRotFlipBitmap (_RenderLayer, x, _YReal+border, insideWidth, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor); - x += _Columns[i].Width + insideWidth; - } - - // Draw the inside horizontals - sint32 y = _YReal + _HReal - border - _Rows[0].Height; - if (_Rows[0].Height != 0) - { - y -= insideWidth; - } - for (i=1; i<_Rows.size(); i++) - { - uint j; - x = _XReal + border; - if (_Rows[i].Height != 0) - { - for (j=0; j<_Columns.size(); j++) - { - rVR.drawRotFlipBitmap (_RenderLayer, x, y, _Columns[j].Width, insideWidth, 0, false, rVR.getBlankTextureId(), finalColor); - x += _Columns[j].Width + insideWidth; - } - y -= _Rows[i].Height+ insideWidth; - } - } - } - } - } - - CInterfaceGroup::draw (); -} - -// ------------------------------------------------------------------------------------------------ -bool CGroupTable::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur, parentGroup)) return false; - // - CXMLAutoPtr ptr; - ptr = (char*) xmlGetProp( cur, (xmlChar*)"border" ); - if (ptr) - { - fromString((const char*)ptr, Border); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellpadding" ); - if (ptr) - { - fromString((const char*)ptr, CellPadding); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellspacing" ); - if (ptr) - { - fromString((const char*)ptr, CellSpacing); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"bgcolor" ); - if (ptr) - { - BgColor = convertColor((const char *) ptr); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"width" ); - if (ptr) - { - convertPixelsOrRatio(ptr, ForceWidthMin, TableRatio); - } - // - ptr = (char*) xmlGetProp( cur, (xmlChar*)"continuous_update" ); - if (ptr) - { - ContinuousUpdate = convertBool(ptr); - } - // parse cells - uint row = 0; - xmlNodePtr currRow = cur->children; - while (currRow != NULL) - { - // look for 'TR' markup - if (strcmp((char*)currRow->name,"TR") == 0) - { - // found a row, parse cells inside - xmlNodePtr currCol = currRow->children; - bool newLine = true; - uint column = 0; - while (currCol != NULL) - { - // look for 'TR' markup - if (strcmp((char*)currCol->name,"TD") == 0) - { - CGroupCell *cell = new CGroupCell(CViewBase::TCtorParam()); - if (cell->parse(currCol, this, column, row)) - { - cell->NewLine = newLine; - newLine = false; - addChild(cell); - } - else - { - delete cell; - } - ++ column; - } - currCol = currCol->next; - } - ++ row; - } - currRow = currRow->next; - } - - return true; -} - diff --git a/code/ryzom/client/src/interface_v3/group_table.h b/code/ryzom/client/src/interface_v3/group_table.h deleted file mode 100644 index 77c3e507c..000000000 --- a/code/ryzom/client/src/interface_v3/group_table.h +++ /dev/null @@ -1,212 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_GROUP_TABLE_H -#define NL_GROUP_TABLE_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/group_frame.h" -#include "nel/gui/view_text.h" -#include "nel/gui/ctrl_button.h" - -/** - * This group is used to simulate HTML cells. - * They have specific parameters to be aligned like HTML cells. - * (Percent of the table size - */ -class CGroupCell: public CInterfaceGroup -{ - friend class CGroupTable; -public: - CGroupCell(const TCtorParam ¶m); - - enum TAlign - { - Left, - Center, - Right - }; - - enum TVAlign - { - Top, - Middle, - Bottom - }; - - /// \from CInterfaceElement - virtual void draw(); - virtual sint32 getMaxUsedW() const; - virtual sint32 getMinUsedW() const; - - // to be called by CGroupTable - bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); - - // If the cell is a new line. This is the first - bool NewLine; - bool IgnoreMaxWidth; - bool IgnoreMinWidth; - bool AddChildW; - - // The table width cell ratio. This is the
after a
parameter - float TableRatio; - - // The Width you want in pixel. This is the parameter - sint32 WidthWanted; - - - // The min height of the cell - sint32 Height; - - // Memorize max width - sint32 WidthMax; - - // The cell color - NLMISC::CRGBA BgColor; - - // Texture - CViewRenderer::CTextureId _TextureId; /// Accelerator - bool _UserTexture; - bool _TextureTiled; - bool _TextureScaled; - - // Alignment - TAlign Align; - TVAlign VAlign; - sint32 LeftMargin; - - // The cell group - CInterfaceGroup *Group; - - // The cell is nowrap - bool NoWrap; - - void setTexture(const std::string & TxName); - void setTextureTile(bool tiled); - void setTextureScale(bool scaled); - - static void setDebugUICell( bool d ){ DebugUICell = d; } - static bool getDebugUICell(){ return DebugUICell; } - -private: - void setEnclosedGroupDefaultParams(); - static bool DebugUICell; -}; - -/** - * This group is used to simulate HTML table. Support "percent of the parent width" sizeRef mode. - */ -class CGroupTable : public CInterfaceGroup -{ -public: - - ///constructor - CGroupTable(const TCtorParam ¶m); - - // dtor - ~CGroupTable(); - - // Add a cell in the table - void addChild (CGroupCell* child); - - // The ratio you want [0 ~1]. This is the parameter - float TableRatio; - - // The Width you want in pixel. This is the
parameter - sint32 ForceWidthMin; - - // Table borders - sint32 Border; - sint32 CellPadding; - sint32 CellSpacing; - - // The table color - NLMISC::CRGBA BgColor; - uint8 CurrentAlpha; - - bool ContinuousUpdate; - -protected: - - /// \from CInterfaceElement - void onInvalidateContent(); - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - void draw (); - - /** - * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here - */ - virtual void updateCoords(); - - virtual void checkCoords(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - - // Content validated - bool _ContentValidated; - - // Last parent width - sint32 _LastParentW; - - // Children - std::vector _Cells; - - // Table column - class CColumn - { - public: - CColumn() - { - Width = 0; - WidthMax = 0; - WidthWanted = 0; - TableRatio = 0; - Height = 0; - } - sint32 Width; - sint32 Height; - sint32 WidthWanted; - sint32 WidthMax; - float TableRatio; - }; - - // Table row - class CRow - { - public: - CRow() - { - Height = 0; - } - sint32 Height; - }; - - // Column table - std::vector _Columns; - - // Column table - std::vector _Rows; -}; - - -#endif // NL_GROUP_TABLE_H - -/* End of group_table.h */ - - diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 6dacf841a..440225f03 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -83,7 +83,7 @@ #include "group_in_scene_bubble.h" #include "group_phrase_skill_filter.h" #include "nel/gui/group_tab.h" -#include "group_table.h" +#include "nel/gui/group_table.h" // DBGroup #include "nel/gui/dbgroup_select_number.h" #include "dbgroup_list_sheet.h" diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 1300de86d..bc78aa1ce 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -146,7 +146,7 @@ #include "string_manager_client.h" #include "nel/gui/lua_manager.h" -#include "interface_v3/group_table.h" +#include "nel/gui/group_table.h" /////////// @@ -4427,7 +4427,7 @@ NLMISC_COMMAND(debugUIGroup, "Debug the ui : show/hide quads of bboxs and hotspo // show hide the debuging of cells NLMISC_COMMAND(debugUICell, "Debug the ui : show/hide quads of bboxs for cells", "") { - CGroupCell::setDebugUICell( !CGroupCell::getDebugUICell() ) + CGroupCell::setDebugUICell( !CGroupCell::getDebugUICell() ); return true; } From 31c887ede8279c7f7f56646aed4e64c1fde7f18a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 30 Jun 2012 05:58:02 +0200 Subject: [PATCH 118/339] CHANGED: #1471 Decoupled CGroupHTML, CGroupParagraph, CViewLink from Ryzom game related code. --- code/nel/include/nel/gui/lua_manager.h | 2 + code/nel/include/nel/gui/widget_manager.h | 2 + code/nel/src/gui/lua_manager.cpp | 16 + .../client/src/interface_v3/group_html.cpp | 125 ++--- .../client/src/interface_v3/group_html.h | 18 +- .../src/interface_v3/group_paragraph.cpp | 14 +- .../client/src/interface_v3/group_paragraph.h | 3 +- .../src/interface_v3/group_quick_help.cpp | 32 +- .../src/interface_v3/interface_manager.cpp | 43 +- .../src/interface_v3/interface_manager.h | 4 - .../src/interface_v3/interface_parser.cpp | 37 ++ .../src/interface_v3/interface_parser.h | 6 + .../src/interface_v3/libwww_nel_stream.cpp | 464 +++++++++--------- .../src/interface_v3/libwww_nel_stream.h | 4 +- .../client/src/interface_v3/view_link.cpp | 6 +- .../ryzom/client/src/interface_v3/view_link.h | 5 +- code/ryzom/client/src/libwww.cpp | 29 +- 17 files changed, 407 insertions(+), 403 deletions(-) diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h index def6ab472..1e6868f57 100644 --- a/code/nel/include/nel/gui/lua_manager.h +++ b/code/nel/include/nel/gui/lua_manager.h @@ -43,6 +43,8 @@ namespace NLGUI NLGUI::CLuaState* getLuaState() const{ return luaState; } + bool executeLuaScript( const std::string &luaScript, bool smallScript = false ); + private: CLuaManager(); diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index df5fd5540..19df9375b 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -52,6 +52,8 @@ namespace NLGUI virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0; + virtual uint getProcedureNumActions( const std::string &procName ) const = 0; + virtual bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const = 0; }; /// Manages the GUI widgets diff --git a/code/nel/src/gui/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp index 5e9ef7761..4307db15d 100644 --- a/code/nel/src/gui/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -34,6 +34,22 @@ namespace NLGUI luaState = NULL; } + bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript ) + { + try + { + if( smallScript ) + luaState->executeSmallScript( luaScript ); + else + luaState->executeScript( luaScript ); + } + catch( const ELuaError &e ) + { + nlwarning( e.luaWhat().c_str() ); + return false; + } + return true; + } } diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index bb90cef39..b1bfdfe80 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -14,8 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdpch.h" - //#include // LibWWW @@ -27,25 +25,21 @@ extern "C" } #include "../libwww.h" - #include "group_html.h" #include "nel/gui/group_list.h" #include "nel/gui/group_container.h" #include "view_link.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" -#include "dbctrl_sheet.h" #include "nel/gui/ctrl_text_button.h" #include "nel/gui/action_handler.h" #include "group_paragraph.h" #include "nel/gui/group_editbox.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/lua_manager.h" #include "nel/gui/view_bitmap.h" -#include "../actions.h" #include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/lua_ihm.h" - -#include "../time_client.h" #include "nel/misc/i18n.h" #include "nel/misc/md5.h" #include "nel/3d/texture_file.h" @@ -62,14 +56,15 @@ using namespace NLMISC; //#define LOG_DL 1 CGroupHTML *CGroupHTML::_ConnectingLock = NULL; -extern CActionsContext ActionsContext; +CGroupHTML::SWebOptions CGroupHTML::options; + // Check if domain is on TrustedDomain bool CGroupHTML::isTrustedDomain(const string &domain) { vector::iterator it; - it = find (ClientCfg.WebIgTrustedDomains.begin(), ClientCfg.WebIgTrustedDomains.end(), domain); - return it != ClientCfg.WebIgTrustedDomains.end(); + it = find ( options.trustedDomains.begin(), options.trustedDomains.end(), domain); + return it != options.trustedDomains.end(); } void CGroupHTML::setImage(CViewBase * view, const string &file) @@ -361,8 +356,7 @@ void CGroupHTML::checkDownloads() CFile::moveFile(file.c_str(), (file+".tmp").c_str()); if (lookupLocalFile (finalUrl, file.c_str(), false)) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->executeLuaScript(it->luaScript, true); + CLuaManager::getInstance().executeLuaScript( it->luaScript, true ); } } } @@ -899,33 +893,8 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) _LinkClass.push_back(value[MY_HTML_A_CLASS]); - // Quick help - if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT]) - { - // Get the action category - string category; - if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY]) - category = value[MY_HTML_A_Z_ACTION_CATEGORY]; - - // Get the action params - string params; - if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS]) - params = value[MY_HTML_A_Z_ACTION_PARAMS]; - - // Get the action descriptor - CActionsManager *actionManager = ActionsContext.getActionsManager (category); - if (actionManager) - { - const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap (); - CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str())); - if (ite != actionCombo.end()) - { - addString (ite->second.toUCString()); - } - } - } - break; + case HTML_DIV: { if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) @@ -972,8 +941,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c else parentId = _Paragraph->getId(); - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *inst = im->createGroupInstance(templateName, parentId+":"+id, tmplParams); + CInterfaceGroup *inst = CWidgetManager::parser->createGroupInstance(templateName, parentId+":"+id, tmplParams); if (inst) { inst->setId(parentId+":"+id); @@ -1272,7 +1240,6 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c paragraphChange (); } - CInterfaceManager *im = CInterfaceManager::getInstance(); typedef pair TTmplParam; vector tmplParams; tmplParams.push_back(TTmplParam("id", name)); @@ -1282,7 +1249,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c tmplParams.push_back(TTmplParam("active", "true")); if (!minWidth.empty()) tmplParams.push_back(TTmplParam("wmin", minWidth)); - CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); + CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); if (buttonGroup) { @@ -1776,8 +1743,7 @@ void CGroupHTML::endElement (uint element_number) { if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); + CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); } _ObjectScript = ""; } @@ -1811,9 +1777,8 @@ void CGroupHTML::endUnparsedElement(const char *buffer, int length) { _ParsingLua = false; // execute the embeded lua script - CInterfaceManager *pIM = CInterfaceManager::getInstance(); _LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript; - pIM->executeLuaScript(_LuaScript, true); + CLuaManager::getInstance().executeLuaScript(_LuaScript, true); } } } @@ -1924,8 +1889,8 @@ CGroupHTML::~CGroupHTML() // stop browsing stopBrowse (); // NB : we don't call updateRefreshButton here, because : // 1) it is useless, - // 2) it crashed before when it called getElementFromId (that didn't work when a master group was being removed...). Btw it should work now - // this is why the call to 'updateRefreshButton' has been removed from stopBrowse + // 2) it crashed before when it called getElementFromId (that didn't work when a master group was being removed...). Btw it should work now + // this is why the call to 'updateRefreshButton' has been removed from stopBrowse clearContext(); delete _LibWWW; @@ -2219,8 +2184,6 @@ void CGroupHTML::doBrowse(const char *url) // if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate) if(!_BrowseTree.empty()) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupTree *groupTree=dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseTree)); if(groupTree) { @@ -2315,7 +2278,7 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara if (lastChar == 0) lastChar = getLastChar(); keep = ((lastChar != (ucchar)' ') && - (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); + (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); if(!getPRE()) input = ' '; } @@ -2327,8 +2290,8 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara if (lastChar == 0) lastChar = getLastChar(); keep = ((lastChar != (ucchar)' ') && - (lastChar != (ucchar)'\n') && - (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); + (lastChar != (ucchar)'\n') && + (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); } break; case 0xd: @@ -2444,14 +2407,13 @@ void CGroupHTML::addString(const ucstring &str) // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" string param = "name=" + this->_Id + "|url=" + getLink(); - CInterfaceManager *im = CInterfaceManager::getInstance(); typedef pair TTmplParam; vector tmplParams; tmplParams.push_back(TTmplParam("id", "")); tmplParams.push_back(TTmplParam("onclick", "browse")); tmplParams.push_back(TTmplParam("onclick_param", param)); tmplParams.push_back(TTmplParam("active", "true")); - CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); + CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); if (buttonGroup) { @@ -2632,8 +2594,6 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const // No more text in this text view _CurrentViewLink = NULL; - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im) { // Not added ? std::vector > templateParams; @@ -2645,7 +2605,7 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const templateParams.push_back (std::pair ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair ("enter_recover_focus", "false")); templateParams.push_back (std::pair ("max_num_chars", "1024")); - CInterfaceGroup *textArea = im->createGroupInstance (templateName.c_str(), + CInterfaceGroup *textArea = CWidgetManager::parser->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); // Group created ? @@ -2679,13 +2639,11 @@ CDBGroupComboBox *CGroupHTML::addComboBox(const std::string &templateName, const } - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im) { // Not added ? std::vector > templateParams; templateParams.push_back (std::pair ("id", name)); - CInterfaceGroup *group = im->createGroupInstance (templateName.c_str(), + CInterfaceGroup *group = CWidgetManager::parser->createGroupInstance (templateName.c_str(), getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); // Group created ? @@ -2736,7 +2694,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ if(!CPath::exists(normal)) { // search in the compressed texture - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(normal); if(id == -1) @@ -2756,7 +2713,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ if(!CPath::exists(pushed)) { // search in the compressed texture - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(pushed); if(id == -1) @@ -3030,7 +2986,6 @@ bool CGroupHTML::lookupLocalFile (string &result, const char *url, bool isUrl) else { // Is it a texture in the big texture ? - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0) { return true; @@ -3115,19 +3070,19 @@ static int timer_called = 0; static int timer_callback(HTTimer * const timer , - void * const user_data , - HTEventType const event ) + void * const user_data , + HTEventType const event ) { /*---------------------------------------------------------------------------- A handy timer callback which cancels the running event loop. -----------------------------------------------------------------------------*/ - nlassert(event == HTEvent_TIMEOUT); - timer_called = 1; - HTEventList_stopLoop(); + nlassert(event == HTEvent_TIMEOUT); + timer_called = 1; + HTEventList_stopLoop(); - /* XXX - The meaning of this return value is undocumented, but close - ** inspection of libwww's source suggests that we want to return HT_OK. */ - return HT_OK; + /* XXX - The meaning of this return value is undocumented, but close + ** inspection of libwww's source suggests that we want to return HT_OK. */ + return HT_OK; } static void handleLibwwwEvents() @@ -3135,9 +3090,9 @@ static void handleLibwwwEvents() HTTimer *timer; timer_called = 0; timer = HTTimer_new(NULL, &timer_callback, NULL, - 1, YES, NO); + 1, YES, NO); if (!timer_called) - HTEventList_newLoop(); + HTEventList_newLoop(); HTTimer_delete(timer); } @@ -3147,12 +3102,14 @@ void CGroupHTML::handle () { H_AUTO(RZ_Interface_Html_handle) + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + if (_Connecting) { nlassert (_ConnectingLock == this); // Check timeout if needed - if (_TimeoutValue != 0 && _ConnectingTimeout <= TimeInSec) + if (_TimeoutValue != 0 && _ConnectingTimeout <= ( times.thisFrameMs / 1000.0f ) ) { browseError(("Connection timeout : "+_URL).c_str()); } @@ -3184,7 +3141,7 @@ void CGroupHTML::handle () nlassert (_ConnectingLock == NULL); _ConnectingLock = this; _Connecting = true; - _ConnectingTimeout = TimeInSec + _TimeoutValue; + _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue; CButtonFreezer freezer; @@ -3238,7 +3195,7 @@ void CGroupHTML::handle () // add supported language header HTList *langs = HTList_new(); // set the language code used by the client - HTLanguage_add(langs, ClientCfg.getHtmlLanguageCode().c_str(), 1.0); + HTLanguage_add(langs, options.languageCode.c_str(), 1.0); HTRequest_setLanguage (_LibWWW->Request, langs, 1); // get_document(_LibWWW->Request, _LibWWW->Anchor); @@ -3343,7 +3300,7 @@ void CGroupHTML::handle () nlassert (_ConnectingLock == NULL); _ConnectingLock = this; _Connecting = true; - _ConnectingTimeout = TimeInSec + _TimeoutValue; + _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue; CButtonFreezer freezer; this->visit(&freezer); @@ -3534,8 +3491,6 @@ const std::string &CGroupHTML::selectTreeNodeRecurs(CGroupTree::SNode *node, con // *************************************************************************** bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string ¶ms, const std::string &url) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - // check if this action match if( (ah=="launch_help" || ah=="browse") && IActionHandler::getParam (params, "url") == url) { @@ -3546,11 +3501,11 @@ bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string { const std::string &procName= params; // look into this proc - uint numActions= pIM->getProcedureNumActions(procName); + uint numActions= CWidgetManager::parser->getProcedureNumActions(procName); for(uint i=0;igetProcedureAction(procName, i, procAh, procParams)) + if( CWidgetManager::parser->getProcedureAction(procName, i, procAh, procParams)) { // recurs proc if needed! if (actionLaunchUrlRecurs(procAh, procParams, url)) @@ -3633,7 +3588,6 @@ void CGroupHTML::browseRedo() // *************************************************************************** void CGroupHTML::updateUndoRedoButtons() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCtrlBaseButton *butUndo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton)); CCtrlBaseButton *butRedo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton)); @@ -3647,7 +3601,6 @@ void CGroupHTML::updateUndoRedoButtons() // *************************************************************************** void CGroupHTML::updateRefreshButton() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCtrlBaseButton *butRefresh = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton)); bool enabled = !_Browsing && !_Connecting; @@ -3957,3 +3910,5 @@ ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str) return result; } + + diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index d5c30cf1f..fa39debf7 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -14,9 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - #ifndef CL_GROUP_HTML_H #define CL_GROUP_HTML_H @@ -47,6 +44,7 @@ namespace NLGUI class CGroupParagraph; + // HTML group /** * Widget to have a resizable scrolltext and its scrollbar @@ -66,7 +64,20 @@ public: friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); + struct SWebOptions + { + public: + std::string appName; + std::string appVersion; + std::string languageCode; + std::vector< std::string > trustedDomains; + SWebOptions() + { + } + }; + + static SWebOptions options; // Constructor CGroupHTML(const TCtorParam ¶m); @@ -644,5 +655,4 @@ public: virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); }; - #endif diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index f789e4738..0ad38ec64 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -15,28 +15,21 @@ // along with this program. If not, see . - -#include "stdpch.h" - #include "group_paragraph.h" #include "group_html.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.h" #include "nel/gui/interface_element.h" -#include "../client_chat_manager.h" +#include "nel/gui/view_pointer_base.h" #include "nel/gui/view_bitmap.h" #include "nel/gui/view_text_id.h" #include "nel/gui/group_container.h" - #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" - #include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; -extern CClientChatManager ChatMngr; - NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); // ---------------------------------------------------------------------------- @@ -737,7 +730,6 @@ void CGroupParagraph::checkCoords () sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); if (_LastW != (sint) parentWidth) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); if (pCB != NULL) { @@ -770,7 +762,6 @@ void CGroupParagraph::draw () //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); if (_Over) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); if (CWidgetManager::getInstance()->getModalWindow() == NULL) @@ -1229,3 +1220,4 @@ sint32 CGroupParagraph::getMinUsedW() const } return minWidth; } + diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index 1366e21a2..ce13eb6c3 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -238,7 +238,7 @@ protected: struct CElementInfo { uint Order; // Used to sort the window by their insertion order. - // This is used to put back a window at the right place if it was turned into a popup. + // This is used to put back a window at the right place if it was turned into a popup. CViewBase *Element; bool EltDeleteOnRemove; }; @@ -292,7 +292,6 @@ private: }; - #endif // NL_GROUP_PARAGRAPH_H /* End of group_paragraph.h */ diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 1419a203a..d67cbeb5d 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -28,7 +28,7 @@ #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "nel/misc/xml_auto_ptr.h" - +#include "../actions.h" #include "../client_cfg.h" using namespace std; @@ -213,6 +213,8 @@ void CGroupQuickHelp::setGroupTextSize (CInterfaceGroup *group, bool selected) // *************************************************************************** +extern CActionsContext ActionsContext; + void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, const char **value) { CGroupHTML::beginElement (element_number, present, value); @@ -220,6 +222,34 @@ void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, co // Paragraph ? switch(element_number) { + case HTML_A: + // Quick help + if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT]) + { + // Get the action category + string category; + if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY]) + category = value[MY_HTML_A_Z_ACTION_CATEGORY]; + + // Get the action params + string params; + if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS]) + params = value[MY_HTML_A_Z_ACTION_PARAMS]; + + // Get the action descriptor + CActionsManager *actionManager = ActionsContext.getActionsManager (category); + if (actionManager) + { + const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap (); + CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str())); + if (ite != actionCombo.end()) + { + addString (ite->second.toUCString()); + } + } + } + break; + case HTML_P: // Get the action name if (present[MY_HTML_P_QUICK_HELP_EVENTS]) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index a3d87f447..b0308b5db 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -21,6 +21,8 @@ // Memory #include +#include "game_share/ryzom_version.h" + #include "nel/misc/i_xml.h" #include "nel/misc/o_xml.h" #include "nel/misc/algo.h" @@ -68,6 +70,7 @@ #include "group_in_scene_bubble.h" #include "group_skills.h" #include "group_compas.h" +#include "group_html.h" // Misc #include "../input.h" @@ -404,6 +407,10 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CViewRenderer::getInstance(); CViewTextID::setTextProvider( &SMTextProvider ); CViewTextFormated::setFormatter( &RyzomTextFormatter ); + CGroupHTML::options.trustedDomains = ClientCfg.WebIgTrustedDomains; + CGroupHTML::options.languageCode = ClientCfg.getHtmlLanguageCode(); + CGroupHTML::options.appName = "Ryzom"; + CGroupHTML::options.appVersion = RYZOM_VERSION; _Instance = this; NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); @@ -3403,42 +3410,6 @@ void CInterfaceManager::setProcedureAction(const std::string &procName, uint act } } -// ------------------------------------------------------------------------------------------------ -uint CInterfaceManager::getProcedureNumActions(const std::string &procName) const -{ - CstItProcedureMap it= _ProcedureMap.find(procName); - if(it!=_ProcedureMap.end()) - { - const CProcedure &proc= it->second; - return (uint)proc.Actions.size(); - } - else - return 0; -} - -// ------------------------------------------------------------------------------------------------ -bool CInterfaceManager::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms) const -{ - CstItProcedureMap it= _ProcedureMap.find(procName); - if(it!=_ProcedureMap.end()) - { - const CProcedure &proc= it->second; - if(actionIndex ¶mList); // replace an action in a procedure (if possible) void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms); - // get info on procedure. return 0 if procedure not found - uint getProcedureNumActions(const std::string &procName) const; - // return false if procedure not found, or if bad action index. return false if has some param variable (@0...) - bool getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms) const; // Execute a anim void startAnim(const std::string &animId); void stopAnim(const std::string &animId); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 440225f03..b2ffddf3f 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -3432,6 +3432,43 @@ void CInterfaceParser::removeAll() } +// ------------------------------------------------------------------------------------------------ +uint CInterfaceParser::getProcedureNumActions(const std::string &procName) const +{ + CstItProcedureMap it= _ProcedureMap.find(procName); + if(it!=_ProcedureMap.end()) + { + const CProcedure &proc= it->second; + return (uint)proc.Actions.size(); + } + else + return 0; +} + +// ------------------------------------------------------------------------------------------------ +bool CInterfaceParser::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms) const +{ + CstItProcedureMap it= _ProcedureMap.find(procName); + if(it!=_ProcedureMap.end()) + { + const CProcedure &proc= it->second; + if(actionIndex. - -#include "stdpch.h" - #include extern "C" @@ -40,81 +37,80 @@ extern "C" using namespace std; using namespace NLMISC; - extern "C" { /* Final states have negative value */ typedef enum _FileState { - FS_RETRY = -4, - FS_ERROR = -3, - FS_NO_DATA = -2, - FS_GOT_DATA = -1, - FS_BEGIN = 0, - FS_PENDING, - FS_DO_CN, - FS_NEED_OPEN_FILE, - FS_NEED_BODY, - FS_PARSE_DIR, - FS_TRY_FTP + FS_RETRY = -4, + FS_ERROR = -3, + FS_NO_DATA = -2, + FS_GOT_DATA = -1, + FS_BEGIN = 0, + FS_PENDING, + FS_DO_CN, + FS_NEED_OPEN_FILE, + FS_NEED_BODY, + FS_PARSE_DIR, + FS_TRY_FTP } FileState; /* This is the context structure for the this module */ typedef struct _file_info { - FileState state; /* Current state of the connection */ - char * local; /* Local representation of file name */ - struct stat stat_info; /* Contains actual file chosen */ - HTNet * net; - HTTimer * timer; + FileState state; /* Current state of the connection */ + char * local; /* Local representation of file name */ + struct stat stat_info; /* Contains actual file chosen */ + HTNet * net; + HTTimer * timer; } file_info; struct _HTStream { - const HTStreamClass * isa; + const HTStreamClass * isa; }; struct _HTInputStream { - const HTInputStreamClass * isa; - HTChannel * ch; - HTHost * host; - char * write; /* Last byte written */ - char * read; /* Last byte read */ - int b_read; - char data [INPUT_BUFFER_SIZE]; /* buffer */ + const HTInputStreamClass * isa; + HTChannel * ch; + HTHost * host; + char * write; /* Last byte written */ + char * read; /* Last byte read */ + int b_read; + char data [INPUT_BUFFER_SIZE]; /* buffer */ }; PRIVATE int FileCleanup (HTRequest *req, int status) { - HTNet * net = HTRequest_net(req); - file_info * file = (file_info *) HTNet_context(net); - HTStream * input = HTRequest_inputStream(req); + HTNet * net = HTRequest_net(req); + file_info * file = (file_info *) HTNet_context(net); + HTStream * input = HTRequest_inputStream(req); - /* Free stream with data TO Local file system */ - if (input) + /* Free stream with data TO Local file system */ + if (input) { - if (status == HT_INTERRUPTED) - (*input->isa->abort)(input, NULL); - else - (*input->isa->_free)(input); - HTRequest_setInputStream(req, NULL); - } + if (status == HT_INTERRUPTED) + (*input->isa->abort)(input, NULL); + else + (*input->isa->_free)(input); + HTRequest_setInputStream(req, NULL); + } - /* - ** Remove if we have registered a timer function as a callback - */ - if (file->timer) + /* + ** Remove if we have registered a timer function as a callback + */ + if (file->timer) { HTTimer_delete(file->timer); file->timer = NULL; - } + } - if (file) + if (file) { HT_FREE(file->local); HT_FREE(file); - } + } HTNet_delete(net, status); - return YES; + return YES; } @@ -122,104 +118,104 @@ PRIVATE int FileEvent (SOCKET soc, void * pVoid, HTEventType type); PUBLIC int HTLoadNeLFile (SOCKET soc, HTRequest * request) { - file_info *file; /* Specific access information */ - HTNet * net = HTRequest_net(request); - HTParentAnchor * anchor = HTRequest_anchor(request); + file_info *file; /* Specific access information */ + HTNet * net = HTRequest_net(request); + HTParentAnchor * anchor = HTRequest_anchor(request); - HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ - HTAnchor_physical(anchor)); - if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) + HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ + HTAnchor_physical(anchor)); + if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) HT_OUTOFMEM((char*)"HTLoadFILE"); - file->state = FS_BEGIN; - file->net = net; - HTNet_setContext(net, file); - HTNet_setEventCallback(net, FileEvent); - HTNet_setEventParam(net, file); /* callbacks get http* */ + file->state = FS_BEGIN; + file->net = net; + HTNet_setContext(net, file); + HTNet_setEventCallback(net, FileEvent); + HTNet_setEventParam(net, file); /* callbacks get http* */ - return FileEvent(soc, file, HTEvent_BEGIN); /* get it started - ops is ignored */ + return FileEvent(soc, file, HTEvent_BEGIN); /* get it started - ops is ignored */ } PRIVATE int ReturnEvent (HTTimer * timer, void * param, HTEventType /* type */) { - file_info * file = (file_info *) param; - if (timer != file->timer) + file_info * file = (file_info *) param; + if (timer != file->timer) HTDEBUGBREAK((char*)"File timer %p not in sync\n" _ timer); - HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer); + HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer); - /* - ** Delete the timer - */ - HTTimer_delete(file->timer); - file->timer = NULL; + /* + ** Delete the timer + */ + HTTimer_delete(file->timer); + file->timer = NULL; - /* - ** Now call the event again - */ - return FileEvent(INVSOC, file, HTEvent_READ); + /* + ** Now call the event again + */ + return FileEvent(INVSOC, file, HTEvent_READ); } PUBLIC int HTNeLFileOpen (HTNet * net, char * local, HTLocalMode /* mode */) { - HTRequest * request = HTNet_request(net); - HTHost * host = HTNet_host(net); - CIFile* fp = new CIFile; + HTRequest * request = HTNet_request(net); + HTHost * host = HTNet_host(net); + CIFile* fp = new CIFile; - if (!fp->open (local)) + if (!fp->open (local)) { - HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open"); - return HT_ERROR; - } + HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open"); + return HT_ERROR; + } - HTHost_setChannel(host, HTChannel_new(INVSOC, (FILE*)fp, YES)); + HTHost_setChannel(host, HTChannel_new(INVSOC, (FILE*)fp, YES)); - HTHost_getInput(host, HTNet_transport(net), NULL, 0); - HTHost_getOutput(host, HTNet_transport(net), NULL, 0); - return HT_OK; + HTHost_getInput(host, HTNet_transport(net), NULL, 0); + HTHost_getOutput(host, HTNet_transport(net), NULL, 0); + return HT_OK; } PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) { - file_info *file = (file_info *)pVoid; /* Specific access information */ - int status = HT_ERROR; - HTNet * net = file->net; - HTRequest * request = HTNet_request(net); - HTParentAnchor * anchor = HTRequest_anchor(request); + file_info *file = (file_info *)pVoid; /* Specific access information */ + int status = HT_ERROR; + HTNet * net = file->net; + HTRequest * request = HTNet_request(net); + HTParentAnchor * anchor = HTRequest_anchor(request); - if (type == HTEvent_CLOSE) + if (type == HTEvent_CLOSE) { /* Interrupted */ HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED, NULL, 0, (char*)"HTLoadFile"); FileCleanup(request, HT_INTERRUPTED); return HT_OK; - } + } - /* Now jump into the machine. We know the state from the previous run */ - for(;;) + /* Now jump into the machine. We know the state from the previous run */ + for(;;) { switch (file->state) { case FS_BEGIN: - /* We only support safe (GET, HEAD, etc) methods for the moment */ - if (!HTMethod_isSafe(HTRequest_method(request))) { + /* We only support safe (GET, HEAD, etc) methods for the moment */ + if (!HTMethod_isSafe(HTRequest_method(request))) { HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; break; - } + } - /* Check whether we have access to local disk at all */ - if (HTLib_secure()) + /* Check whether we have access to local disk at all */ + if (HTLib_secure()) { HTTRACE(PROT_TRACE, "LoadFile.... No access to local file system\n"); file->state = FS_TRY_FTP; break; - } + } /*file->local = HTWWWToLocal(HTAnchor_physical(anchor), "", - HTRequest_userProfile(request));*/ + HTRequest_userProfile(request));*/ { string tmp = HTAnchor_physical(anchor); if (strlwr(tmp).find("file:/") == 0) @@ -229,70 +225,70 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) StrAllocCopy(file->local, tmp.c_str()); } - if (!file->local) + if (!file->local) { file->state = FS_TRY_FTP; break; - } + } - /* Create a new host object and link it to the net object */ - { + /* Create a new host object and link it to the net object */ + { HTHost * host = NULL; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; HTNet_setHost(net, host); if (HTHost_addNet(host, net) == HT_PENDING) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); - /* move to the hack state */ - file->state = FS_PENDING; - return HT_OK; + HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); + /* move to the hack state */ + file->state = FS_PENDING; + return HT_OK; } - } - file->state = FS_DO_CN; - break; + } + file->state = FS_DO_CN; + break; case FS_PENDING: - { + { HTHost * host = NULL; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; HTNet_setHost(net, host); if (HTHost_addNet(host, net) == HT_PENDING) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); - file->state = FS_PENDING; - return HT_OK; + HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); + file->state = FS_PENDING; + return HT_OK; } - } - file->state = FS_DO_CN; - break; + } + file->state = FS_DO_CN; + break; case FS_DO_CN: - if (HTRequest_negotiation(request) && + if (HTRequest_negotiation(request) && HTMethod_isSafe(HTRequest_method(request))) { HTAnchor_setPhysical(anchor, file->local); HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local); - } else { + } else { if (HT_STAT(file->local, &file->stat_info) == -1) { - HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local); - HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_ERROR; - break; + HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local); + HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_ERROR; + break; + } } - } - if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR) { + if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR) { if (HTRequest_method(request) == METHOD_GET) - file->state = FS_PARSE_DIR; + file->state = FS_PARSE_DIR; else { - HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_NO_DATA; + HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_NO_DATA; } break; - } + } - { + { BOOL editable = FALSE; HTBind_getAnchorBindings(anchor); if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT); @@ -306,124 +302,124 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) nelFile.close(); if (file->stat_info.st_size) - HTAnchor_setLength(anchor, file->stat_info.st_size); + HTAnchor_setLength(anchor, file->stat_info.st_size); /* Set the file last modified time stamp */ if (file->stat_info.st_mtime > 0) - HTAnchor_setLastModified(anchor, file->stat_info.st_mtime); + HTAnchor_setLastModified(anchor, file->stat_info.st_mtime); /* Check to see if we can edit it */ if (!editable && !file->stat_info.st_size) { - HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_NO_DATA; + HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_NO_DATA; } else { - file->state = (HTRequest_method(request)==METHOD_GET) ? + file->state = (HTRequest_method(request)==METHOD_GET) ? FS_NEED_OPEN_FILE : FS_GOT_DATA; } - } - break; + } + break; case FS_NEED_OPEN_FILE: - status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY); - if (status == HT_OK) { + status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY); + if (status == HT_OK) { { - HTStream * rstream = HTStreamStack(HTAnchor_format(anchor), - HTRequest_outputFormat(request), - HTRequest_outputStream(request), - request, YES); - HTNet_setReadStream(net, rstream); - HTRequest_setOutputConnected(request, YES); + HTStream * rstream = HTStreamStack(HTAnchor_format(anchor), + HTRequest_outputFormat(request), + HTRequest_outputStream(request), + request, YES); + HTNet_setReadStream(net, rstream); + HTRequest_setOutputConnected(request, YES); } { - HTOutputStream * output = HTNet_getOutput(net, NULL, 0); - HTRequest_setInputStream(request, (HTStream *) output); + HTOutputStream * output = HTNet_getOutput(net, NULL, 0); + HTRequest_setInputStream(request, (HTStream *) output); } if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request)) - return HT_OK; + return HT_OK; HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0, (char*)"HTLoadFile"); file->state = FS_NEED_BODY; if (HTEvent_isCallbacksRegistered()) { - if (!HTRequest_preemptive(request)) { + if (!HTRequest_preemptive(request)) { if (!HTNet_preemptive(net)) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); - HTHost_register(HTNet_host(net), net, HTEvent_READ); + HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); + HTHost_register(HTNet_host(net), net, HTEvent_READ); } else if (!file->timer) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); - file->timer = + HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); + file->timer = HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO); } return HT_OK; - } + } } - } else if (status == HT_WOULD_BLOCK || status == HT_PENDING) + } else if (status == HT_WOULD_BLOCK || status == HT_PENDING) return HT_OK; - else { + else { HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; /* Error or interrupt */ - } - break; + } + break; case FS_NEED_BODY: - status = HTHost_read(HTNet_host(net), net); - if (status == HT_WOULD_BLOCK) + status = HTHost_read(HTNet_host(net), net); + if (status == HT_WOULD_BLOCK) return HT_OK; - else if (status == HT_LOADED || status == HT_CLOSED) { + else if (status == HT_LOADED || status == HT_CLOSED) { file->state = FS_GOT_DATA; - } else { + } else { HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; - } - break; + } + break; case FS_TRY_FTP: - { + { char *url = HTAnchor_physical(anchor); HTAnchor *anchor; char *newname = NULL; StrAllocCopy(newname, "ftp:"); if (!strncmp(url, "file:", 5)) - StrAllocCat(newname, url+5); + StrAllocCat(newname, url+5); else - StrAllocCat(newname, url); + StrAllocCat(newname, url); anchor = HTAnchor_findAddress(newname); HTRequest_setAnchor(request, anchor); HT_FREE(newname); FileCleanup(request, HT_IGNORE); return HTLoad(request, YES); - } - break; + } + break; case FS_GOT_DATA: - FileCleanup(request, HT_LOADED); - return HT_OK; - break; + FileCleanup(request, HT_LOADED); + return HT_OK; + break; case FS_NO_DATA: - FileCleanup(request, HT_NO_DATA); - return HT_OK; - break; + FileCleanup(request, HT_NO_DATA); + return HT_OK; + break; case FS_RETRY: - FileCleanup(request, HT_RETRY); - return HT_OK; - break; + FileCleanup(request, HT_RETRY); + return HT_OK; + break; case FS_ERROR: - FileCleanup(request, HT_ERROR); - return HT_OK; - break; + FileCleanup(request, HT_ERROR); + return HT_OK; + break; default: - break; + break; } - } /* End of while(1) */ + } /* End of while(1) */ } // ************************************************************************* @@ -440,12 +436,12 @@ size_t nel_fread (void *buffer, uint size, FILE *fp) PRIVATE int HTNeLReader_read (HTInputStream * me) { - FILE * fp = HTChannel_file(me->ch); - HTNet * net = HTHost_getReadNet(me->host); - int status; + FILE * fp = HTChannel_file(me->ch); + HTNet * net = HTHost_getReadNet(me->host); + int status; - /* Read the file desriptor */ - while (fp) + /* Read the file desriptor */ + while (fp) { if ((me->b_read = (int)nel_fread(me->data, FILE_BUFFER_SIZE, fp)) == 0) { @@ -492,9 +488,9 @@ PRIVATE int HTNeLReader_read (HTInputStream * me) } } me->write = me->data + me->b_read; - } - HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n"); - return HT_ERROR; + } + HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n"); + return HT_ERROR; } PRIVATE int HTNeLReader_close (HTInputStream * me) @@ -505,32 +501,32 @@ PRIVATE int HTNeLReader_close (HTInputStream * me) file->close(); } - int status = HT_OK; - HTNet * net = HTHost_getReadNet(me->host); + int status = HT_OK; + HTNet * net = HTHost_getReadNet(me->host); - if (net && net->readStream) { + if (net && net->readStream) { if ((status = (*net->readStream->isa->_free)(net->readStream))==HT_WOULD_BLOCK) - return HT_WOULD_BLOCK; + return HT_WOULD_BLOCK; net->readStream = NULL; - } - HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n"); - HT_FREE(me); - return status; + } + HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n"); + HT_FREE(me); + return status; } PUBLIC int HTNeLReader_consumed (HTInputStream * me, size_t bytes) { - me->write += bytes; - me->b_read -= (int)bytes; - HTHost_setRemainingRead(me->host, me->b_read); - return HT_OK; + me->write += bytes; + me->b_read -= (int)bytes; + HTHost_setRemainingRead(me->host, me->b_read); + return HT_OK; } PRIVATE int HTNeLReader_flush (HTInputStream * me) { - HTNet * net = HTHost_getReadNet(me->host); - return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK; + HTNet * net = HTHost_getReadNet(me->host); + return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK; } PRIVATE int HTNeLReader_free (HTInputStream * me) @@ -542,54 +538,56 @@ PRIVATE int HTNeLReader_free (HTInputStream * me) HTChannel_setFile (me->ch, NULL); } - HTNet * net = HTHost_getReadNet(me->host); - if (net && net->readStream) { + HTNet * net = HTHost_getReadNet(me->host); + if (net && net->readStream) { int status = (*net->readStream->isa->_free)(net->readStream); - if (status == HT_OK) net->readStream = NULL; + if (status == HT_OK) net->readStream = NULL; return status; - } - return HT_OK; + } + return HT_OK; } PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */) { - HTNet * net = HTHost_getReadNet(me->host); - if (net && net->readStream) { + HTNet * net = HTHost_getReadNet(me->host); + if (net && net->readStream) { int status = (*net->readStream->isa->abort)(net->readStream, NULL); if (status != HT_IGNORE) net->readStream = NULL; - } - return HT_ERROR; + } + return HT_ERROR; } PRIVATE const HTInputStreamClass HTNeLReader = { - (char*)"SocketReader", - HTNeLReader_flush, - HTNeLReader_free, - HTNeLReader_abort, - HTNeLReader_read, - HTNeLReader_close, - HTNeLReader_consumed + (char*)"SocketReader", + HTNeLReader_flush, + HTNeLReader_free, + HTNeLReader_abort, + HTNeLReader_read, + HTNeLReader_close, + HTNeLReader_consumed }; PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, - void * /* param */, int /* mode */) + void * /* param */, int /* mode */) { - if (host && ch) { + if (host && ch) { HTInputStream * me = HTChannel_input(ch); if (me == NULL) { - if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) - HT_OUTOFMEM((char*)"HTNeLReader_new"); - me->isa = &HTNeLReader; - me->ch = ch; - me->host = host; - HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me); + if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) + HT_OUTOFMEM((char*)"HTNeLReader_new"); + me->isa = &HTNeLReader; + me->ch = ch; + me->host = host; + HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me); } return me; - } - return NULL; + } + return NULL; } //PUBLIC unsigned int WWW_TraceFlag = 0; } // extern "C" + + diff --git a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h b/code/ryzom/client/src/interface_v3/libwww_nel_stream.h index d213baab2..e9cb8d9ee 100644 --- a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h +++ b/code/ryzom/client/src/interface_v3/libwww_nel_stream.h @@ -23,8 +23,6 @@ #include "HTProt.h" extern "C" HTProtCallback HTLoadNeLFile; - -extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, - void * param, int mode); +extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode); #endif // LIBWWW_NEL_STREAM_H diff --git a/code/ryzom/client/src/interface_v3/view_link.cpp b/code/ryzom/client/src/interface_v3/view_link.cpp index 61421133e..efe760567 100644 --- a/code/ryzom/client/src/interface_v3/view_link.cpp +++ b/code/ryzom/client/src/interface_v3/view_link.cpp @@ -14,13 +14,8 @@ // 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/misc/bit_mem_stream.h" #include "nel/misc/i18n.h" - #include "view_link.h" using namespace std; @@ -62,3 +57,4 @@ bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col) // *************************************************************************** + diff --git a/code/ryzom/client/src/interface_v3/view_link.h b/code/ryzom/client/src/interface_v3/view_link.h index 169487a1d..dce116b82 100644 --- a/code/ryzom/client/src/interface_v3/view_link.h +++ b/code/ryzom/client/src/interface_v3/view_link.h @@ -21,6 +21,8 @@ #include "nel/gui/view_text.h" +class CGroupHTML; + /** * class implementing a link view * \author Cyril 'Hulud' Corvazier @@ -41,7 +43,7 @@ public: std::string LinkTitle; // Set the main group - void setHTMLView(class CGroupHTML *html); + void setHTMLView( CGroupHTML *html); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); protected: @@ -50,7 +52,6 @@ protected: CGroupHTML *HTML; }; - #endif // NL_VIEW_LINK_H /* End of view_link.h */ diff --git a/code/ryzom/client/src/libwww.cpp b/code/ryzom/client/src/libwww.cpp index a1c0ce826..b2c699cd5 100644 --- a/code/ryzom/client/src/libwww.cpp +++ b/code/ryzom/client/src/libwww.cpp @@ -15,9 +15,6 @@ // along with this program. If not, see . - -#include "stdpch.h" - // LibWWW extern "C" { @@ -27,8 +24,6 @@ extern "C" } #include "interface_v3/group_html.h" -#include "game_share/ryzom_version.h" - #include "interface_v3/libwww_nel_stream.h" using namespace NLMISC; @@ -45,7 +40,7 @@ std::string HTTPCurrentDomain; // The current domain that will be used to get wh // The HText structure for libwww struct _HText { - CGroupHTML *Parent; + CGroupHTML *Parent; }; // *************************************************************************** @@ -273,7 +268,7 @@ HText * TextNew (HTRequest * request, { HText *text = new HText; text->Parent = (CGroupHTML *) HTRequest_context(request); - return text; + return text; } // *************************************************************************** @@ -281,7 +276,7 @@ HText * TextNew (HTRequest * request, BOOL TextDelete (HText * me) { delete me; - return YES; + return YES; } // *************************************************************************** @@ -437,7 +432,7 @@ int requestTerminater (HTRequest * request, HTResponse * /* response */, gh->requestTerminated(request); } } - return HT_OK; + return HT_OK; } @@ -486,7 +481,7 @@ HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */) HTAnchor * TextFindAnchor (HText * /* me */, int /* index */) { - return NULL; + return NULL; } int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value) @@ -544,7 +539,7 @@ void initLibWWW() static bool initialized = false; if (!initialized) { - //HTProfile_newNoCacheClient("Ryzom", "1.1"); + //HTProfile_newNoCacheClient("Ryzom", "1.1"); /* Need our own trace and print functions */ HTPrint_setCallback(NelPrinter); @@ -552,8 +547,8 @@ void initLibWWW() /* Initiate libwww */ - HTLib_setAppName("Ryzom"); - HTLib_setAppVersion(RYZOM_VERSION); + HTLib_setAppName( CGroupHTML::options.appName.c_str() ); + HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() ); /* Set up TCP as transport */ VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new)); @@ -563,7 +558,7 @@ void initLibWWW() /* Set up HTTP as protocol */ VerifyLibWWW("HTProtocol_add", HTProtocol_add("http", "buffered_tcp", 80, NO, HTLoadHTTP, NULL)); - VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL)); + VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL)); //VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL)); // HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL); @@ -657,8 +652,8 @@ void initLibWWW() /* Set up default event loop */ HTEventInit(); - /* Add our own request terminate handler */ - HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); + /* Add our own request terminate handler */ + HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); /* Setup cookies */ HTCookie_init(); @@ -670,7 +665,7 @@ void initLibWWW() /* Go into the event loop... */ // HTEventList_newLoop(); - // App_delete(app); + // App_delete(app); HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ From bf624b79ec251f5b291cc95ba1efd1db4346353a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 1 Jul 2012 03:11:24 +0200 Subject: [PATCH 119/339] CHANGED: #1471 CGroupHTML, CGroupParagraph, CViewLink are now part of the NELGUI library and are under the NLGUI namespace. --- code/nel/include/nel/gui/group_html.h | 659 +++ code/nel/include/nel/gui/group_paragraph.h | 304 ++ code/nel/include/nel/gui/interface_element.h | 5 +- code/nel/include/nel/gui/libwww.h | 283 ++ .../include/nel/gui}/libwww_nel_stream.h | 0 .../include/nel/gui}/view_link.h | 51 +- code/nel/src/gui/group_html.cpp | 3923 +++++++++++++++++ code/nel/src/gui/group_paragraph.cpp | 1228 ++++++ code/nel/src/gui/libwww.cpp | 712 +++ .../src/gui}/libwww_nel_stream.cpp | 2 +- .../src/gui}/view_link.cpp | 63 +- .../src/interface_v3/action_handler_item.cpp | 2 +- .../src/interface_v3/action_handler_ui.cpp | 2 +- .../client/src/interface_v3/group_html.cpp | 3914 ---------------- .../client/src/interface_v3/group_html.h | 658 --- .../client/src/interface_v3/group_html_cs.h | 2 +- .../src/interface_v3/group_html_forum.h | 2 +- .../client/src/interface_v3/group_html_mail.h | 2 +- .../client/src/interface_v3/group_html_qcm.h | 2 +- .../src/interface_v3/group_html_webig.h | 2 +- .../interface_v3/group_in_scene_bubble.cpp | 2 +- .../src/interface_v3/group_paragraph.cpp | 1223 ----- .../client/src/interface_v3/group_paragraph.h | 299 -- .../src/interface_v3/group_quick_help.cpp | 4 +- .../src/interface_v3/group_quick_help.h | 2 +- .../client/src/interface_v3/guild_manager.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +- .../register_interface_elements.cpp | 2 +- .../client/src/interface_v3/view_pointer.cpp | 4 +- code/ryzom/client/src/libwww.cpp | 708 --- code/ryzom/client/src/libwww.h | 283 -- code/ryzom/client/src/login.cpp | 2 +- code/ryzom/client/src/user_entity.cpp | 2 +- 35 files changed, 7193 insertions(+), 7162 deletions(-) create mode 100644 code/nel/include/nel/gui/group_html.h create mode 100644 code/nel/include/nel/gui/group_paragraph.h create mode 100644 code/nel/include/nel/gui/libwww.h rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/libwww_nel_stream.h (100%) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/view_link.h (59%) create mode 100644 code/nel/src/gui/group_html.cpp create mode 100644 code/nel/src/gui/group_paragraph.cpp create mode 100644 code/nel/src/gui/libwww.cpp rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/libwww_nel_stream.cpp (95%) rename code/{ryzom/client/src/interface_v3 => nel/src/gui}/view_link.cpp (53%) delete mode 100644 code/ryzom/client/src/interface_v3/group_html.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_html.h delete mode 100644 code/ryzom/client/src/interface_v3/group_paragraph.cpp delete mode 100644 code/ryzom/client/src/interface_v3/group_paragraph.h delete mode 100644 code/ryzom/client/src/libwww.cpp delete mode 100644 code/ryzom/client/src/libwww.h diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h new file mode 100644 index 000000000..3d0b641fd --- /dev/null +++ b/code/nel/include/nel/gui/group_html.h @@ -0,0 +1,659 @@ +// Ryzom - MMORPG Framework +// 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 CL_GROUP_HTML_H +#define CL_GROUP_HTML_H + +#define CURL_STATICLIB 1 +#include + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_scrolltext.h" +#include "nel/gui/group_tree.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/group_table.h" + +typedef std::map TStyle; + +extern "C" +{ +#include "WWWInit.h" +} + +namespace NLGUI +{ + class CCtrlButton; + class CCtrlScroll; + class CGroupList; + class CDBGroupComboBox; + class CGroupParagraph; + + + + // HTML group + /** + * Widget to have a resizable scrolltext and its scrollbar + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2002 + */ + class CGroupHTML : public CGroupScrollText + { + public: + friend void TextAdd (struct _HText *me, const char * buf, int len); + friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value); + friend void TextEndElement (_HText *me, int element_number); + friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value); + friend void TextBuild (HText * me, HTextStatus status); + friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length); + friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); + friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); + + struct SWebOptions + { + public: + std::string appName; + std::string appVersion; + std::string languageCode; + std::vector< std::string > trustedDomains; + + SWebOptions() + { + } + }; + + static SWebOptions options; + + // Constructor + CGroupHTML(const TCtorParam ¶m); + ~CGroupHTML(); + + // CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void draw (); + + // Events + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + // Browse + virtual void browse (const char *url); + + // Refresh + void refresh(); + + // submit form + void submitForm (uint formId, const char *submitButtonName); + + // Browse error + void browseError (const char *msg); + + // stop browse + void stopBrowse (); + + bool isBrowsing(); + + void clean() { stopBrowse(); updateRefreshButton(); removeContent(); } + + // Update coords + void updateCoords(); + + // New paragraph + void newParagraph(uint beginSpace); + + // End of the paragraph + void endParagraph(); + + // Timeout + void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} + float getTimeout() const {return (float)_TimeoutValue;} + + // Some constants + NLMISC::CRGBA BgColor; + NLMISC::CRGBA ErrorColor; + NLMISC::CRGBA LinkColor; + NLMISC::CRGBA TextColor; + NLMISC::CRGBA H1Color; + NLMISC::CRGBA H2Color; + NLMISC::CRGBA H3Color; + NLMISC::CRGBA H4Color; + NLMISC::CRGBA H5Color; + NLMISC::CRGBA H6Color; + bool ErrorColorGlobalColor; + bool LinkColorGlobalColor; + bool TextColorGlobalColor; + bool H1ColorGlobalColor; + bool H2ColorGlobalColor; + bool H3ColorGlobalColor; + bool H4ColorGlobalColor; + bool H5ColorGlobalColor; + bool H6ColorGlobalColor; + uint TextFontSize; + uint H1FontSize; + uint H2FontSize; + uint H3FontSize; + uint H4FontSize; + uint H5FontSize; + uint H6FontSize; + uint TDBeginSpace; + uint PBeginSpace; + uint LIBeginSpace; + uint ULBeginSpace; + uint LIIndent; + uint ULIndent; + float LineSpaceFontFactor; + std::string DefaultButtonGroup; + std::string DefaultFormTextGroup; + std::string DefaultFormTextAreaGroup; + std::string DefaultFormSelectGroup; + std::string DefaultCheckBoxBitmapNormal; + std::string DefaultCheckBoxBitmapPushed; + std::string DefaultCheckBoxBitmapOver; + std::string DefaultBackgroundBitmapView; + std::string CurrentLinkTitle; + + // Browser home + std::string Home; + + // Undo browse: Browse the precedent url browsed. no op if none + void browseUndo (); + // Redo browse: Browse the precedent url undoed. no op if none + void browseRedo (); + // clear undo/redo + void clearUndoRedo(); + + + std::string getURL() const { return _URL; } + void setURL(const std::string &url); + + + int luaBrowse(CLuaState &ls); + int luaRefresh(CLuaState &ls); + int luaRemoveContent(CLuaState &ls); + int luaInsertText(CLuaState &ls); + int luaAddString(CLuaState &ls); + int luaAddImage(CLuaState &ls); + int luaBeginElement(CLuaState &ls); + int luaEndElement(CLuaState &ls); + int luaShowDiv(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) + REFLECT_LUA_METHOD("browse", luaBrowse) + REFLECT_LUA_METHOD("refresh", luaRefresh) + REFLECT_LUA_METHOD("removeContent", luaRemoveContent) + REFLECT_LUA_METHOD("insertText", luaInsertText) + REFLECT_LUA_METHOD("addString", luaAddString) + REFLECT_LUA_METHOD("addImage", luaAddImage) + REFLECT_LUA_METHOD("beginElement", luaBeginElement) + REFLECT_LUA_METHOD("endElement", luaEndElement) + REFLECT_LUA_METHOD("showDiv", luaShowDiv) + REFLECT_STRING("url", getURL, setURL) + REFLECT_FLOAT("timeout", getTimeout, setTimeout) + REFLECT_EXPORT_END + + protected : + + // \name callback from libwww + + // Begin of the parsing of a HTML document + virtual void beginBuild (); + + // End of the parsing of a HTML document + virtual void endBuild (); + + // A new text block has been parsed + virtual void addText (const char * buf, int len); + + // A link has been parsed + virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); + + // A new begin HTML element has been parsed ( for exemple) + virtual void beginElement (uint element_number, const BOOL *present, const char **value); + + // A new end HTML element has been parsed ( for exemple) + virtual void endElement (uint element_number); + + // A new begin unparsed element has been found + virtual void beginUnparsedElement(const char *buffer, int length); + + // A new end unparsed element has been found + virtual void endUnparsedElement(const char *buffer, int length); + + // Add GET params to the url + virtual void addHTTPGetParams (std::string &url, bool trustedDomain); + + // Add POST params to the libwww list + virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain); + + // the current request is terminated + virtual void requestTerminated(HTRequest *request); + + // Get Home URL + virtual std::string home(); + + // Parse style html tag + TStyle parseStyle(const std::string &str_styles); + + // Handle some work at each pass + virtual void handle (); + + // \name internal methods + + // Add a group in the current parent group + void addGroup (CInterfaceGroup *group, uint beginSpace); + + // Get the current parent group + CInterfaceGroup *getCurrentGroup(); + + // Update current paragraph dependent data + void paragraphChange (); + + // Clear the contexts info + void clearContext(); + + // Translate a char + bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; + + // Add a string in the current paragraph + void addString(const ucstring &str); + + // Add an image in the current paragraph + void addImage(const char *image, bool globalColor, bool reloadImg=false); + + // Add a text area in the current paragraph + CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content); + + // Add a combo box in the current paragraph + CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); + + // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. + CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, + const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip); + + // Set the background color + void setBackgroundColor (const NLMISC::CRGBA &bgcolor); + + // Set the background + void setBackground (const std::string &bgtex, bool scale, bool tile); + + // Force the current string to be in a single string + void flushString(); + + // Set the title + void setTitle (const ucstring &title); + + // Lookup a url in local file system + bool lookupLocalFile (std::string &result, const char *url, bool isUrl); + + // Delete page content and prepare next page + void removeContent (); + + // Current URL + std::string _URL; + + // Current DOMAIN + bool _TrustedDomain; + + // Title prefix + ucstring _TitlePrefix; + + // Title string + ucstring _TitleString; + + // Need to browse next update coords.. + bool _BrowseNextTime; + bool _PostNextTime; + uint _PostFormId; + std::string _PostFormSubmitButton; + + // Browsing.. + bool _Browsing; + bool _Connecting; + double _TimeoutValue; // the timeout in seconds + double _ConnectingTimeout; + + // minimal embeded lua script support + // Note : any embeded script is executed immediately after the closing + // element has been found + // True when the element has been encountered + bool _ParsingLua; + bool _IgnoreText; + // the script to execute + std::string _LuaScript; + + bool _Object; + std::string _ObjectScript; + + // Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client. + static CGroupHTML *_ConnectingLock; + + // LibWWW data + class CLibWWWData *_LibWWW; + + // Current paragraph + std::string _DivName; + CGroupParagraph* _Paragraph; + inline CGroupParagraph *getParagraph() + { + return _Paragraph; + /*if (_Paragraph.empty()) + return NULL; + return _Paragraph.back();*/ + } + + // PRE mode + std::vector _PRE; + inline bool getPRE() const + { + if (_PRE.empty()) + return false; + return _PRE.back(); + } + + // UL mode + std::vector _UL; + inline bool getUL() const + { + if (_UL.empty()) + return false; + return _UL.back(); + } + + // A mode + std::vector _A; + inline bool getA() const + { + if (_A.empty()) + return false; + return _A.back(); + } + + // IL mode + bool _LI; + + // Current text color + std::vector _TextColor; + inline const NLMISC::CRGBA &getTextColor() const + { + if (_TextColor.empty()) + return TextColor; + return _TextColor.back(); + } + + // Current global color flag + std::vector _GlobalColor; + inline bool getGlobalColor() const + { + if (_GlobalColor.empty()) + return false; + return _GlobalColor.back(); + } + + // Current font size + std::vector _FontSize; + inline uint getFontSize() const + { + if (_FontSize.empty()) + return TextFontSize; + return _FontSize.back(); + } + + // Current link + std::vector _Link; + inline const char *getLink() const + { + if (_Link.empty()) + return ""; + return _Link.back().c_str(); + } + + std::vector _LinkTitle; + inline const char *getLinkTitle() const + { + if (_LinkTitle.empty()) + return ""; + return _LinkTitle.back().c_str(); + } + std::vector _LinkClass; + inline const char *getLinkClass() const + { + if (_LinkClass.empty()) + return ""; + return _LinkClass.back().c_str(); + } + + // Divs (i.e. interface group) + std::vector _Divs; + inline CInterfaceGroup *getDiv() const + { + if (_Divs.empty()) + return NULL; + return _Divs.back(); + } + + // Tables + std::vector _Tables; + inline CGroupTable *getTable() const + { + if (_Tables.empty()) + return NULL; + return _Tables.back(); + } + + // Cells + std::vector _Cells; + + // TR + std::vector _TR; + inline bool getTR() const + { + if (_TR.empty()) + return false; + return _TR.back(); + } + + // Forms + class CForm + { + public: + + class CEntry + { + public: + CEntry () + { + TextArea = NULL; + Checkbox = NULL; + ComboBox = NULL; + InitialSelection = 0; + } + + // Variable name + std::string Name; + + // Variable value + ucstring Value; + + // Text area group + CInterfaceGroup *TextArea; + + // Checkbox + CCtrlButton *Checkbox; + + // Combobox group + CDBGroupComboBox *ComboBox; + + // select values (for the tag) - std::vector SelectValues; - sint InitialSelection; // initial selection for the combo box - }; - - // The action the form has to perform - std::string Action; - - // The text area associated with the form - std::vector Entries; - }; - std::vector _Forms; - std::vector _Groups; - - // Cells parameters - class CCellParams - { - public: - CCellParams () : BgColor(0,0,0,0) - { - Align = CGroupCell::Left; - VAlign = CGroupCell::Top; - LeftMargin = 0; - NoWrap = false; - } - NLMISC::CRGBA BgColor; - std::string Style; - CGroupCell::TAlign Align; - CGroupCell::TVAlign VAlign; - sint32 LeftMargin; - bool NoWrap; - }; - std::vector _CellParams; - - // Indentation - uint _Indent; - - // Current node is a title - bool _Title; - - // Current node must be localized - bool _Localize; - - // Current node is a text area - bool _TextArea; - std::string _TextAreaTemplate; - ucstring _TextAreaContent; - std::string _TextAreaName; - uint _TextAreaRow; - uint _TextAreaCols; - - // current mode is in select option - bool _SelectOption; - ucstring _SelectOptionStr; - - // Current node is a object - std::string _ObjectType; - std::string _ObjectData; - std::string _ObjectMD5Sum; - std::string _ObjectAction; - std::string _TextAreaScript; - - // Get last char - ucchar getLastChar() const; - - // Current link view - class CViewLink *_CurrentViewLink; - class CViewBitmap *_CurrentViewImage; - - // Current group table - class CGroupCell *_CurrentCell; - - // The main group - class CGroupListAdaptor *_GroupListAdaptor; - - // For auto selecting the node in a BrowseTree bound to this HTML web page - std::string _BrowseTree; - // select the tree node that has the correct url - const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url); - // search if the action / params match the url. look recurs into procedures - bool actionLaunchUrlRecurs(const std::string &ah, const std::string ¶ms, const std::string &url); - - // Browse undo and redo - enum {MaxUrlUndoRedo= 256}; - std::string _BrowseUndoButton; - std::string _BrowseRedoButton; - std::string _BrowseRefreshButton; - // _BrowseUrl is different from _URL, in that _URL may change in handle() - std::string _AskedUrl; - std::deque _BrowseUndo; - std::deque _BrowseRedo; - void pushUrlUndoRedo(const std::string &url); - void doBrowse(const char *url); - void updateUndoRedoButtons(); - void updateRefreshButton(); - - // For Killing request. Associate each CGroupHTML object with a unique ID. - uint32 _GroupHtmlUID; - static uint32 _GroupHtmlUIDPool; - typedef std::map > TGroupHtmlByUIDMap; - static TGroupHtmlByUIDMap _GroupHtmlByUID; - -private: - - // decode all HTML entities - static ucstring decodeHTMLEntities(const ucstring &str); - - // ImageDownload system - enum TDataType {ImgType= 0, BnpType}; - - struct CDataDownload - { - CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f) - { - if (t == ImgType) imgs.push_back(i); - } - - CURL *curl; - std::string url; - std::string luaScript; - std::string md5sum; - TDataType type; - FILE *fp; - std::vector imgs; - }; - - std::vector Curls; - CURLM *MultiCurl; - int RunningCurls; - - void initImageDownload(); - void checkImageDownload(); - void addImageDownload(const std::string &url, CViewBase *img); - std::string localImageName(const std::string &url); - - bool isTrustedDomain(const std::string &domain); - void setImage(CViewBase *view, const std::string &file); - - // BnpDownload system - void initBnpDownload(); - void checkBnpDownload(); - bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum); - std::string localBnpName(const std::string &url); - - void releaseDownloads(); - void checkDownloads(); - -}; - -// adapter group that store y offset for inputs inside an html form -class CGroupHTMLInputOffset : public CInterfaceGroup -{ -public: - sint32 Offset; - CGroupHTMLInputOffset(const TCtorParam ¶m); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); -}; - -#endif diff --git a/code/ryzom/client/src/interface_v3/group_html_cs.h b/code/ryzom/client/src/interface_v3/group_html_cs.h index e3c8a765e..9d322ad54 100644 --- a/code/ryzom/client/src/interface_v3/group_html_cs.h +++ b/code/ryzom/client/src/interface_v3/group_html_cs.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_CS_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_forum.h b/code/ryzom/client/src/interface_v3/group_html_forum.h index fe233fecc..c3a0bcbf6 100644 --- a/code/ryzom/client/src/interface_v3/group_html_forum.h +++ b/code/ryzom/client/src/interface_v3/group_html_forum.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_FORUM_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_mail.h b/code/ryzom/client/src/interface_v3/group_html_mail.h index 51f363c3c..5477be085 100644 --- a/code/ryzom/client/src/interface_v3/group_html_mail.h +++ b/code/ryzom/client/src/interface_v3/group_html_mail.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_MAIL_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_qcm.h b/code/ryzom/client/src/interface_v3/group_html_qcm.h index 61f763f8c..21607dced 100644 --- a/code/ryzom/client/src/interface_v3/group_html_qcm.h +++ b/code/ryzom/client/src/interface_v3/group_html_qcm.h @@ -21,7 +21,7 @@ #define CL_GROUP_HTML_QCM_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.h b/code/ryzom/client/src/interface_v3/group_html_webig.h index 5967f671d..a0a71a27f 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.h +++ b/code/ryzom/client/src/interface_v3/group_html_webig.h @@ -18,7 +18,7 @@ #define CL_GROUP_HTML_WEBIG_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** * Auth HTML group diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 97777043d..9d2413f20 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -23,7 +23,7 @@ #include "../character_cl.h" #include "nel/gui/action_handler.h" #include "../entities.h" -#include "group_paragraph.h" // For CCtrlLink +#include "nel/gui/group_paragraph.h" // For CCtrlLink #include "../net_manager.h" #include "../string_manager_client.h" #include "../login.h" diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp deleted file mode 100644 index 0ad38ec64..000000000 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ /dev/null @@ -1,1223 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "group_paragraph.h" -#include "group_html.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_element.h" -#include "nel/gui/view_pointer_base.h" -#include "nel/gui/view_bitmap.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/group_container.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/i18n.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); - -// ---------------------------------------------------------------------------- -CGroupParagraph::CGroupParagraph(const TCtorParam ¶m) -: CInterfaceGroup(param), - _Templ(TCtorParam()) -{ - _IdCounter = 0; - _AddElt = Bottom; - _Align = Left; - _Space = 0; - _MinW= 0; - _MinH= 0; - _Over = false; - _OverColor = CRGBA(255,255,255,32); - _OverElt = -1; - _LastW = 0; - invalidateContent(); - _TopSpace = 0; - _Indent = 0; - _FirstViewIndentView = false; - _BrowseGroup = NULL; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addChild (CViewBase* child, bool deleteOnRemove) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return; - } - - // add child at last index - addChildAtIndex(child, (uint)_Elements.size(), deleteOnRemove); - if (_Elements.size() >= 2) - { - setOrder((uint)_Elements.size() - 1, getOrder((uint)_Elements.size() - 2) + 1); - } - invalidateContent(); -} - -// ---------------------------------------------------------------------------- -CGroupParagraph::~CGroupParagraph() -{ - deleteAllChildren(); -} - -// ---------------------------------------------------------------------------- -// Set Hotspot of the first element in reference to the group -/*void CGroupParagraph::setHSGroup (CViewBase *child, EAlign addElt, EAlign align) -{ - switch (addElt) - { - case Bottom: - if (align == Left) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - break; - case Left: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TR; - child->_PosRef = Hotspot_TR; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Top: - if (align == Left) - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - else // align == Right - { - child->_ParentPosRef = Hotspot_BR; - child->_PosRef = Hotspot_BR; - } - break; - case Right: - if (align == Top) - { - child->_ParentPosRef = Hotspot_TL; - child->_PosRef = Hotspot_TL; - } - else // align == Bottom - { - child->_ParentPosRef = Hotspot_BL; - child->_PosRef = Hotspot_BL; - } - break; - default: - nlassert(false); - break; - } -}*/ - -// ---------------------------------------------------------------------------- -/** align an element towards its parent in the group - */ -/*void CGroupParagraph::setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space) -{ - if ((addElt == Top) || (addElt == Bottom)) - { - if (addElt == Bottom) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_BL; - else // align == Right - view->_ParentPosRef = Hotspot_BR; - view->_Y = -abs(space); - } - else if (addElt == Top) - { - if (_Align == Left) - view->_ParentPosRef = Hotspot_TL; - else // align == Right - view->_ParentPosRef = Hotspot_TR; - view->_Y = abs(space); - } - } - else - { - if (addElt == Left) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TL; - else // align == Bottom - view->_ParentPosRef = Hotspot_BL; - view->_X = -abs(space); - } - else if (addElt == Right) - { - if (_Align == Top) - view->_ParentPosRef = Hotspot_TR; - else // align == Bottom - view->_ParentPosRef = Hotspot_BR; - view->_X = abs(space); - } - } -}*/ - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if (!CInterfaceGroup::parse(cur,parentGroup)) - return false; - - // Parse location. If these properties are not specified, set them to 0 - - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"addelt" )); - _AddElt = Bottom; - if (ptr) - { - if (stricmp(ptr,"B") == 0) - _AddElt = Bottom; - else if (stricmp(ptr,"T") == 0) - _AddElt = Top; - else if (stricmp(ptr,"L") == 0) - _AddElt = Left; - else if (stricmp(ptr,"R") == 0) - _AddElt = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"align" ); - _Align = Left; - if (ptr) - { - if (stricmp(ptr,"B") == 0) - _Align = Bottom; - else if (stricmp(ptr,"T") == 0) - _Align = Top; - else if (stricmp(ptr,"L") == 0) - _Align = Left; - else if (stricmp(ptr,"R") == 0) - _Align = Right; - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"space" ); - _Space = 0; - if (ptr) - fromString((const char*)ptr, _Space); - - EAlign addElt = _AddElt; -// EAlign align = _Align; - _GroupSizeRef = _SizeRef; - if ((addElt == Top) || (addElt == Bottom)) - { - setMaxW (_W); - setMaxH(_H); - _H = 0; - _SizeRef = _SizeRef&(~2); - } - else - { - setMaxW (_W); - setMaxH (_H); - _W = 0; - _SizeRef = _SizeRef&(~1); - } - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"over" ); - _Over = false; - if (ptr) _Over = convertBool(ptr); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"col_over" ); - _OverColor = CRGBA(255,255,255,32); - if (ptr) _OverColor = convertColor(ptr); - - - // TEMPLATE TEXT SETUP - - // justification parameters - _Templ.parseTextOptions (cur); - - // initial text - ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (ptr) - { - const char *propPtr = ptr; - ucstring Text = ucstring(propPtr); - if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i')) - Text = CI18N::get (propPtr); - - addTextChild(Text); - } - else - { - ptr = (char*) xmlGetProp( cur, (xmlChar*)"textid" ); - if (ptr) - { - uint32 textId; - fromString((const char*)ptr, textId); - addTextChildID(textId); - } - } - - return true; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChild(const ucstring& line, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - view->setTextMode(_Templ.getTextMode()); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChild(const ucstring& line, const CRGBA& textColor, bool multiLine /*= true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewText *view= new CViewText (elid, string(""), _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - view->setText (line); - view->setColor (textColor); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChildID (uint32 nID, bool multiLine) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, nID, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addTextChildID(const std::string &dbPath,bool multiLine /*=true*/) -{ - const string elid = _Id + ":el" + toString(_IdCounter); ++_IdCounter; - CViewTextID *view= new CViewTextID (elid, dbPath, _Templ.getFontSize(), _Templ.getColor(), _Templ.getShadow()); - view->_Parent = this; - view->setMultiLine (multiLine); - if (multiLine) view->setMultiLineSpace (_Space); - // Herit global-coloring - view->setModulateGlobalColor(getModulateGlobalColor()); - addChild (view); - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::delChild (CViewBase* childToDel) -{ - // Look for child - uint posChildToDel = 0; - for (posChildToDel = 0; posChildToDel < _Elements.size(); ++posChildToDel) - { - CElementInfo rEI = _Elements[posChildToDel]; - if (rEI.Element == childToDel) - break; - } - - if (posChildToDel == _Elements.size()) - { - nlwarning("Can't del child %s, it does not exist in the list", childToDel->getId().c_str()); - return; - } - delChild(posChildToDel); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::delChild(uint posChildToDel) -{ - if (posChildToDel >= (uint) _Elements.size()) - { - nlwarning(" bad index"); - return; - } - - CViewBase* childToDel = _Elements[posChildToDel].Element; - bool ElementMustBeDeleted = _Elements[posChildToDel].EltDeleteOnRemove; - _Elements.erase (_Elements.begin()+posChildToDel); - // Remove from drawing - if (dynamic_cast(childToDel)) delGroup(static_cast(childToDel), !ElementMustBeDeleted); - else if (dynamic_cast(childToDel)) delCtrl(static_cast(childToDel), !ElementMustBeDeleted); - else delView(childToDel, !ElementMustBeDeleted); - - // Bind the new first element - if (posChildToDel < _Elements.size()) - { - CViewBase *pVB = _Elements[posChildToDel].Element; - if (posChildToDel == 0) - { - pVB->_ParentPos = NULL; - // setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0); - } - else - pVB->_ParentPos = _Elements[posChildToDel-1].Element; - } -} - -// ---------------------------------------------------------------------------- -/*void CGroupParagraph::removeHead () -{ - if (_Elements.empty()) - { - nlwarning(" Can't remove head, list is empty"); - return; - } - delChild (_Elements.begin()->Element);*/ - /*CViewBase *pVB = _Elements.begin()->Element; - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - sint32 shift = _H - (pVB->getH() + _Space); - _H = shift; - } - else - { - sint32 shift = _W - (pVB->getW() + _Space); - _W = shift; - } - - bool FirstElementMustBeDeleted = _Elements.begin()->EltDeleteOnRemove; - if (FirstElementMustBeDeleted) - delete pVB; - _Elements.erase (_Elements.begin()); - // Remove from drawing - for (vector::iterator itg = _ChildrenGroups.begin(); itg != _ChildrenGroups.end(); itg++) - if(*itg == pVB) - { - _ChildrenGroups.erase (itg); - break; - } - for (vector::iterator itc = _Controls.begin(); itc != _Controls.end(); itc++) - if(*itc == pVB) - { - _Controls.erase (itc); - break; - } - for (vector::iterator itv = _Views.begin(); itv != _Views.end(); itv++) - if(*itv == pVB) - { - _Views.erase (itv); - break; - } - delEltOrder (pVB); - - // Bind the new first element - pVB = _Elements.begin()->Element; - pVB->_ParentPos = NULL; - setHSGroup (pVB, _AddElt, _Align); - if ((_AddElt == Top) || (_AddElt == Bottom)) - pVB->setY (0); - else - pVB->setX (0);*/ -//} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setTextTemplate(const CViewText& templ) -{ - _Templ = templ; -} - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::updateCoords() -{ - if (_Parent) - { - if (!_ContentValidated) - { - // Update W - CInterfaceElement::updateCoords(); - - // Current X and Y - sint32 x=_Indent; - sint32 y=-(sint32)_TopSpace; - - // Current W - sint width = std::min(getMaxWReal(), getWReal()); - - // For each elements, place them - uint firstElementOnLine = 0; - const uint elmCount = (uint)_Elements.size(); - uint i; - for (i = 0; i < elmCount+1; ++i) - { - // Force flush for the last element - bool changeLine = (i == elmCount); - uint lastLineElement = i+1; - - // Not the end of the element - if (i < elmCount) - { - // Active element ? - if (_Elements[i].Element->getActive()) - { - _Elements[i].Element->updateCoords(); - // Is a view text ? - CViewText *viewText = dynamic_cast(_Elements[i].Element); - if (viewText) - { - viewText->setFirstLineX(x + ((i==0)?_FirstViewIndentView:0)); - viewText->setX(0); - viewText->updateTextContext(); - } - else - { - _Elements[i].Element->setX(x + ((i==0)?_FirstViewIndentView:0)); - } - _Elements[i].Element->setPosRef(Hotspot_TL); - _Elements[i].Element->setParentPosRef(Hotspot_TL); - - // Update coords for this element - _Elements[i].Element->updateCoords(); - - // Does we balance the last line height ? - if (viewText) - { - changeLine = viewText->getNumLine() > 1; - if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n') - { - changeLine = true; - } - } - else - { - // If this element is too big for the line, place it next time - if ((i!=firstElementOnLine) && ((_Elements[i].Element->getX() + _Elements[i].Element->getW()) > width)) - { - lastLineElement--; - changeLine = true; - i--; - } - } - - - // New x coordinate - x = _Elements[i].Element->getX() + _Elements[i].Element->getWReal(); - } - } - else - lastLineElement = i; - - // Balance line height - if (changeLine) - { - // Eval line height - uint j; - uint lineHeight = 0; - uint multiLineHeight = 0; - uint legHeight = 0; - uint lastLineWidth = _Indent; - - for (j=firstElementOnLine; j(_Elements[j].Element); - - // Element height - if (viewTextOnLine) - { - // Height is just under the first line letter - newHeight = viewTextOnLine->getFontHeight() - viewTextOnLine->getFontLegHeight(); - - // Leg height for this view - legHeight = std::max(legHeight, viewTextOnLine->getFontLegHeight()); - - // Last element is a text multi line - if (j==(lastLineElement-1)) - { - const uint numLine = viewTextOnLine->getNumLine(); - if (numLine>1) - { - multiLineHeight = (numLine-2) * viewTextOnLine->getFontHeight() + (numLine-1) * viewTextOnLine->getMultiLineSpace(); - lastLineWidth = _Indent + viewTextOnLine->getLastLineW (); - } - } - } - else - { - newHeight = _Elements[j].Element->getH(); - CGroupHTMLInputOffset *inputOffset = dynamic_cast(_Elements[j].Element); - if (inputOffset && inputOffset->Offset < 0) - { - newHeight += inputOffset->Offset; - legHeight = max(-(inputOffset->Offset), sint32(legHeight)); - } - } - - if (lineHeight < newHeight) - lineHeight = newHeight; - } - - // Repos element on the line - for (j=firstElementOnLine; j(_Elements[j].Element); - - sint32 offsetY=0; - CGroupHTMLInputOffset *inputOffset = dynamic_cast(_Elements[j].Element); - if (inputOffset) - offsetY = inputOffset->Offset; - // Element height - if (viewTextOnLine) - newHeight = viewTextOnLine->getFontHeight() - viewTextOnLine->getFontLegHeight() - offsetY; - else - newHeight = _Elements[j].Element->getH(); - - sint32 posY = y-lineHeight+newHeight+offsetY; - _Elements[j].Element->setY(posY); - } - - if (i < elmCount) - { - nlassert(lastLineElement>0); - nlassert(lastLineElement-1getNumLine()); - - // Number of line.. - uint j; - for (j=0; j<3; j++) - { - if (jsetId(getId()+":"+"links"+toString(i)+"-"+toString(j)); - ctrl->setParent (this); - ctrl->setParentSize (this); - ctrl->setParentPos (this); - ctrl->setParentPosRef (Hotspot_TL); - ctrl->setPosRef (Hotspot_TL); - ctrl->setActive(true); - if (_BrowseGroup) - { - ctrl->setActionOnLeftClick("browse"); - ctrl->setParamsOnLeftClick("name="+_BrowseGroup->getId()+"|url="+link.Link->Link); - } - ctrl->setScale(true); - addCtrl(ctrl); - } - - // Pos the links - int x, y, width, height; - int fontSize = link.Link->getFontHeight(); - int fontLineSpace = link.Link->getMultiLineSpace(); - - // X - x = (j == 0) ? link.Link->getFirstLineX() : link.Link->getX(); - - // Y - if (j < 2) - y = link.Link->getY() - (fontSize+fontLineSpace) * j; - else - y = link.Link->getY() - ((fontSize+fontLineSpace) * (link.Link->getNumLine()-1)); - - // Width - - // Last line ? - if (j == (links-1)) - width = link.Link->getLastLineW (); - else - { - width = link.Link->getW(); - - // First line ? - if (j == 0) - width -= (link.Link->getFirstLineX() - link.Link->getX()); - } - - if ((j == 1) && (links==3)) - height = (fontSize+fontLineSpace)*(link.Link->getNumLine()-2); - else - height = fontSize; - - ctrl->setX(x); - ctrl->setY(y); - ctrl->setW(width); - ctrl->setH(height); - } - else - { - if (link.CtrlLink[j]) - { - delCtrl (link.CtrlLink[j]); - link.CtrlLink[j] = NULL; - } - } - } - } - } - } - CInterfaceGroup::updateCoords(); - - // Validated - _ContentValidated = true; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::checkCoords () -{ - if (_Parent != NULL) - { - sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); - if (_LastW != (sint) parentWidth) - { - CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); - if (pCB != NULL) - { - CCtrlResizer *pCR = dynamic_cast(pCB); - if (pCR != NULL) - { - // We are resizing !!!! - } - else - { - _LastW = parentWidth; - invalidateContent(); - } - } - else - { - _LastW = parentWidth; - invalidateContent(); - } - } - } - CInterfaceGroup::checkCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::draw () -{ - // TEMP TEMP - //CViewRenderer &rVR = *CViewRenderer::getInstance(); - //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); - if (_Over) - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if (CWidgetManager::getInstance()->getModalWindow() == NULL) - { - sint32 x = CWidgetManager::getInstance()->getPointer()->getX(); - sint32 y = CWidgetManager::getInstance()->getPointer()->getY(); - - CInterfaceGroup *pIG = CWidgetManager::getInstance()->getWindowUnder(x,y); - CInterfaceGroup *pParent = this; - bool bFound = false; - while (pParent != NULL) - { - if (pParent == pIG) - { - bFound = true; - break; - } - pParent = pParent->getParent(); - } - - sint32 clipx,clipy,clipw,cliph; - getClip(clipx,clipy,clipw,cliph); - if ((x < clipx) || - (x > (clipx + clipw)) || - (y < clipy) || - (y > (clipy + cliph)) || !bFound) - { - _OverElt = -1; - } - else - { - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((x >= pVB->getXReal()) && - (x < (pVB->getXReal() + pVB->getWReal()))&& - (y >= pVB->getYReal()) && - (y < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - } - - if (_OverElt != -1) - { - CViewBase *pVB = _Elements[_OverElt].Element; - CRGBA col = _OverColor; - if(getModulateGlobalColor()) - { - col.modulateFromColor (_OverColor, CWidgetManager::getInstance()->getGlobalColorForContent()); - } - else - { - col= _OverColor; - col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8); - } - rVR.drawRotFlipBitmap (_RenderLayer, pVB->getXReal(), pVB->getYReal(), - pVB->getWReal(), pVB->getHReal(), 0, false, rVR.getBlankTextureId(), - col ); - - } - } - - CInterfaceGroup::draw (); -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::handleEvent (const NLGUI::CEventDescriptor& event) -{ - if (!_Active) - return false; - - bool bReturn = CInterfaceGroup::handleEvent(event); - - if (event.getType() == NLGUI::CEventDescriptor::mouse) - { - const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; - - _OverElt = -1; - if (!isIn(eventDesc.getX(), eventDesc.getY())) - return false; - - for (uint32 i = 0; i < _Elements.size(); ++i) - if (_Elements[i].Element->getActive()) - { - CViewBase *pVB = _Elements[i].Element; - if ((eventDesc.getX() >= pVB->getXReal()) && - (eventDesc.getX() < (pVB->getXReal() + pVB->getWReal()))&& - (eventDesc.getY() >= pVB->getYReal()) && - (eventDesc.getY() < (pVB->getYReal() + pVB->getHReal()))) - { - _OverElt = i; - } - } - } - - return bReturn; -} - - - -// predicate to remove a view from the list of element -struct CRemoveViewPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a ctrl from the list of element -struct CRemoveCtrlPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - -// predicate to remove a group from the list of element -struct CRemoveGroupPred -{ - bool operator()(const CGroupParagraph::CElementInfo &info) const { return dynamic_cast(info.Element) != NULL; } -}; - - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearViews() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveViewPred()), _Elements.end()); - CInterfaceGroup::clearViews(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearControls() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveCtrlPred()), _Elements.end()); - CInterfaceGroup::clearControls(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::clearGroups() -{ - _IdCounter = 0; - // remove views from the list of elements - _Elements.erase(std::remove_if(_Elements.begin(), _Elements.end(), CRemoveGroupPred()), _Elements.end()); - CInterfaceGroup::clearGroups(); - updateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::forceSizeW (sint32 newSizeW) -{ - _W = newSizeW; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setW (_W); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::forceSizeH (sint32 newSizeH) -{ - _H = newSizeH; - for (uint32 i = 0; i < _Elements.size(); ++i) - { - _Elements[i].Element->setH (_H); - _Elements[i].Element->CInterfaceElement::updateCoords(); - } -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setMinW(sint32 minW) -{ - _MinW= minW; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setMinH(sint32 minH) -{ - _MinH= minH; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove /*=true*/) -{ - if (!child) - { - nlwarning(" : tried to add a NULL view"); - return false; - } - if (index > _Elements.size()) - { - return false; - } - child->_Parent = this; - child->_ParentPos = NULL; - child->_Active = true; - child->_X = 0; - child->_Y = 0; - child->_RenderLayer = this->_RenderLayer; - // Can't have sizeref on the coordinate corresponding to alignement - switch(_AddElt) - { - case Top: - case Bottom: - child->_SizeRef &= 1; // sizeref on w is permitted - break; - case Left: - case Right: - child->_SizeRef &= 2; // sizeref on h is permitted - break; - default: - nlwarning(" bad align"); - child->_SizeRef = 0; - break; - } - - child->_SizeDivW = 10; - child->_SizeDivH = 10; - - // Position the element according to the list alignement - // setHSGroup (child, _AddElt, _Align); - - // update coords of the element (it may use child_resize_h or w) - //child->updateCoords(); - child->invalidateCoords(); - - // Update size - if ((_AddElt == Top) || (_AddElt == Bottom)) - { - // update the list size - sint32 newH = _H + child->getH(); - if (_Elements.size() > 0) - newH += _Space; - _H = newH; - - if ((_SizeRef&1) == 0) // No parent size reference in W - { - sint32 newW = max (_W, child->getW()); - _W = newW; - } - } - else - { - // Update the list coords - sint32 newW = _W + child->getW(); - if (_Elements.size() > 0) - newW += _Space; - _W = newW; - - if ((_SizeRef&2) == 0) // No parent size reference in H - { - sint32 newH = max (_H, child->getH()); - _H = newH; - } - } - - CElementInfo ei; - ei.Element = child; - ei.EltDeleteOnRemove = deleteOnRemove; - ei.Order = 0; - - if (index != 0) - { - // update alignement - // setHSParent(child, _AddElt, _Align, _Space); - // child->_ParentPos = _Elements[index - 1].Element; - } - _Elements.insert(_Elements.begin() + index, ei); - // link next element to this one - if (index < _Elements.size() - 1) - { - // _Elements[index + 1].Element->_ParentPos = child; - // setHSParent(_Elements[index + 1].Element, _AddElt, _Align, _Space); - } - - // Add this element for drawing - { - CInterfaceGroup *pIG = dynamic_cast(child); - if (pIG != NULL) - { - addGroup (pIG, (sint) index); - return true; - } - CCtrlBase *pCB = dynamic_cast(child); - if (pCB != NULL) - { - addCtrl (pCB, (sint) index); - return true; - } - CViewBase *pVB = dynamic_cast(child); - if (pVB != NULL) - { - addView (pVB, (sint) index); - return true; - } - nlstop; - return false; - } - return false; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getElementIndex(CViewBase* child) const -{ - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element == child) return k; - } - return -1; -} - -// ---------------------------------------------------------------------------- -/*void CGroupParagraph::swapChildren(uint index1, uint index2) -{ - if (index1 >= _Elements.size() - || index2 >= _Elements.size()) - { - nlwarning(" bad indexes"); - return; - } - // prevent elements from being deleted - bool oldMustDelete1 = _Elements[index1].EltDeleteOnRemove; - bool oldMustDelete2 = _Elements[index2].EltDeleteOnRemove; - - uint order1 = _Elements[index1].Order; - uint order2 = _Elements[index2].Order; - - _Elements[index1].EltDeleteOnRemove = false; - _Elements[index2].EltDeleteOnRemove = false; - - CViewBase *v1 = _Elements[index1].Element; - CViewBase *v2 = _Elements[index2].Element; - - - if (index1 < index2) - { - delChild(index2); - delChild(index1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - } - else - { - delChild(index1); - delChild(index2); - addChildAtIndex(v1, index2, oldMustDelete1); - setOrder(index2, order1); - addChildAtIndex(v2, index1, oldMustDelete2); - setOrder(index1, order2); - } -}*/ - -// ---------------------------------------------------------------------------- -void CGroupParagraph::deleteAllChildren() -{ - uint numChildren = getNbElement(); - for(uint k = 0; k < numChildren; ++k) - { - delChild(numChildren - 1 - k); // delete in reverse order to avoid unnecessary vector copies - } -} - -// ---------------------------------------------------------------------------- -uint CGroupParagraph::getNumActiveChildren() const -{ - uint numChildren = 0; - for(uint k = 0; k < _Elements.size(); ++k) - { - if (_Elements[k].Element->getActive()) ++numChildren; - } - return numChildren; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::setDelOnRemove(uint index, bool delOnRemove) -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return; - } - _Elements[index].EltDeleteOnRemove = delOnRemove; -} - -// ---------------------------------------------------------------------------- -bool CGroupParagraph::getDelOnRemove(uint index) const -{ - if (index >= _Elements.size()) - { - nlwarning("bad index"); - return false; - } - return _Elements[index].EltDeleteOnRemove; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::addChildLink (CViewLink* child, bool deleteOnRemove) -{ - // Add the child - addChild (child, deleteOnRemove); - - // Add the link - _Links.push_back (CLink(child)); -} - -// ---------------------------------------------------------------------------- -CGroupParagraph::CLink::CLink (CViewLink *link) -{ - Link = link; - CtrlLink[0] = NULL; - CtrlLink[1] = NULL; - CtrlLink[2] = NULL; -} - -// ---------------------------------------------------------------------------- -void CGroupParagraph::onInvalidateContent() -{ - _ContentValidated = false; - invalidateCoords(); -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getMaxUsedW() const -{ - // The paragraph max is the sum of the components max - sint maxWidth = 0; - for (uint k = 0; k < _Elements.size(); ++k) - { - // Get the child width - maxWidth += _Elements[k].Element->getMaxUsedW(); - } - return maxWidth; -} - -// ---------------------------------------------------------------------------- -sint32 CGroupParagraph::getMinUsedW() const -{ - // The paragraph min is the max of the components min - sint32 minWidth = 0; - for (uint k = 0; k < _Elements.size(); ++k) - { - // Get the child width - sint32 width = _Elements[k].Element->getMinUsedW(); - if (width > minWidth) - minWidth = width; - } - return minWidth; -} - diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h deleted file mode 100644 index ce13eb6c3..000000000 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ /dev/null @@ -1,299 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 NL_GROUP_PARAGRAPH_H -#define NL_GROUP_PARAGRAPH_H - -#include "nel/misc/types_nl.h" -#include "nel/gui/group_frame.h" -#include "nel/gui/view_text.h" -#include "view_link.h" -#include "nel/gui/ctrl_button.h" - -class CCtrlLink : public CCtrlButton -{ -public: - CCtrlLink (const TCtorParam ¶m) : CCtrlButton(param) - {} -}; - -// ---------------------------------------------------------------------------- -class CGroupParagraph : public CInterfaceGroup -{ -public: - enum EAlign - { - Bottom = 0, - Top, - Left, - Right - }; - - ///constructor - CGroupParagraph(const TCtorParam ¶m); - - // dtor - ~CGroupParagraph(); - - /** - * add a child element to the group at the last position - * 'order' of the element is set to the last order + 1 - * \param child : pointer to the child element - */ - void addChild (CViewBase* child, bool deleteOnRemove=true); - - /** - * add a link element to the group at the last position - * \param child : pointer to the child element - */ - void addChildLink (CViewLink* child, bool deleteOnRemove=true); - - /** add a child before the element at the given index. - * 'order' of the element is set to 0 - * \return true if there was enough room for that child - */ - bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - * \param color : text color - */ - void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true); - - /** - * add a text child element to the group, using the text template - * \param line : text to be added - */ - void addTextChild (const ucstring& line, bool multiLine = true); - - /// Same as adding a text child but the text will be taken from the string manager - void addTextChildID (uint32 id, bool multiLine = true); - // the same, but with id taken from the database - void addTextChildID (const std::string &dbPath, bool multiLine = true); - -protected: - - void delChild (CViewBase* child); - - void delChild(uint index); - -public: - - CViewBase *getChild(uint index) const { return _Elements[index].Element; } - - void deleteAllChildren(); - - // void removeHead(); - - // Get the number of children - uint getNumChildren() const { return (uint)_Elements.size(); } - - // Get the number of active children - uint getNumActiveChildren() const; - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - void setTextTemplate(const CViewText& templ); - - /** - * set the template that will be used to add text; - * \templ : a CViewText object. Only its font size, color and shadow are required. - */ - CViewText * getTextTemplatePtr() - { - return &_Templ; - } - - /** - * parse the element and initalize it - * \paral cur : pointer to the node describing this element - * \param parentGroup : the parent group of this element - * \return true if success - */ - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - //virtual uint32 getMemory(); - /** - * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here - */ - virtual void updateCoords(); - - virtual void checkCoords(); - - virtual void draw(); - - virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); - - virtual void clearViews(); - virtual void clearControls(); - virtual void clearGroups(); - - void setSpace (sint32 s) { _Space = s; } - - virtual CInterfaceElement* getElement (const std::string &id) - { return CInterfaceGroup::getElement (id); } - - sint32 getNbElement() { return (sint32)_Elements.size(); } - sint32 getSpace() { return _Space; } - - void forceSizeW (sint32 newSizeW); - void forceSizeH (sint32 newSizeH); - - void setMinW(sint32 minW); - void setMinH(sint32 minH); - sint32 getMinW() const {return _MinW;} - sint32 getMinH() const {return _MinH;} - - // set the rank for the element at the given index (used to reinsert container after they have been turned into popups) - void setOrder(uint index, uint order) { _Elements[index].Order = order; } - uint getOrder(uint index) const { return _Elements[index].Order; } - - // get element of index or -1 if not found - sint32 getElementIndex(CViewBase* child) const; - - // swap 2 entries in the list (and also their orders) - // void swapChildren(uint index1, uint index2); - - // deleteOnRemove flag - void setDelOnRemove(uint index, bool delOnRemove); - bool getDelOnRemove(uint index) const; - - void setTopSpace(uint topSpace) - { - _TopSpace = topSpace; - setResizeFromChildHMargin(topSpace); - invalidateContent(); - }; - - uint getTopSpace() - { - return _TopSpace; - }; - - void setIndent(uint indent) { _Indent = indent; } - - void setFirstViewIndent(sint indent) - { - _FirstViewIndentView = indent; - invalidateContent(); - } - - // Set the HTML group used for links - void setBrowseGroup (CInterfaceElement *group) - { - _BrowseGroup = group; - } - - /// \from CInterfaceElement - void onInvalidateContent(); - sint32 getMaxUsedW() const; - sint32 getMinUsedW() const; - -protected: - - // Content validated - bool _ContentValidated; - - // Where to add next element - EAlign _AddElt; - - // Where to align the newly added element - EAlign _Align; - - // Space between two elements in pixel - sint32 _Space; - - // Text template - CViewText _Templ; - - // Current id of the view - sint32 _IdCounter; - - // Do we have a color under the element pointed by the mouse - bool _Over; - - // If over is true so we have a color - NLMISC::CRGBA _OverColor; - - // Current elt over the pointer - sint32 _OverElt; - - struct CElementInfo - { - uint Order; // Used to sort the window by their insertion order. - // This is used to put back a window at the right place if it was turned into a popup. - CViewBase *Element; - bool EltDeleteOnRemove; - }; - friend struct CRemoveViewPred; - friend struct CRemoveCtrlPred; - friend struct CRemoveGroupPred; - - // The list is forced to be at least this size in updateCoords(). - sint32 _MinW; - sint32 _MinH; - - - // To conserve elements in the order they have been added - // (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup - std::vector _Elements; - - // Last parent width - sint32 _LastW; - - // Top space - uint _TopSpace; - - // Indent - uint _Indent; // Left margin - sint _FirstViewIndentView; // Additionnal left margin for the first view - - // A link structure - class CLink - { - public: - - CLink(CViewLink *link); - - // The link view - CViewLink *Link; - - // The three control button - CCtrlLink *CtrlLink[3]; - }; - - // The links - std::vector _Links; - - // The HTML group used - CInterfaceElement *_BrowseGroup; - -private: - - // void setHSGroup (CViewBase *child, EAlign addElt, EAlign align); - // void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space); - -}; - -#endif // NL_GROUP_PARAGRAPH_H - -/* End of group_paragraph.h */ - - diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index d67cbeb5d..ea6b4e6a6 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -23,8 +23,8 @@ #include "group_quick_help.h" #include "nel/gui/group_list.h" -#include "group_paragraph.h" -#include "../libwww.h" +#include "nel/gui/group_paragraph.h" +#include "nel/gui/libwww.h" #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.h b/code/ryzom/client/src/interface_v3/group_quick_help.h index bef4bdd7e..05810fbeb 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.h +++ b/code/ryzom/client/src/interface_v3/group_quick_help.h @@ -21,7 +21,7 @@ #define CL_GROUP_QUICK_HELP_H #include "nel/misc/types_nl.h" -#include "group_html.h" +#include "nel/gui/group_html.h" /** diff --git a/code/ryzom/client/src/interface_v3/guild_manager.cpp b/code/ryzom/client/src/interface_v3/guild_manager.cpp index 63a120944..6b627330d 100644 --- a/code/ryzom/client/src/interface_v3/guild_manager.cpp +++ b/code/ryzom/client/src/interface_v3/guild_manager.cpp @@ -26,7 +26,7 @@ #include "dbctrl_sheet.h" #include "nel/gui/group_container.h" #include "nel/gui/group_menu.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "../init_main_loop.h" #include "inventory_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index b0308b5db..5a43ddbbb 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -70,7 +70,7 @@ #include "group_in_scene_bubble.h" #include "group_skills.h" #include "group_compas.h" -#include "group_html.h" +#include "nel/gui/group_html.h" // Misc #include "../input.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index b2ffddf3f..a65420c01 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -57,7 +57,7 @@ #include "nel/gui/ctrl_col_pick.h" #include "nel/gui/ctrl_tooltip.h" #include "nel/gui/ctrl_text_button.h" -#include "group_paragraph.h" // For CCtrlLink +#include "nel/gui/group_paragraph.h" // For CCtrlLink // DBCtrl #include "dbctrl_sheet.h" // Group diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 54892a61a..7b71fd3a5 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -60,7 +60,7 @@ #include "nel/misc/i18n.h" #include "nel/misc/time_nl.h" #include "skill_manager.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "../net_manager.h" #include "../user_entity.h" #include "sphrase_manager.h" diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 436e492e1..8c7d12dc5 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -49,7 +49,7 @@ #include "nel/gui/ctrl_scroll.h" #include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/group_tab.h" -#include "group_html.h" +#include "nel/gui/group_html.h" #include "nel/gui/group_header.h" #include "sphrase_manager.h" // diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 0b30cf47a..21c7bbd5f 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -21,8 +21,8 @@ #include "interface_manager.h" #include "nel/gui/view_renderer.h" #include "nel/gui/ctrl_col_pick.h" -#include "group_paragraph.h" -#include "group_html.h" +#include "nel/gui/group_paragraph.h" +#include "nel/gui/group_html.h" #include "group_map.h" // #include "nel/misc/xml_auto_ptr.h" diff --git a/code/ryzom/client/src/libwww.cpp b/code/ryzom/client/src/libwww.cpp deleted file mode 100644 index b2c699cd5..000000000 --- a/code/ryzom/client/src/libwww.cpp +++ /dev/null @@ -1,708 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - - -// LibWWW -extern "C" -{ -#include "WWWLib.h" /* Global Library Include file */ -#include "WWWApp.h" -#include "WWWInit.h" -} - -#include "interface_v3/group_html.h" -#include "interface_v3/libwww_nel_stream.h" - -using namespace NLMISC; - -/// the cookie value for session identification (nel cookie) -std::string CurrentCookie; - -/// store all cookies we receive and resent them depending of the domain -std::map > HTTPCookies; -std::string HTTPCurrentDomain; // The current domain that will be used to get which cookies to send - -// *************************************************************************** - -// The HText structure for libwww -struct _HText -{ - CGroupHTML *Parent; -}; - -// *************************************************************************** - -// Some DTD table - -// Here, modify the DTD table to change the HTML parser (add new tags for examples) - -#undef HTML_ATTR -#define HTML_ATTR(a,b) { (char*) #b } - -HTAttr a_attr[] = -{ - HTML_ATTR(A,ACCESSKEY), - HTML_ATTR(A,CHARSET), - HTML_ATTR(A,CLASS), - HTML_ATTR(A,COORDS), - HTML_ATTR(A,DIR), - HTML_ATTR(A,HREF), - HTML_ATTR(A,HREFLANG), - HTML_ATTR(A,ID), - HTML_ATTR(A,NAME), - HTML_ATTR(A,REL), - HTML_ATTR(A,REV), - HTML_ATTR(A,SHAPE), - HTML_ATTR(A,STYLE), - HTML_ATTR(A,TABINDEX), - HTML_ATTR(A,TARGET), - HTML_ATTR(A,TYPE), - HTML_ATTR(A,TITLE), - HTML_ATTR(A,Z_ACTION_CATEGORY), - HTML_ATTR(A,Z_ACTION_PARAMS), - HTML_ATTR(A,Z_ACTION_SHORTCUT), - { 0 } -}; - -HTAttr table_attr[] = -{ - HTML_ATTR(TABLE,ALIGN), - HTML_ATTR(TABLE,BGCOLOR), - HTML_ATTR(TABLE,BORDER), - HTML_ATTR(TABLE,CELLPADDING), - HTML_ATTR(TABLE,CELLSPACING), - HTML_ATTR(TABLE,CLASS), - HTML_ATTR(TABLE,DIR), - HTML_ATTR(TABLE,FRAME), - HTML_ATTR(TABLE,ID), - HTML_ATTR(TABLE,L_MARGIN), - HTML_ATTR(TABLE,LANG), - HTML_ATTR(TABLE,NOWRAP), - HTML_ATTR(TABLE,RULES), - HTML_ATTR(TABLE,SUMMARY), - HTML_ATTR(TABLE,STYLE), - HTML_ATTR(TABLE,TITLE), - HTML_ATTR(TABLE,VALIGN), - HTML_ATTR(TABLE,WIDTH), - { 0 } -}; - -HTAttr tr_attr[] = -{ - HTML_ATTR(TR,ALIGN), - HTML_ATTR(TR,BGCOLOR), - HTML_ATTR(TR,L_MARGIN), - HTML_ATTR(TR,NOWRAP), - HTML_ATTR(TR,VALIGN), - { 0 } -}; - -HTAttr td_attr[] = -{ - HTML_ATTR(TD,ABBR), - HTML_ATTR(TD,ALIGN), - HTML_ATTR(TD,AXIS), - HTML_ATTR(TD,BGCOLOR), - HTML_ATTR(TD,CHAR), - HTML_ATTR(TD,CHAROFF), - HTML_ATTR(TD,CLASS), - HTML_ATTR(TD,COLSPAN), - HTML_ATTR(TD,DIR), - HTML_ATTR(TD,ID), - HTML_ATTR(TD,HEADERS), - HTML_ATTR(TD,HEIGHT), - HTML_ATTR(TD,L_MARGIN), - HTML_ATTR(TD,LANG), - HTML_ATTR(TD,NOWRAP), - HTML_ATTR(TD,ROWSPAN), - HTML_ATTR(TD,SCOPE), - HTML_ATTR(TD,STYLE), - HTML_ATTR(TD,TITLE), - HTML_ATTR(TD,VALIGN), - HTML_ATTR(TD,WIDTH), - { 0 } -}; - -HTAttr img_attr[] = -{ - HTML_ATTR(IMG,ALIGN), - HTML_ATTR(IMG,ALT), - HTML_ATTR(IMG,BORDER), - HTML_ATTR(IMG,CLASS), - HTML_ATTR(IMG,DIR), - HTML_ATTR(IMG,GLOBAL_COLOR), - HTML_ATTR(IMG,HEIGHT), - HTML_ATTR(IMG,HSPACE), - HTML_ATTR(IMG,ID), - HTML_ATTR(IMG,ISMAP), - HTML_ATTR(IMG,LANG), - HTML_ATTR(IMG,LONGDESC), - HTML_ATTR(IMG,SRC), - HTML_ATTR(IMG,STYLE), - HTML_ATTR(IMG,TITLE), - HTML_ATTR(IMG,USEMAP), - HTML_ATTR(IMG,VSPACE), - HTML_ATTR(IMG,WIDTH), - { 0 } -}; - -HTAttr input_attr[] = -{ - HTML_ATTR(INPUT,ACCEPT), - HTML_ATTR(INPUT,ACCESSKEY), - HTML_ATTR(INPUT,ALIGN), - HTML_ATTR(INPUT,ALT), - HTML_ATTR(INPUT,CHECKED), - HTML_ATTR(INPUT,CLASS), - HTML_ATTR(INPUT,DIR), - HTML_ATTR(INPUT,DISABLED), - HTML_ATTR(INPUT,GLOBAL_COLOR), - HTML_ATTR(INPUT,ID), - HTML_ATTR(INPUT,LANG), - HTML_ATTR(INPUT,MAXLENGTH), - HTML_ATTR(INPUT,NAME), - HTML_ATTR(INPUT,READONLY), - HTML_ATTR(INPUT,SIZE), - HTML_ATTR(INPUT,SRC), - HTML_ATTR(INPUT,STYLE), - HTML_ATTR(INPUT,TABINDEX), - HTML_ATTR(INPUT,TITLE), - HTML_ATTR(INPUT,TYPE), - HTML_ATTR(INPUT,USEMAP), - HTML_ATTR(INPUT,VALUE), - HTML_ATTR(INPUT,Z_BTN_TMPL), - HTML_ATTR(INPUT,Z_INPUT_TMPL), - HTML_ATTR(INPUT,Z_INPUT_WIDTH), - { 0 } -}; - -HTAttr textarea_attr[] = -{ - HTML_ATTR(TEXTAREA,CLASS), - HTML_ATTR(TEXTAREA,COLS), - HTML_ATTR(TEXTAREA,DIR), - HTML_ATTR(TEXTAREA,DISABLED), - HTML_ATTR(TEXTAREA,ID), - HTML_ATTR(TEXTAREA,LANG), - HTML_ATTR(TEXTAREA,NAME), - HTML_ATTR(TEXTAREA,READONLY), - HTML_ATTR(TEXTAREA,ROWS), - HTML_ATTR(TEXTAREA,STYLE), - HTML_ATTR(TEXTAREA,TABINDEX), - HTML_ATTR(TEXTAREA,TITLE), - HTML_ATTR(TEXTAREA,Z_INPUT_TMPL), - { 0 } -}; - - -HTAttr p_attr[] = -{ - HTML_ATTR(P,QUICK_HELP_CONDITION), - HTML_ATTR(P,QUICK_HELP_EVENTS), - HTML_ATTR(P,QUICK_HELP_LINK), - HTML_ATTR(P,NAME), - { 0 } -}; - - -HTAttr div_attr[] = -{ - HTML_ATTR(DIV,CLASS), - HTML_ATTR(DIV,ID), - HTML_ATTR(DIV,NAME), - HTML_ATTR(DIV,STYLE), - { 0 } -}; - -// *************************************************************************** - -void _VerifyLibWWW(const char *function, bool ok, const char *file, int line) -{ - if (!ok) - nlwarning("%s(%d) : LIBWWW %s returned a bad status", file, line, function); -} -#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__) - -// *************************************************************************** - -int NelPrinter (const char * fmt, va_list pArgs) -{ - char info[1024]; - int ret; - - ret = vsnprintf(info, sizeof(info), fmt, pArgs); - nlinfo("%s", info); - return ret; -} - -// *************************************************************************** - -int NelTracer (const char * fmt, va_list pArgs) -{ - char err[1024]; - int ret; - - ret = vsnprintf(err, sizeof(err), fmt, pArgs); - nlwarning ("%s", err); - return ret; -} - -// *************************************************************************** - -HText * TextNew (HTRequest * request, - HTParentAnchor * /* anchor */, - HTStream * /* output_stream */) -{ - HText *text = new HText; - text->Parent = (CGroupHTML *) HTRequest_context(request); - return text; -} - -// *************************************************************************** - -BOOL TextDelete (HText * me) -{ - delete me; - return YES; -} - -// *************************************************************************** - -void TextBuild (HText * me, HTextStatus status) -{ - // Do the work in the class - if (status == HTEXT_BEGIN) - me->Parent->beginBuild (); - else if (status == HTEXT_END) - me->Parent->endBuild (); -} - -// *************************************************************************** - -void TextAdd (HText * me, const char * buf, int len) -{ - // Do the work in the class - me->Parent->addText (buf, len); -} - -// *************************************************************************** - -void TextLink (HText * me, - int element_number, - int attribute_number, - HTChildAnchor * anchor, - const BOOL * present, - const char ** value) -{ - // Do the work in the class - me->Parent->addLink (element_number, attribute_number, anchor, present, value); -} - -// *************************************************************************** - -// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false -bool getPercentage (sint32 &width, float &percent, const char *str) -{ - // Percent ? - const char *percentChar; - if ((percentChar = strchr (str, '%')) != NULL) - { - std::string toto = str; - toto = toto.substr (0, percentChar - str); - fromString(toto, percent); - percent /= 100.f; - return true; - } - else - { - fromString(str, width); - return false; - } -} - -// *************************************************************************** - -CRGBA getColor (const char *color) -{ - if (strlen (color) != 7 && strlen (color) != 9 ) - return CRGBA::White; - char tmp[3] = {0,0,0}; - CRGBA dst; - int value; - tmp[0] = color[1]; - tmp[1] = color[2]; - sscanf (tmp, "%x", &value); - dst.R = uint8(value); - tmp[0] = color[3]; - tmp[1] = color[4]; - sscanf (tmp, "%x", &value); - dst.G = uint8(value); - tmp[0] = color[5]; - tmp[1] = color[6]; - sscanf (tmp, "%x", &value); - dst.B = uint8(value); - if (strlen (color) == 9) - { - tmp[0] = color[7]; - tmp[1] = color[8]; - sscanf (tmp, "%x", &value); - dst.A = uint8(value); - } - else - { - // extension to html ; try to parse an additional alpha - dst.A = 255; - } - return dst; -} - -// *************************************************************************** - -void TextBeginElement (HText *me, int element_number, const BOOL *present, const char **value) -{ - // Do the work in the class - me->Parent->beginElement (element_number, present, value); -} - -// *************************************************************************** - -void TextEndElement (HText *me, int element_number) -{ - // Do the work in the class - me->Parent->endElement (element_number); -} - -// *************************************************************************** -void TextBeginUnparsedElement(HText *me, const char *buffer, int length) -{ - me->Parent->beginUnparsedElement(buffer, length); -} - -// *************************************************************************** -void TextEndUnparsedElement(HText *me, const char *buffer, int length) -{ - me->Parent->endUnparsedElement(buffer, length); -} - -// *************************************************************************** -void TextUnparsedEntity (HText * /* HText */, const char *buffer, int length) -{ - std::string str(buffer, buffer+length); - nlinfo("Unparsed entity '%s'", str.c_str()); -} - -// *************************************************************************** -int requestTerminater (HTRequest * request, HTResponse * /* response */, - void * param, int /* status */) -{ - /* - Yoyo and Boris: we had to make the request terminate by UID and not by pointer (param is an uid). - Because this method was called at mainLoop time, but for GroupHTML created/deleted at login time !!! - => Memory Crash. - */ - - // TestYoyo - //nlinfo("** requestTerminater(): uid%d", (uint32)param); - - // the parameter is actually an uint32 - if (param != 0) - { - CGroupHTML::TGroupHtmlByUIDMap::iterator it= CGroupHTML::_GroupHtmlByUID.find((uint32)(size_t)param); - if(it!=CGroupHTML::_GroupHtmlByUID.end()) - { - // get the pointer. NB: the refptr should not be NULL - // since object removed from map when deleted - CGroupHTML *gh = it->second; - nlassert(gh); - - // callback the browser - gh->requestTerminated(request); - } - } - return HT_OK; -} - - -// callback called when receiving a cookie -BOOL receiveCookie (HTRequest * /* request */, HTCookie * cookie, void * /* param */) -{ - if (strcmp(HTCookie_name(cookie), "ryzomId") == 0) - { - // we receive the ryzom id cookie, store it - CurrentCookie = HTCookie_value(cookie); - } - else - { - // store the id/value cookie - HTTPCookies[HTTPCurrentDomain][HTCookie_name(cookie)] = HTCookie_value(cookie); -// nlwarning("get cookie for domain %s %s=%s", HTTPCurrentDomain.c_str(), HTCookie_name(cookie), HTCookie_value(cookie)); - } - - return YES; -} - -// callback called to add cookie to a request before sending it to the server -HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */) -{ - HTAssocList * alist = 0; - if (!CurrentCookie.empty()) - { - if(alist == 0) alist = HTAssocList_new(); /* Is deleted by the cookie module */ - HTAssocList_addObject(alist, "ryzomId", CurrentCookie.c_str()); - } - - if(!HTTPCookies[HTTPCurrentDomain].empty()) - { - if(alist == 0) alist = HTAssocList_new(); - for(std::map::iterator it = HTTPCookies[HTTPCurrentDomain].begin(); it != HTTPCookies[HTTPCurrentDomain].end(); it++) - { - HTAssocList_addObject(alist, it->first.c_str(), it->second.c_str()); -// nlwarning("set cookie for domain '%s' %s=%s", HTTPCurrentDomain.c_str(), it->first.c_str(), it->second.c_str()); - } - } - return alist; -} - - -// *************************************************************************** - -HTAnchor * TextFindAnchor (HText * /* me */, int /* index */) -{ - return NULL; -} - -int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value) -{ - char * location = HTStrip(value); - - std::string finalLocation; - - //nlinfo("redirect to '%s' '%s'", value, location); - - // If not absolute URI (Error) then find the base - if (!HTURL_isAbsolute(location)) - { - char * base = HTAnchor_address((HTAnchor *) HTRequest_anchor(request)); - location = HTParse(location, base, PARSE_ALL); - //redirection = HTAnchor_findAddress(location); - finalLocation = location; - HT_FREE(base); - HT_FREE(location); - } - else - { - finalLocation = location; - } - //nlinfo("final location '%s'", finalLocation.c_str()); - - CGroupHTML *gh = (CGroupHTML *) HTRequest_context(request); - - gh->setURL(finalLocation); - - return HT_OK; -} - - -// *************************************************************************** - -const std::string &setCurrentDomain(const std::string &url) -{ - if(url.find("http://") == 0) - { - HTTPCurrentDomain = url.substr(7, url.find('/', 7)-7); -// nlinfo("****cd: %s", HTTPCurrentDomain.c_str()); - } - else - { - HTTPCurrentDomain.clear(); -// nlinfo("****cd: clear the domain"); - } - return HTTPCurrentDomain; -} - - -void initLibWWW() -{ - static bool initialized = false; - if (!initialized) - { - //HTProfile_newNoCacheClient("Ryzom", "1.1"); - - /* Need our own trace and print functions */ - HTPrint_setCallback(NelPrinter); - HTTrace_setCallback(NelTracer); - - /* Initiate libwww */ - - HTLib_setAppName( CGroupHTML::options.appName.c_str() ); - HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() ); - - /* Set up TCP as transport */ - VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new)); - VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTNeLReader_new, HTWriter_new)); - // VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTWriter_new)); - // VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new)); - - /* Set up HTTP as protocol */ - VerifyLibWWW("HTProtocol_add", HTProtocol_add("http", "buffered_tcp", 80, NO, HTLoadHTTP, NULL)); - VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL)); - //VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL)); - // HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL); - - HTBind_init(); - // HTCacheInit(NULL, 20); - - /* Setup up transfer coders */ - HTFormat_addTransferCoding((char*)"chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0); - - /* Setup MIME stream converters */ - HTFormat_addConversion("message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-head", "*/*", HTMIMEHeader, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-cont", "*/*", HTMIMEContinue, 1.0, 0.0, 0.0); - HTFormat_addConversion("message/x-rfc822-partial","*/*", HTMIMEPartial, 1.0, 0.0, 0.0); - HTFormat_addConversion("multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0); - - /* Setup HTTP protocol stream */ - HTFormat_addConversion("text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0); - - /* Setup the HTML parser */ - HTFormat_addConversion("text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0); - - /* Setup black hole stream */ - HTFormat_addConversion("*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0); - HTFormat_addConversion("*/*", "www/present", HTBlackHoleConverter, 0.3, 0.0, 0.0); - - /* Set max number of sockets we want open simultaneously */ - HTNet_setMaxSocket(32); - - /* Register our HTML parser callbacks */ - VerifyLibWWW("HText_registerCDCallback", HText_registerCDCallback (TextNew, TextDelete)); - VerifyLibWWW("HText_registerBuildCallback", HText_registerBuildCallback (TextBuild)); - VerifyLibWWW("HText_registerTextCallback", HText_registerTextCallback(TextAdd)); - VerifyLibWWW("HText_registerLinkCallback", HText_registerLinkCallback (TextLink)); - VerifyLibWWW("HText_registerElementCallback", HText_registerElementCallback (TextBeginElement, TextEndElement)); - VerifyLibWWW("HText_registerUnparsedElementCallback", HText_registerUnparsedElementCallback(TextBeginUnparsedElement, TextEndUnparsedElement)); - VerifyLibWWW("HText_registerUnparsedEntityCallback ", HText_registerUnparsedEntityCallback (TextUnparsedEntity )); - - - /* Register the default set of MIME header parsers */ - struct { - const char * string; - HTParserCallback * pHandler; - } fixedHandlers[] = { - {"accept", &HTMIME_accept}, - {"accept-charset", &HTMIME_acceptCharset}, - {"accept-encoding", &HTMIME_acceptEncoding}, - {"accept-language", &HTMIME_acceptLanguage}, - {"accept-ranges", &HTMIME_acceptRanges}, - {"authorization", NULL}, - {"cache-control", &HTMIME_cacheControl}, - {"connection", &HTMIME_connection}, - {"content-encoding", &HTMIME_contentEncoding}, - {"content-length", &HTMIME_contentLength}, - {"content-range", &HTMIME_contentRange}, - {"content-transfer-encoding", &HTMIME_contentTransferEncoding}, - {"content-type", &HTMIME_contentType}, - {"digest-MessageDigest", &HTMIME_messageDigest}, - {"keep-alive", &HTMIME_keepAlive}, - {"link", &HTMIME_link}, - {"location", &HTMIME_location_custom}, - {"max-forwards", &HTMIME_maxForwards}, - {"mime-version", NULL}, - {"pragma", &HTMIME_pragma}, - {"protocol", &HTMIME_protocol}, - {"protocol-info", &HTMIME_protocolInfo}, - {"protocol-request", &HTMIME_protocolRequest}, - {"proxy-authenticate", &HTMIME_authenticate}, - {"proxy-authorization", &HTMIME_proxyAuthorization}, - {"public", &HTMIME_public}, - {"range", &HTMIME_range}, - {"referer", &HTMIME_referer}, - {"retry-after", &HTMIME_retryAfter}, - {"server", &HTMIME_server}, - {"trailer", &HTMIME_trailer}, - {"transfer-encoding", &HTMIME_transferEncoding}, - {"upgrade", &HTMIME_upgrade}, - {"user-agent", &HTMIME_userAgent}, - {"vary", &HTMIME_vary}, - {"via", &HTMIME_via}, - {"warning", &HTMIME_warning}, - {"www-authenticate", &HTMIME_authenticate}, - {"authentication-info", &HTMIME_authenticationInfo}, - {"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo} - }; - - for (uint i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++) - HTHeader_addParser(fixedHandlers[i].string, NO, fixedHandlers[i].pHandler); - - /* Set up default event loop */ - HTEventInit(); - - /* Add our own request terminate handler */ - HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); - - /* Setup cookies */ - HTCookie_init(); - HTCookie_setCookieMode(HTCookieMode(HT_COOKIE_ACCEPT | HT_COOKIE_SEND)); - HTCookie_setCallbacks(receiveCookie, NULL, sendCookie, NULL); - - /* Start the first request */ - - /* Go into the event loop... */ - // HTEventList_newLoop(); - - // App_delete(app); - - HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ - HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ - - HTBind_caseSensitive(NO); - - // Change the HTML DTD - SGML_dtd *HTML_DTD = HTML_dtd (); - HTML_DTD->tags[HTML_TABLE].attributes = table_attr; - HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TR].attributes = tr_attr; - HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TD].attributes = td_attr; - HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_IMG].attributes = img_attr; - HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_INPUT].attributes = input_attr; - HTML_DTD->tags[HTML_INPUT].number_of_attributes = sizeof(input_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_TEXTAREA].attributes = textarea_attr; - HTML_DTD->tags[HTML_TEXTAREA].number_of_attributes = sizeof(textarea_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_P].attributes = p_attr; - HTML_DTD->tags[HTML_P].number_of_attributes = sizeof(p_attr) / sizeof(HTAttr) - 1; - HTML_DTD->tags[HTML_A].attributes = a_attr; - HTML_DTD->tags[HTML_A].number_of_attributes = sizeof(a_attr) / sizeof(HTAttr) - 1; - //HTML_DTD->tags[HTML_I].attributes = a_attr; - HTML_DTD->tags[HTML_I].number_of_attributes = 0; - HTML_DTD->tags[HTML_DIV].attributes = div_attr; - HTML_DTD->tags[HTML_DIV].number_of_attributes = sizeof(div_attr) / sizeof(HTAttr) - 1; - - // Set a request timeout -// HTHost_setEventTimeout (30000); -// HTHost_setActiveTimeout (30000); -// HTHost_setPersistTimeout (30000); - - // Initialized - initialized = true; - } -} - -// *************************************************************************** diff --git a/code/ryzom/client/src/libwww.h b/code/ryzom/client/src/libwww.h deleted file mode 100644 index aa3f6b424..000000000 --- a/code/ryzom/client/src/libwww.h +++ /dev/null @@ -1,283 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_LIB_WWW_H -#define CL_LIB_WWW_H - -extern "C" -{ -#include "WWWInit.h" -} - -namespace NLGUI -{ - class CCtrlBaseButton; - class CCtrlScroll; - class CGroupList; -} - -// *************************************************************************** - -// Init the libwww -void initLibWWW(); - -// Get an url and setup a local domain -const std::string &setCurrentDomain(const std::string &url); - -extern std::string CurrentCookie; - -// *************************************************************************** - -// Some DTD table - -// Here, modify the DTD table to change the HTML parser (add new tags for exemples) - -#undef HTML_ATTR -#define HTML_ATTR(t,a) MY_HTML_##t##_##a - -enum -{ - HTML_ATTR(A,ACCESSKEY) = 0, - HTML_ATTR(A,CHARSET), - HTML_ATTR(A,CLASS), - HTML_ATTR(A,COORDS), - HTML_ATTR(A,DIR), - HTML_ATTR(A,HREF), - HTML_ATTR(A,HREFLANG), - HTML_ATTR(A,ID), - HTML_ATTR(A,NAME), - HTML_ATTR(A,REL), - HTML_ATTR(A,REV), - HTML_ATTR(A,SHAPE), - HTML_ATTR(A,STYLE), - HTML_ATTR(A,TABINDEX), - HTML_ATTR(A,TARGET), - HTML_ATTR(A,TYPE), - HTML_ATTR(A,TITLE), - HTML_ATTR(A,Z_ACTION_CATEGORY), - HTML_ATTR(A,Z_ACTION_PARAMS), - HTML_ATTR(A,Z_ACTION_SHORTCUT), -}; - -enum -{ - HTML_ATTR(TABLE,ALIGN) = 0, - HTML_ATTR(TABLE,BGCOLOR), - HTML_ATTR(TABLE,BORDER), - HTML_ATTR(TABLE,CELLPADDING), - HTML_ATTR(TABLE,CELLSPACING), - HTML_ATTR(TABLE,CLASS), - HTML_ATTR(TABLE,DIR), - HTML_ATTR(TABLE,FRAME), - HTML_ATTR(TABLE,ID), - HTML_ATTR(TABLE,L_MARGIN), - HTML_ATTR(TABLE,LANG), - HTML_ATTR(TABLE,NOWRAP), - HTML_ATTR(TABLE,RULES), - HTML_ATTR(TABLE,SUMMARY), - HTML_ATTR(TABLE,STYLE), - HTML_ATTR(TABLE,TITLE), - HTML_ATTR(TABLE,VALIGN), - HTML_ATTR(TABLE,WIDTH) -}; - -enum -{ - HTML_ATTR(TR,ALIGN) = 0, - HTML_ATTR(TR,BGCOLOR), - HTML_ATTR(TR,L_MARGIN), - HTML_ATTR(TR,NOWRAP), - HTML_ATTR(TR,VALIGN), -}; - -enum -{ - HTML_ATTR(TD,ABBR) = 0, - HTML_ATTR(TD,ALIGN), - HTML_ATTR(TD,AXIS), - HTML_ATTR(TD,BGCOLOR), - HTML_ATTR(TD,CHAR), - HTML_ATTR(TD,CHAROFF), - HTML_ATTR(TD,CLASS), - HTML_ATTR(TD,COLSPAN), - HTML_ATTR(TD,DIR), - HTML_ATTR(TD,ID), - HTML_ATTR(TD,HEADERS), - HTML_ATTR(TD,HEIGHT), - HTML_ATTR(TD,L_MARGIN), - HTML_ATTR(TD,LANG), - HTML_ATTR(TD,NOWRAP), - HTML_ATTR(TD,ROWSPAN), - HTML_ATTR(TD,SCOPE), - HTML_ATTR(TD,STYLE), - HTML_ATTR(TD,TITLE), - HTML_ATTR(TD,VALIGN), - HTML_ATTR(TD,WIDTH), -}; - -enum -{ - HTML_ATTR(IMG,ALIGN) = 0, - HTML_ATTR(IMG,ALT), - HTML_ATTR(IMG,BORDER), - HTML_ATTR(IMG,CLASS), - HTML_ATTR(IMG,DIR), - HTML_ATTR(IMG,GLOBAL_COLOR), - HTML_ATTR(IMG,HEIGHT), - HTML_ATTR(IMG,HSPACE), - HTML_ATTR(IMG,ID), - HTML_ATTR(IMG,ISMAP), - HTML_ATTR(IMG,LANG), - HTML_ATTR(IMG,LONGDESC), - HTML_ATTR(IMG,SRC), - HTML_ATTR(IMG,STYLE), - HTML_ATTR(IMG,TITLE), - HTML_ATTR(IMG,USEMAP), - HTML_ATTR(IMG,VSPACE), - HTML_ATTR(IMG,WIDTH), -}; - -enum -{ - HTML_ATTR(INPUT,ACCEPT) = 0, - HTML_ATTR(INPUT,ACCESSKEY), - HTML_ATTR(INPUT,ALIGN), - HTML_ATTR(INPUT,ALT), - HTML_ATTR(INPUT,CHECKED), - HTML_ATTR(INPUT,CLASS), - HTML_ATTR(INPUT,DIR), - HTML_ATTR(INPUT,DISABLED), - HTML_ATTR(INPUT,GLOBAL_COLOR), - HTML_ATTR(INPUT,ID), - HTML_ATTR(INPUT,LANG), - HTML_ATTR(INPUT,MAXLENGTH), - HTML_ATTR(INPUT,NAME), - HTML_ATTR(INPUT,READONLY), - HTML_ATTR(INPUT,SIZE), - HTML_ATTR(INPUT,SRC), - HTML_ATTR(INPUT,STYLE), - HTML_ATTR(INPUT,TABINDEX), - HTML_ATTR(INPUT,TITLE), - HTML_ATTR(INPUT,TYPE), - HTML_ATTR(INPUT,USEMAP), - HTML_ATTR(INPUT,VALUE), - HTML_ATTR(INPUT,Z_BTN_TMPL), - HTML_ATTR(INPUT,Z_INPUT_TMPL), - HTML_ATTR(INPUT,Z_INPUT_WIDTH), -}; - -enum -{ - HTML_ATTR(TEXTAREA,CLASS) = 0, - HTML_ATTR(TEXTAREA,COLS), - HTML_ATTR(TEXTAREA,DIR), - HTML_ATTR(TEXTAREA,DISABLED), - HTML_ATTR(TEXTAREA,ID), - HTML_ATTR(TEXTAREA,LANG), - HTML_ATTR(TEXTAREA,NAME), - HTML_ATTR(TEXTAREA,READONLY), - HTML_ATTR(TEXTAREA,ROWS), - HTML_ATTR(TEXTAREA,STYLE), - HTML_ATTR(TEXTAREA,TABINDEX), - HTML_ATTR(TEXTAREA,TITLE), - HTML_ATTR(TEXTAREA,Z_INPUT_TMPL), -}; - -enum -{ - HTML_ATTR(P,QUICK_HELP_CONDITION) = 0, - HTML_ATTR(P,QUICK_HELP_EVENTS), - HTML_ATTR(P,QUICK_HELP_LINK), - HTML_ATTR(P,NAME), -}; - -enum -{ - HTML_ATTR(DIV,CLASS) = 0, - HTML_ATTR(DIV,ID), - HTML_ATTR(DIV,NAME), - HTML_ATTR(DIV,STYLE), -}; - - -#undef HTML_ATTR - -// *************************************************************************** - -// A smart ptr for LibWWW strings -class C3WSmartPtr -{ -public: - C3WSmartPtr () - { - _Ptr = NULL; - } - C3WSmartPtr (const char *ptr) - { - _Ptr = ptr; - } - ~C3WSmartPtr () - { - clear(); - } - void operator=(const char *str) - { - clear (); - _Ptr = str; - } - operator const char *() const - { - return _Ptr; - } - void clear() - { - if (_Ptr) - { - void *ptr = (void*)_Ptr; - HT_FREE(ptr); - } - _Ptr = NULL; - } -private: - const char *_Ptr; -}; - -// *************************************************************************** - -// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false -bool getPercentage (sint32 &width, float &percent, const char *str); - -// *************************************************************************** - -// Parse a HTML color -NLMISC::CRGBA getColor (const char *color); - -// *************************************************************************** - -void _VerifyLibWWW(const char *function, bool ok, const char *file, int line); -#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__) - -// *************************************************************************** - -// Standard request terminator -int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ; - -// *************************************************************************** - -#endif diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 7d1b8a3fa..df7d68e73 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -49,7 +49,7 @@ #include "client_cfg.h" #include "global.h" #include "input.h" -#include "libwww.h" +#include "nel/gui/libwww.h" #include "http_client.h" #include "http_client_curl.h" #include "login_progress_post_thread.h" diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index f91e22eb4..45bffbf57 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -55,7 +55,7 @@ #include "main_loop.h" #include "interface_v3/group_in_scene_bubble.h" #include "interface_v3/inventory_manager.h" -#include "interface_v3/group_html.h" +#include "nel/gui/group_html.h" #include "interface_v3/people_interraction.h" #include "init_main_loop.h" #include "view.h" From 70fb3d64124f63b7df1d14829185de7d304cb57f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 1 Jul 2012 03:45:38 +0200 Subject: [PATCH 120/339] CHANGED: #1471 CInterfaceAnim no longer depends on Ryzom game related code. --- .../src/interface_v3/action_handler_misc.cpp | 25 +++++++++++ .../src/interface_v3/interface_anim.cpp | 43 +++---------------- .../client/src/interface_v3/interface_anim.h | 1 - 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp index 273e05d36..aefc33d34 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_misc.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_misc.cpp @@ -924,6 +924,31 @@ bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(ucstring &inOut) +// *************************************************************************** +class CAHAnimStart : public IActionHandler +{ +public: + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string sAnim = getParam(Params, "anim"); + pIM->startAnim(sAnim); + } +}; +REGISTER_ACTION_HANDLER (CAHAnimStart, "anim_start"); + +// *************************************************************************** +class CAHAnimStop : public IActionHandler +{ +public: + virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) + { + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + string sAnim = getParam(Params, "anim"); + pIM->stopAnim(sAnim); + } +}; +REGISTER_ACTION_HANDLER (CAHAnimStop, "anim_stop"); diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp index 6f3001dd9..4f9654b62 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ b/code/ryzom/client/src/interface_v3/interface_anim.cpp @@ -14,17 +14,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -// ---------------------------------------------------------------------------- -#include "stdpch.h" - #include "interface_anim.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.h" #include "nel/gui/interface_expr.h" #include "nel/misc/xml_auto_ptr.h" #include "nel/gui/action_handler.h" -#include "../time_client.h" // ---------------------------------------------------------------------------- using namespace std; @@ -591,11 +585,13 @@ void CInterfaceAnim::update() if ((_Duration == 0) || (_Finished)) return; + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + // Delta time limiter - if (DT > 0.1) + if ( ( times.frameDiffMs / 1000.0f ) > 0.1) _CurrentTime += 0.1; else - _CurrentTime += DT; + _CurrentTime += ( times.frameDiffMs / 1000.0f ); // Stop the anim if we have to if (_AnimHasToBeStopped) @@ -640,37 +636,8 @@ void CInterfaceAnim::stop() { _Finished = true; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (!_AHOnFinish.empty()) CAHManager::getInstance()->runActionHandler(_AHOnFinish, _Parent, _AHOnFinishParams); } -// ************************** -// Action handlers associated -// ************************** -// *************************************************************************** -class CAHAnimStart : public IActionHandler -{ -public: - virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string sAnim = getParam(Params, "anim"); - pIM->startAnim(sAnim); - } -}; -REGISTER_ACTION_HANDLER (CAHAnimStart, "anim_start"); - -// *************************************************************************** -class CAHAnimStop : public IActionHandler -{ -public: - virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params) - { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - string sAnim = getParam(Params, "anim"); - pIM->stopAnim(sAnim); - } -}; -REGISTER_ACTION_HANDLER (CAHAnimStop, "anim_stop"); diff --git a/code/ryzom/client/src/interface_v3/interface_anim.h b/code/ryzom/client/src/interface_v3/interface_anim.h index c8b06df5e..4154e790b 100644 --- a/code/ryzom/client/src/interface_v3/interface_anim.h +++ b/code/ryzom/client/src/interface_v3/interface_anim.h @@ -22,7 +22,6 @@ #include "nel/gui/interface_property.h" #include "nel/gui/interface_group.h" #include "nel/gui/interface_link.h" - #include "nel/3d/u_track.h" /** From 66293a4fd98b947f994c182a48bc1e3b4a0089ce Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 1 Jul 2012 04:13:24 +0200 Subject: [PATCH 121/339] CHANGED: #1471 CInterfaceTrack and CInterfaceAnim are now part of the NELGUI library and are under the NLGUI namespace. --- code/nel/include/nel/gui/interface_anim.h | 135 ++++ code/nel/src/gui/interface_anim.cpp | 647 ++++++++++++++++++ .../src/interface_v3/interface_anim.cpp | 643 ----------------- .../client/src/interface_v3/interface_anim.h | 129 ---- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/interface_manager.h | 3 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_parser.h | 2 +- 8 files changed, 786 insertions(+), 777 deletions(-) create mode 100644 code/nel/include/nel/gui/interface_anim.h create mode 100644 code/nel/src/gui/interface_anim.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_anim.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_anim.h diff --git a/code/nel/include/nel/gui/interface_anim.h b/code/nel/include/nel/gui/interface_anim.h new file mode 100644 index 000000000..660005a3e --- /dev/null +++ b/code/nel/include/nel/gui/interface_anim.h @@ -0,0 +1,135 @@ +// Ryzom - MMORPG Framework +// 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 RZ_INTERFACE_ANIM_H +#define RZ_INTERFACE_ANIM_H + +#include "nel/gui/interface_property.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/interface_link.h" +#include "nel/3d/animation_time.h" +#include "nel/3d/u_track.h" + +namespace NLGUI +{ + + /** + * class managing an animation track + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2003 + */ + class CInterfaceTrack + { + + public: + + CInterfaceTrack(); + ~CInterfaceTrack(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + void update (double currentTime); + + bool isDynamic () { return _Dynamic; } + + void eval(); // Evaluate dynamic keys + + private: + + enum ETrackType + { + Track_Linear, + Track_TCB, + Track_Bezier + }; + + struct SDynKey + { + std::string Time; + std::string Value; + std::string InTan; + std::string OutTan; + std::string Step; + std::string Tension; + std::string Continuity; + std::string Bias; + std::string EaseTo; + std::string EaseFrom; + }; + + bool _Dynamic; + std::vector _DynKeys; + + ETrackType _Type; + NL3D::UTrackKeyframer *_TrackKeyFramer; + std::vector _Targets; + }; + + /** + * class managing an animation of the interface + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2003 + */ + class CInterfaceAnim + { + + public: + + CInterfaceAnim(); + ~CInterfaceAnim(); + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + void update(); + void start(); + void stop(); + + bool isFinished() { return _Finished; } + bool isDisableButtons() { return _DisableButtons; } + + protected: + + CInterfaceGroup *_Parent; + + // Parsed properties + double _Duration; + bool _DisableButtons; + + std::string _AHOnFinish; + std::string _AHOnFinishParams; + + std::string _Id; + + std::vector _Tracks; + + // Current anim + double _CurrentTime; + bool _Finished; + bool _AnimHasToBeStopped; + + }; + +} + +#endif // NL_INTERFACE_ANIM_H + +/* End of interface_anim.h */ + + diff --git a/code/nel/src/gui/interface_anim.cpp b/code/nel/src/gui/interface_anim.cpp new file mode 100644 index 000000000..4ca996731 --- /dev/null +++ b/code/nel/src/gui/interface_anim.cpp @@ -0,0 +1,647 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/interface_anim.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/interface_expr.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/action_handler.h" + +// ---------------------------------------------------------------------------- +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +namespace NLGUI +{ + + // ---------------------------------------------------------------------------- + // CInterfaceTrack + // ---------------------------------------------------------------------------- + CInterfaceTrack::CInterfaceTrack() + { + _Type = Track_Linear; + _TrackKeyFramer = NULL; + _Dynamic = false; + } + + // ---------------------------------------------------------------------------- + CInterfaceTrack::~CInterfaceTrack() + { + delete _TrackKeyFramer; + } + + // ---------------------------------------------------------------------------- + bool CInterfaceTrack::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + CXMLAutoPtr ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"dynamic"); + if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"type"); + string sTmp = ptr; + sTmp = strlwr(sTmp); + if (sTmp == "linear") + _Type = Track_Linear; + else if (sTmp == "bezier") + _Type = Track_Bezier; + else if (sTmp == "tcb") + _Type = Track_TCB; + else + nlwarning ("track unknown type : %s, setting linear by default", (const char*)ptr); + + ptr = xmlGetProp (cur, (xmlChar*)"target"); + if (!ptr) + { + nlwarning ("no target for track"); + return false; + } + + // + if (!CInterfaceLink::splitLinkTargets (ptr, parentGroup, _Targets)) + { + nlwarning ("no target for track"); + return false; + } + + // Initialize the track + switch(_Type) + { + case Track_Linear: _TrackKeyFramer = UTrackKeyframer::createLinearFloatTrack(); break; + case Track_TCB: _TrackKeyFramer = UTrackKeyframer::createTCBFloatTrack(); break; + case Track_Bezier: _TrackKeyFramer = UTrackKeyframer::createBezierFloatTrack(); break; + default: nlstop; break; + } + + cur = cur->children; + bool ok = true; + + if (_Dynamic) + { + while (cur) + { + // Check that this is a key node + if ( stricmp((char*)cur->name,"key") != 0 ) + { + cur = cur->next; + continue; + } + + // Read time and value the 2 main key attributes + CXMLAutoPtr time, value; + time = xmlGetProp (cur, (xmlChar*)"time"); + value = xmlGetProp (cur, (xmlChar*)"value"); + if (!time || !value) + { + nlwarning("track key with no time or no value"); + ok = false; + cur = cur->next; + continue; + } + + SDynKey k; + k.Value = (const char*)value; + k.Time = (const char*)time; + if (isdigit(k.Time[0]) || (k.Time[0] == '-')) + { + double dTime; + fromString(k.Time, dTime); + k.Time = toString(dTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat()); + } + + // Depending on the type of the track read extra values + switch(_Type) + { + case Track_Linear: + break; + + case Track_Bezier: + { + CXMLAutoPtr inTan, outTan, step; + inTan = xmlGetProp (cur, (xmlChar*)"intan"); + outTan = xmlGetProp (cur, (xmlChar*)"outtan"); + step = xmlGetProp (cur, (xmlChar*)"step"); + + if (inTan) k.InTan = (const char*)inTan; + if (outTan) k.OutTan = (const char*)outTan; + if (step) k.Step = (const char*)step; + } + break; + + case Track_TCB: + { + CXMLAutoPtr tension, continuity, bias, easeto, easefrom; + tension = xmlGetProp (cur, (xmlChar*)"tension"); + continuity = xmlGetProp (cur, (xmlChar*)"continuity"); + bias = xmlGetProp (cur, (xmlChar*)"bias"); + easeto = xmlGetProp (cur, (xmlChar*)"easeto"); + easefrom = xmlGetProp (cur, (xmlChar*)"easefrom"); + + if (tension) k.Tension = (const char*)tension; + if (continuity) k.Continuity = (const char*)continuity; + if (bias) k.Bias = (const char*)bias; + if (easeto) k.EaseTo = (const char*)easeto; + if (easefrom) k.EaseFrom = (const char*)easefrom; + } + break; + default: nlstop; break; + } + _DynKeys.push_back(k); + + cur = cur->next; + } + } + else // Static parsing + { + while (cur) + { + // Check that this is a key node + if ( stricmp((char*)cur->name,"key") != 0 ) + { + cur = cur->next; + continue; + } + + // Read time and value the 2 main key attributes + CXMLAutoPtr time, value; + time = xmlGetProp (cur, (xmlChar*)"time"); + value = xmlGetProp (cur, (xmlChar*)"value"); + if (!time || !value) + { + nlwarning("track key with no time or no value"); + ok = false; + cur = cur->next; + continue; + } + + float fAnimTime; + fromString((const char*)time, fAnimTime); + TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); + double animValue; + fromString(value, animValue); + + // Depending on the type of the track add the key + switch(_Type) + { + case Track_Linear: + { + UTrackKeyframer::UKeyLinearFloat k; + k.Time = animTime; + k.Value = (float)animValue; + _TrackKeyFramer->addLinearFloatKey (k); + } + break; + + case Track_Bezier: + { + UTrackKeyframer::UKeyBezierFloat k; + k.Time = animTime; + k.Value = (float)animValue; + + // Read extra values + CXMLAutoPtr inTan, outTan, step; + inTan = xmlGetProp (cur, (xmlChar*)"intan"); + outTan = xmlGetProp (cur, (xmlChar*)"outtan"); + step = xmlGetProp (cur, (xmlChar*)"step"); + + k.TanIn = 0.0f; + k.TanOut = 0.0f; + k.Step = false; + + if (inTan) fromString((const char*)inTan, k.TanIn); + if (outTan) fromString((const char*)outTan, k.TanOut); + if (step) k.Step = CInterfaceElement::convertBool(step); + + _TrackKeyFramer->addBezierFloatKey (k); + } + break; + + case Track_TCB: + { + UTrackKeyframer::UKeyTCBFloat k; + k.Time = animTime; + k.Value = (float)animValue; + + // Read extra values + CXMLAutoPtr tension, continuity, bias, easeto, easefrom; + tension = xmlGetProp (cur, (xmlChar*)"tension"); + continuity = xmlGetProp (cur, (xmlChar*)"continuity"); + bias = xmlGetProp (cur, (xmlChar*)"bias"); + easeto = xmlGetProp (cur, (xmlChar*)"easeto"); + easefrom = xmlGetProp (cur, (xmlChar*)"easefrom"); + + k.Tension = 0.0f; + k.Continuity = 0.0f; + k.Bias = 0.0f; + k.EaseTo = 0.0f; + k.EaseFrom = 0.0f; + + if (tension) fromString((const char*)tension, k.Tension); + if (continuity) fromString((const char*)continuity, k.Continuity); + if (bias) fromString((const char*)bias, k.Bias); + if (easeto) fromString((const char*)easeto, k.EaseTo); + if (easefrom) fromString((const char*)easefrom, k.EaseFrom); + + _TrackKeyFramer->addTCBFloatKey (k); + } + break; + default: nlstop; break; + } + cur = cur->next; + } + } + return true; + } + + // ---------------------------------------------------------------------------- + void CInterfaceTrack::update (double currentTime) + { + float currentValue; + UTrack *pTrack = dynamic_cast(_TrackKeyFramer); + if (pTrack == NULL) return; + pTrack->interpolate((TAnimationTime)currentTime, currentValue); + + // Update the targets + CInterfaceExprValue expr; + expr.setDouble(currentValue); + for (uint i = 0; i < _Targets.size(); ++i) + _Targets[i].affect(expr); + } + + // ---------------------------------------------------------------------------- + void CInterfaceTrack::eval() + { + if (!_Dynamic) return; + + if (_TrackKeyFramer != NULL) + delete _TrackKeyFramer; + + switch(_Type) + { + case Track_Linear: + { + _TrackKeyFramer = UTrackKeyframer::createLinearFloatTrack(); + for (uint i = 0; i < _DynKeys.size(); ++i) + { + SDynKey &rKey = _DynKeys[i]; + UTrackKeyframer::UKeyLinearFloat k; + CInterfaceExprValue res; + if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Time to double"); + else + k.Time = (TAnimationTime)res.getDouble(); + } + else + { + k.Time = 0; + } + + if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Value to double"); + else + k.Value = (float)res.getDouble(); + } + else + { + k.Value = 0; + } + + _TrackKeyFramer->addLinearFloatKey (k); + } + } + break; + + case Track_TCB: + { + _TrackKeyFramer = UTrackKeyframer::createTCBFloatTrack(); + for (uint i = 0; i < _DynKeys.size(); ++i) + { + SDynKey &rKey = _DynKeys[i]; + UTrackKeyframer::UKeyTCBFloat k; + CInterfaceExprValue res; + if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Time to double"); + else + k.Time = (TAnimationTime)res.getDouble(); + } + else + { + k.Time = 0; + } + + if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Value to double"); + else + k.Value = (float)res.getDouble(); + } + else + { + k.Value = 0; + } + + if (!rKey.Tension.empty() && CInterfaceExpr::eval(rKey.Tension, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Tension to double"); + else + k.Tension = (float)res.getDouble(); + } + else + { + k.Tension = 0; + } + + if (!rKey.Continuity.empty() && CInterfaceExpr::eval(rKey.Continuity, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Continuity to double"); + else + k.Continuity = (float)res.getDouble(); + } + else + { + k.Continuity = 0; + } + + if (!rKey.Bias.empty() && CInterfaceExpr::eval(rKey.Bias, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Bias to double"); + else + k.Bias = (float)res.getDouble(); + } + else + { + k.Bias = 0; + } + + if (!rKey.EaseTo.empty() && CInterfaceExpr::eval(rKey.EaseTo, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert EaseTo to double"); + else + k.EaseTo = (float)res.getDouble(); + } + else + { + k.EaseTo = 0; + } + + if (!rKey.EaseFrom.empty() && CInterfaceExpr::eval(rKey.EaseFrom, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert EaseFrom to double"); + else + k.EaseFrom = (float)res.getDouble(); + } + else + { + k.EaseFrom = 0; + } + + _TrackKeyFramer->addTCBFloatKey (k); + } + } + break; + + case Track_Bezier: + { + _TrackKeyFramer = UTrackKeyframer::createBezierFloatTrack(); break; + for (uint i = 0; i < _DynKeys.size(); ++i) + { + SDynKey &rKey = _DynKeys[i]; + UTrackKeyframer::UKeyBezierFloat k; + CInterfaceExprValue res; + if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Time to double"); + else + k.Time = (TAnimationTime)res.getDouble(); + } + else + { + k.Time = 0; + } + + if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert Value to double"); + else + k.Value = (float)res.getDouble(); + } + else + { + k.Value = 0; + } + + if (!rKey.InTan.empty() && CInterfaceExpr::eval(rKey.InTan, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert TanIn to double"); + else + k.TanIn = (float)res.getDouble(); + } + else + { + k.TanIn = 0; + } + + if (!rKey.OutTan.empty() && CInterfaceExpr::eval(rKey.OutTan, res)) + { + if (!res.toDouble()) + nlwarning ("cannot convert TanOut to double"); + else + k.TanOut = (float)res.getDouble(); + } + else + { + k.TanOut = 0; + } + + if (!rKey.Step.empty() && CInterfaceExpr::eval(rKey.Step, res)) + { + if (!res.toBool()) + nlwarning ("cannot convert Step to bool"); + else + k.Step = res.getBool(); + } + else + { + k.Step = false; + } + + _TrackKeyFramer->addBezierFloatKey (k); + } + } + default: nlstop; break; + } + + } + + // ---------------------------------------------------------------------------- + // CInterfaceAnim + // ---------------------------------------------------------------------------- + + // ---------------------------------------------------------------------------- + CInterfaceAnim::CInterfaceAnim() + { + _CurrentTime = 0; + _Finished = true; + _Duration = 0; + _DisableButtons = true; + _AnimHasToBeStopped = false; + _Parent = NULL; + } + + // ---------------------------------------------------------------------------- + CInterfaceAnim::~CInterfaceAnim() + { + for (uint i = 0; i < _Tracks.size(); ++i) + delete _Tracks[i]; + } + + // ---------------------------------------------------------------------------- + bool CInterfaceAnim::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) + { + CXMLAutoPtr ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"id"); + _Id = (const char*)ptr; + + ptr = xmlGetProp (cur, (xmlChar*)"duration"); + if (!ptr) + { + nlwarning("anim with no duration"); + return false; + } + fromString((const char*)ptr, _Duration); + if (_Duration == 0) + _Duration = 1.0; + _Duration *= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); + + ptr = xmlGetProp (cur, (xmlChar*)"disable_buttons"); + if (ptr) + _DisableButtons = CInterfaceElement::convertBool(ptr); + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"on_finish" ); + if (ptr) _AHOnFinish = (const char *) ptr; + ptr = (char*) xmlGetProp( cur, (xmlChar*)"on_finish_params" ); + if (ptr) _AHOnFinishParams = (const char *) ptr; + + cur = cur->children; + + // bool ok = true; + while (cur) + { + // Check that this is a key node + if ( stricmp((char*)cur->name,"track") != 0 ) + { + cur = cur->next; + continue; + } + + CInterfaceTrack *pTrack = new CInterfaceTrack; + if (!pTrack->parse(cur,parentGroup)) + { + delete pTrack; + nlwarning("track not added to anim"); + } + else + { + _Tracks.push_back(pTrack); + } + cur = cur->next; + } + + _Parent = parentGroup; + + return true; + } + + // ---------------------------------------------------------------------------- + void CInterfaceAnim::update() + { + if ((_Duration == 0) || (_Finished)) + return; + + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + + // Delta time limiter + if ( ( times.frameDiffMs / 1000.0f ) > 0.1) + _CurrentTime += 0.1; + else + _CurrentTime += ( times.frameDiffMs / 1000.0f ); + + // Stop the anim if we have to + if (_AnimHasToBeStopped) + { + stop(); + return; + } + + // Do this here to let it play the last frame of the animation + if (_CurrentTime >= _Duration) + { + _CurrentTime = _Duration; + _AnimHasToBeStopped = true; + } + + // Update tracks + for (uint i = 0; i < _Tracks.size(); ++i) + { + CInterfaceTrack *pTrack = _Tracks[i]; + pTrack->update (_CurrentTime); + } + } + + // ---------------------------------------------------------------------------- + void CInterfaceAnim::start() + { + _CurrentTime = 0.0f; + _Finished = false; + _AnimHasToBeStopped = false; + + // Look if there are some dynamic tracks + for (uint i = 0; i < _Tracks.size(); ++i) + if (_Tracks[i]->isDynamic()) + _Tracks[i]->eval(); + + // Play the first frame + update(); + } + + // ---------------------------------------------------------------------------- + void CInterfaceAnim::stop() + { + _Finished = true; + + if (!_AHOnFinish.empty()) + CAHManager::getInstance()->runActionHandler(_AHOnFinish, _Parent, _AHOnFinishParams); + } + +} + diff --git a/code/ryzom/client/src/interface_v3/interface_anim.cpp b/code/ryzom/client/src/interface_v3/interface_anim.cpp deleted file mode 100644 index 4f9654b62..000000000 --- a/code/ryzom/client/src/interface_v3/interface_anim.cpp +++ /dev/null @@ -1,643 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "interface_anim.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/interface_expr.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/action_handler.h" - -// ---------------------------------------------------------------------------- -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -// ---------------------------------------------------------------------------- -// CInterfaceTrack -// ---------------------------------------------------------------------------- -CInterfaceTrack::CInterfaceTrack() -{ - _Type = Track_Linear; - _TrackKeyFramer = NULL; - _Dynamic = false; -} - -// ---------------------------------------------------------------------------- -CInterfaceTrack::~CInterfaceTrack() -{ - delete _TrackKeyFramer; -} - -// ---------------------------------------------------------------------------- -bool CInterfaceTrack::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - CXMLAutoPtr ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"dynamic"); - if (ptr) _Dynamic = CInterfaceElement::convertBool (ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"type"); - string sTmp = ptr; - sTmp = strlwr(sTmp); - if (sTmp == "linear") - _Type = Track_Linear; - else if (sTmp == "bezier") - _Type = Track_Bezier; - else if (sTmp == "tcb") - _Type = Track_TCB; - else - nlwarning ("track unknown type : %s, setting linear by default", (const char*)ptr); - - ptr = xmlGetProp (cur, (xmlChar*)"target"); - if (!ptr) - { - nlwarning ("no target for track"); - return false; - } - - // - if (!CInterfaceLink::splitLinkTargets (ptr, parentGroup, _Targets)) - { - nlwarning ("no target for track"); - return false; - } - - // Initialize the track - switch(_Type) - { - case Track_Linear: _TrackKeyFramer = UTrackKeyframer::createLinearFloatTrack(); break; - case Track_TCB: _TrackKeyFramer = UTrackKeyframer::createTCBFloatTrack(); break; - case Track_Bezier: _TrackKeyFramer = UTrackKeyframer::createBezierFloatTrack(); break; - default: nlstop; break; - } - - cur = cur->children; - bool ok = true; - - if (_Dynamic) - { - while (cur) - { - // Check that this is a key node - if ( stricmp((char*)cur->name,"key") != 0 ) - { - cur = cur->next; - continue; - } - - // Read time and value the 2 main key attributes - CXMLAutoPtr time, value; - time = xmlGetProp (cur, (xmlChar*)"time"); - value = xmlGetProp (cur, (xmlChar*)"value"); - if (!time || !value) - { - nlwarning("track key with no time or no value"); - ok = false; - cur = cur->next; - continue; - } - - SDynKey k; - k.Value = (const char*)value; - k.Time = (const char*)time; - if (isdigit(k.Time[0]) || (k.Time[0] == '-')) - { - double dTime; - fromString(k.Time, dTime); - k.Time = toString(dTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat()); - } - - // Depending on the type of the track read extra values - switch(_Type) - { - case Track_Linear: - break; - - case Track_Bezier: - { - CXMLAutoPtr inTan, outTan, step; - inTan = xmlGetProp (cur, (xmlChar*)"intan"); - outTan = xmlGetProp (cur, (xmlChar*)"outtan"); - step = xmlGetProp (cur, (xmlChar*)"step"); - - if (inTan) k.InTan = (const char*)inTan; - if (outTan) k.OutTan = (const char*)outTan; - if (step) k.Step = (const char*)step; - } - break; - - case Track_TCB: - { - CXMLAutoPtr tension, continuity, bias, easeto, easefrom; - tension = xmlGetProp (cur, (xmlChar*)"tension"); - continuity = xmlGetProp (cur, (xmlChar*)"continuity"); - bias = xmlGetProp (cur, (xmlChar*)"bias"); - easeto = xmlGetProp (cur, (xmlChar*)"easeto"); - easefrom = xmlGetProp (cur, (xmlChar*)"easefrom"); - - if (tension) k.Tension = (const char*)tension; - if (continuity) k.Continuity = (const char*)continuity; - if (bias) k.Bias = (const char*)bias; - if (easeto) k.EaseTo = (const char*)easeto; - if (easefrom) k.EaseFrom = (const char*)easefrom; - } - break; - default: nlstop; break; - } - _DynKeys.push_back(k); - - cur = cur->next; - } - } - else // Static parsing - { - while (cur) - { - // Check that this is a key node - if ( stricmp((char*)cur->name,"key") != 0 ) - { - cur = cur->next; - continue; - } - - // Read time and value the 2 main key attributes - CXMLAutoPtr time, value; - time = xmlGetProp (cur, (xmlChar*)"time"); - value = xmlGetProp (cur, (xmlChar*)"value"); - if (!time || !value) - { - nlwarning("track key with no time or no value"); - ok = false; - cur = cur->next; - continue; - } - - float fAnimTime; - fromString((const char*)time, fAnimTime); - TAnimationTime animTime = fAnimTime * CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); - double animValue; - fromString(value, animValue); - - // Depending on the type of the track add the key - switch(_Type) - { - case Track_Linear: - { - UTrackKeyframer::UKeyLinearFloat k; - k.Time = animTime; - k.Value = (float)animValue; - _TrackKeyFramer->addLinearFloatKey (k); - } - break; - - case Track_Bezier: - { - UTrackKeyframer::UKeyBezierFloat k; - k.Time = animTime; - k.Value = (float)animValue; - - // Read extra values - CXMLAutoPtr inTan, outTan, step; - inTan = xmlGetProp (cur, (xmlChar*)"intan"); - outTan = xmlGetProp (cur, (xmlChar*)"outtan"); - step = xmlGetProp (cur, (xmlChar*)"step"); - - k.TanIn = 0.0f; - k.TanOut = 0.0f; - k.Step = false; - - if (inTan) fromString((const char*)inTan, k.TanIn); - if (outTan) fromString((const char*)outTan, k.TanOut); - if (step) k.Step = CInterfaceElement::convertBool(step); - - _TrackKeyFramer->addBezierFloatKey (k); - } - break; - - case Track_TCB: - { - UTrackKeyframer::UKeyTCBFloat k; - k.Time = animTime; - k.Value = (float)animValue; - - // Read extra values - CXMLAutoPtr tension, continuity, bias, easeto, easefrom; - tension = xmlGetProp (cur, (xmlChar*)"tension"); - continuity = xmlGetProp (cur, (xmlChar*)"continuity"); - bias = xmlGetProp (cur, (xmlChar*)"bias"); - easeto = xmlGetProp (cur, (xmlChar*)"easeto"); - easefrom = xmlGetProp (cur, (xmlChar*)"easefrom"); - - k.Tension = 0.0f; - k.Continuity = 0.0f; - k.Bias = 0.0f; - k.EaseTo = 0.0f; - k.EaseFrom = 0.0f; - - if (tension) fromString((const char*)tension, k.Tension); - if (continuity) fromString((const char*)continuity, k.Continuity); - if (bias) fromString((const char*)bias, k.Bias); - if (easeto) fromString((const char*)easeto, k.EaseTo); - if (easefrom) fromString((const char*)easefrom, k.EaseFrom); - - _TrackKeyFramer->addTCBFloatKey (k); - } - break; - default: nlstop; break; - } - cur = cur->next; - } - } - return true; -} - -// ---------------------------------------------------------------------------- -void CInterfaceTrack::update (double currentTime) -{ - float currentValue; - UTrack *pTrack = dynamic_cast(_TrackKeyFramer); - if (pTrack == NULL) return; - pTrack->interpolate((TAnimationTime)currentTime, currentValue); - - // Update the targets - CInterfaceExprValue expr; - expr.setDouble(currentValue); - for (uint i = 0; i < _Targets.size(); ++i) - _Targets[i].affect(expr); -} - -// ---------------------------------------------------------------------------- -void CInterfaceTrack::eval() -{ - if (!_Dynamic) return; - - if (_TrackKeyFramer != NULL) - delete _TrackKeyFramer; - - switch(_Type) - { - case Track_Linear: - { - _TrackKeyFramer = UTrackKeyframer::createLinearFloatTrack(); - for (uint i = 0; i < _DynKeys.size(); ++i) - { - SDynKey &rKey = _DynKeys[i]; - UTrackKeyframer::UKeyLinearFloat k; - CInterfaceExprValue res; - if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Time to double"); - else - k.Time = (TAnimationTime)res.getDouble(); - } - else - { - k.Time = 0; - } - - if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Value to double"); - else - k.Value = (float)res.getDouble(); - } - else - { - k.Value = 0; - } - - _TrackKeyFramer->addLinearFloatKey (k); - } - } - break; - - case Track_TCB: - { - _TrackKeyFramer = UTrackKeyframer::createTCBFloatTrack(); - for (uint i = 0; i < _DynKeys.size(); ++i) - { - SDynKey &rKey = _DynKeys[i]; - UTrackKeyframer::UKeyTCBFloat k; - CInterfaceExprValue res; - if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Time to double"); - else - k.Time = (TAnimationTime)res.getDouble(); - } - else - { - k.Time = 0; - } - - if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Value to double"); - else - k.Value = (float)res.getDouble(); - } - else - { - k.Value = 0; - } - - if (!rKey.Tension.empty() && CInterfaceExpr::eval(rKey.Tension, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Tension to double"); - else - k.Tension = (float)res.getDouble(); - } - else - { - k.Tension = 0; - } - - if (!rKey.Continuity.empty() && CInterfaceExpr::eval(rKey.Continuity, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Continuity to double"); - else - k.Continuity = (float)res.getDouble(); - } - else - { - k.Continuity = 0; - } - - if (!rKey.Bias.empty() && CInterfaceExpr::eval(rKey.Bias, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Bias to double"); - else - k.Bias = (float)res.getDouble(); - } - else - { - k.Bias = 0; - } - - if (!rKey.EaseTo.empty() && CInterfaceExpr::eval(rKey.EaseTo, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert EaseTo to double"); - else - k.EaseTo = (float)res.getDouble(); - } - else - { - k.EaseTo = 0; - } - - if (!rKey.EaseFrom.empty() && CInterfaceExpr::eval(rKey.EaseFrom, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert EaseFrom to double"); - else - k.EaseFrom = (float)res.getDouble(); - } - else - { - k.EaseFrom = 0; - } - - _TrackKeyFramer->addTCBFloatKey (k); - } - } - break; - - case Track_Bezier: - { - _TrackKeyFramer = UTrackKeyframer::createBezierFloatTrack(); break; - for (uint i = 0; i < _DynKeys.size(); ++i) - { - SDynKey &rKey = _DynKeys[i]; - UTrackKeyframer::UKeyBezierFloat k; - CInterfaceExprValue res; - if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Time to double"); - else - k.Time = (TAnimationTime)res.getDouble(); - } - else - { - k.Time = 0; - } - - if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert Value to double"); - else - k.Value = (float)res.getDouble(); - } - else - { - k.Value = 0; - } - - if (!rKey.InTan.empty() && CInterfaceExpr::eval(rKey.InTan, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert TanIn to double"); - else - k.TanIn = (float)res.getDouble(); - } - else - { - k.TanIn = 0; - } - - if (!rKey.OutTan.empty() && CInterfaceExpr::eval(rKey.OutTan, res)) - { - if (!res.toDouble()) - nlwarning ("cannot convert TanOut to double"); - else - k.TanOut = (float)res.getDouble(); - } - else - { - k.TanOut = 0; - } - - if (!rKey.Step.empty() && CInterfaceExpr::eval(rKey.Step, res)) - { - if (!res.toBool()) - nlwarning ("cannot convert Step to bool"); - else - k.Step = res.getBool(); - } - else - { - k.Step = false; - } - - _TrackKeyFramer->addBezierFloatKey (k); - } - } - default: nlstop; break; - } - -} - -// ---------------------------------------------------------------------------- -// CInterfaceAnim -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -CInterfaceAnim::CInterfaceAnim() -{ - _CurrentTime = 0; - _Finished = true; - _Duration = 0; - _DisableButtons = true; - _AnimHasToBeStopped = false; - _Parent = NULL; -} - -// ---------------------------------------------------------------------------- -CInterfaceAnim::~CInterfaceAnim() -{ - for (uint i = 0; i < _Tracks.size(); ++i) - delete _Tracks[i]; -} - -// ---------------------------------------------------------------------------- -bool CInterfaceAnim::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - CXMLAutoPtr ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"id"); - _Id = (const char*)ptr; - - ptr = xmlGetProp (cur, (xmlChar*)"duration"); - if (!ptr) - { - nlwarning("anim with no duration"); - return false; - } - fromString((const char*)ptr, _Duration); - if (_Duration == 0) - _Duration = 1.0; - _Duration *= CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionMulCoefAnim).getValFloat(); - - ptr = xmlGetProp (cur, (xmlChar*)"disable_buttons"); - if (ptr) - _DisableButtons = CInterfaceElement::convertBool(ptr); - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"on_finish" ); - if (ptr) _AHOnFinish = (const char *) ptr; - ptr = (char*) xmlGetProp( cur, (xmlChar*)"on_finish_params" ); - if (ptr) _AHOnFinishParams = (const char *) ptr; - - cur = cur->children; - -// bool ok = true; - while (cur) - { - // Check that this is a key node - if ( stricmp((char*)cur->name,"track") != 0 ) - { - cur = cur->next; - continue; - } - - CInterfaceTrack *pTrack = new CInterfaceTrack; - if (!pTrack->parse(cur,parentGroup)) - { - delete pTrack; - nlwarning("track not added to anim"); - } - else - { - _Tracks.push_back(pTrack); - } - cur = cur->next; - } - - _Parent = parentGroup; - - return true; -} - -// ---------------------------------------------------------------------------- -void CInterfaceAnim::update() -{ - if ((_Duration == 0) || (_Finished)) - return; - - const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); - - // Delta time limiter - if ( ( times.frameDiffMs / 1000.0f ) > 0.1) - _CurrentTime += 0.1; - else - _CurrentTime += ( times.frameDiffMs / 1000.0f ); - - // Stop the anim if we have to - if (_AnimHasToBeStopped) - { - stop(); - return; - } - - // Do this here to let it play the last frame of the animation - if (_CurrentTime >= _Duration) - { - _CurrentTime = _Duration; - _AnimHasToBeStopped = true; - } - - // Update tracks - for (uint i = 0; i < _Tracks.size(); ++i) - { - CInterfaceTrack *pTrack = _Tracks[i]; - pTrack->update (_CurrentTime); - } -} - -// ---------------------------------------------------------------------------- -void CInterfaceAnim::start() -{ - _CurrentTime = 0.0f; - _Finished = false; - _AnimHasToBeStopped = false; - - // Look if there are some dynamic tracks - for (uint i = 0; i < _Tracks.size(); ++i) - if (_Tracks[i]->isDynamic()) - _Tracks[i]->eval(); - - // Play the first frame - update(); -} - -// ---------------------------------------------------------------------------- -void CInterfaceAnim::stop() -{ - _Finished = true; - - if (!_AHOnFinish.empty()) - CAHManager::getInstance()->runActionHandler(_AHOnFinish, _Parent, _AHOnFinishParams); -} - - diff --git a/code/ryzom/client/src/interface_v3/interface_anim.h b/code/ryzom/client/src/interface_v3/interface_anim.h deleted file mode 100644 index 4154e790b..000000000 --- a/code/ryzom/client/src/interface_v3/interface_anim.h +++ /dev/null @@ -1,129 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_INTERFACE_ANIM_H -#define RZ_INTERFACE_ANIM_H - -#include "nel/gui/interface_property.h" -#include "nel/gui/interface_group.h" -#include "nel/gui/interface_link.h" -#include "nel/3d/u_track.h" - -/** - * class managing an animation track - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2003 - */ -class CInterfaceTrack -{ - -public: - - CInterfaceTrack(); - ~CInterfaceTrack(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - void update (double currentTime); - - bool isDynamic () { return _Dynamic; } - - void eval(); // Evaluate dynamic keys - -private: - - enum ETrackType - { - Track_Linear, - Track_TCB, - Track_Bezier - }; - - struct SDynKey - { - std::string Time; - std::string Value; - std::string InTan; - std::string OutTan; - std::string Step; - std::string Tension; - std::string Continuity; - std::string Bias; - std::string EaseTo; - std::string EaseFrom; - }; - - bool _Dynamic; - std::vector _DynKeys; - - ETrackType _Type; - NL3D::UTrackKeyframer *_TrackKeyFramer; - std::vector _Targets; -}; - -/** - * class managing an animation of the interface - * \author Matthieu 'TrapII' Besson - * \author Nevrax France - * \date 2003 - */ -class CInterfaceAnim -{ - -public: - - CInterfaceAnim(); - ~CInterfaceAnim(); - - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - - void update(); - void start(); - void stop(); - - bool isFinished() { return _Finished; } - bool isDisableButtons() { return _DisableButtons; } - -protected: - - CInterfaceGroup *_Parent; - - // Parsed properties - double _Duration; - bool _DisableButtons; - - std::string _AHOnFinish; - std::string _AHOnFinishParams; - - std::string _Id; - - std::vector _Tracks; - - // Current anim - double _CurrentTime; - bool _Finished; - bool _AnimHasToBeStopped; - -}; - -#endif // NL_INTERFACE_ANIM_H - -/* End of interface_anim.h */ - - diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 5a43ddbbb..dc204b2dd 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -43,7 +43,7 @@ #include "nel/gui/action_handler.h" #include "action_handler_misc.h" #include "interface_observer.h" -#include "interface_anim.h" +#include "nel/gui/interface_anim.h" #include "interface_ddx.h" #include "action_handler_help.h" #include "action_handler_item.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 9c5dd87d0..564a27525 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -71,10 +71,9 @@ namespace NLGUI class CInterfaceOptions; class CGroupContainer; class CGroupMenu; + class CInterfaceAnim; } -class CInterfaceAnim; - /** * class managing the interface * \author Matthieu 'TrapII' Besson diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index a65420c01..bf120d761 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -33,7 +33,7 @@ #include "interface_observer.h" #include "nel/gui/interface_options.h" #include "interface_options_ryzom.h" -#include "interface_anim.h" +#include "nel/gui/interface_anim.h" #include "interface_3d_scene.h" // View #include "nel/gui/view_bitmap.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index dc240ce00..6373ae128 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -38,9 +38,9 @@ namespace NLGUI class CCtrlBase; class CGroupList; class CGroupContainer; + class CInterfaceAnim; } -class CInterfaceAnim; class CViewPointer; class CBrickJob; From 923695fe703f9c3bedc578d4624f67ea8680bed2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Jul 2012 02:50:47 +0200 Subject: [PATCH 122/339] CHANGED: #1471 Broke up CViewPointer into a generic and a Ryzom game related class. --- code/nel/include/nel/gui/widget_manager.h | 5 + code/nel/src/gui/widget_manager.cpp | 1 + code/ryzom/client/src/input.cpp | 1 + .../src/interface_v3/interface_manager.cpp | 12 +- .../src/interface_v3/interface_manager.h | 1 + .../register_interface_elements.cpp | 4 + .../client/src/interface_v3/view_pointer.cpp | 213 ++---------------- .../client/src/interface_v3/view_pointer.h | 43 ++-- .../src/interface_v3/view_pointer_ryzom.cpp | 161 +++++++++++++ .../src/interface_v3/view_pointer_ryzom.h | 31 +++ 10 files changed, 260 insertions(+), 212 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/view_pointer_ryzom.cpp create mode 100644 code/ryzom/client/src/interface_v3/view_pointer_ryzom.h diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 19df9375b..4c0720a71 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -376,6 +376,9 @@ namespace NLGUI const SInterfaceTimes& getInterfaceTimes() const{ return interfaceTimes; } void updateInterfaceTimes( const SInterfaceTimes × ){ interfaceTimes = times; } + + void setIngame( bool i ){ inGame = i; } + bool isIngame() const{ return inGame; } static IParser *parser; @@ -436,6 +439,8 @@ namespace NLGUI NLMISC::CRGBA _OverExtendViewTextBackColor; SInterfaceTimes interfaceTimes; + + bool inGame; }; } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index da9870352..a8e0610ea 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -1508,6 +1508,7 @@ namespace NLGUI _AlphaRolloverSpeedDB = NULL; _MouseHandlingEnabled = true; + inGame = false; } CWidgetManager::~CWidgetManager() diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index 6427529f8..42fa9842a 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -96,6 +96,7 @@ bool InitMouseWithCursor (bool hardware) // Get the new mouse state MouseHardware = hardware; + CViewPointer::setHWMouse( hardware ); // Reinit ? if (MouseDevice == NULL) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index dc204b2dd..8b0f5668e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -443,7 +443,7 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext _CurrentMode = 0; - _InGame = false; + setInGame( false ); _LocalSyncActionCounter= 0; // 4Bits counter. @@ -537,6 +537,12 @@ void CInterfaceManager::releaseServerToLocalAutoCopyObservers() ServerToLocalAutoCopySkillPoints.release(); } +void CInterfaceManager::setInGame( bool i ) +{ + _InGame = i; + CWidgetManager::getInstance()->setIngame( i ); +} + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::resetShardSpecificData() { @@ -925,7 +931,7 @@ void CInterfaceManager::initInGame() initActions(); } - _InGame = true; + setInGame( true ); // Init bubble manager InSceneBubbleManager.init(); @@ -1324,7 +1330,7 @@ void CInterfaceManager::uninitInGame1 () // Close LUA Scripting uninitLUA(); - _InGame = false; + setInGame( false ); _NeutralColor = NULL; _WarningColor = NULL; _ErrorColor = NULL; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 564a27525..ac3865e74 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -143,6 +143,7 @@ public: // release all of the global db autocopy observers void releaseServerToLocalAutoCopyObservers(); + void setInGame( bool i ); bool isInGame() const { return _InGame; } /// initialize the whole login interface diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 8c7d12dc5..4947d251e 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -60,10 +60,14 @@ #include "../r2/tool.h" #include "../r2/tool_pick.h" +#include "view_pointer_ryzom.h" + void registerInterfaceElements() { + CViewPointerRyzom::forceLinking(); + REGISTER_REFLECTABLE_CLASS(CInterfaceElement, CReflectable); REGISTER_REFLECTABLE_CLASS(CViewBase, CInterfaceElement); REGISTER_REFLECTABLE_CLASS(CViewText, CViewBase); diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp index 21c7bbd5f..0da7ed610 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ b/code/ryzom/client/src/interface_v3/view_pointer.cpp @@ -15,30 +15,19 @@ // along with this program. If not, see . - -#include "../input.h" #include "view_pointer.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.h" #include "nel/gui/view_renderer.h" -#include "nel/gui/ctrl_col_pick.h" #include "nel/gui/group_paragraph.h" -#include "nel/gui/group_html.h" -#include "group_map.h" -// #include "nel/misc/xml_auto_ptr.h" -// #include "nel/gui/group_container.h" -#include "interface_3d_scene.h" -// -#include "../r2/editor.h" - - - using namespace std; using namespace NLMISC; -NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "pointer"); +NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "generic_pointer"); + +bool CViewPointer::hwMouse = true; // -------------------------------------------------------------------------------------------------------------------- CViewPointer::CViewPointer (const TCtorParam ¶m) @@ -125,16 +114,13 @@ bool CViewPointer::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) if (prop) _TxCanPan = (const char *) prop; _TxCanPan = NLMISC::strlwr (_TxCanPan); - if (ClientCfg.R2EDEnabled) - { - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2"); - if (prop) _TxPanR2 = (const char *) prop; - _TxPanR2 = NLMISC::strlwr (_TxPanR2); + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2"); + if (prop) _TxPanR2 = (const char *) prop; + _TxPanR2 = NLMISC::strlwr (_TxPanR2); - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2"); - if (prop) _TxCanPanR2 = (const char *) prop; - _TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2); - } + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2"); + if (prop) _TxCanPanR2 = (const char *) prop; + _TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2); prop = (char*) xmlGetProp (cur, (xmlChar*)"color"); if (prop) _Color = convertColor(prop); @@ -162,23 +148,22 @@ void CViewPointer::draw () if(!_PointerVisible) return; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); - if (pIM->isInGame()) + if ( CWidgetManager::getInstance()->isIngame() ) if (!_StringCursor) { // Create the string cursor instance std::vector > templateParams; templateParams.push_back (std::pair("id", "string_cursor")); - _StringCursor = pIM->createGroupInstance("string_cursor", "", templateParams); + _StringCursor = CWidgetManager::parser->createGroupInstance("string_cursor", "", templateParams); if (_StringCursor) _StringCursor->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); templateParams.clear(); templateParams.push_back (std::pair("id", "string_cursor_hardware")); - _StringCursorHardware = pIM->createGroupInstance("string_cursor_hardware", "", templateParams); + _StringCursorHardware = CWidgetManager::parser->createGroupInstance("string_cursor_hardware", "", templateParams); if (_StringCursorHardware) _StringCursorHardware->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); } @@ -225,11 +210,9 @@ void CViewPointer::draw () _TxIdColPick = rVR.getTextureIdFromName (_TxColPick); _TxIdPan = rVR.getTextureIdFromName (_TxPan); _TxIdCanPan = rVR.getTextureIdFromName (_TxCanPan); - if (ClientCfg.R2EDEnabled) - { - _TxIdPanR2 = rVR.getTextureIdFromName (_TxPanR2); - _TxIdCanPanR2 = rVR.getTextureIdFromName (_TxCanPanR2); - } + _TxIdPanR2 = rVR.getTextureIdFromName (_TxPanR2); + _TxIdCanPanR2 = rVR.getTextureIdFromName (_TxCanPanR2); + } const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer (); @@ -240,7 +223,6 @@ void CViewPointer::draw () if (pCB != NULL) { if (drawResizer(pCB,col)) return; - //if (drawMover(pCB,col)) return; if (drawColorPicker(pCB,col)) return; if (drawRotate(pCB,col)) return; if (drawPan(pCB,col)) return; @@ -264,7 +246,7 @@ void CViewPointer::draw () setString(ucstring(tooltip)); sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); - CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor; + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; if (stringCursor) { stringCursor->setX(_PointerX); @@ -272,7 +254,7 @@ void CViewPointer::draw () stringCursor->updateCoords(); stringCursor->draw(); // if in hardware mode, force to draw the default cursor no matter what.. - if (IsMouseCursorHardware()) + if ( hwMouse ) drawCursor(texId, col, 0); } else @@ -357,8 +339,6 @@ void CViewPointer::draw () } } } - - //if (drawMover(pCB,col)) return; } } @@ -382,7 +362,7 @@ void CViewPointer::draw () if (_StringMode && CWidgetManager::getInstance()->isMouseHandlingEnabled()) { - CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor; + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; if (stringCursor) { stringCursor->setX(_PointerX); @@ -390,7 +370,7 @@ void CViewPointer::draw () stringCursor->updateCoords(); stringCursor->draw(); // if in hardware mode, force to draw the default cursor no matter what.. - if (IsMouseCursorHardware()) + if ( hwMouse ) { drawCursor(_TxIdDefault, col, 0); } @@ -403,150 +383,6 @@ void CViewPointer::draw () } } -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawResizer(CCtrlBase* pCB, CRGBA col) -{ - CCtrlResizer *pCR = dynamic_cast(pCB); - if (pCR != NULL) - { - CGroupContainer *parent = dynamic_cast(pCR->getParent()); - if (parent && !parent->isLocked()) - { - sint32 texID= -1; - switch(pCR->getRealResizerPos()) - { - case Hotspot_BR: - case Hotspot_TL: - texID = _TxIdResizeBRTL; - break; - case Hotspot_BL: - case Hotspot_TR: - texID = _TxIdResizeBLTR; - break; - case Hotspot_MR: - case Hotspot_ML: - texID = _TxIdResizeLR; - break; - case Hotspot_TM: - case Hotspot_BM: - texID = _TxIdResizeTB; - break; - default: - return false; - break; - } - drawCursor(texID, col, false); - return true; - } - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawMover(CCtrlBase* pCB, CRGBA col) -{ - CCtrlMover *pCM = dynamic_cast(pCB); - if ((pCM != NULL) && (pCM->canMove() == true)) - { - drawCursor(_TxIdMoveWindow, col, 0); - return true; - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawRotate (CCtrlBase* pCB, CRGBA col) -{ - CInterface3DScene *pI3DS = dynamic_cast(pCB); - if (pI3DS != NULL) - { - drawCursor(_TxIdRotate, col, 0); - return true; - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawScale (CCtrlBase* pCB, CRGBA col) -{ - CInterface3DScene *pI3DS = dynamic_cast(pCB); - if (pI3DS != NULL) - { - drawCursor(_TxIdScale, col, 0); - return true; - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawColorPicker (CCtrlBase* pCB, CRGBA col) -{ - CCtrlColPick *pCCP = dynamic_cast(pCB); - if (pCCP != NULL) - { - drawCursor(_TxIdColPick, col, 0); - return true; - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawLink (CCtrlBase* pCB, CRGBA col) -{ - CCtrlLink *pCCP = dynamic_cast(pCB); - if (pCCP != NULL) - { - drawCursor(_TxIdColPick, col, 0); - return true; - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawBrowse (CCtrlBase* pCB, CRGBA col) -{ - CGroupHTML *pCGH = dynamic_cast(pCB); - if (pCGH != NULL) - { - if (pCGH->isBrowsing()) - { - static uint8 rot =0; - drawCursor(_TxIdRotate, col, rot>>3); - rot = (rot+1) & 0x1f; - return true; - } - } - return false; -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawPan(CCtrlBase* pCB, NLMISC::CRGBA col) -{ - CGroupMap *gm = dynamic_cast(pCB); - if (gm) - { - sint32 texId; - if (ClientCfg.R2EDEnabled && R2::getEditor().getCurrentTool()) - { - /** If cursor is set to anything other than the default cursor, use that cursor (because action can be performed on the map - * by the current tool - */ - if (_TxDefault == "curs_default.tga") - { - texId = gm->isPanning() ? _TxIdPanR2 : _TxIdCanPanR2; - } - else return false; - } - else - { - texId = gm->isPanning() ? _TxIdPan : _TxIdCanPan; - } - drawCursor(texId, col, 0); - return true; - } - return false; -} - // -------------------------------------------------------------------------------------------------------------------- bool CViewPointer::drawCustom(CCtrlBase* pCB) { @@ -565,11 +401,10 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) tooltip = tooltipInfosList[1]; nlinfo(tooltip.c_str()); setString(ucstring(tooltip)); - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); - CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor; + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; if (stringCursor) { stringCursor->setX(_PointerX); @@ -577,7 +412,7 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) stringCursor->updateCoords(); stringCursor->draw(); // if in hardware mode, force to draw the default cursor no matter what.. - if (IsMouseCursorHardware()) + if ( hwMouse ) drawCursor(texId, col, 0); } else @@ -588,7 +423,6 @@ bool CViewPointer::drawCustom(CCtrlBase* pCB) } else { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 texId = rVR.getTextureIdFromName (texName); drawCursor(texId, col, 0); @@ -647,11 +481,10 @@ void CViewPointer::setString (const ucstring &str) // -------------------------------------------------------------------------------------------------------------------- void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 xPos = _XReal + _OffsetX; sint32 yPos = _YReal + _OffsetY; - if (!IsMouseCursorHardware()) + if ( !hwMouse ) { rVR.draw11RotFlipBitmap (_RenderLayer, xPos, yPos, rot, false, texId, col); } diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h index 7b1b85e30..cc422734c 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ b/code/ryzom/client/src/interface_v3/view_pointer.h @@ -38,13 +38,15 @@ namespace NLGUI class CViewPointer : public CViewPointerBase { - friend void SetMouseFreeLook (); - friend void SetMouseCursor (bool updateMousePos); + public: - DECLARE_UI_CLASS( CViewPointerBase ) - CViewPointer (const TCtorParam ¶m); + DECLARE_UI_CLASS( CViewPointer ) + + CViewPointer( const TCtorParam ¶m ); + virtual ~CViewPointer(){} + bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - void draw (); + void draw(); // Set cursor mode void setStringMode (bool stringCursor); @@ -53,7 +55,6 @@ public: // Set cursor string void setString (const ucstring &str); -public: // TEMP PATCH void setCursor (const std::string &name) { @@ -62,24 +63,25 @@ public: } // TEMP PATCH -private: - /// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead. void show(bool s) {_PointerVisible = s;} - /// Drawing helpers - bool drawResizer (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawMover (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawRotate (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawScale (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawColorPicker (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawLink (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawBrowse (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawPan (CCtrlBase* pCB, NLMISC::CRGBA col); - bool drawCustom (CCtrlBase* pCB); + static void setHWMouse( bool hw ){ hwMouse = hw; } private: + /// Drawing helpers + virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawCustom(CCtrlBase* pCB); + +protected: + // Look of the cursor in different situation std::string _TxDefault; std::string _TxMoveWindow; @@ -123,12 +125,15 @@ private: CInterfaceGroup *_StringCursorHardware; ucstring _ContextString; -private: // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); + +private: // set the string into frame for software or hardware version void setString (const ucstring &str, CInterfaceGroup *target); + static bool hwMouse; + }; diff --git a/code/ryzom/client/src/interface_v3/view_pointer_ryzom.cpp b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.cpp new file mode 100644 index 000000000..b161b9dda --- /dev/null +++ b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.cpp @@ -0,0 +1,161 @@ +#include "view_pointer_ryzom.h" +#include "group_map.h" +#include "nel/gui/group_html.h" +#include "interface_3d_scene.h" +#include "../r2/editor.h" +#include "nel/gui/ctrl_col_pick.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/group_paragraph.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/group_container.h" + + +NLMISC_REGISTER_OBJECT( CViewBase, CViewPointerRyzom, std::string, "pointer"); + +CViewPointerRyzom::CViewPointerRyzom( const TCtorParam ¶m ) : +CViewPointer( param ) +{ +} + +CViewPointerRyzom::~CViewPointerRyzom() +{ +} + +void CViewPointerRyzom::forceLinking() +{ +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawResizer(CCtrlBase* pCB, CRGBA col) +{ + CCtrlResizer *pCR = dynamic_cast(pCB); + if (pCR != NULL) + { + CGroupContainer *parent = dynamic_cast(pCR->getParent()); + if (parent && !parent->isLocked()) + { + sint32 texID= -1; + switch(pCR->getRealResizerPos()) + { + case Hotspot_BR: + case Hotspot_TL: + texID = _TxIdResizeBRTL; + break; + case Hotspot_BL: + case Hotspot_TR: + texID = _TxIdResizeBLTR; + break; + case Hotspot_MR: + case Hotspot_ML: + texID = _TxIdResizeLR; + break; + case Hotspot_TM: + case Hotspot_BM: + texID = _TxIdResizeTB; + break; + default: + return false; + break; + } + drawCursor(texID, col, false); + return true; + } + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawRotate (CCtrlBase* pCB, CRGBA col) +{ + CInterface3DScene *pI3DS = dynamic_cast(pCB); + if (pI3DS != NULL) + { + drawCursor(_TxIdRotate, col, 0); + return true; + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawScale (CCtrlBase* pCB, CRGBA col) +{ + CInterface3DScene *pI3DS = dynamic_cast(pCB); + if (pI3DS != NULL) + { + drawCursor(_TxIdScale, col, 0); + return true; + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawColorPicker (CCtrlBase* pCB, CRGBA col) +{ + CCtrlColPick *pCCP = dynamic_cast(pCB); + if (pCCP != NULL) + { + drawCursor(_TxIdColPick, col, 0); + return true; + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawLink (CCtrlBase* pCB, CRGBA col) +{ + CCtrlLink *pCCP = dynamic_cast(pCB); + if (pCCP != NULL) + { + drawCursor(_TxIdColPick, col, 0); + return true; + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawBrowse (CCtrlBase* pCB, CRGBA col) +{ + CGroupHTML *pCGH = dynamic_cast(pCB); + if (pCGH != NULL) + { + if (pCGH->isBrowsing()) + { + static uint8 rot =0; + drawCursor(_TxIdRotate, col, rot>>3); + rot = (rot+1) & 0x1f; + return true; + } + } + return false; +} + +// -------------------------------------------------------------------------------------------------------------------- +bool CViewPointerRyzom::drawPan(CCtrlBase* pCB, NLMISC::CRGBA col) +{ + CGroupMap *gm = dynamic_cast(pCB); + if (gm) + { + sint32 texId; + if (ClientCfg.R2EDEnabled && R2::getEditor().getCurrentTool()) + { + /** If cursor is set to anything other than the default cursor, use that cursor (because action can be performed on the map + * by the current tool + */ + if (_TxDefault == "curs_default.tga") + { + texId = gm->isPanning() ? _TxIdPanR2 : _TxIdCanPanR2; + } + else return false; + } + else + { + texId = gm->isPanning() ? _TxIdPan : _TxIdCanPan; + } + drawCursor(texId, col, 0); + return true; + } + return false; +} + + diff --git a/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h new file mode 100644 index 000000000..8afa7d654 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h @@ -0,0 +1,31 @@ +#ifndef VIEW_POINTER_RYZOM_H +#define VIEW_POINTER_RYZOM_H + + +#include "view_pointer.h" + +class CViewPointerRyzom : public CViewPointer +{ +public: + DECLARE_UI_CLASS( CViewPointerRyzom ) + CViewPointerRyzom( const TCtorParam ¶m ); + ~CViewPointerRyzom(); + + static void forceLinking(); + +private: + bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col); + bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col); + +}; + + + +#endif + + From 363bb731c7bebdc2f323f002d3c99d23406d7ceb Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Jul 2012 03:21:42 +0200 Subject: [PATCH 123/339] CHANGED: #1471 CViewPointer is now part of the NELGUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/view_pointer.h | 142 +++++ code/nel/src/gui/view_pointer.cpp | 505 ++++++++++++++++++ .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- .../src/interface_v3/interface_parser.h | 2 +- .../client/src/interface_v3/view_pointer.cpp | 499 ----------------- .../client/src/interface_v3/view_pointer.h | 143 ----- .../src/interface_v3/view_pointer_ryzom.h | 2 +- 8 files changed, 651 insertions(+), 646 deletions(-) create mode 100644 code/nel/include/nel/gui/view_pointer.h create mode 100644 code/nel/src/gui/view_pointer.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_pointer.cpp delete mode 100644 code/ryzom/client/src/interface_v3/view_pointer.h diff --git a/code/nel/include/nel/gui/view_pointer.h b/code/nel/include/nel/gui/view_pointer.h new file mode 100644 index 000000000..1bcfefc08 --- /dev/null +++ b/code/nel/include/nel/gui/view_pointer.h @@ -0,0 +1,142 @@ +// Ryzom - MMORPG Framework +// 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 RZ_VIEW_POINTER_H +#define RZ_VIEW_POINTER_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/events.h" +#include "nel/gui/view_pointer_base.h" + +namespace NLGUI +{ + class CCtrlBase; + class CGroupContainer; + + /** + * class describing the pointer + * \author Matthieu 'Trap' Besson + * \author Nevrax France + * \date 2002 + */ + + class CViewPointer : public CViewPointerBase + { + + public: + DECLARE_UI_CLASS( CViewPointer ) + + CViewPointer( const TCtorParam ¶m ); + virtual ~CViewPointer(){} + + bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + void draw(); + + // Set cursor mode + void setStringMode (bool stringCursor); + bool getStringMode() const {return _StringMode;} + + // Set cursor string + void setString (const ucstring &str); + + // TEMP PATCH + void setCursor (const std::string &name) + { + _TxDefault = name; + _TxIdDefault = -2; + } + // TEMP PATCH + + /// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead. + void show(bool s) {_PointerVisible = s;} + + static void setHWMouse( bool hw ){ hwMouse = hw; } + + private: + + /// Drawing helpers + virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } + virtual bool drawCustom(CCtrlBase* pCB); + + protected: + + // Look of the cursor in different situation + std::string _TxDefault; + std::string _TxMoveWindow; + std::string _TxResizeBRTL; + std::string _TxResizeBLTR; + std::string _TxResizeTB; + std::string _TxResizeLR; + std::string _TxRotate; + std::string _TxScale; + std::string _TxColPick; + std::string _TxPan; + std::string _TxCanPan; + std::string _TxPanR2; + std::string _TxCanPanR2; + + sint32 _TxIdDefault; + sint32 _TxIdMoveWindow; + sint32 _TxIdResizeBRTL; + sint32 _TxIdResizeBLTR; + sint32 _TxIdResizeTB; + sint32 _TxIdResizeLR; + sint32 _TxIdRotate; + sint32 _TxIdScale; + sint32 _TxIdColPick; + sint32 _TxIdPan; + sint32 _TxIdCanPan; + sint32 _TxIdPanR2; + sint32 _TxIdCanPanR2; + + NLMISC::CRGBA _Color; + + sint32 _OffsetX; + sint32 _OffsetY; + + CGroupContainer *_LastHightLight; + + // Cursor mode + bool _StringMode; + bool _ForceStringMode; + CInterfaceGroup *_StringCursor; + CInterfaceGroup *_StringCursorHardware; + ucstring _ContextString; + + // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape + void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); + + private: + // set the string into frame for software or hardware version + void setString (const ucstring &str, CInterfaceGroup *target); + + static bool hwMouse; + + }; + +} + +#endif // RZ_VIEW_POINTER_H + +/* End of view_pointer.h */ diff --git a/code/nel/src/gui/view_pointer.cpp b/code/nel/src/gui/view_pointer.cpp new file mode 100644 index 000000000..ce0e3ad7b --- /dev/null +++ b/code/nel/src/gui/view_pointer.cpp @@ -0,0 +1,505 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/view_pointer.h" +#include "nel/gui/widget_manager.h" +#include "nel/gui/view_renderer.h" +#include "nel/gui/group_paragraph.h" +#include "nel/gui/group_container.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/misc/algo.h" + +using namespace std; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "generic_pointer"); + +namespace NLGUI +{ + + bool CViewPointer::hwMouse = true; + + // -------------------------------------------------------------------------------------------------------------------- + CViewPointer::CViewPointer (const TCtorParam ¶m) + : CViewPointerBase(param) + { + _TxIdDefault = -2; + _TxIdMoveWindow = -2; + _TxIdResizeBRTL = -2; + _TxIdResizeBLTR = -2; + _TxIdResizeTB = -2; + _TxIdResizeLR = -2; + _TxIdRotate = -2; + _TxIdScale = -2; + _TxIdColPick = -2; + _TxIdPan = -2; + _TxIdCanPan = -2; + _TxIdPanR2 = -2; + _TxIdCanPanR2 = -2; + + // The pointer must be draw over ALL layers + _RenderLayer= VR_LAYER_MAX; + _Color = CRGBA(255,255,255,255); + _LastHightLight = NULL; + _StringMode = false; + _ForceStringMode = false; + _StringCursor = NULL; + } + + + // +++ VIEW SPECIFIC +++ + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointer::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) + { + CXMLAutoPtr prop; + + if (! CViewBase::parse(cur, parentGroup) ) + return false; + + _OffsetX = getX(); + _OffsetY = getY(); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default"); + if (prop) _TxDefault = (const char *) prop; + _TxDefault = NLMISC::strlwr (_TxDefault); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window"); + if (prop) _TxMoveWindow = (const char *) prop; + _TxMoveWindow = NLMISC::strlwr (_TxMoveWindow); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL"); + if (prop) _TxResizeBRTL = (const char *) prop; + _TxResizeBRTL = NLMISC::strlwr (_TxResizeBRTL); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR"); + if (prop) _TxResizeBLTR = (const char *) prop; + _TxResizeBLTR = NLMISC::strlwr (_TxResizeBLTR); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB"); + if (prop) _TxResizeTB = (const char *) prop; + _TxResizeTB = NLMISC::strlwr (_TxResizeTB); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR"); + if (prop) _TxResizeLR = (const char *) prop; + _TxResizeLR = NLMISC::strlwr (_TxResizeLR); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate"); + if (prop) _TxRotate = (const char *) prop; + _TxRotate = NLMISC::strlwr (_TxRotate); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale"); + if (prop) _TxScale = (const char *) prop; + _TxScale = NLMISC::strlwr (_TxScale); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick"); + if (prop) _TxColPick = (const char *) prop; + _TxColPick = NLMISC::strlwr (_TxColPick); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan"); + if (prop) _TxPan = (const char *) prop; + _TxPan = NLMISC::strlwr (_TxPan); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan"); + if (prop) _TxCanPan = (const char *) prop; + _TxCanPan = NLMISC::strlwr (_TxCanPan); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2"); + if (prop) _TxPanR2 = (const char *) prop; + _TxPanR2 = NLMISC::strlwr (_TxPanR2); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2"); + if (prop) _TxCanPanR2 = (const char *) prop; + _TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2); + + prop = (char*) xmlGetProp (cur, (xmlChar*)"color"); + if (prop) _Color = convertColor(prop); + + return true; + } + + // -------------------------------------------------------------------------------------------------------------------- + class CCtrlDepthEntry + { + public: + CCtrlBase *Ctrl; + uint Depth; + bool operator<(const CCtrlDepthEntry &o) const + { + // Inverse Test => descending order + return Depth>o.Depth; + } + }; + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointer::draw () + { + // Do not display the pointer if not visible. + if(!_PointerVisible) + return; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + if ( CWidgetManager::getInstance()->isIngame() ) + if (!_StringCursor) + { + // Create the string cursor instance + std::vector > templateParams; + templateParams.push_back (std::pair("id", "string_cursor")); + + _StringCursor = CWidgetManager::parser->createGroupInstance("string_cursor", "", templateParams); + if (_StringCursor) + _StringCursor->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); + + templateParams.clear(); + templateParams.push_back (std::pair("id", "string_cursor_hardware")); + _StringCursorHardware = CWidgetManager::parser->createGroupInstance("string_cursor_hardware", "", templateParams); + if (_StringCursorHardware) + _StringCursorHardware->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); + } + + CRGBA col; + if(getModulateGlobalColor()) + col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColor()); + else + col= _Color; + + //col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColor().A+1))>>8); + col.A = _Color.A; + + if (_LastHightLight != NULL) + { + _LastHightLight->setHighLighted(false,0); + _LastHightLight = NULL; + } + + if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + CCtrlMover *pCM = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft()); + if ((pCM != NULL) && (pCM->canMove() == true)) + { + CGroupContainer *pGC = dynamic_cast(pCM->getParent()); + if (pGC != NULL && !pGC->isLocked()) + { + pGC->setHighLighted(true, 255); + _LastHightLight = pGC; + } + } + } + + if (_TxIdDefault == -2) + { + _TxIdDefault = rVR.getTextureIdFromName (_TxDefault); + _TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow); + _TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL); + _TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR); + _TxIdResizeTB = rVR.getTextureIdFromName (_TxResizeTB); + _TxIdResizeLR = rVR.getTextureIdFromName (_TxResizeLR); + _TxIdRotate = rVR.getTextureIdFromName (_TxRotate); + _TxIdScale = rVR.getTextureIdFromName (_TxScale); + _TxIdColPick = rVR.getTextureIdFromName (_TxColPick); + _TxIdPan = rVR.getTextureIdFromName (_TxPan); + _TxIdCanPan = rVR.getTextureIdFromName (_TxCanPan); + _TxIdPanR2 = rVR.getTextureIdFromName (_TxPanR2); + _TxIdCanPanR2 = rVR.getTextureIdFromName (_TxCanPanR2); + + } + + const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer (); + + + // Draw the captured cursor + CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); + if (pCB != NULL) + { + if (drawResizer(pCB,col)) return; + if (drawColorPicker(pCB,col)) return; + if (drawRotate(pCB,col)) return; + if (drawPan(pCB,col)) return; + if (drawCustom(pCB)) return; + drawCursor(_TxIdDefault, col, 0); + return; + } + + const vector &vUP = CWidgetManager::getInstance()->getViewsUnderPointer (); + + for(uint i=0;i(vUP[i]); + if (vLink != NULL) + { + string tooltip; + uint8 rot; + + if (vLink->getMouseOverShape(tooltip, rot, col)) + { + setString(ucstring(tooltip)); + sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); + + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; + if (stringCursor) + { + stringCursor->setX(_PointerX); + stringCursor->setY(_PointerY); + stringCursor->updateCoords(); + stringCursor->draw(); + // if in hardware mode, force to draw the default cursor no matter what.. + if ( hwMouse ) + drawCursor(texId, col, 0); + } + else + { + drawCursor(texId, col, 0); + } + return; + } + } + } + + // Draw if capture right + pCB = CWidgetManager::getInstance()->getCapturePointerRight(); + if (pCB != NULL) + { + // Is it a 3d scene ? + if (drawScale(pCB,col)) return; + drawCursor(_TxIdDefault, col, 0); + return; + } + + bool overModalWindow = false; + + + // is the cursor currently over a modal window ? + CInterfaceGroup *currModal = CWidgetManager::getInstance()->getModalWindow(); + if (currModal) + { + sint32 xPos = _XReal + _OffsetX; + sint32 yPos = _YReal + _OffsetY; + overModalWindow = currModal->isIn(xPos, yPos, _WReal, _HReal); + } + + // Draw the cursor type that are under the pointer + if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + // Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo. + // Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group) + static vector sortedControls; + sortedControls.clear(); + for(uint i=0;igetParentDepth() + cde.Ctrl->getDeltaDepth(); + sortedControls.push_back(cde); + } + std::sort(sortedControls.begin(), sortedControls.end()); + + // Then draw the correct cursor + for (uint32 i = 0; i < sortedControls.size(); ++i) + { + CCtrlBase *pCB = sortedControls[i].Ctrl; + + if (overModalWindow) + { + if (!pCB->isSonOf(currModal)) continue; + } + + if (drawBrowse(pCB, col)) return; + if (drawResizer(pCB,col)) return; + if (drawColorPicker(pCB,col)) return; + if (drawLink (pCB, col)) return; + if (drawCustom(pCB)) return; + + // test for move highlight + if (_LastHightLight == NULL) + { + CCtrlMover *pCM = dynamic_cast(pCB); + if ( (pCM != NULL) && (pCM->canMove() == true) ) + { + CGroupContainer *pGC = dynamic_cast(pCM->getParent()); + if (pGC != NULL && !pGC->isLocked()) + { + if (CWidgetManager::getInstance()->getCapturePointerLeft() != pCM) + pGC->setHighLighted(true, 128); + else + pGC->setHighLighted(true, 255); + _LastHightLight = pGC; + break; + } + } + } + } + } + + if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + if (rICL.empty()) + { + const vector &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer (); + for (uint32 i = 0; i < rIGL.size(); ++i) + { + CInterfaceGroup *pG = rIGL[i]; + if (overModalWindow) + { + if (!pG->isSonOf(currModal)) continue; + } + if (drawPan (pG, col)) return; + if (drawBrowse(pG, col)) return; + } + } + } + + if (_StringMode && CWidgetManager::getInstance()->isMouseHandlingEnabled()) + { + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; + if (stringCursor) + { + stringCursor->setX(_PointerX); + stringCursor->setY(_PointerY); + stringCursor->updateCoords(); + stringCursor->draw(); + // if in hardware mode, force to draw the default cursor no matter what.. + if ( hwMouse ) + { + drawCursor(_TxIdDefault, col, 0); + } + } + } + else + { + // Draw the default cursor + drawCursor(_TxIdDefault, col, 0); + } + } + + // -------------------------------------------------------------------------------------------------------------------- + bool CViewPointer::drawCustom(CCtrlBase* pCB) + { + string texName; + uint8 rot; + NLMISC::CRGBA col; + if (pCB->getMouseOverShape(texName, rot, col)) + { + if (texName[0] == '@') + { + const string &tooltipInfos = texName.substr(1); + string tooltip; + vector tooltipInfosList; + splitString(tooltipInfos, "@", tooltipInfosList); + texName = tooltipInfosList[0]; + tooltip = tooltipInfosList[1]; + nlinfo(tooltip.c_str()); + setString(ucstring(tooltip)); + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 texId = rVR.getTextureIdFromName (texName); + + CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; + if (stringCursor) + { + stringCursor->setX(_PointerX); + stringCursor->setY(_PointerY); + stringCursor->updateCoords(); + stringCursor->draw(); + // if in hardware mode, force to draw the default cursor no matter what.. + if ( hwMouse ) + drawCursor(texId, col, 0); + } + else + { + drawCursor(texId, col, 0); + } + return true; + } + else + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 texId = rVR.getTextureIdFromName (texName); + drawCursor(texId, col, 0); + return true; + } + } + return false; + } + + + // +++ SET +++ + + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointer::setStringMode (bool stringCursor) + { + _StringMode = stringCursor; + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointer::setString (const ucstring &str, CInterfaceGroup *target) + { + if (target) + { + CInterfaceElement *element = target->getView ("fake_txt"); + if (element) + { + CViewText *text = dynamic_cast (element); + if (text) + text->setText(str); + } + element = target->getView ("real_txt"); + if (element) + { + CViewText *text = dynamic_cast (element); + if (text) + text->setText(str); + } + target->updateCoords(); + target->updateCoords(); + _ContextString = str; + } + } + + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointer::setString (const ucstring &str) + { + if (_ContextString != str) + { + setString(str, _StringCursor); + setString(str, _StringCursorHardware); + } + } + + // -------------------------------------------------------------------------------------------------------------------- + void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 xPos = _XReal + _OffsetX; + sint32 yPos = _YReal + _OffsetY; + if ( !hwMouse ) + { + rVR.draw11RotFlipBitmap (_RenderLayer, xPos, yPos, rot, false, texId, col); + } + else + { + // set new cursor for the hardware mouse + std::string name = rVR.getTextureNameFromId(texId); + rVR.getDriver()->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0)); + } + } + + +} + diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index ac3865e74..a142f4d17 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -27,7 +27,7 @@ #include "nel/gui/interface_link.h" #include "nel/gui/group_list.h" #include "nel/gui/view_base.h" -#include "view_pointer.h" +#include "nel/gui/view_pointer.h" #include "nel/gui/ctrl_base.h" #include "nel/gui/ctrl_scroll.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index bf120d761..5d8462e94 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -44,7 +44,7 @@ #include "nel/gui/view_text_id.h" #include "nel/gui/view_text_id_formated.h" #include "view_radar.h" -#include "view_pointer.h" +#include "nel/gui/view_pointer.h" // DBView (View linked to the database) #include "nel/gui/dbview_bar.h" #include "nel/gui/dbview_bar3.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 6373ae128..076fe56ff 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -39,9 +39,9 @@ namespace NLGUI class CGroupList; class CGroupContainer; class CInterfaceAnim; + class CViewPointer; } -class CViewPointer; class CBrickJob; // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/view_pointer.cpp b/code/ryzom/client/src/interface_v3/view_pointer.cpp deleted file mode 100644 index 0da7ed610..000000000 --- a/code/ryzom/client/src/interface_v3/view_pointer.cpp +++ /dev/null @@ -1,499 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "view_pointer.h" -#include "nel/gui/widget_manager.h" -#include "nel/gui/view_renderer.h" -#include "nel/gui/group_paragraph.h" -#include "nel/misc/xml_auto_ptr.h" -#include "nel/gui/group_container.h" - -using namespace std; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CViewPointer, std::string, "generic_pointer"); - -bool CViewPointer::hwMouse = true; - -// -------------------------------------------------------------------------------------------------------------------- -CViewPointer::CViewPointer (const TCtorParam ¶m) - : CViewPointerBase(param) -{ - _TxIdDefault = -2; - _TxIdMoveWindow = -2; - _TxIdResizeBRTL = -2; - _TxIdResizeBLTR = -2; - _TxIdResizeTB = -2; - _TxIdResizeLR = -2; - _TxIdRotate = -2; - _TxIdScale = -2; - _TxIdColPick = -2; - _TxIdPan = -2; - _TxIdCanPan = -2; - _TxIdPanR2 = -2; - _TxIdCanPanR2 = -2; - - // The pointer must be draw over ALL layers - _RenderLayer= VR_LAYER_MAX; - _Color = CRGBA(255,255,255,255); - _LastHightLight = NULL; - _StringMode = false; - _ForceStringMode = false; - _StringCursor = NULL; -} - - -// +++ VIEW SPECIFIC +++ - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) -{ - CXMLAutoPtr prop; - - if (! CViewBase::parse(cur, parentGroup) ) - return false; - - _OffsetX = getX(); - _OffsetY = getY(); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_default"); - if (prop) _TxDefault = (const char *) prop; - _TxDefault = NLMISC::strlwr (_TxDefault); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_move_window"); - if (prop) _TxMoveWindow = (const char *) prop; - _TxMoveWindow = NLMISC::strlwr (_TxMoveWindow); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BR_TL"); - if (prop) _TxResizeBRTL = (const char *) prop; - _TxResizeBRTL = NLMISC::strlwr (_TxResizeBRTL); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_BL_TR"); - if (prop) _TxResizeBLTR = (const char *) prop; - _TxResizeBLTR = NLMISC::strlwr (_TxResizeBLTR); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_TB"); - if (prop) _TxResizeTB = (const char *) prop; - _TxResizeTB = NLMISC::strlwr (_TxResizeTB); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_resize_LR"); - if (prop) _TxResizeLR = (const char *) prop; - _TxResizeLR = NLMISC::strlwr (_TxResizeLR); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_rotate"); - if (prop) _TxRotate = (const char *) prop; - _TxRotate = NLMISC::strlwr (_TxRotate); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_scale"); - if (prop) _TxScale = (const char *) prop; - _TxScale = NLMISC::strlwr (_TxScale); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_colpick"); - if (prop) _TxColPick = (const char *) prop; - _TxColPick = NLMISC::strlwr (_TxColPick); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan"); - if (prop) _TxPan = (const char *) prop; - _TxPan = NLMISC::strlwr (_TxPan); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan"); - if (prop) _TxCanPan = (const char *) prop; - _TxCanPan = NLMISC::strlwr (_TxCanPan); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_pan_r2"); - if (prop) _TxPanR2 = (const char *) prop; - _TxPanR2 = NLMISC::strlwr (_TxPanR2); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"tx_can_pan_r2"); - if (prop) _TxCanPanR2 = (const char *) prop; - _TxCanPanR2 = NLMISC::strlwr (_TxCanPanR2); - - prop = (char*) xmlGetProp (cur, (xmlChar*)"color"); - if (prop) _Color = convertColor(prop); - - return true; -} - -// -------------------------------------------------------------------------------------------------------------------- -class CCtrlDepthEntry -{ -public: - CCtrlBase *Ctrl; - uint Depth; - bool operator<(const CCtrlDepthEntry &o) const - { - // Inverse Test => descending order - return Depth>o.Depth; - } -}; - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::draw () -{ - // Do not display the pointer if not visible. - if(!_PointerVisible) - return; - - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - if ( CWidgetManager::getInstance()->isIngame() ) - if (!_StringCursor) - { - // Create the string cursor instance - std::vector > templateParams; - templateParams.push_back (std::pair("id", "string_cursor")); - - _StringCursor = CWidgetManager::parser->createGroupInstance("string_cursor", "", templateParams); - if (_StringCursor) - _StringCursor->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); - - templateParams.clear(); - templateParams.push_back (std::pair("id", "string_cursor_hardware")); - _StringCursorHardware = CWidgetManager::parser->createGroupInstance("string_cursor_hardware", "", templateParams); - if (_StringCursorHardware) - _StringCursorHardware->setParentPos(CWidgetManager::getInstance()->getElementFromId("ui:interface")); - } - - CRGBA col; - if(getModulateGlobalColor()) - col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColor()); - else - col= _Color; - - //col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColor().A+1))>>8); - col.A = _Color.A; - - if (_LastHightLight != NULL) - { - _LastHightLight->setHighLighted(false,0); - _LastHightLight = NULL; - } - - if ( CWidgetManager::getInstance()->getCapturePointerLeft() != NULL && CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - CCtrlMover *pCM = dynamic_cast( CWidgetManager::getInstance()->getCapturePointerLeft()); - if ((pCM != NULL) && (pCM->canMove() == true)) - { - CGroupContainer *pGC = dynamic_cast(pCM->getParent()); - if (pGC != NULL && !pGC->isLocked()) - { - pGC->setHighLighted(true, 255); - _LastHightLight = pGC; - } - } - } - - if (_TxIdDefault == -2) - { - _TxIdDefault = rVR.getTextureIdFromName (_TxDefault); - _TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow); - _TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL); - _TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR); - _TxIdResizeTB = rVR.getTextureIdFromName (_TxResizeTB); - _TxIdResizeLR = rVR.getTextureIdFromName (_TxResizeLR); - _TxIdRotate = rVR.getTextureIdFromName (_TxRotate); - _TxIdScale = rVR.getTextureIdFromName (_TxScale); - _TxIdColPick = rVR.getTextureIdFromName (_TxColPick); - _TxIdPan = rVR.getTextureIdFromName (_TxPan); - _TxIdCanPan = rVR.getTextureIdFromName (_TxCanPan); - _TxIdPanR2 = rVR.getTextureIdFromName (_TxPanR2); - _TxIdCanPanR2 = rVR.getTextureIdFromName (_TxCanPanR2); - - } - - const vector &rICL = CWidgetManager::getInstance()->getCtrlsUnderPointer (); - - - // Draw the captured cursor - CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); - if (pCB != NULL) - { - if (drawResizer(pCB,col)) return; - if (drawColorPicker(pCB,col)) return; - if (drawRotate(pCB,col)) return; - if (drawPan(pCB,col)) return; - if (drawCustom(pCB)) return; - drawCursor(_TxIdDefault, col, 0); - return; - } - - const vector &vUP = CWidgetManager::getInstance()->getViewsUnderPointer (); - - for(uint i=0;i(vUP[i]); - if (vLink != NULL) - { - string tooltip; - uint8 rot; - - if (vLink->getMouseOverShape(tooltip, rot, col)) - { - setString(ucstring(tooltip)); - sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga"); - - CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; - if (stringCursor) - { - stringCursor->setX(_PointerX); - stringCursor->setY(_PointerY); - stringCursor->updateCoords(); - stringCursor->draw(); - // if in hardware mode, force to draw the default cursor no matter what.. - if ( hwMouse ) - drawCursor(texId, col, 0); - } - else - { - drawCursor(texId, col, 0); - } - return; - } - } - } - - // Draw if capture right - pCB = CWidgetManager::getInstance()->getCapturePointerRight(); - if (pCB != NULL) - { - // Is it a 3d scene ? - if (drawScale(pCB,col)) return; - drawCursor(_TxIdDefault, col, 0); - return; - } - - bool overModalWindow = false; - - - // is the cursor currently over a modal window ? - CInterfaceGroup *currModal = CWidgetManager::getInstance()->getModalWindow(); - if (currModal) - { - sint32 xPos = _XReal + _OffsetX; - sint32 yPos = _YReal + _OffsetY; - overModalWindow = currModal->isIn(xPos, yPos, _WReal, _HReal); - } - - // Draw the cursor type that are under the pointer - if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - // Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo. - // Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group) - static vector sortedControls; - sortedControls.clear(); - for(uint i=0;igetParentDepth() + cde.Ctrl->getDeltaDepth(); - sortedControls.push_back(cde); - } - std::sort(sortedControls.begin(), sortedControls.end()); - - // Then draw the correct cursor - for (uint32 i = 0; i < sortedControls.size(); ++i) - { - CCtrlBase *pCB = sortedControls[i].Ctrl; - - if (overModalWindow) - { - if (!pCB->isSonOf(currModal)) continue; - } - - if (drawBrowse(pCB, col)) return; - if (drawResizer(pCB,col)) return; - if (drawColorPicker(pCB,col)) return; - if (drawLink (pCB, col)) return; - if (drawCustom(pCB)) return; - - // test for move highlight - if (_LastHightLight == NULL) - { - CCtrlMover *pCM = dynamic_cast(pCB); - if ( (pCM != NULL) && (pCM->canMove() == true) ) - { - CGroupContainer *pGC = dynamic_cast(pCM->getParent()); - if (pGC != NULL && !pGC->isLocked()) - { - if (CWidgetManager::getInstance()->getCapturePointerLeft() != pCM) - pGC->setHighLighted(true, 128); - else - pGC->setHighLighted(true, 255); - _LastHightLight = pGC; - break; - } - } - } - } - } - - if (CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - if (rICL.empty()) - { - const vector &rIGL = CWidgetManager::getInstance()->getGroupsUnderPointer (); - for (uint32 i = 0; i < rIGL.size(); ++i) - { - CInterfaceGroup *pG = rIGL[i]; - if (overModalWindow) - { - if (!pG->isSonOf(currModal)) continue; - } - if (drawPan (pG, col)) return; - if (drawBrowse(pG, col)) return; - } - } - } - - if (_StringMode && CWidgetManager::getInstance()->isMouseHandlingEnabled()) - { - CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; - if (stringCursor) - { - stringCursor->setX(_PointerX); - stringCursor->setY(_PointerY); - stringCursor->updateCoords(); - stringCursor->draw(); - // if in hardware mode, force to draw the default cursor no matter what.. - if ( hwMouse ) - { - drawCursor(_TxIdDefault, col, 0); - } - } - } - else - { - // Draw the default cursor - drawCursor(_TxIdDefault, col, 0); - } -} - -// -------------------------------------------------------------------------------------------------------------------- -bool CViewPointer::drawCustom(CCtrlBase* pCB) -{ - string texName; - uint8 rot; - NLMISC::CRGBA col; - if (pCB->getMouseOverShape(texName, rot, col)) - { - if (texName[0] == '@') - { - const string &tooltipInfos = texName.substr(1); - string tooltip; - vector tooltipInfosList; - splitString(tooltipInfos, "@", tooltipInfosList); - texName = tooltipInfosList[0]; - tooltip = tooltipInfosList[1]; - nlinfo(tooltip.c_str()); - setString(ucstring(tooltip)); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 texId = rVR.getTextureIdFromName (texName); - - CInterfaceGroup *stringCursor = hwMouse ? _StringCursorHardware : _StringCursor; - if (stringCursor) - { - stringCursor->setX(_PointerX); - stringCursor->setY(_PointerY); - stringCursor->updateCoords(); - stringCursor->draw(); - // if in hardware mode, force to draw the default cursor no matter what.. - if ( hwMouse ) - drawCursor(texId, col, 0); - } - else - { - drawCursor(texId, col, 0); - } - return true; - } - else - { - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 texId = rVR.getTextureIdFromName (texName); - drawCursor(texId, col, 0); - return true; - } - } - return false; -} - - -// +++ SET +++ - - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setStringMode (bool stringCursor) -{ - _StringMode = stringCursor; -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setString (const ucstring &str, CInterfaceGroup *target) -{ - if (target) - { - CInterfaceElement *element = target->getView ("fake_txt"); - if (element) - { - CViewText *text = dynamic_cast (element); - if (text) - text->setText(str); - } - element = target->getView ("real_txt"); - if (element) - { - CViewText *text = dynamic_cast (element); - if (text) - text->setText(str); - } - target->updateCoords(); - target->updateCoords(); - _ContextString = str; - } -} - - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::setString (const ucstring &str) -{ - if (_ContextString != str) - { - setString(str, _StringCursor); - setString(str, _StringCursorHardware); - } -} - -// -------------------------------------------------------------------------------------------------------------------- -void CViewPointer::drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot) -{ - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 xPos = _XReal + _OffsetX; - sint32 yPos = _YReal + _OffsetY; - if ( !hwMouse ) - { - rVR.draw11RotFlipBitmap (_RenderLayer, xPos, yPos, rot, false, texId, col); - } - else - { - // set new cursor for the hardware mouse - std::string name = rVR.getTextureNameFromId(texId); - rVR.getDriver()->setCursor(name, col, rot, (uint32) std::max(getX() - xPos, (sint32) 0), (uint32) std::max(getY() - yPos, (sint32) 0)); - } -} - - diff --git a/code/ryzom/client/src/interface_v3/view_pointer.h b/code/ryzom/client/src/interface_v3/view_pointer.h deleted file mode 100644 index cc422734c..000000000 --- a/code/ryzom/client/src/interface_v3/view_pointer.h +++ /dev/null @@ -1,143 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 RZ_VIEW_POINTER_H -#define RZ_VIEW_POINTER_H - -#include "nel/misc/types_nl.h" -#include "nel/misc/events.h" -#include "nel/gui/view_pointer_base.h" - -namespace NLGUI -{ - class CCtrlBase; - class CGroupContainer; -} - -/** - * class describing the pointer - * \author Matthieu 'Trap' Besson - * \author Nevrax France - * \date 2002 - */ - -class CViewPointer : public CViewPointerBase -{ - -public: - DECLARE_UI_CLASS( CViewPointer ) - - CViewPointer( const TCtorParam ¶m ); - virtual ~CViewPointer(){} - - bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); - void draw(); - - // Set cursor mode - void setStringMode (bool stringCursor); - bool getStringMode() const {return _StringMode;} - - // Set cursor string - void setString (const ucstring &str); - - // TEMP PATCH - void setCursor (const std::string &name) - { - _TxDefault = name; - _TxIdDefault = -2; - } - // TEMP PATCH - - /// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead. - void show(bool s) {_PointerVisible = s;} - - static void setHWMouse( bool hw ){ hwMouse = hw; } - -private: - - /// Drawing helpers - virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; } - virtual bool drawCustom(CCtrlBase* pCB); - -protected: - - // Look of the cursor in different situation - std::string _TxDefault; - std::string _TxMoveWindow; - std::string _TxResizeBRTL; - std::string _TxResizeBLTR; - std::string _TxResizeTB; - std::string _TxResizeLR; - std::string _TxRotate; - std::string _TxScale; - std::string _TxColPick; - std::string _TxPan; - std::string _TxCanPan; - std::string _TxPanR2; - std::string _TxCanPanR2; - - sint32 _TxIdDefault; - sint32 _TxIdMoveWindow; - sint32 _TxIdResizeBRTL; - sint32 _TxIdResizeBLTR; - sint32 _TxIdResizeTB; - sint32 _TxIdResizeLR; - sint32 _TxIdRotate; - sint32 _TxIdScale; - sint32 _TxIdColPick; - sint32 _TxIdPan; - sint32 _TxIdCanPan; - sint32 _TxIdPanR2; - sint32 _TxIdCanPanR2; - - NLMISC::CRGBA _Color; - - sint32 _OffsetX; - sint32 _OffsetY; - - CGroupContainer *_LastHightLight; - - // Cursor mode - bool _StringMode; - bool _ForceStringMode; - CInterfaceGroup *_StringCursor; - CInterfaceGroup *_StringCursorHardware; - ucstring _ContextString; - - // draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape - void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot); - -private: - // set the string into frame for software or hardware version - void setString (const ucstring &str, CInterfaceGroup *target); - - static bool hwMouse; - -}; - - - -#endif // RZ_VIEW_POINTER_H - -/* End of view_pointer.h */ diff --git a/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h index 8afa7d654..9361bbcb3 100644 --- a/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h +++ b/code/ryzom/client/src/interface_v3/view_pointer_ryzom.h @@ -2,7 +2,7 @@ #define VIEW_POINTER_RYZOM_H -#include "view_pointer.h" +#include "nel/gui/view_pointer.h" class CViewPointerRyzom : public CViewPointer { From 5a76ae7b382522ddead81f75b5687c4083bbb0b2 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Jul 2012 05:07:13 +0200 Subject: [PATCH 124/339] CHANGED: #1471 Moved the basic interface expression user functions into the NELGUI library under the NLGUI namespace. --- code/nel/src/gui/interface_expr_user_fct.cpp | 1181 ++++++++++++++++ code/nel/src/gui/link_hack.cpp | 3 + .../interface_v3/interface_expr_user_fct.cpp | 1187 ----------------- 3 files changed, 1184 insertions(+), 1187 deletions(-) create mode 100644 code/nel/src/gui/interface_expr_user_fct.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp diff --git a/code/nel/src/gui/interface_expr_user_fct.cpp b/code/nel/src/gui/interface_expr_user_fct.cpp new file mode 100644 index 000000000..5f1607dcf --- /dev/null +++ b/code/nel/src/gui/interface_expr_user_fct.cpp @@ -0,0 +1,1181 @@ +// Ryzom - MMORPG Framework +// 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 "nel/gui/interface_expr.h" +#include "nel/gui/interface_link.h" +#include "nel/gui/interface_element.h" +#include "nel/gui/db_manager.h" +#include "nel/misc/i18n.h" + +using namespace std; +using namespace NLMISC; + +namespace NLGUI +{ + + void ifexprufct_forcelink() + { + } + + + // alias to CInterfaceExprValue + typedef CInterfaceExprValue CIEV; + + /** takes arguments of a binary operator, and promote them to the best type. + * string are not supported + * \return true + */ + bool promoteToNumericalBestType(CInterfaceExpr::TArgList &_list) + { + uint i; + bool bIsNumerical = true; + + for (i = 0 ; i < _list.size(); ++i) + if (!_list[i].isNumerical()) + bIsNumerical = false; + + if (bIsNumerical) + { + bool bDouble = false; + + for (i = 0 ; i < _list.size(); ++i) + if (_list[i].getType() == CIEV::Double) + bDouble = true; + + if (bDouble) + { + for (i = 0 ; i < _list.size(); ++i) + _list[i].toDouble(); + } + else + { + for (i = 0 ; i < _list.size(); ++i) + _list[i].toInteger(); + } + return true; + } + + return false; + } + + + ///////////////////// + // ADD 2 numbers // + ///////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctAdd) + { + if (!promoteToNumericalBestType(args)) + { + nlwarning("add : invalid entry"); + return false; + } + switch(args[0].getType()) + { + case CIEV::Integer: result.setInteger(args[0].getInteger() + args[1].getInteger()); return true; + case CIEV::Double: result.setDouble(args[0].getDouble() + args[1].getDouble()); return true; + default: break; + } + return false; + } + REGISTER_INTERFACE_USER_FCT("add", userFctAdd) + + ///////////////////// + // SUB 2 numbers // + ///////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctSub) + { + if (!promoteToNumericalBestType(args)) + { + nlwarning("sub : invalid entry"); + return false; + } + switch(args[0].getType()) + { + case CIEV::Integer: result.setInteger(args[0].getInteger() - args[1].getInteger()); return true; + case CIEV::Double: result.setDouble(args[0].getDouble() - args[1].getDouble()); return true; + default: break; + } + return false; + } + REGISTER_INTERFACE_USER_FCT("sub", userFctSub) + + /////////////////// + // MUL 2 numbers // + /////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctMul) + { + if (!promoteToNumericalBestType(args)) + { + nlwarning("mul : invalid entry"); + return false; + } + switch(args[0].getType()) + { + case CIEV::Integer: result.setInteger(args[0].getInteger() * args[1].getInteger()); return true; + case CIEV::Double: result.setDouble(args[0].getDouble() * args[1].getDouble()); return true; + default: break; + } + return false; + } + REGISTER_INTERFACE_USER_FCT("mul", userFctMul) + + /////////////////// + // DIV 2 numbers // + /////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctDiv) + { + if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) + { + nlwarning("div: bad arguments"); + return false; + } + args[0].toDouble(); + args[1].toDouble(); + if (args[1].getDouble() == 0) + { + nlwarning("div: zero divide"); + return false; + } + result.setDouble(args[0].getDouble() / args[1].getDouble()); + return true; + } + REGISTER_INTERFACE_USER_FCT("div", userFctDiv) + + /////////////////// + // MOD 2 numbers // + /////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctMod) + { + if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) + { + nlwarning("mod: bad arguments"); + return false; + } + args[0].toDouble(); + args[1].toDouble(); + if (args[1].getDouble() == 0) + { + nlwarning("mod: zero divide"); + return false; + } + result.setDouble(fmod(args[0].getDouble(), args[1].getDouble())); + return true; + } + REGISTER_INTERFACE_USER_FCT("mod", userFctMod) + + /////////////////// + // abs 1 number // + /////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctAbs) + { + if (args.size() != 1 || !args[0].isNumerical()) + { + nlwarning("abs: bad arguments"); + return false; + } + args[0].toDouble(); + result.setDouble(fabs(args[0].getDouble())); + return true; + } + REGISTER_INTERFACE_USER_FCT("abs", userFctAbs) + + //////////////////////////////////// + // Identity (copy its first arg) // + //////////////////////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctIdentity) + { + if (args.size() > 0) + { + result = args[0]; + return true; + } + else + { + return false; + } + } + REGISTER_INTERFACE_USER_FCT("identity", userFctIdentity) + + + ////////////////////////////////////////////////////////////////////////////////////////////////////// + // Evaluate all of the args, and return 0, so may be used to create dependances on database entries // + ////////////////////////////////////////////////////////////////////////////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctDepends) + { + result.setInteger(0); + return true; + } + REGISTER_INTERFACE_USER_FCT("depends", userFctDepends) + + + ////////////////////////// + // comparison operators // + ////////////////////////// + + /** ugly macro to declare comparison operator in a 'compact' way + * this can compare number vs number & string vs string + */ + #define CREATE_CMP_OPERATOR(op, name) \ + static DECLARE_INTERFACE_USER_FCT(userFct##name) \ + { \ + \ + if (args.size() != 2) \ + { \ + nlwarning("comparison : bad number of arguments"); \ + return false; \ + } \ + if (args[0].getType() == CIEV::String && args[1].getType() == CIEV::String) \ + { \ + result.setBool(strcmp(args[0].getString().c_str(), \ + args[1].getString().c_str()) op 0); \ + return true; \ + } \ + if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) \ + { \ + nlwarning("comparison : arguments are not numerical"); \ + return false; \ + } \ + args[0].toDouble(); \ + args[1].toDouble(); \ + result.setBool(args[0].getDouble() op args[1].getDouble()); \ + return true; \ + } \ + REGISTER_INTERFACE_USER_FCT(#name, userFct##name) + + + + // declare all comparison operators + //CREATE_CMP_OPERATOR(==, eq) + CREATE_CMP_OPERATOR(!=, ne) + CREATE_CMP_OPERATOR(==, eq) + CREATE_CMP_OPERATOR(< , lt) + CREATE_CMP_OPERATOR(<=, le) + CREATE_CMP_OPERATOR(> , gt) + CREATE_CMP_OPERATOR(>=, ge) + + + + ////////////////// + // Logical OR // + ////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctOr) + { + for(uint k = 0; k < args.size(); ++k) + { + if (!args[k].toBool()) + { + nlwarning("Argument is not boolean"); + return false; + } + if (args[k].getBool()) + { + result.setBool(true); + return true; + } + } + result.setBool(false); + return true; + } + REGISTER_INTERFACE_USER_FCT("or", userFctOr) + + ////////////////// + // Logical AND // + ////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctAnd) + { + for(uint k = 0; k < args.size(); ++k) + { + if (!args[k].toBool()) + { + nlwarning("Argument is not boolean"); + return false; + } + if (!args[k].getBool()) + { + result.setBool(false); + return true; + } + } + result.setBool(true); + return true; + } + REGISTER_INTERFACE_USER_FCT("and", userFctAnd) + + ////////////////// + // Logical NOT // + ////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctNot) + { + if (args.size() != 1) + { + nlwarning("not : bad number of arguments"); + return false; + } + if (!args[0].toBool()) + { + nlwarning("Argument is not boolean"); + return false; + } + result.setBool(!args[0].getBool()); + return true; + } + REGISTER_INTERFACE_USER_FCT("not", userFctNot) + + + //////////////////////////////////// + // String Add Operation // + //////////////////////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctStr) + { + if (args.size() > 0) + { + ucstring res(""); + for (uint32 i = 0; i < args.size(); ++i) + { + args[i].toString(); + res += args[i].getUCString(); + } + result.setUCString (res); + + return true; + } + else + { + return false; + } + } + REGISTER_INTERFACE_USER_FCT("str", userFctStr) + + //////////////////////////////////// + // Integer Operation // + //////////////////////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctInt) + { + if (args.size() != 1) + { + return false; + } + + args[0].toInteger(); + result.setInteger(args[0].getInteger()); + return true; + } + REGISTER_INTERFACE_USER_FCT("int", userFctInt) + + //////////////////////////////////// + // Branching Operation ifthenelse // + //////////////////////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctIfThenElse) + { + if ((args.size() < 1) || (args.size() > 3)) + return false; + + if (!args[0].toBool()) + return false; + + if (args[0].getBool()) + { + result = args[1]; + } + else + { + if (args.size() == 3) + result = args[2]; + else + result.setBool (false); + } + + return true; + } + REGISTER_INTERFACE_USER_FCT("ifthenelse", userFctIfThenElse) + + //////////////////////////////// + // Branching Operation switch // + //////////////////////////////// + + static DECLARE_INTERFACE_USER_FCT(userFctSwitch) + { + if (args.size() < 2) + return false; + + if (!args[0].toInteger()) + return false; + + sint64 n = args[0].getInteger(); + if ((n > ((sint64)args.size()-2)) || (n < 0)) + return false; + + result = args[(uint)n+1]; + + return true; + } + REGISTER_INTERFACE_USER_FCT("switch", userFctSwitch) + + ///////////////////////////////// + // Takes maximum of any numbers // + ///////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctMax) + { + // compute type of ouput + if (!promoteToNumericalBestType(args)) + { + nlwarning("max : invalid entry"); + return false; + } + uint i; + if (args[0].getType() == CIEV::Integer) + { + sint64 m; + m = args[0].getInteger(); + for (i = 1; i < args.size(); ++i) + m = std::max(m,args[i].getInteger()); + result.setInteger(m); + } + else + { + double m; + m = args[0].getDouble(); + for (i = 1; i < args.size(); ++i) + m = std::max(m,args[i].getDouble()); + result.setDouble(m); + } + return true; + } + REGISTER_INTERFACE_USER_FCT("max", userFctMax) + + ///////////////////////////////// + // Takes minimum of 2 numbers // + ///////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctMin) + { + // compute type of ouput + if (!promoteToNumericalBestType(args)) + { + nlwarning("max : invalid entry"); + return false; + } + uint i; + if (args[0].getType() == CIEV::Integer) + { + sint64 m; + m = args[0].getInteger(); + for (i = 1; i < args.size(); ++i) + m = std::min(m,args[i].getInteger()); + result.setInteger(m); + } + else + { + double m; + m = args[0].getDouble(); + for (i = 1; i < args.size(); ++i) + m = std::min(m,args[i].getDouble()); + result.setDouble(m); + } + return true; + } + REGISTER_INTERFACE_USER_FCT("min", userFctMin) + + ////////////////////////////// + // Get Reflected Property // + ////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctGetProp) + { + if (args.size() != 1) + return false; + + if (args[0].getType() != CIEV::String) + return false; + + string sTmp = args[0].getString(); + std::vector targetsVector; + CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector); + + if (targetsVector.empty()) + { + nlwarning("no target found"); + return false; + } + CInterfaceLink::CTargetInfo &rTI = targetsVector[0]; + + CInterfaceElement *elem = rTI.Elem; + if (!elem) + { + nlwarning(" : Element is NULL"); + return false; + } + const CReflectedProperty *pRP = elem->getReflectedProperty(rTI.PropertyName); + + if (!pRP) return false; + switch(pRP->Type) + { + case CReflectedProperty::Boolean: + result.setBool ((elem->*(pRP->GetMethod.GetBool))()); + break; + case CReflectedProperty::SInt32: + result.setInteger ((elem->*(pRP->GetMethod.GetSInt32))()); + break; + case CReflectedProperty::Float: + result.setDouble ((elem->*(pRP->GetMethod.GetFloat))()); + break; + case CReflectedProperty::String: + result.setString ((elem->*(pRP->GetMethod.GetString))()); + break; + case CReflectedProperty::UCString: + result.setUCString ((elem->*(pRP->GetMethod.GetUCString))()); + break; + case CReflectedProperty::RGBA: + result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))()); + break; + default: + nlstop; + return false; + } + return true; + } + REGISTER_INTERFACE_USER_FCT("getprop", userFctGetProp) + + + /////////////////////////////// + // Convert an int to a color // + /////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userIntToColor) + { + if (args.size() != 1) + { + nlwarning("Bad number of args"); + return false; + } + if (!args[0].toInteger()) + { + nlwarning("Bad type for arg 0 : should be an integer"); + return false; + } + CRGBA col; + uint32 intCol = (uint32) args[0].getInteger(); + col.R = uint8(intCol & 0xff); + col.G = uint8((intCol >> 8) & 0xff); + col.B = uint8((intCol >> 16) & 0xff); + col.A = uint8((intCol >> 24) & 0xff); + result.setRGBA(col); + return true; + } + REGISTER_INTERFACE_USER_FCT("intToColor", userIntToColor) + + /////////////////////////////// + // Get components of a color // + /////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userGetRed) + { + if (args.size() != 1) + { + nlwarning("Bad number of args"); + return false; + } + if (!args[0].toRGBA()) + { + nlwarning("Bad type for arg 0 : should be a color"); + return false; + } + result.setInteger((sint64) args[0].getRGBA().R); + return true; + } + REGISTER_INTERFACE_USER_FCT("getRed", userGetRed) + // + static DECLARE_INTERFACE_USER_FCT(userGetGreen) + { + if (args.size() != 1) + { + nlwarning("Bad number of args"); + return false; + } + if (!args[0].toRGBA()) + { + nlwarning("Bad type for arg 0 : should be a color"); + return false; + } + result.setInteger((sint64) args[0].getRGBA().G); + return true; + } + REGISTER_INTERFACE_USER_FCT("getGreen", userGetGreen) + // + static DECLARE_INTERFACE_USER_FCT(userGetBlue) + { + if (args.size() != 1) + { + nlwarning("Bad number of args"); + return false; + } + if (!args[0].toRGBA()) + { + nlwarning("Bad type for arg 0 : should be a color"); + return false; + } + result.setInteger((sint64) args[0].getRGBA().B); + return true; + } + REGISTER_INTERFACE_USER_FCT("getBlue", userGetBlue) + // + static DECLARE_INTERFACE_USER_FCT(userGetAlpha) + { + if (args.size() != 1) + { + nlwarning("Bad number of args"); + return false; + } + if (!args[0].toRGBA()) + { + nlwarning("Bad type for arg 0 : should be a color"); + return false; + } + result.setInteger((sint64) args[0].getRGBA().A); + return true; + } + REGISTER_INTERFACE_USER_FCT("getAlpha", userGetAlpha) + + //////////////////////////////////////////////// + // make a rgb color from 3 components R, G, B // + //////////////////////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userMakeRGB) + { + if ((args.size() != 3) && (args.size() != 4)) + { + nlwarning("Bad number of args : 3 or 4 args required : R, G, B, [A]"); + return false; + } + if (!args[0].toInteger() || !args[1].toInteger() || !args[2].toInteger()) + { + nlwarning("Not all args converting to integer"); + return false; + } + uint8 nAlpha = 255; + if (args.size() == 4 ) + nAlpha = (uint8)args[3].getInteger(); + + NLMISC::CRGBA col((uint8) args[0].getInteger(), (uint8) args[1].getInteger(), (uint8) args[2].getInteger(),nAlpha); + result.setRGBA(col); + + return true; + } + REGISTER_INTERFACE_USER_FCT("makeRGB", userMakeRGB) + + + ////////////////////////////// + // Get number of DB entries // + ////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userDBCount) + { + if (args.size() != 1) + return false; + + if (args[0].getType() != CIEV::String) + return false; + + string sTmp = args[0].getString(); + + if (sTmp.find('$') == string::npos) + return false; + + string sFirstPart = sTmp.substr(0,sTmp.find('$')); + string sSecondPart = sTmp.substr(sTmp.find('$')+1,sTmp.size()); + + sint i = 0; + bool bExit = false; + + while (!bExit) + { + sTmp = sFirstPart + NLMISC::toString(i) + sSecondPart; + CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false); + CCDBNodeBranch *pNB = NLGUI::CDBManager::getInstance()->getDbBranch(sTmp); + if (pNL != NULL) + { + if (pNL->getValue64() == 0) + bExit = true; + else + ++i; + } + else if (pNB != NULL) + { + ++i; + } + else + { + bExit = true; + } + } + + result.setInteger(i); + + return true; + } + REGISTER_INTERFACE_USER_FCT("dbcount", userDBCount) + + //////////////////////// + // Get a random value // + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctRand) + { + if ((args.size() != 2) && (args.size() != 0)) + return false; + + if (args.size() == 2) + { + if (!args[0].toDouble()) return false; + if (!args[1].toDouble()) return false; + + double s = args[0].getDouble(); + double e = 0.999+args[1].getDouble(); + + result.setDouble ( s + (e-s)*NLMISC::frand(1.0)); + } + else + { + result.setDouble (NLMISC::frand(1.0)); + } + + return true; + } + REGISTER_INTERFACE_USER_FCT("rand", userFctRand) + + + static DECLARE_INTERFACE_USER_FCT(userFctGetBit) + { + if (args.size() != 2) + return false; + + if (!args[0].toInteger()) return false; + if (!args[1].toInteger()) return false; + + sint64 i = args[0].getInteger(); + sint64 s = args[1].getInteger(); + + result.setInteger (0); + + if ((i & (SINT64_CONSTANT(1)<> args[1].getInteger()); + return true; + } + REGISTER_INTERFACE_USER_FCT("shr", userFctSHR) + + ////////////////////////// + // Unsigned left shift // + ////////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctSHL) + { + if (args.size() != 2) + { + nlwarning("shl : bad number of arguments"); + return false; + } + if (!args[0].toInteger() || !args[1].toInteger()) + { + nlwarning("Argument is not integer"); + return false; + } + result.setInteger(((uint64)args[0].getInteger()) << args[1].getInteger()); + return true; + } + REGISTER_INTERFACE_USER_FCT("shl", userFctSHL) + + ///////////////////////// + // Signed right shift // + ///////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctSAR) + { + if (args.size() != 2) + { + nlwarning("sar : bad number of arguments"); + return false; + } + if (!args[0].toInteger() || !args[1].toInteger()) + { + nlwarning("Argument is not integer"); + return false; + } + result.setInteger(args[0].getInteger() >> args[1].getInteger()); + return true; + } + REGISTER_INTERFACE_USER_FCT("sar", userFctSAR) + + //////////////////////// + // Signed left shift // + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(userFctSAL) + { + if (args.size() != 2) + { + nlwarning("sal : bad number of arguments"); + return false; + } + if (!args[0].toInteger() || !args[1].toInteger()) + { + nlwarning("Argument is not integer"); + return false; + } + result.setInteger(args[0].getInteger() << args[1].getInteger()); + return true; + } + REGISTER_INTERFACE_USER_FCT("sal", userFctSAL) + + ///////////////////////////////////////////////////////////////////////////// + // Extend the sign of the argument considered over 8 bits to a 64 bits int // + ///////////////////////////////////////////////////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(extSign8To64) + { + if (args.size() != 1) + { + nlwarning("extSign8To64 : bad number of arguments"); + return false; + } + if (!args[0].toInteger()) + { + nlwarning("Argument is not integer"); + return false; + } + sint8 i = (sint8)args[0].getInteger(); + result.setInteger((sint64)i); + return true; + } + REGISTER_INTERFACE_USER_FCT("extSign8To64", extSign8To64) + + ////////////////////////////////////////////////////////////////////////////// + // Extend the sign of the argument considered over 11 bits to a 64 bits int // + ////////////////////////////////////////////////////////////////////////////// + static DECLARE_INTERFACE_USER_FCT(extSign11To64) + { + if (args.size() != 1) + { + nlwarning("extSign12To64 : bad number of arguments"); + return false; + } + if (!args[0].toInteger()) + { + nlwarning("Argument is not integer"); + return false; + } + sint32 i = (sint16)args[0].getInteger() & 0x7ff; + if( i > 1023 ) + i |= 0xfffff800; + result.setInteger((sint64)i); + return true; + } + REGISTER_INTERFACE_USER_FCT("extSign11To64", extSign11To64) + + //////////////////////// + // Ryzom version info // + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(isFinalVersion) + { + if (!args.empty()) + { + nlwarning("isFinalVersion : no args required"); + return false; + } + #if FINAL_VERSION + result.setBool(true); + #else + result.setBool(false); + #endif + return true; + } + REGISTER_INTERFACE_USER_FCT("isFinalVersion", isFinalVersion) + + //////////////////////// + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(secondsToTimeString) + { + if (args.size() != 1) + { + nlwarning("intToTimeString : 1 args required"); + return false; + } + if (!args[0].toInteger()) + { + nlwarning("intToTimeString : args 0 required to be an int"); + return false; + } + + sint64 nVal = args[0].getInteger(); + ucstring sTmp; + + if (nVal < 0) nVal = 0; + + sTmp = toString(nVal % 60) + " " + CI18N::get("uiMissionTimerSecond"); + + nVal = nVal / 60; + + if( nVal > 0 ) + { + sTmp = toString(nVal % 60) + " " + CI18N::get("uiMissionTimerMinute") + " " + sTmp; + + nVal = nVal / 60; + + if( nVal > 0 ) + { + sTmp = toString(nVal % 24) + " " + CI18N::get("uiMissionTimerHour") + " " + sTmp; + + nVal = nVal / 24; + + if( nVal > 0 ) + { + sTmp = toString(nVal) + " " + CI18N::get("uiMissionTimerDay") + " " + sTmp; + } + } + } + + result.setUCString(sTmp); + + return true; + } + REGISTER_INTERFACE_USER_FCT("secondsToTimeString", secondsToTimeString) + + //////////////////////// + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(secondsToTimeStringShort) + { + if (args.size() != 1) + { + nlwarning("intToTimeString : 1 args required"); + return false; + } + if (!args[0].toInteger()) + { + nlwarning("intToTimeString : args 0 required to be an int"); + return false; + } + + sint64 nVal = args[0].getInteger(); + ucstring sTmp; + + if (nVal < 0) nVal = 0; + + sTmp = toString("%02d", nVal % 60); + + nVal = nVal / 60; + + if( nVal > 0 ) + { + sTmp = toString(nVal % 60) + "'" + sTmp; + + nVal = nVal / 60; + + // if at least one hour, just display number of hour + if( nVal > 0 ) + { + sTmp = toString(nVal % 24) + "h"; + + nVal = nVal / 24; + + // if at least one hour, just display number of days + if( nVal > 0 ) + { + sTmp = toString(nVal) + "d"; + } + } + } + + result.setUCString(sTmp); + + return true; + } + REGISTER_INTERFACE_USER_FCT("secondsToTimeStringShort", secondsToTimeStringShort) + + //////////////////////// + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(oldvalue) + { + if (args.size() != 1) + { + nlwarning("oldvalue : 1 arg required"); + return false; + } + CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(args[0].getString()); + if (!nl) + { + nlwarning("oldvalue : arg 0 required to be an interface leaf"); + return false; + } + result.setInteger (nl->getOldValue64()); + + return true; + } + REGISTER_INTERFACE_USER_FCT("oldvalue", oldvalue) + + //////////////////////// + //////////////////////// + static DECLARE_INTERFACE_USER_FCT(localize) + { + if (args.size() != 1) + { + nlwarning("localize : 1 arg required"); + return false; + } + result.setUCString(CI18N::get(args[0].getString())); + return true; + } + REGISTER_INTERFACE_USER_FCT("localize", localize); + +} + diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp index 2b1a59676..0ff2f4dc6 100644 --- a/code/nel/src/gui/link_hack.cpp +++ b/code/nel/src/gui/link_hack.cpp @@ -4,11 +4,14 @@ namespace NLGUI { + void ifexprufct_forcelink(); + /// Necessary so the linker doesn't drop the code of these classes from the library void LinkHack() { CDBViewBar3::forceLink(); CDBViewNumber::forceLink(); CDBViewQuantity::forceLink(); + ifexprufct_forcelink(); } } \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp deleted file mode 100644 index 3c16cdd75..000000000 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct.cpp +++ /dev/null @@ -1,1187 +0,0 @@ -// Ryzom - MMORPG Framework -// 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" - -// client -#include "nel/gui/interface_expr.h" -#include "ctrl_sheet_selection.h" -#include "interface_manager.h" -// game_share -#include "game_share/slot_types.h" - -using namespace std; -using namespace NLMISC; - -//////////// -// EXTERN // -//////////// - -//extern CClientChatManager ChatMngr; - - -// here we declare some operators that are used by the user interface expressions - - -// alias to CInterfaceExprValue -typedef CInterfaceExprValue CIEV; - -/** takes arguments of a binary operator, and promote them to the best type. - * string are not supported - * \return true - */ -bool promoteToNumericalBestType(CInterfaceExpr::TArgList &_list) -{ - uint i; - bool bIsNumerical = true; - - for (i = 0 ; i < _list.size(); ++i) - if (!_list[i].isNumerical()) - bIsNumerical = false; - - if (bIsNumerical) - { - bool bDouble = false; - - for (i = 0 ; i < _list.size(); ++i) - if (_list[i].getType() == CIEV::Double) - bDouble = true; - - if (bDouble) - { - for (i = 0 ; i < _list.size(); ++i) - _list[i].toDouble(); - } - else - { - for (i = 0 ; i < _list.size(); ++i) - _list[i].toInteger(); - } - return true; - } - - return false; -} - - -///////////////////// -// ADD 2 numbers // -///////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctAdd) -{ - if (!promoteToNumericalBestType(args)) - { - nlwarning("add : invalid entry"); - return false; - } - switch(args[0].getType()) - { - case CIEV::Integer: result.setInteger(args[0].getInteger() + args[1].getInteger()); return true; - case CIEV::Double: result.setDouble(args[0].getDouble() + args[1].getDouble()); return true; - default: break; - } - return false; -} -REGISTER_INTERFACE_USER_FCT("add", userFctAdd) - -///////////////////// -// SUB 2 numbers // -///////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctSub) -{ - if (!promoteToNumericalBestType(args)) - { - nlwarning("sub : invalid entry"); - return false; - } - switch(args[0].getType()) - { - case CIEV::Integer: result.setInteger(args[0].getInteger() - args[1].getInteger()); return true; - case CIEV::Double: result.setDouble(args[0].getDouble() - args[1].getDouble()); return true; - default: break; - } - return false; -} -REGISTER_INTERFACE_USER_FCT("sub", userFctSub) - -/////////////////// -// MUL 2 numbers // -/////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctMul) -{ - if (!promoteToNumericalBestType(args)) - { - nlwarning("mul : invalid entry"); - return false; - } - switch(args[0].getType()) - { - case CIEV::Integer: result.setInteger(args[0].getInteger() * args[1].getInteger()); return true; - case CIEV::Double: result.setDouble(args[0].getDouble() * args[1].getDouble()); return true; - default: break; - } - return false; -} -REGISTER_INTERFACE_USER_FCT("mul", userFctMul) - -/////////////////// -// DIV 2 numbers // -/////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctDiv) -{ - if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) - { - nlwarning("div: bad arguments"); - return false; - } - args[0].toDouble(); - args[1].toDouble(); - if (args[1].getDouble() == 0) - { - nlwarning("div: zero divide"); - return false; - } - result.setDouble(args[0].getDouble() / args[1].getDouble()); - return true; -} -REGISTER_INTERFACE_USER_FCT("div", userFctDiv) - -/////////////////// -// MOD 2 numbers // -/////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctMod) -{ - if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) - { - nlwarning("mod: bad arguments"); - return false; - } - args[0].toDouble(); - args[1].toDouble(); - if (args[1].getDouble() == 0) - { - nlwarning("mod: zero divide"); - return false; - } - result.setDouble(fmod(args[0].getDouble(), args[1].getDouble())); - return true; -} -REGISTER_INTERFACE_USER_FCT("mod", userFctMod) - -/////////////////// -// abs 1 number // -/////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctAbs) -{ - if (args.size() != 1 || !args[0].isNumerical()) - { - nlwarning("abs: bad arguments"); - return false; - } - args[0].toDouble(); - result.setDouble(fabs(args[0].getDouble())); - return true; -} -REGISTER_INTERFACE_USER_FCT("abs", userFctAbs) - -//////////////////////////////////// -// Identity (copy its first arg) // -//////////////////////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctIdentity) -{ - if (args.size() > 0) - { - result = args[0]; - return true; - } - else - { - return false; - } -} -REGISTER_INTERFACE_USER_FCT("identity", userFctIdentity) - - -////////////////////////////////////////////////////////////////////////////////////////////////////// -// Evaluate all of the args, and return 0, so may be used to create dependances on database entries // -////////////////////////////////////////////////////////////////////////////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctDepends) -{ - result.setInteger(0); - return true; -} -REGISTER_INTERFACE_USER_FCT("depends", userFctDepends) - - -////////////////////////// -// comparison operators // -////////////////////////// - -/** ugly macro to declare comparison operator in a 'compact' way - * this can compare number vs number & string vs string - */ -#define CREATE_CMP_OPERATOR(op, name) \ -static DECLARE_INTERFACE_USER_FCT(userFct##name) \ -{ \ - \ - if (args.size() != 2) \ - { \ - nlwarning("comparison : bad number of arguments"); \ - return false; \ - } \ - if (args[0].getType() == CIEV::String && args[1].getType() == CIEV::String) \ - { \ - result.setBool(strcmp(args[0].getString().c_str(), \ - args[1].getString().c_str()) op 0); \ - return true; \ - } \ - if (args.size() != 2 || !args[0].isNumerical() || !args[1].isNumerical()) \ - { \ - nlwarning("comparison : arguments are not numerical"); \ - return false; \ - } \ - args[0].toDouble(); \ - args[1].toDouble(); \ - result.setBool(args[0].getDouble() op args[1].getDouble()); \ - return true; \ -} \ -REGISTER_INTERFACE_USER_FCT(#name, userFct##name) - - - -// declare all comparison operators -//CREATE_CMP_OPERATOR(==, eq) -CREATE_CMP_OPERATOR(!=, ne) -CREATE_CMP_OPERATOR(==, eq) -CREATE_CMP_OPERATOR(< , lt) -CREATE_CMP_OPERATOR(<=, le) -CREATE_CMP_OPERATOR(> , gt) -CREATE_CMP_OPERATOR(>=, ge) - - - -////////////////// -// Logical OR // -////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctOr) -{ - for(uint k = 0; k < args.size(); ++k) - { - if (!args[k].toBool()) - { - nlwarning("Argument is not boolean"); - return false; - } - if (args[k].getBool()) - { - result.setBool(true); - return true; - } - } - result.setBool(false); - return true; -} -REGISTER_INTERFACE_USER_FCT("or", userFctOr) - -////////////////// -// Logical AND // -////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctAnd) -{ - for(uint k = 0; k < args.size(); ++k) - { - if (!args[k].toBool()) - { - nlwarning("Argument is not boolean"); - return false; - } - if (!args[k].getBool()) - { - result.setBool(false); - return true; - } - } - result.setBool(true); - return true; -} -REGISTER_INTERFACE_USER_FCT("and", userFctAnd) - -////////////////// -// Logical NOT // -////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctNot) -{ - if (args.size() != 1) - { - nlwarning("not : bad number of arguments"); - return false; - } - if (!args[0].toBool()) - { - nlwarning("Argument is not boolean"); - return false; - } - result.setBool(!args[0].getBool()); - return true; -} -REGISTER_INTERFACE_USER_FCT("not", userFctNot) - - -//////////////////////////////////// -// String Add Operation // -//////////////////////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctStr) -{ - if (args.size() > 0) - { - ucstring res(""); - for (uint32 i = 0; i < args.size(); ++i) - { - args[i].toString(); - res += args[i].getUCString(); - } - result.setUCString (res); - - return true; - } - else - { - return false; - } -} -REGISTER_INTERFACE_USER_FCT("str", userFctStr) - -//////////////////////////////////// -// Integer Operation // -//////////////////////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctInt) -{ - if (args.size() != 1) - { - return false; - } - - args[0].toInteger(); - result.setInteger(args[0].getInteger()); - return true; -} -REGISTER_INTERFACE_USER_FCT("int", userFctInt) - -//////////////////////////////////// -// Branching Operation ifthenelse // -//////////////////////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctIfThenElse) -{ - if ((args.size() < 1) || (args.size() > 3)) - return false; - - if (!args[0].toBool()) - return false; - - if (args[0].getBool()) - { - result = args[1]; - } - else - { - if (args.size() == 3) - result = args[2]; - else - result.setBool (false); - } - - return true; -} -REGISTER_INTERFACE_USER_FCT("ifthenelse", userFctIfThenElse) - -//////////////////////////////// -// Branching Operation switch // -//////////////////////////////// - -static DECLARE_INTERFACE_USER_FCT(userFctSwitch) -{ - if (args.size() < 2) - return false; - - if (!args[0].toInteger()) - return false; - - sint64 n = args[0].getInteger(); - if ((n > ((sint64)args.size()-2)) || (n < 0)) - return false; - - result = args[(uint)n+1]; - - return true; -} -REGISTER_INTERFACE_USER_FCT("switch", userFctSwitch) - -///////////////////////////////// -// Takes maximum of any numbers // -///////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctMax) -{ - // compute type of ouput - if (!promoteToNumericalBestType(args)) - { - nlwarning("max : invalid entry"); - return false; - } - uint i; - if (args[0].getType() == CIEV::Integer) - { - sint64 m; - m = args[0].getInteger(); - for (i = 1; i < args.size(); ++i) - m = std::max(m,args[i].getInteger()); - result.setInteger(m); - } - else - { - double m; - m = args[0].getDouble(); - for (i = 1; i < args.size(); ++i) - m = std::max(m,args[i].getDouble()); - result.setDouble(m); - } - return true; -} -REGISTER_INTERFACE_USER_FCT("max", userFctMax) - -///////////////////////////////// -// Takes minimum of 2 numbers // -///////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctMin) -{ - // compute type of ouput - if (!promoteToNumericalBestType(args)) - { - nlwarning("max : invalid entry"); - return false; - } - uint i; - if (args[0].getType() == CIEV::Integer) - { - sint64 m; - m = args[0].getInteger(); - for (i = 1; i < args.size(); ++i) - m = std::min(m,args[i].getInteger()); - result.setInteger(m); - } - else - { - double m; - m = args[0].getDouble(); - for (i = 1; i < args.size(); ++i) - m = std::min(m,args[i].getDouble()); - result.setDouble(m); - } - return true; -} -REGISTER_INTERFACE_USER_FCT("min", userFctMin) - -////////////////////////////// -// Get Reflected Property // -////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctGetProp) -{ - if (args.size() != 1) - return false; - - if (args[0].getType() != CIEV::String) - return false; - - string sTmp = args[0].getString(); - std::vector targetsVector; - CInterfaceLink::splitLinkTargets(sTmp, NULL, targetsVector); - - if (targetsVector.empty()) - { - nlwarning("no target found"); - return false; - } - CInterfaceLink::CTargetInfo &rTI = targetsVector[0]; - - CInterfaceElement *elem = rTI.Elem; - if (!elem) - { - nlwarning(" : Element is NULL"); - return false; - } - const CReflectedProperty *pRP = elem->getReflectedProperty(rTI.PropertyName); - - if (!pRP) return false; - switch(pRP->Type) - { - case CReflectedProperty::Boolean: - result.setBool ((elem->*(pRP->GetMethod.GetBool))()); - break; - case CReflectedProperty::SInt32: - result.setInteger ((elem->*(pRP->GetMethod.GetSInt32))()); - break; - case CReflectedProperty::Float: - result.setDouble ((elem->*(pRP->GetMethod.GetFloat))()); - break; - case CReflectedProperty::String: - result.setString ((elem->*(pRP->GetMethod.GetString))()); - break; - case CReflectedProperty::UCString: - result.setUCString ((elem->*(pRP->GetMethod.GetUCString))()); - break; - case CReflectedProperty::RGBA: - result.setRGBA ((elem->*(pRP->GetMethod.GetRGBA))()); - break; - default: - nlstop; - return false; - } - return true; -} -REGISTER_INTERFACE_USER_FCT("getprop", userFctGetProp) - - -/////////////////////////////// -// Convert an int to a color // -/////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userIntToColor) -{ - if (args.size() != 1) - { - nlwarning("Bad number of args"); - return false; - } - if (!args[0].toInteger()) - { - nlwarning("Bad type for arg 0 : should be an integer"); - return false; - } - CRGBA col; - uint32 intCol = (uint32) args[0].getInteger(); - col.R = uint8(intCol & 0xff); - col.G = uint8((intCol >> 8) & 0xff); - col.B = uint8((intCol >> 16) & 0xff); - col.A = uint8((intCol >> 24) & 0xff); - result.setRGBA(col); - return true; -} -REGISTER_INTERFACE_USER_FCT("intToColor", userIntToColor) - -/////////////////////////////// -// Get components of a color // -/////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userGetRed) -{ - if (args.size() != 1) - { - nlwarning("Bad number of args"); - return false; - } - if (!args[0].toRGBA()) - { - nlwarning("Bad type for arg 0 : should be a color"); - return false; - } - result.setInteger((sint64) args[0].getRGBA().R); - return true; -} -REGISTER_INTERFACE_USER_FCT("getRed", userGetRed) -// -static DECLARE_INTERFACE_USER_FCT(userGetGreen) -{ - if (args.size() != 1) - { - nlwarning("Bad number of args"); - return false; - } - if (!args[0].toRGBA()) - { - nlwarning("Bad type for arg 0 : should be a color"); - return false; - } - result.setInteger((sint64) args[0].getRGBA().G); - return true; -} -REGISTER_INTERFACE_USER_FCT("getGreen", userGetGreen) -// -static DECLARE_INTERFACE_USER_FCT(userGetBlue) -{ - if (args.size() != 1) - { - nlwarning("Bad number of args"); - return false; - } - if (!args[0].toRGBA()) - { - nlwarning("Bad type for arg 0 : should be a color"); - return false; - } - result.setInteger((sint64) args[0].getRGBA().B); - return true; -} -REGISTER_INTERFACE_USER_FCT("getBlue", userGetBlue) -// -static DECLARE_INTERFACE_USER_FCT(userGetAlpha) -{ - if (args.size() != 1) - { - nlwarning("Bad number of args"); - return false; - } - if (!args[0].toRGBA()) - { - nlwarning("Bad type for arg 0 : should be a color"); - return false; - } - result.setInteger((sint64) args[0].getRGBA().A); - return true; -} -REGISTER_INTERFACE_USER_FCT("getAlpha", userGetAlpha) - -//////////////////////////////////////////////// -// make a rgb color from 3 components R, G, B // -//////////////////////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userMakeRGB) -{ - if ((args.size() != 3) && (args.size() != 4)) - { - nlwarning("Bad number of args : 3 or 4 args required : R, G, B, [A]"); - return false; - } - if (!args[0].toInteger() || !args[1].toInteger() || !args[2].toInteger()) - { - nlwarning("Not all args converting to integer"); - return false; - } - uint8 nAlpha = 255; - if (args.size() == 4 ) - nAlpha = (uint8)args[3].getInteger(); - - NLMISC::CRGBA col((uint8) args[0].getInteger(), (uint8) args[1].getInteger(), (uint8) args[2].getInteger(),nAlpha); - result.setRGBA(col); - - return true; -} -REGISTER_INTERFACE_USER_FCT("makeRGB", userMakeRGB) - - -////////////////////////////// -// Get number of DB entries // -////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userDBCount) -{ - if (args.size() != 1) - return false; - - if (args[0].getType() != CIEV::String) - return false; - - string sTmp = args[0].getString(); - - if (sTmp.find('$') == string::npos) - return false; - - string sFirstPart = sTmp.substr(0,sTmp.find('$')); - string sSecondPart = sTmp.substr(sTmp.find('$')+1,sTmp.size()); - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - - sint i = 0; - bool bExit = false; - - while (!bExit) - { - sTmp = sFirstPart + NLMISC::toString(i) + sSecondPart; - CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp,false); - CCDBNodeBranch *pNB = NLGUI::CDBManager::getInstance()->getDbBranch(sTmp); - if (pNL != NULL) - { - if (pNL->getValue64() == 0) - bExit = true; - else - ++i; - } - else if (pNB != NULL) - { - ++i; - } - else - { - bExit = true; - } - } - - result.setInteger(i); - - return true; -} -REGISTER_INTERFACE_USER_FCT("dbcount", userDBCount) - -//////////////////////// -// Get a random value // -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctRand) -{ - if ((args.size() != 2) && (args.size() != 0)) - return false; - - if (args.size() == 2) - { - if (!args[0].toDouble()) return false; - if (!args[1].toDouble()) return false; - - double s = args[0].getDouble(); - double e = 0.999+args[1].getDouble(); - - result.setDouble ( s + (e-s)*NLMISC::frand(1.0)); - } - else - { - result.setDouble (NLMISC::frand(1.0)); - } - - return true; -} -REGISTER_INTERFACE_USER_FCT("rand", userFctRand) - - -static DECLARE_INTERFACE_USER_FCT(userFctGetBit) -{ - if (args.size() != 2) - return false; - - if (!args[0].toInteger()) return false; - if (!args[1].toInteger()) return false; - - sint64 i = args[0].getInteger(); - sint64 s = args[1].getInteger(); - - result.setInteger (0); - - if ((i & (SINT64_CONSTANT(1)<> args[1].getInteger()); - return true; -} -REGISTER_INTERFACE_USER_FCT("shr", userFctSHR) - -////////////////////////// -// Unsigned left shift // -////////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctSHL) -{ - if (args.size() != 2) - { - nlwarning("shl : bad number of arguments"); - return false; - } - if (!args[0].toInteger() || !args[1].toInteger()) - { - nlwarning("Argument is not integer"); - return false; - } - result.setInteger(((uint64)args[0].getInteger()) << args[1].getInteger()); - return true; -} -REGISTER_INTERFACE_USER_FCT("shl", userFctSHL) - -///////////////////////// -// Signed right shift // -///////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctSAR) -{ - if (args.size() != 2) - { - nlwarning("sar : bad number of arguments"); - return false; - } - if (!args[0].toInteger() || !args[1].toInteger()) - { - nlwarning("Argument is not integer"); - return false; - } - result.setInteger(args[0].getInteger() >> args[1].getInteger()); - return true; -} -REGISTER_INTERFACE_USER_FCT("sar", userFctSAR) - -//////////////////////// -// Signed left shift // -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(userFctSAL) -{ - if (args.size() != 2) - { - nlwarning("sal : bad number of arguments"); - return false; - } - if (!args[0].toInteger() || !args[1].toInteger()) - { - nlwarning("Argument is not integer"); - return false; - } - result.setInteger(args[0].getInteger() << args[1].getInteger()); - return true; -} -REGISTER_INTERFACE_USER_FCT("sal", userFctSAL) - -///////////////////////////////////////////////////////////////////////////// -// Extend the sign of the argument considered over 8 bits to a 64 bits int // -///////////////////////////////////////////////////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(extSign8To64) -{ - if (args.size() != 1) - { - nlwarning("extSign8To64 : bad number of arguments"); - return false; - } - if (!args[0].toInteger()) - { - nlwarning("Argument is not integer"); - return false; - } - sint8 i = (sint8)args[0].getInteger(); - result.setInteger((sint64)i); - return true; -} -REGISTER_INTERFACE_USER_FCT("extSign8To64", extSign8To64) - -////////////////////////////////////////////////////////////////////////////// -// Extend the sign of the argument considered over 11 bits to a 64 bits int // -////////////////////////////////////////////////////////////////////////////// -static DECLARE_INTERFACE_USER_FCT(extSign11To64) -{ - if (args.size() != 1) - { - nlwarning("extSign12To64 : bad number of arguments"); - return false; - } - if (!args[0].toInteger()) - { - nlwarning("Argument is not integer"); - return false; - } - sint32 i = (sint16)args[0].getInteger() & 0x7ff; - if( i > 1023 ) - i |= 0xfffff800; - result.setInteger((sint64)i); - return true; -} -REGISTER_INTERFACE_USER_FCT("extSign11To64", extSign11To64) - -//////////////////////// -// Ryzom version info // -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(isFinalVersion) -{ - if (!args.empty()) - { - nlwarning("isFinalVersion : no args required"); - return false; - } - #if FINAL_VERSION - result.setBool(true); - #else - result.setBool(false); - #endif - return true; -} -REGISTER_INTERFACE_USER_FCT("isFinalVersion", isFinalVersion) - -//////////////////////// -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(secondsToTimeString) -{ - if (args.size() != 1) - { - nlwarning("intToTimeString : 1 args required"); - return false; - } - if (!args[0].toInteger()) - { - nlwarning("intToTimeString : args 0 required to be an int"); - return false; - } - - sint64 nVal = args[0].getInteger(); - ucstring sTmp; - - if (nVal < 0) nVal = 0; - - sTmp = toString(nVal % 60) + " " + CI18N::get("uiMissionTimerSecond"); - - nVal = nVal / 60; - - if( nVal > 0 ) - { - sTmp = toString(nVal % 60) + " " + CI18N::get("uiMissionTimerMinute") + " " + sTmp; - - nVal = nVal / 60; - - if( nVal > 0 ) - { - sTmp = toString(nVal % 24) + " " + CI18N::get("uiMissionTimerHour") + " " + sTmp; - - nVal = nVal / 24; - - if( nVal > 0 ) - { - sTmp = toString(nVal) + " " + CI18N::get("uiMissionTimerDay") + " " + sTmp; - } - } - } - - result.setUCString(sTmp); - - return true; -} -REGISTER_INTERFACE_USER_FCT("secondsToTimeString", secondsToTimeString) - -//////////////////////// -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(secondsToTimeStringShort) -{ - if (args.size() != 1) - { - nlwarning("intToTimeString : 1 args required"); - return false; - } - if (!args[0].toInteger()) - { - nlwarning("intToTimeString : args 0 required to be an int"); - return false; - } - - sint64 nVal = args[0].getInteger(); - ucstring sTmp; - - if (nVal < 0) nVal = 0; - - sTmp = toString("%02d", nVal % 60); - - nVal = nVal / 60; - - if( nVal > 0 ) - { - sTmp = toString(nVal % 60) + "'" + sTmp; - - nVal = nVal / 60; - - // if at least one hour, just display number of hour - if( nVal > 0 ) - { - sTmp = toString(nVal % 24) + "h"; - - nVal = nVal / 24; - - // if at least one hour, just display number of days - if( nVal > 0 ) - { - sTmp = toString(nVal) + "d"; - } - } - } - - result.setUCString(sTmp); - - return true; -} -REGISTER_INTERFACE_USER_FCT("secondsToTimeStringShort", secondsToTimeStringShort) - -//////////////////////// -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(oldvalue) -{ - if (args.size() != 1) - { - nlwarning("oldvalue : 1 arg required"); - return false; - } - CCDBNodeLeaf *nl = NLGUI::CDBManager::getInstance()->getDbProp(args[0].getString()); - if (!nl) - { - nlwarning("oldvalue : arg 0 required to be an interface leaf"); - return false; - } - result.setInteger (nl->getOldValue64()); - - return true; -} -REGISTER_INTERFACE_USER_FCT("oldvalue", oldvalue) - -//////////////////////// -//////////////////////// -static DECLARE_INTERFACE_USER_FCT(localize) -{ - if (args.size() != 1) - { - nlwarning("localize : 1 arg required"); - return false; - } - result.setUCString(CI18N::get(args[0].getString())); - return true; -} -REGISTER_INTERFACE_USER_FCT("localize", localize); From a04280c7ef1989e619f914eedfb6e7436c6c1841 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 4 Jul 2012 06:27:40 +0200 Subject: [PATCH 125/339] ADDED: #1471 The first GUI editor widget, with some test data. Altough it's for verification purposes only, so later it will be removed. http://www.youtube.com/watch?v=CpcUp1RcsMQ --- .../src/plugins/gui_editor/CMakeLists.txt | 4 +- .../plugins/gui_editor/gui_editor_window.cpp | 15 +++ .../plugins/gui_editor/gui_editor_window.h | 5 +- .../plugins/gui_editor/widget_properties.cpp | 111 ++++++++++++++++++ .../plugins/gui_editor/widget_properties.h | 41 +++++++ .../plugins/gui_editor/widget_properties.ui | 84 +++++++++++++ 6 files changed, 257 insertions(+), 3 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt index 769561d34..9a24e2c3f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -9,8 +9,8 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) -SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h ) -SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui ) +SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h widget_properties.h ) +SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui widget_properties.ui ) SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTOPENGL TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index bd0b97d14..6faca8363 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -19,12 +19,16 @@ #include "../core/icore.h" #include "../core/core_constants.h" +#include "../core/core.h" +#include "../core/menu_manager.h" #include #include #include +#include "widget_properties.h" + namespace GUIEditor { QString _lastDir; @@ -34,6 +38,7 @@ namespace GUIEditor { m_ui.setupUi(this); m_undoStack = new QUndoStack(this); + widgetProps = new CWidgetProperties; createMenus(); readSettings(); } @@ -41,6 +46,8 @@ namespace GUIEditor GUIEditorWindow::~GUIEditorWindow() { writeSettings(); + delete widgetProps; + widgetProps = NULL; } QUndoStack *GUIEditorWindow::undoStack() const @@ -66,6 +73,14 @@ namespace GUIEditor void GUIEditorWindow::createMenus() { + Core::MenuManager *mm = Core::ICore::instance()->menuManager(); + QMenu *menu = mm->menu( Core::Constants::M_TOOLS ); + if( menu != NULL ) + { + QAction *a = new QAction( "Widget Properties", this ); + connect( a, SIGNAL( triggered( bool ) ), widgetProps, SLOT( show() ) ); + menu->addAction( a ); + } } void GUIEditorWindow::readSettings() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 943a21655..a6883aa2f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -18,11 +18,13 @@ #define GUI_EDITOR_WINDOW_H #include "ui_gui_editor_window.h" - #include namespace GUIEditor { + + class CWidgetProperties; + class GUIEditorWindow: public QMainWindow { Q_OBJECT @@ -50,6 +52,7 @@ private: QUndoStack *m_undoStack; Ui::GUIEditorWindow m_ui; + CWidgetProperties *widgetProps; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp new file mode 100644 index 000000000..053f77d20 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp @@ -0,0 +1,111 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "widget_properties.h" +#include +#include + +namespace +{ + struct SPropEntry + { + std::string propName; + std::string propType; + std::string propDefault; + + static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) + { + SPropEntry entry; + entry.propName = propname; + entry.propType = proptype; + entry.propDefault = propdefault; + return entry; + } + }; + + std::map< std::string, std::vector< SPropEntry > > props; +} + +namespace GUIEditor{ + + CWidgetProperties::CWidgetProperties( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + + widgetList->addItem( QString( "InterfaceElement" ) ); + widgetList->addItem( QString( "CtrlBase" ) ); + + props[ "InterfaceElement" ] = std::vector< SPropEntry >(); + props[ "CtrlBase" ] = std::vector< SPropEntry >(); + + std::map< std::string, std::vector< SPropEntry > >::iterator itr = + props.find( "InterfaceElement" ); + if( itr != props.end() ) + { + itr->second.push_back( SPropEntry::create( "id", "string", "ie" ) ); + itr->second.push_back( SPropEntry::create( "active", "bool", "false" ) ); + } + + itr = props.find( "CtrlBase" ); + if( itr != props.end() ) + { + itr->second.push_back( SPropEntry::create( "on_tooltip", "string", "tooltip" ) ); + itr->second.push_back( SPropEntry::create( "on_tooltip_params", "string", "params" ) ); + } + + connect( closeButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) ); + connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) ); + + } + + CWidgetProperties::~CWidgetProperties() + { + } + + void CWidgetProperties::onListSelectionChanged( int i ) + { + if( i >= widgetList->count() ) + return; + + QListWidgetItem *item = widgetList->item( i ); + setPropsOf( item->text().toStdString().c_str() ); + } + + void CWidgetProperties::setPropsOf( const char *name ) + { + std::map< std::string, std::vector< SPropEntry > >::iterator itr = + props.find( name ); + + if( itr == props.end() ) + return; + + widgetPropTree->clear(); + + std::vector< SPropEntry > &v = itr->second; + for( std::vector< SPropEntry >::iterator itr2 = v.begin(); itr2 != v.end(); ++itr2 ) + { + SPropEntry e = *itr2; + QTreeWidgetItem *item = new QTreeWidgetItem; + item->setText( 0, e.propName.c_str() ); + item->setText( 1, e.propType.c_str() ); + item->setText( 2, e.propDefault.c_str() ); + widgetPropTree->addTopLevelItem( item ); + } + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h new file mode 100644 index 000000000..c691806a2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -0,0 +1,41 @@ +// Object Viewer Qt GUI Editor plugin +// 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 WIDGETPROPS_H +#define WIDGETPROPS_H + +#include "ui_widget_properties.h" + +namespace GUIEditor +{ + class CWidgetProperties : public QWidget, public Ui::WidgetProperties + { + Q_OBJECT + + public: + CWidgetProperties( QWidget *parent = NULL ); + ~CWidgetProperties(); + + private Q_SLOTS: + void onListSelectionChanged( int i ); + + private: + void setPropsOf( const char *name ); + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui new file mode 100644 index 000000000..be65f5276 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.ui @@ -0,0 +1,84 @@ + + + WidgetProperties + + + + 0 + 0 + 618 + 308 + + + + Widget Properties + + + + + + + + + + + + Property + + + + + Type + + + + + Value + + + + + + + + + + Qt::Vertical + + + + 20 + 56 + + + + + + + + + + Qt::Horizontal + + + + 428 + 20 + + + + + + + + Close + + + + + + + + + + From 27fd3ae6337e000c80de2ebcdc0bb375c8df287d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 07:22:28 +0200 Subject: [PATCH 126/339] CHANGED: #1471 The GUI widget properties are now read from the GUI XML files ( widget inheritance is not yet supported ). --- .../plugins/gui_editor/gui_editor_window.cpp | 182 +++++++++++++++++- .../plugins/gui_editor/gui_editor_window.h | 8 + .../plugins/gui_editor/widget_properties.cpp | 67 ++----- .../plugins/gui_editor/widget_properties.h | 33 ++++ 4 files changed, 237 insertions(+), 53 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 6faca8363..b2b53328d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -32,6 +32,7 @@ namespace GUIEditor { QString _lastDir; + std::map< std::string, SWidgetInfo > widgetInfo; GUIEditorWindow::GUIEditorWindow(QWidget *parent) : QMainWindow(parent) @@ -41,6 +42,8 @@ namespace GUIEditor widgetProps = new CWidgetProperties; createMenus(); readSettings(); + parseGUIWidgets(); + widgetProps->setupWidgetInfo( &widgetInfo ); } GUIEditorWindow::~GUIEditorWindow() @@ -97,5 +100,182 @@ namespace GUIEditor settings->endGroup(); settings->sync(); } - + + void GUIEditorWindow::parseGUIWidgets() + { + QDir d( "widgets" ); + if( !d.exists() ) + { + nlwarning( "GUI widgets directory doesn't exist!" ); + return; + } + + QStringList nameFilters; + nameFilters.push_back( "*.xml" ); + + QStringList files = d.entryList( nameFilters, QDir::Files ); + if( files.empty() ) + { + nlwarning( "GUI widgets directory has no files!" ); + return; + } + + QStringListIterator itr( files ); + while( itr.hasNext() ) + parseGUIWidget( "widgets/" + itr.next() ); + } + + void GUIEditorWindow::parseGUIWidget( const QString &file ) + { + QFile f( file ); + if( f.open( QIODevice::ReadOnly ) ) + { + parseGUIWidgetXML( f ); + f.close(); + } + else + nlwarning( QString( "File %1 cannot be opened!" ).arg( file ).toStdString().c_str() ); + } + + void GUIEditorWindow::parseGUIWidgetXML( QFile &file ) + { + QXmlStreamReader reader; + reader.setDevice( &file ); + + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "widget" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "header" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + QString name = parseGUIWidgetHeader( reader ); + if( name.isEmpty() ) + { + nlwarning( "malformed XML." ); + return; + } + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "properties" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + parseGUIWidgetProperties( reader, name ); + } + + QString GUIEditorWindow::parseGUIWidgetHeader( QXmlStreamReader &reader ) + { + reader.readNext(); + if( reader.atEnd() ) + return QString( "" ); + + SWidgetInfo info; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + info.name = value.toStdString(); + else + if( key == "guiname" ) + info.GUIName = value.toStdString(); + else + if( key == "description" ) + info.description = value.toStdString(); + else + if( key == "icon" ) + info.icon == value.toStdString(); + else + if( key == "abstract" ) + { + info.isAbstract = false; + if( value == "true" ) + info.isAbstract = true; + } + else + nlwarning( "Malformed XML." ); + } + } + + reader.readNext(); + } + if( reader.atEnd() ) + return QString( "" ); + if( info.name.empty() ) + return QString( "" ); + + widgetInfo[ info.name.c_str() ] = info; + return QString( info.name.c_str() ); + } + + void GUIEditorWindow::parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ) + { + reader.readNext(); + if( reader.atEnd() ) + return; + + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo.find( widgetName.toStdString() ); + if( itr == widgetInfo.end() ) + return; + + std::vector< SPropEntry > &v = itr->second.props; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "properties" ) ) ) + { + if( reader.isStartElement() && reader.name() == "property" ) + { + SPropEntry prop; + reader.readNext(); + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "property" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + prop.propName = value.toStdString(); + else + if( key == "type" ) + prop.propType = value.toStdString(); + else + if( key == "default" ) + prop.propDefault = value.toStdString(); + else + nlwarning( QString( "Unknown tag %1 within a property" ).arg( key ).toStdString().c_str() ); + + } + else + nlwarning( "Malformed XML." ); + } + + reader.readNext(); + } + if( reader.atEnd() ) + return; + + v.push_back( prop ); + } + + reader.readNext(); + } + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index a6883aa2f..8faa6b790 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -19,6 +19,8 @@ #include "ui_gui_editor_window.h" #include +#include +#include namespace GUIEditor { @@ -49,6 +51,12 @@ private: void writeSettings(); + void parseGUIWidgets(); + void parseGUIWidget( const QString &file ); + void parseGUIWidgetXML( QFile &file ); + QString parseGUIWidgetHeader( QXmlStreamReader &reader ); + void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ); + QUndoStack *m_undoStack; Ui::GUIEditorWindow m_ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp index 053f77d20..802dcd591 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.cpp @@ -15,67 +15,30 @@ // along with this program. If not, see . #include "widget_properties.h" -#include -#include - -namespace -{ - struct SPropEntry - { - std::string propName; - std::string propType; - std::string propDefault; - - static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) - { - SPropEntry entry; - entry.propName = propname; - entry.propType = proptype; - entry.propDefault = propdefault; - return entry; - } - }; - - std::map< std::string, std::vector< SPropEntry > > props; -} namespace GUIEditor{ - CWidgetProperties::CWidgetProperties( QWidget *parent ) : QWidget( parent ) { setupUi( this ); - - widgetList->addItem( QString( "InterfaceElement" ) ); - widgetList->addItem( QString( "CtrlBase" ) ); - - props[ "InterfaceElement" ] = std::vector< SPropEntry >(); - props[ "CtrlBase" ] = std::vector< SPropEntry >(); - - std::map< std::string, std::vector< SPropEntry > >::iterator itr = - props.find( "InterfaceElement" ); - if( itr != props.end() ) - { - itr->second.push_back( SPropEntry::create( "id", "string", "ie" ) ); - itr->second.push_back( SPropEntry::create( "active", "bool", "false" ) ); - } - - itr = props.find( "CtrlBase" ); - if( itr != props.end() ) - { - itr->second.push_back( SPropEntry::create( "on_tooltip", "string", "tooltip" ) ); - itr->second.push_back( SPropEntry::create( "on_tooltip_params", "string", "params" ) ); - } - connect( closeButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) ); - connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) ); - } CWidgetProperties::~CWidgetProperties() { } + void CWidgetProperties::setupWidgetInfo( std::map< std::string, SWidgetInfo > *info ) + { + widgetInfo = info; + for( std::map< std::string, SWidgetInfo >::iterator itr = info->begin(); itr != info->end(); ++itr ){ + widgetList->addItem( itr->first.c_str() ); + } + + onListSelectionChanged( 0 ); + connect( widgetList, SIGNAL( currentRowChanged( int ) ), this, SLOT( onListSelectionChanged( int ) ) ); + } + void CWidgetProperties::onListSelectionChanged( int i ) { if( i >= widgetList->count() ) @@ -87,15 +50,15 @@ namespace GUIEditor{ void CWidgetProperties::setPropsOf( const char *name ) { - std::map< std::string, std::vector< SPropEntry > >::iterator itr = - props.find( name ); + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( name ); - if( itr == props.end() ) + if( itr == widgetInfo->end() ) return; widgetPropTree->clear(); - std::vector< SPropEntry > &v = itr->second; + std::vector< SPropEntry > &v = itr->second.props; for( std::vector< SPropEntry >::iterator itr2 = v.begin(); itr2 != v.end(); ++itr2 ) { SPropEntry e = *itr2; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h index c691806a2..9346a6df2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -19,9 +19,40 @@ #define WIDGETPROPS_H #include "ui_widget_properties.h" +#include +#include +#include namespace GUIEditor { + struct SPropEntry + { + std::string propName; + std::string propType; + std::string propDefault; + + static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) + { + SPropEntry entry; + entry.propName = propname; + entry.propType = proptype; + entry.propDefault = propdefault; + return entry; + } + }; + + struct SWidgetInfo + { + std::string name; + std::string GUIName; + std::string description; + bool isAbstract; + std::string icon; + + std::vector< SPropEntry > props; + }; + + class CWidgetProperties : public QWidget, public Ui::WidgetProperties { Q_OBJECT @@ -29,12 +60,14 @@ namespace GUIEditor public: CWidgetProperties( QWidget *parent = NULL ); ~CWidgetProperties(); + void setupWidgetInfo( std::map< std::string, SWidgetInfo > *info ); private Q_SLOTS: void onListSelectionChanged( int i ); private: void setPropsOf( const char *name ); + std::map< std::string, SWidgetInfo > *widgetInfo; }; } From 7538396dbe23bebc1e54ba89e9afc42f16c66a29 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 07:30:41 +0200 Subject: [PATCH 127/339] CHANGED: #1471 Ups, forgot to commit the example XML files. --- .../gui_editor/widgets/ControlBase.xml | 21 +++++++++++++++++++ .../gui_editor/widgets/InterfaceElement.xml | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml new file mode 100644 index 000000000..3f092e135 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml @@ -0,0 +1,21 @@ + +
+ CtrlBase + cb + + true + +
+ + + on_tooltip + string + handler + + + on_tooltip_params + string + params + + +
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml new file mode 100644 index 000000000..e8a3f0aa2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceElement.xml @@ -0,0 +1,21 @@ + +
+ InterfaceElement + ie + + true + +
+ + + id + string + ie + + + active + bool + true + + +
From 30eef5ddef4d39b915d41514c019e54214c79dac Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 5 Jul 2012 08:18:33 +0200 Subject: [PATCH 128/339] CHANGED: #1471 Little bit of refactoring, moved the parser code from GUIEditorWindow to a new class CWidgetPropParser. --- .../plugins/gui_editor/gui_editor_window.cpp | 185 +--------------- .../plugins/gui_editor/gui_editor_window.h | 1 + .../src/plugins/gui_editor/widget_info.h | 54 +++++ .../plugins/gui_editor/widget_properties.h | 29 +-- .../gui_editor/widget_properties_parser.cpp | 208 ++++++++++++++++++ .../gui_editor/widget_properties_parser.h | 49 +++++ 6 files changed, 319 insertions(+), 207 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index b2b53328d..832c39fe9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -28,6 +28,7 @@ #include #include "widget_properties.h" +#include "widget_properties_parser.h" namespace GUIEditor { @@ -42,7 +43,11 @@ namespace GUIEditor widgetProps = new CWidgetProperties; createMenus(); readSettings(); - parseGUIWidgets(); + + CWidgetPropParser parser; + + parser.setWidgetPropMap( &widgetInfo ); + parser.parseGUIWidgets(); widgetProps->setupWidgetInfo( &widgetInfo ); } @@ -100,182 +105,4 @@ namespace GUIEditor settings->endGroup(); settings->sync(); } - - void GUIEditorWindow::parseGUIWidgets() - { - QDir d( "widgets" ); - if( !d.exists() ) - { - nlwarning( "GUI widgets directory doesn't exist!" ); - return; - } - - QStringList nameFilters; - nameFilters.push_back( "*.xml" ); - - QStringList files = d.entryList( nameFilters, QDir::Files ); - if( files.empty() ) - { - nlwarning( "GUI widgets directory has no files!" ); - return; - } - - QStringListIterator itr( files ); - while( itr.hasNext() ) - parseGUIWidget( "widgets/" + itr.next() ); - } - - void GUIEditorWindow::parseGUIWidget( const QString &file ) - { - QFile f( file ); - if( f.open( QIODevice::ReadOnly ) ) - { - parseGUIWidgetXML( f ); - f.close(); - } - else - nlwarning( QString( "File %1 cannot be opened!" ).arg( file ).toStdString().c_str() ); - } - - void GUIEditorWindow::parseGUIWidgetXML( QFile &file ) - { - QXmlStreamReader reader; - reader.setDevice( &file ); - - reader.readNext(); - if( reader.atEnd() ) - return; - - while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "widget" ) ) ) - reader.readNext(); - if( reader.atEnd() ) - return; - - while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "header" ) ) ) - reader.readNext(); - if( reader.atEnd() ) - return; - - QString name = parseGUIWidgetHeader( reader ); - if( name.isEmpty() ) - { - nlwarning( "malformed XML." ); - return; - } - - while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "properties" ) ) ) - reader.readNext(); - if( reader.atEnd() ) - return; - - parseGUIWidgetProperties( reader, name ); - } - - QString GUIEditorWindow::parseGUIWidgetHeader( QXmlStreamReader &reader ) - { - reader.readNext(); - if( reader.atEnd() ) - return QString( "" ); - - SWidgetInfo info; - - while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) ) - { - if( reader.isStartElement() ) - { - QString key = reader.name().toString(); - QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); - - if( !reader.hasError() ) - { - if( key == "name" ) - info.name = value.toStdString(); - else - if( key == "guiname" ) - info.GUIName = value.toStdString(); - else - if( key == "description" ) - info.description = value.toStdString(); - else - if( key == "icon" ) - info.icon == value.toStdString(); - else - if( key == "abstract" ) - { - info.isAbstract = false; - if( value == "true" ) - info.isAbstract = true; - } - else - nlwarning( "Malformed XML." ); - } - } - - reader.readNext(); - } - if( reader.atEnd() ) - return QString( "" ); - if( info.name.empty() ) - return QString( "" ); - - widgetInfo[ info.name.c_str() ] = info; - return QString( info.name.c_str() ); - } - - void GUIEditorWindow::parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ) - { - reader.readNext(); - if( reader.atEnd() ) - return; - - std::map< std::string, SWidgetInfo >::iterator itr = - widgetInfo.find( widgetName.toStdString() ); - if( itr == widgetInfo.end() ) - return; - - std::vector< SPropEntry > &v = itr->second.props; - - while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "properties" ) ) ) - { - if( reader.isStartElement() && reader.name() == "property" ) - { - SPropEntry prop; - reader.readNext(); - - while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "property" ) ) ) - { - if( reader.isStartElement() ) - { - QString key = reader.name().toString(); - QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); - - if( !reader.hasError() ) - { - if( key == "name" ) - prop.propName = value.toStdString(); - else - if( key == "type" ) - prop.propType = value.toStdString(); - else - if( key == "default" ) - prop.propDefault = value.toStdString(); - else - nlwarning( QString( "Unknown tag %1 within a property" ).arg( key ).toStdString().c_str() ); - - } - else - nlwarning( "Malformed XML." ); - } - - reader.readNext(); - } - if( reader.atEnd() ) - return; - - v.push_back( prop ); - } - - reader.readNext(); - } - } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 8faa6b790..ee0db991b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -21,6 +21,7 @@ #include #include #include +#include "widget_info.h" namespace GUIEditor { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h new file mode 100644 index 000000000..3fed78733 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h @@ -0,0 +1,54 @@ +// Object Viewer Qt GUI Editor plugin +// 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 WIDGET_INFO_H +#define WIDGET_INFO_H + +#include +#include + +namespace GUIEditor +{ + struct SPropEntry + { + std::string propName; + std::string propType; + std::string propDefault; + + static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) + { + SPropEntry entry; + entry.propName = propname; + entry.propType = proptype; + entry.propDefault = propdefault; + return entry; + } + }; + + struct SWidgetInfo + { + std::string name; + std::string GUIName; + std::string description; + bool isAbstract; + std::string icon; + + std::vector< SPropEntry > props; + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h index 9346a6df2..4ab026401 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties.h @@ -19,40 +19,13 @@ #define WIDGETPROPS_H #include "ui_widget_properties.h" +#include "widget_info.h" #include #include #include namespace GUIEditor { - struct SPropEntry - { - std::string propName; - std::string propType; - std::string propDefault; - - static SPropEntry create( const char *propname, const char *proptype, const char *propdefault ) - { - SPropEntry entry; - entry.propName = propname; - entry.propType = proptype; - entry.propDefault = propdefault; - return entry; - } - }; - - struct SWidgetInfo - { - std::string name; - std::string GUIName; - std::string description; - bool isAbstract; - std::string icon; - - std::vector< SPropEntry > props; - }; - - class CWidgetProperties : public QWidget, public Ui::WidgetProperties { Q_OBJECT diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp new file mode 100644 index 000000000..8f5b64191 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp @@ -0,0 +1,208 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "widget_properties_parser.h" +#include +#include +#include "nel/misc/debug.h" + +using namespace NLMISC; + +namespace GUIEditor +{ + void CWidgetPropParser::parseGUIWidgets() + { + QDir d( "widgets" ); + if( !d.exists() ) + { + nlwarning( "GUI widgets directory doesn't exist!" ); + return; + } + + QStringList nameFilters; + nameFilters.push_back( "*.xml" ); + + QStringList files = d.entryList( nameFilters, QDir::Files ); + if( files.empty() ) + { + nlwarning( "GUI widgets directory has no files!" ); + return; + } + + QStringListIterator itr( files ); + while( itr.hasNext() ) + parseGUIWidget( "widgets/" + itr.next() ); + + widgetInfo = NULL; + } + + void CWidgetPropParser::parseGUIWidget( const QString &file ) + { + QFile f( file ); + if( f.open( QIODevice::ReadOnly ) ) + { + parseGUIWidgetXML( f ); + f.close(); + } + else + nlwarning( QString( "File %1 cannot be opened!" ).arg( file ).toStdString().c_str() ); + } + + void CWidgetPropParser::parseGUIWidgetXML( QFile &file ) + { + QXmlStreamReader reader; + reader.setDevice( &file ); + + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "widget" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "header" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + QString name = parseGUIWidgetHeader( reader ); + if( name.isEmpty() ) + { + nlwarning( "malformed XML." ); + return; + } + + while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "properties" ) ) ) + reader.readNext(); + if( reader.atEnd() ) + return; + + parseGUIWidgetProperties( reader, name ); + } + + QString CWidgetPropParser::parseGUIWidgetHeader( QXmlStreamReader &reader ) + { + reader.readNext(); + if( reader.atEnd() ) + return QString( "" ); + + SWidgetInfo info; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + info.name = value.toStdString(); + else + if( key == "guiname" ) + info.GUIName = value.toStdString(); + else + if( key == "description" ) + info.description = value.toStdString(); + else + if( key == "icon" ) + info.icon == value.toStdString(); + else + if( key == "abstract" ) + { + info.isAbstract = false; + if( value == "true" ) + info.isAbstract = true; + } + else + nlwarning( "Malformed XML." ); + } + } + + reader.readNext(); + } + if( reader.atEnd() ) + return QString( "" ); + if( info.name.empty() ) + return QString( "" ); + + (*widgetInfo)[ info.name.c_str() ] = info; + return QString( info.name.c_str() ); + } + + void CWidgetPropParser::parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ) + { + reader.readNext(); + if( reader.atEnd() ) + return; + + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( widgetName.toStdString() ); + if( itr == widgetInfo->end() ) + return; + + std::vector< SPropEntry > &v = itr->second.props; + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "properties" ) ) ) + { + if( reader.isStartElement() && reader.name() == "property" ) + { + SPropEntry prop; + reader.readNext(); + + while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "property" ) ) ) + { + if( reader.isStartElement() ) + { + QString key = reader.name().toString(); + QString value = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement ); + + if( !reader.hasError() ) + { + if( key == "name" ) + prop.propName = value.toStdString(); + else + if( key == "type" ) + prop.propType = value.toStdString(); + else + if( key == "default" ) + prop.propDefault = value.toStdString(); + else + nlwarning( QString( "Unknown tag %1 within a property" ).arg( key ).toStdString().c_str() ); + + } + else + nlwarning( "Malformed XML." ); + } + + reader.readNext(); + } + if( reader.atEnd() ) + return; + + v.push_back( prop ); + } + + reader.readNext(); + } + } +} + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h new file mode 100644 index 000000000..b3dc403ca --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h @@ -0,0 +1,49 @@ +// Object Viewer Qt GUI Editor plugin +// 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 WIDGET_PROP_PARSER +#define WIDGET_PROP_PARSER + +#include "widget_info.h" +#include +#include +#include +#include + +namespace GUIEditor +{ + /// Parser for the widget properties XML files + class CWidgetPropParser + { + public: + CWidgetPropParser(){} + ~CWidgetPropParser(){} + + void setWidgetPropMap( std::map< std::string, SWidgetInfo > *info ){ widgetInfo = info; } + void parseGUIWidgets(); + + private: + void parseGUIWidget( const QString &file ); + void parseGUIWidgetXML( QFile &file ); + QString parseGUIWidgetHeader( QXmlStreamReader &reader ); + void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ); + + std::map< std::string, SWidgetInfo > *widgetInfo; + }; +} + +#endif From 042e9e0000a9af5622ffac9352ca4bdae493ed7e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 6 Jul 2012 03:15:15 +0200 Subject: [PATCH 129/339] CHANGED: #1471 Widget definition inheritance is now supported in the GUI editor. www.youtube.com/watch?v=VG_TnZiGjBk --- .../src/plugins/gui_editor/widget_info.h | 8 +++ .../gui_editor/widget_properties_parser.cpp | 66 ++++++++++++++++++- .../gui_editor/widget_properties_parser.h | 2 + .../gui_editor/widgets/ControlBase.xml | 1 + .../gui_editor/widgets/InterfaceGroup.xml | 22 +++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h index 3fed78733..684cbc8ca 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_info.h @@ -43,11 +43,19 @@ namespace GUIEditor { std::string name; std::string GUIName; + std::string ancestor; std::string description; bool isAbstract; std::string icon; + bool resolved; std::vector< SPropEntry > props; + + SWidgetInfo() + { + resolved = false; + isAbstract = true; + } }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp index 8f5b64191..dc2b016c7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.cpp @@ -47,6 +47,8 @@ namespace GUIEditor while( itr.hasNext() ) parseGUIWidget( "widgets/" + itr.next() ); + resolveInheritance(); + widgetInfo = NULL; } @@ -119,6 +121,9 @@ namespace GUIEditor if( key == "guiname" ) info.GUIName = value.toStdString(); else + if( key == "ancestor" ) + info.ancestor = value.toStdString(); + else if( key == "description" ) info.description = value.toStdString(); else @@ -202,7 +207,66 @@ namespace GUIEditor reader.readNext(); } - } + } + + bool propCompare( const SPropEntry &left, const SPropEntry &right ) + { + return left.propName < right.propName; + } + + void CWidgetPropParser::resolveInheritance() + { + for( std::map< std::string, SWidgetInfo >::iterator itr = widgetInfo->begin(); itr != widgetInfo->end(); ++itr ) + { + resolveInheritanceFor( itr->first ); + std::sort( itr->second.props.begin(), itr->second.props.end(), propCompare ); + } + + } + + void CWidgetPropParser::resolveInheritanceFor( const std::string name ) + { + if( name.empty() ) + return; + + std::map< std::string, SWidgetInfo >::iterator itr = + widgetInfo->find( name ); + if( itr == widgetInfo->end() ) + return; + + SWidgetInfo *info = &(itr->second); + if( info->resolved ) + return; + + if( info->ancestor.empty() ) + return; + + std::vector< SPropEntry > &props = info->props; + + std::map< std::string, SWidgetInfo >::iterator itr2 = + widgetInfo->find( info->ancestor ); + if( itr2 == widgetInfo->end() ) + return; + SWidgetInfo *info2 = &(itr2->second); + + do + { + for( std::vector< SPropEntry >::iterator propItr = info2->props.begin(); propItr != info2->props.end(); ++propItr ) + props.push_back( *propItr ); + + if( !info2->resolved && !info2->ancestor.empty() ) + { + itr2 = widgetInfo->find( info2->ancestor ); + if( itr2 != widgetInfo->end() ) + info2 = &(itr2->second); + else + info2 = NULL; + } + } + while( ( info2 != NULL ) && !info2->resolved && !info2->ancestor.empty() ); + + info->resolved = true; + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h index b3dc403ca..4dcbffacf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_properties_parser.h @@ -41,6 +41,8 @@ namespace GUIEditor void parseGUIWidgetXML( QFile &file ); QString parseGUIWidgetHeader( QXmlStreamReader &reader ); void parseGUIWidgetProperties( QXmlStreamReader &reader, const QString &widgetName ); + void resolveInheritance(); + void resolveInheritanceFor( const std::string name ); std::map< std::string, SWidgetInfo > *widgetInfo; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml index 3f092e135..809ccacfd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/ControlBase.xml @@ -2,6 +2,7 @@
CtrlBase cb + InterfaceElement true diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml new file mode 100644 index 000000000..d11ceb180 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widgets/InterfaceGroup.xml @@ -0,0 +1,22 @@ + +
+ InterfaceGroup + ig + CtrlBase + + false + +
+ + + on_enter + string + handler + + + on_enter_params + string + params + + +
From aa352b2f30c524281855b818d9d04e73b13b07ab Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 6 Jul 2012 06:10:20 +0200 Subject: [PATCH 130/339] ADDED: #1471 Created ActionEditor, LinkEditor, ProcEditor, WidgetHierarchy dialogs for the GUI editor, altough obviously they are just an empty shell for now. http://www.youtube.com/watch?v=nOhlliU6tCE --- .../src/plugins/gui_editor/CMakeLists.txt | 21 +++- .../src/plugins/gui_editor/action_editor.cpp | 32 +++++ .../src/plugins/gui_editor/action_editor.h | 34 ++++++ .../src/plugins/gui_editor/action_editor.ui | 88 ++++++++++++++ .../plugins/gui_editor/gui_editor_window.cpp | 27 ++++ .../plugins/gui_editor/gui_editor_window.h | 4 + .../plugins/gui_editor/gui_editor_window.ui | 7 +- .../src/plugins/gui_editor/link_editor.cpp | 33 +++++ .../src/plugins/gui_editor/link_editor.h | 35 ++++++ .../src/plugins/gui_editor/link_editor.ui | 101 +++++++++++++++ .../src/plugins/gui_editor/proc_editor.cpp | 39 ++++++ .../src/plugins/gui_editor/proc_editor.h | 40 ++++++ .../src/plugins/gui_editor/proc_editor.ui | 115 ++++++++++++++++++ .../plugins/gui_editor/widget_hierarchy.cpp | 31 +++++ .../src/plugins/gui_editor/widget_hierarchy.h | 34 ++++++ .../plugins/gui_editor/widget_hierarchy.ui | 90 ++++++++++++++ 16 files changed, 724 insertions(+), 7 deletions(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt index 9a24e2c3f..e9350bbf2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -9,8 +9,25 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin. ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) -SET(OVQT_PLUGIN_GUI_EDITOR_HDR gui_editor_plugin.h gui_editor_window.h gui_editor_context.h widget_properties.h ) -SET(OVQT_PLUGIN_GUI_EDITOR_UIS gui_editor_window.ui widget_properties.ui ) +SET(OVQT_PLUGIN_GUI_EDITOR_HDR + gui_editor_plugin.h + gui_editor_window.h + gui_editor_context.h + widget_properties.h + widget_hierarchy.h + action_editor.h + link_editor.h + proc_editor.h + ) + +SET(OVQT_PLUGIN_GUI_EDITOR_UIS + gui_editor_window.ui + widget_properties.ui + widget_hierarchy.ui + action_editor.ui + link_editor.ui + proc_editor.ui + ) SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTOPENGL TRUE) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp new file mode 100644 index 000000000..abcfe1ec5 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp @@ -0,0 +1,32 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "action_editor.h" + +namespace GUIEditor +{ + ActionEditor::ActionEditor( QWidget *parent ) + { + setupUi( this ); + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + } + + ActionEditor::~ActionEditor() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h new file mode 100644 index 000000000..6d2128c7d --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h @@ -0,0 +1,34 @@ +// Object Viewer Qt GUI Editor plugin +// 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 ACTION_EDITOR_H +#define ACTION_EDITOR_H + +#include "ui_action_editor.h" + +namespace GUIEditor +{ + class ActionEditor : public QWidget, public Ui::ActionEditor + { + Q_OBJECT + public: + ActionEditor( QWidget *parent = NULL ); + ~ActionEditor(); + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui new file mode 100644 index 000000000..e9d0188d9 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.ui @@ -0,0 +1,88 @@ + + + ActionEditor + + + + 0 + 0 + 340 + 111 + + + + Action Editor + + + + + + + + Handler + + + + + + + Handler + + + + + + + Parameters + + + + + + + Parameters + + + + + + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + Qt::Horizontal + + + + 38 + 20 + + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 832c39fe9..672df715a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -26,9 +26,13 @@ #include #include +#include #include "widget_properties.h" #include "widget_properties_parser.h" +#include "widget_hierarchy.h" +#include "link_editor.h" +#include "proc_editor.h" namespace GUIEditor { @@ -41,6 +45,8 @@ namespace GUIEditor m_ui.setupUi(this); m_undoStack = new QUndoStack(this); widgetProps = new CWidgetProperties; + linkEditor = new LinkEditor; + procEditor = new ProcEditor; createMenus(); readSettings(); @@ -49,13 +55,26 @@ namespace GUIEditor parser.setWidgetPropMap( &widgetInfo ); parser.parseGUIWidgets(); widgetProps->setupWidgetInfo( &widgetInfo ); + + QDockWidget *dock = new QDockWidget( "Widget Hierarchy", this ); + dock->setAllowedAreas( Qt::LeftDockWidgetArea ); + WidgetHierarchy *ha = new WidgetHierarchy; + dock->setWidget( ha ); + addDockWidget( Qt::LeftDockWidgetArea, dock ); } GUIEditorWindow::~GUIEditorWindow() { writeSettings(); + delete widgetProps; widgetProps = NULL; + + delete linkEditor; + linkEditor = NULL; + + delete procEditor; + procEditor = NULL; } QUndoStack *GUIEditorWindow::undoStack() const @@ -88,6 +107,14 @@ namespace GUIEditor QAction *a = new QAction( "Widget Properties", this ); connect( a, SIGNAL( triggered( bool ) ), widgetProps, SLOT( show() ) ); menu->addAction( a ); + + a = new QAction( "Link Editor", this ); + connect( a, SIGNAL( triggered( bool ) ), linkEditor, SLOT( show() ) ); + menu->addAction( a ); + + a = new QAction( "Proc Editor", this ); + connect( a, SIGNAL( triggered( bool ) ), procEditor, SLOT( show() ) ); + menu->addAction( a ); } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index ee0db991b..0418a12e5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -27,6 +27,8 @@ namespace GUIEditor { class CWidgetProperties; + class LinkEditor; + class ProcEditor; class GUIEditorWindow: public QMainWindow { @@ -62,6 +64,8 @@ private: Ui::GUIEditorWindow m_ui; CWidgetProperties *widgetProps; + LinkEditor *linkEditor; + ProcEditor *procEditor; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui index baf1f01f4..6b0a0f7c3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.ui @@ -14,11 +14,7 @@ MainWindow - - - - - + @@ -32,5 +28,6 @@ + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp new file mode 100644 index 000000000..7a028f649 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp @@ -0,0 +1,33 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "link_editor.h" + +namespace GUIEditor +{ + LinkEditor::LinkEditor( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + } + + LinkEditor::~LinkEditor() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h new file mode 100644 index 000000000..93b7fb348 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h @@ -0,0 +1,35 @@ +// Object Viewer Qt GUI Editor plugin +// 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 LINK_EDITOR_H +#define LINK_EDITOR_H + +#include "ui_link_editor.h" + +namespace GUIEditor +{ + class LinkEditor : public QWidget, public Ui::LinkEditor + { + Q_OBJECT + public: + LinkEditor( QWidget *parent = NULL ); + ~LinkEditor(); + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui new file mode 100644 index 000000000..af2c24f72 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.ui @@ -0,0 +1,101 @@ + + + LinkEditor + + + + 0 + 0 + 545 + 340 + + + + Link Editor + + + + + + Expression + + + + + + + expression + + + + + + + When the condition is met + + + + + + + Activate group + + + + + + + Run Action Handler + + + + + + + Group or action handler + + + + + + + Action Handler parameters + + + + + + + + + Qt::Horizontal + + + + 348 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp new file mode 100644 index 000000000..c9c728603 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp @@ -0,0 +1,39 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "proc_editor.h" +#include "action_editor.h" + + +namespace GUIEditor +{ + ProcEditor::ProcEditor( QWidget *parent ) + { + setupUi( this ); + actionEditor = new ActionEditor; + connect( okButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( hide() ) ); + connect( editButton, SIGNAL( clicked( bool ) ), actionEditor, SLOT( show() ) ); + + } + + ProcEditor::~ProcEditor() + { + delete actionEditor; + actionEditor = NULL; + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h new file mode 100644 index 000000000..b7ee0bff2 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h @@ -0,0 +1,40 @@ +// Object Viewer Qt GUI Editor plugin +// 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 PROC_EDITOR_H +#define PROC_EDITOR_H + +#include "ui_proc_editor.h" + +namespace GUIEditor +{ + class ActionEditor; + + class ProcEditor : public QWidget, public Ui::ProcEditor + { + Q_OBJECT + public: + ProcEditor( QWidget *parent = NULL ); + ~ProcEditor(); + + private: + ActionEditor *actionEditor; + }; +} + +#endif + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui new file mode 100644 index 000000000..f8c17af54 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.ui @@ -0,0 +1,115 @@ + + + ProcEditor + + + + 0 + 0 + 424 + 327 + + + + Proc Editor + + + + + + + action1 + + + + + action2 + + + + + action3 + + + + + + + + Move Up + + + + + + + Move Down + + + + + + + Add + + + + + + + Remove + + + + + + + Edit + + + + + + + Qt::Vertical + + + + 20 + 132 + + + + + + + + OK + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 197 + 20 + + + + + + + + + diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp new file mode 100644 index 000000000..6bcd5cf0a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.cpp @@ -0,0 +1,31 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "widget_hierarchy.h" + +namespace GUIEditor +{ + WidgetHierarchy::WidgetHierarchy( QWidget *parent ) : + QWidget( parent ) + { + setupUi( this ); + } + + WidgetHierarchy::~WidgetHierarchy() + { + } +} diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h new file mode 100644 index 000000000..17fde2c29 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.h @@ -0,0 +1,34 @@ +// Object Viewer Qt GUI Editor plugin +// 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 WIDGET_HA_H +#define WIDGET_HA_H + +#include "ui_widget_hierarchy.h" + +namespace GUIEditor +{ + class WidgetHierarchy : public QWidget, public Ui::WidgetHierarchyTree + { + Q_OBJECT + public: + WidgetHierarchy( QWidget *parent = NULL ); + ~WidgetHierarchy(); + + }; +} + +#endif diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui new file mode 100644 index 000000000..d0c1d9db5 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_hierarchy.ui @@ -0,0 +1,90 @@ + + + WidgetHierarchyTree + + + + 0 + 0 + 497 + 434 + + + + Widget Hieararchy + + + + + + + Widgets + + + + + root + + + + container1 + + + + group1 + + + + group3 + + + + + group4 + + + + button1 + + + + + button2 + + + + + text1 + + + + + bitmap1 + + + + + + + group2 + + + + + + container2 + + + + + container3 + + + + + + + + + + From c641c67c8e90c554dbd5f9169208fa2ea2f77600 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 05:01:32 +0200 Subject: [PATCH 131/339] ADDED: #1471 Qt property browser, for browsing and editing the selected widget's properties ( this is an empty shell as well for now ) --- .../src/plugins/gui_editor/CMakeLists.txt | 3 +- .../plugins/gui_editor/gui_editor_window.cpp | 10 +++ .../plugins/gui_editor/gui_editor_window.h | 3 + .../gui_editor/property_browser_ctrl.cpp | 65 +++++++++++++++++++ .../gui_editor/property_browser_ctrl.h | 48 ++++++++++++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp create mode 100644 code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt index e9350bbf2..4d2aebd0b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/CMakeLists.txt @@ -18,6 +18,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR action_editor.h link_editor.h proc_editor.h + property_browser_ctrl.h ) SET(OVQT_PLUGIN_GUI_EDITOR_UIS @@ -49,7 +50,7 @@ ADD_LIBRARY(ovqt_plugin_gui_editor MODULE ${SRC} ${OVQT_PLUGIN_GUI_EDITOR_RC_SRCS} ) -TARGET_LINK_LIBRARIES(ovqt_plugin_gui_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +TARGET_LINK_LIBRARIES(ovqt_plugin_gui_editor ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} qt_property_browser) NL_DEFAULT_PROPS(ovqt_plugin_gui_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: GUI Editor") NL_ADD_RUNTIME_FLAGS(ovqt_plugin_gui_editor) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 672df715a..094d780be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser" #include "widget_properties.h" #include "widget_properties_parser.h" @@ -61,6 +62,15 @@ namespace GUIEditor WidgetHierarchy *ha = new WidgetHierarchy; dock->setWidget( ha ); addDockWidget( Qt::LeftDockWidgetArea, dock ); + + dock = new QDockWidget( "Widget Properties", this ); + dock->setAllowedAreas( Qt::RightDockWidgetArea ); + QtTreePropertyBrowser *tb = new QtTreePropertyBrowser; + browserCtrl.setBrowser( tb ); + browserCtrl.setup(); + dock->setWidget( tb ); + addDockWidget( Qt::RightDockWidgetArea, dock ); + } GUIEditorWindow::~GUIEditorWindow() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 0418a12e5..25f454fb4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -22,6 +22,7 @@ #include #include #include "widget_info.h" +#include "property_browser_ctrl.h" namespace GUIEditor { @@ -66,6 +67,8 @@ private: CWidgetProperties *widgetProps; LinkEditor *linkEditor; ProcEditor *procEditor; + + CPropBrowserCtrl browserCtrl; }; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp new file mode 100644 index 000000000..3a8dafd99 --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -0,0 +1,65 @@ +// Object Viewer Qt GUI Editor plugin +// 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 "property_browser_ctrl.h" +#include "../../3rdparty/qtpropertybrowser/QtVariantPropertyManager" +#include "../../3rdparty/qtpropertybrowser/QtTreePropertyBrowser" + +namespace GUIEditor +{ + CPropBrowserCtrl::CPropBrowserCtrl() + { + browser = NULL; + propertyMgr = new QtVariantPropertyManager; + } + + CPropBrowserCtrl::~CPropBrowserCtrl() + { + delete propertyMgr; + propertyMgr = NULL; + browser = NULL; + } + + void CPropBrowserCtrl::setBrowser( QtTreePropertyBrowser *b ) + { + browser = b; + } + + void CPropBrowserCtrl::setup() + { + if( browser == NULL ) + return; + + QtVariantProperty *p; + + p = propertyMgr->addProperty( QVariant::String, "Id" ); + p->setValue( "ExampleId" ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::Bool, "Active" ); + p->setValue( true ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::String, "on_enter" ); + p->setValue( "on_enter_handler" ); + browser->addProperty( p ); + + p = propertyMgr->addProperty( QVariant::String, "on_enter_params" ); + p->setValue( "someparams" ); + browser->addProperty( p ); + } +} \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h new file mode 100644 index 000000000..f8549205a --- /dev/null +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h @@ -0,0 +1,48 @@ +// Object Viewer Qt GUI Editor plugin +// 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 PROP_BROWSER_CTRL +#define PROP_BROWSER_CTRL + +#include + +class QtTreePropertyBrowser; +class QtVariantPropertyManager; + +namespace GUIEditor +{ + + /// This class controls the Widget property browser widget. + /// It receives signals from the widget that draws/manages the Nel GUI widgets, and handles them. + class CPropBrowserCtrl : public QObject + { + Q_OBJECT + + public: + CPropBrowserCtrl(); + ~CPropBrowserCtrl(); + void setBrowser( QtTreePropertyBrowser *b ); + void setup(); + + private: + QtTreePropertyBrowser *browser; + QtVariantPropertyManager *propertyMgr; + }; + +} + +#endif From 097ee504f69e1e3223324e389cf0a991d65ae52e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 19:49:13 +0200 Subject: [PATCH 132/339] CHANGED: #1471 Little cleanup in CInterfaceParser. --- code/ryzom/client/src/commands.h | 6 +- .../src/interface_v3/ctrl_sheet_selection.h | 4 - .../src/interface_v3/interface_parser.cpp | 294 +----------------- .../src/interface_v3/interface_parser.h | 39 +-- 4 files changed, 16 insertions(+), 327 deletions(-) diff --git a/code/ryzom/client/src/commands.h b/code/ryzom/client/src/commands.h index 19e2bc02f..7b16f442c 100644 --- a/code/ryzom/client/src/commands.h +++ b/code/ryzom/client/src/commands.h @@ -37,12 +37,12 @@ public: public: uint KeywordsCount; std::string Action; - std::vector Keywords; + std::vector Keywords; }; - CUserCommand (const string &commandName, const ucstring &help, const ucstring &argsHelp); + CUserCommand (const std::string &commandName, const ucstring &help, const ucstring &argsHelp); - void addMode (const string &action, uint numArg, bool infiniteAgr, const std::vector &keywords); + void addMode (const std::string &action, uint numArg, bool infiniteAgr, const std::vector &keywords); // From ICommand virtual bool execute(const std::string &rawCommandString, const std::vector &args, NLMISC::CLog &log, bool quiet, bool human); diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h index 3d1ea5ca7..febff220b 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h +++ b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h @@ -19,10 +19,6 @@ #ifndef CL_SHEET_CTRL_SELECTION_H #define CL_SHEET_CTRL_SELECTION_H - - -class CDBCtrlSheet; - namespace NLGUI { class IActionHandler; diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 5d8462e94..53798f910 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -14,129 +14,40 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -// ---------------------------------------------------------------------------- - -#include "stdpch.h" - +#include "interface_parser.h" #include "nel/misc/i_xml.h" #include "nel/misc/file.h" #include "nel/misc/algo.h" #include "nel/misc/mem_stream.h" #include "nel/misc/factory.h" #include "nel/misc/big_file.h" - #include "nel/misc/xml_auto_ptr.h" - -#include "interface_parser.h" -#include "interface_observer.h" #include "nel/gui/interface_options.h" -#include "interface_options_ryzom.h" #include "nel/gui/interface_anim.h" -#include "interface_3d_scene.h" -// View -#include "nel/gui/view_bitmap.h" -#include "view_bitmap_faber_mp.h" -#include "nel/gui/view_bitmap_combo.h" -#include "nel/gui/view_text.h" -#include "nel/gui/view_text_formated.h" -#include "nel/gui/view_text_id.h" -#include "nel/gui/view_text_id_formated.h" -#include "view_radar.h" +#include "nel/gui/interface_expr.h" #include "nel/gui/view_pointer.h" -// DBView (View linked to the database) -#include "nel/gui/dbview_bar.h" -#include "nel/gui/dbview_bar3.h" -#include "nel/gui/dbview_number.h" -#include "nel/gui/dbview_quantity.h" -#include "nel/gui/dbview_digit.h" -// Ctrl -#include "nel/gui/ctrl_scroll.h" -#include "nel/gui/ctrl_button.h" -#include "nel/gui/ctrl_col_pick.h" -#include "nel/gui/ctrl_tooltip.h" -#include "nel/gui/ctrl_text_button.h" -#include "nel/gui/group_paragraph.h" // For CCtrlLink -// DBCtrl -#include "dbctrl_sheet.h" -// Group -#include "nel/gui/group_frame.h" -#include "group_career.h" #include "nel/gui/group_modal.h" -#include "group_modal_get_key.h" #include "nel/gui/group_list.h" -#include "nel/gui/group_tree.h" -#include "nel/gui/group_menu.h" #include "nel/gui/group_container.h" -#include "nel/gui/group_scrolltext.h" -#include "nel/gui/group_editbox.h" -#include "group_skills.h" -#include "group_html_forum.h" -#include "group_html_mail.h" -#include "group_html_qcm.h" -#include "group_html_cs.h" -#include "group_quick_help.h" -#include "group_compas.h" -#include "group_map.h" -#include "group_in_scene_user_info.h" -#include "group_in_scene_bubble.h" -#include "group_phrase_skill_filter.h" -#include "nel/gui/group_tab.h" -#include "nel/gui/group_table.h" -// DBGroup -#include "nel/gui/dbgroup_select_number.h" -#include "dbgroup_list_sheet.h" -#include "nel/gui/dbgroup_combo_box.h" -#include "dbgroup_list_sheet_trade.h" -#include "dbgroup_list_sheet_mission.h" -#include "guild_manager.h" // for CDBGroupListAscensor -#include "dbgroup_build_phrase.h" -#include "dbgroup_list_sheet_text_phrase.h" -#include "dbgroup_list_sheet_text_phrase_id.h" -#include "dbgroup_list_sheet_text_brick_composition.h" -#include "dbgroup_list_sheet_text_share.h" -#include "dbgroup_list_sheet_bonus_malus.h" -#include "dbgroup_list_sheet_icon_phrase.h" -// Misc. #include "nel/gui/interface_link.h" -#include "interface_ddx.h" -#include "../actions.h" -#include "macrocmd_manager.h" -#include "inventory_manager.h" -#include "task_bar_manager.h" -#include "../commands.h" #include "nel/gui/lua_helper.h" -using namespace NLGUI; #include "nel/gui/lua_ihm.h" -#include "lua_ihm_ryzom.h" -#include "../r2/editor.h" #include "nel/gui/lua_manager.h" +#include "interface_options_ryzom.h" +#include "interface_3d_scene.h" +#include "lua_ihm_ryzom.h" +#include "interface_ddx.h" +#include "macrocmd_manager.h" +#include "../commands.h" + #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger #endif const uint32 UI_CACHE_SERIAL_CHECK = (uint32) 'IUG_'; using namespace NLMISC; - -void badLuaParseMessageBox() -{ - NL3D::UDriver::TMessageBoxId ret = - CViewRenderer::getInstance()->getDriver()->systemMessageBox( "LUA files reading failed!\n" - "Some LUA files are corrupted, moved or may have been removed.\n" - "Ryzom may need to be restarted to run properly.\n" - "Would you like to quit now?", - "LUA reading failed!", - NL3D::UDriver::yesNoType, - NL3D::UDriver::exclamationIcon); - if (ret == NL3D::UDriver::yesId) - { - extern void quitCrashReport (); - quitCrashReport (); - exit (EXIT_FAILURE); - } -} +using namespace NLGUI; void saveXMLTree(COFile &f, xmlNodePtr node) { @@ -418,7 +329,7 @@ bool CInterfaceParser::parseInterface (const std::vector & strings, xmlNodePtr cur = NULL; bool saveParseResult = false; bool readFromUncompressedXML = true; - if (isFilename && ClientCfg.CacheUIParsing) + if( false /* isFilename && ClientCfg.CacheUIParsing */ ) { saveParseResult = true; std::string archive = CPath::lookup(nextFileName + "_compressed", false, false); @@ -699,12 +610,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) // todo hulud interface syntax error nlwarning ("could not parse vector"); } - else if ( !strcmp((char*)root->name,"observer") ) - { - if (!parseObserver(root,rootGroup)) - // todo hulud interface syntax error - nlwarning ("could not parse observer"); - } else if ( !strcmp((char*)root->name,"link") ) { if (!parseLink(root,rootGroup)) @@ -779,8 +684,8 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) { if(!parseLUAScript(root)) { - badLuaParseMessageBox(); nlwarning ("could not parse 'lua'"); + exit( EXIT_FAILURE ); } } @@ -1185,14 +1090,6 @@ bool CInterfaceParser::parseVector(xmlNodePtr cur) return step > 0 ? (i == index + size) : (i == index - size); } -// ---------------------------------------------------------------------------- -bool CInterfaceParser::parseObserver (xmlNodePtr cur, CInterfaceGroup *parentGroup) -{ - H_AUTO(parseObserver ) - - return IInterfaceObserverFactory::create(cur,parentGroup)!= NULL; -} - // ---------------------------------------------------------------------------- bool CInterfaceParser::parseLink(xmlNodePtr cur, CInterfaceGroup * parentGroup) { @@ -1481,8 +1378,6 @@ bool CInterfaceParser::parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * pare ok = ok && parseInstance(cur); else if ( !strcmp((char*)cur->name,"vector") ) ok = ok && parseVector(cur); - else if ( !strcmp((char*)cur->name,"observer") ) - ok = ok && parseObserver(cur,parentGroup); else if ( !strcmp((char*)cur->name,"link") ) ok = ok && parseLink(cur,parentGroup); else if ( !strcmp((char*)cur->name,"scene3d") ) @@ -2129,7 +2024,6 @@ bool CInterfaceParser::initCoordsAndLuaScript() for (map::const_iterator itLua = _LuaClassAssociation.begin(); itLua != _LuaClassAssociation.end(); itLua++) { // execute the script on this group - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CAHManager::getInstance()->runActionHandler("lua", itLua->first, itLua->second); } @@ -2573,147 +2467,6 @@ xmlNodePtr CInterfaceParser::searchTreeNodeInHierarchy(xmlNodePtr root, const ch return NULL; } - -// *************************************************************************** -bool CInterfaceParser::parseCareerGenerator(xmlNodePtr /* cur */) -{ - H_AUTO(parseCareerGenerator) - - // No more CAREER / Bricks!!! - // TODO_BRICK: remove this code. - return false; - - /* - CBrickManager *pBM= CBrickManager::getInstance(); - - CXMLAutoPtr prop; - - string templateCareer; - string templateJob; - string careerWindow; - string jobWindow; - string knownWindow; - xmlNodePtr rootTreeNode; - bool brickTypeFilter; - BRICK_TYPE::EBrickType brickType; - - if(! parseCareerGeneratorParams(cur, templateCareer, templateJob, careerWindow, jobWindow, rootTreeNode, - brickTypeFilter, brickType) ) - return false; - - - // knownWindow (optional) - prop = xmlGetProp (cur, (xmlChar*)"known_window"); - if(prop) knownWindow= (const char*)prop; - - - // **** Create all existing careers - xmlNodePtr nextSibling=cur; - for(uint careerId=0;careerIdgetCareer(brickType, (ROLES::ERole)careerId ); - - // if no filter, then dispplay all careers - if(career || !brickTypeFilter) - { - // Ok, create the xml node to instanciate the career - xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateCareer.c_str()); - xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str()); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr careerTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - string windowId= careerWindow + toString(careerId); - xmlSetProp(careerTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it to the root - xmlAddChild(rootTreeNode, careerTreeNode); - - - // Create the associated tree node for the known sentence if needed - if(!knownWindow.empty()) - { - xmlNodePtr knownTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - windowId= knownWindow + toString(careerId); - xmlSetProp(knownTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it to the career - xmlAddChild(careerTreeNode, knownTreeNode); - } - - - // **** create all existing jobs. - sint numJobs; - - // parse all jobs if not brick type filter - if(!brickTypeFilter) - numJobs= BRICKS_MAX_JOB_PER_CAREER; - else - numJobs= career->Jobs.size(); - - // for all jobs to parse - for(sint jobIndex=0;jobIndexJobs[jobIndex].Job ); - - // if the job exist - if(jobId>=0) - { - // create the xml node to instanciate the job - xmlNodePtr node= xmlNewNode(cur->ns, (xmlChar*)"instance" ); - xmlSetProp(node, (xmlChar*)"template", (xmlChar*)templateJob.c_str()); - xmlSetProp(node, (xmlChar*)"careerid", (xmlChar*)toString(careerId).c_str()); - xmlSetProp(node, (xmlChar*)"jobid", (xmlChar*)toString(jobId).c_str()); - - // add it before rootContainer => next to nextSibling - xmlAddNextSibling (nextSibling, node); - nextSibling = nextSibling->next; - - // Create the associated tree node - xmlNodePtr jobTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - windowId= jobWindow + toString(careerId) + "_" + toString(jobId); - xmlSetProp(jobTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it - xmlAddChild(careerTreeNode, jobTreeNode); - - - // Create the associated tree node for the known sentence if needed - if(!knownWindow.empty()) - { - xmlNodePtr knownTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - windowId= knownWindow + toString(careerId) + "_" + toString(jobId); - xmlSetProp(knownTreeNode, (xmlChar*)"node", (xmlChar*)windowId.c_str()); - // link it to the job - xmlAddChild(jobTreeNode, knownTreeNode); - } - } - } - } - } - - return true;*/ -} - - //================================================================== bool CInterfaceParser::parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup) { @@ -3302,7 +3055,6 @@ CInterfaceElement *CInterfaceParser::createUIElement(const std::string &template return NULL; } - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CInterfaceElement *pIE= CWidgetManager::getInstance()->getElementFromId(parentID); CInterfaceGroup * parentGroup = dynamic_cast(pIE); @@ -3405,28 +3157,13 @@ void CInterfaceParser::removeAllAnims() // *************************************************************************** void CInterfaceParser::removeAll() { - NLMISC::TTime initStart; - initStart = ryzomGetLocalTime (); removeAllLinks(); - //nlinfo ("%d seconds for removeAllLinks", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); CWidgetManager::getInstance()->removeAllOptions(); - //nlinfo ("%d seconds for removeAllOptions", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); removeAllProcedures(); - //nlinfo ("%d seconds for removeAllProcedures", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); removeAllDefines(); - //nlinfo ("%d seconds for removeAllDefines", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); removeAllTemplates(); - //nlinfo ("%d seconds for removeAllTemplates", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); removeAllAnims(); - //nlinfo ("%d seconds for removeAllAnims", (uint32)(ryzomGetLocalTime ()-initStart)/1000); - initStart = ryzomGetLocalTime (); CWidgetManager::getInstance()->removeAllMasterGroups(); - //nlinfo ("%d seconds for removeAllMasterGroups", (uint32)(ryzomGetLocalTime ()-initStart)/1000); _StyleMap.clear(); _CtrlSheetSelection.deleteGroups(); } @@ -3634,13 +3371,6 @@ bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */) } -// *************************************************************************** -void CInterfaceParser::createJobBricks(BRICK_TYPE::EBrickType brickType, xmlNodePtr &nextSibling, xmlNodePtr parentTreeNode, - const CBrickJob &/* job */, const string &/* templateBrick */, const string &/* baseWindowId */, sint32 /* xstart */) -{ -} - - // *************************************************************************** bool CInterfaceParser::parseBrickSuffixGenerator(xmlNodePtr /* cur */) { diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 076fe56ff..693b2e6da 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -27,7 +27,6 @@ #include "game_share/brick_types.h" #include "nel/gui/lua_helper.h" #include "nel/gui/widget_manager.h" -using namespace NLGUI; namespace NLGUI { @@ -42,7 +41,7 @@ namespace NLGUI class CViewPointer; } -class CBrickJob; +using namespace NLGUI; // *************************************************************************** /** @@ -73,65 +72,32 @@ public: bool parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false); bool parseXMLDocument (xmlNodePtr root, bool reload); - bool parseTemplateNode (xmlNodePtr node,xmlNodePtr instance,xmlNodePtr templ); - bool parseInstance(xmlNodePtr cur); - - // bool parseDynamicList (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseVector (xmlNodePtr cur); - - bool parseObserver (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseVariable (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseOptions (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); - bool parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); - bool parseControl (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); - bool parseLink (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseView (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); - bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); - bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); - bool parseDefine(xmlNodePtr cur); - bool parseProcedure(xmlNodePtr cur, bool reload); - bool parseSheetSelection(xmlNodePtr cur); - - bool parseCareerGenerator(xmlNodePtr cur); - bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseScene3D (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseActionCategory (xmlNodePtr cur); - bool parseKey(xmlNodePtr cur); - bool parseMacro(xmlNodePtr cur); - bool parseCommand(xmlNodePtr cur); - bool parseBrickCareerGenerator(xmlNodePtr cur); - bool parseBrickSuffixGenerator(xmlNodePtr cur); - bool parseStyle(xmlNodePtr cur); - bool parseDDX (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseLUAScript (xmlNodePtr cur); - bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); @@ -353,9 +319,6 @@ protected: BRICK_TYPE::EBrickType &brickType ); - void createJobBricks(BRICK_TYPE::EBrickType brickType, xmlNodePtr &nextSibling, xmlNodePtr parentTreeNode, - const CBrickJob &job, const std::string &templateBrick, const std::string &baseWindowId, sint32 xstart); - bool parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode); From 28288d2543dd66c580f68b07bf416a1b64774bef Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 20:38:45 +0200 Subject: [PATCH 133/339] CHANGED: #1471 Moved CSheetSelectionGroup and CSheetSelection to the GUI library. --- .../include/nel/gui/ctrl_sheet_selection.h | 83 ++++++++++++++++ code/nel/src/gui/ctrl_sheet_selection.cpp | 98 +++++++++++++++++++ .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/ctrl_sheet_selection.cpp | 95 ------------------ .../src/interface_v3/ctrl_sheet_selection.h | 83 ---------------- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 7 -- .../src/interface_v3/interface_parser.h | 2 +- 9 files changed, 185 insertions(+), 189 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_sheet_selection.h create mode 100644 code/nel/src/gui/ctrl_sheet_selection.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h diff --git a/code/nel/include/nel/gui/ctrl_sheet_selection.h b/code/nel/include/nel/gui/ctrl_sheet_selection.h new file mode 100644 index 000000000..4ca52427e --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_sheet_selection.h @@ -0,0 +1,83 @@ +// Ryzom - MMORPG Framework +// 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 CL_SHEET_CTRL_SELECTION_H +#define CL_SHEET_CTRL_SELECTION_H + +namespace NLGUI +{ + class IActionHandler; + + /** Infos about a selection group + */ + class CSheetSelectionGroup + { + public: + CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {} + void setTexture(const std::string &texName); + sint32 getTextureIndex() const { return _TextureIndex; } + sint32 getTextureWidth() const { return _TextureWidth; } + sint32 getTextureHeight() const { return _TextureHeight; } + void setColor(NLMISC::CRGBA color) { _Color = color; } + NLMISC::CRGBA getColor() const { return _Color; } + void setActive(bool active) { _Active = active; } + bool isActive() const { return _Active; } + const std::string &getName() const { return _Name; } + void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; } + bool isGlobalColorEnabled() const { return _GlobalColorEnabled; } + private: + std::string _Name; + bool _Active; + sint32 _TextureIndex; // index for the selection texture + sint32 _TextureWidth; + sint32 _TextureHeight; + NLMISC::CRGBA _Color; // color that modulate the texture of selection + bool _GlobalColorEnabled; + }; + + /** Class to manage selection of sheet. + * Sheet are managed by groups, identified by their ID. + */ + class CCtrlSheetSelection + { + public: + // Add a group, and returns its index, or -1 if already created. + sint addGroup(const std::string &name); + // Get a group by its name (must exist) + CSheetSelectionGroup *getGroup(const std::string &name); + const CSheetSelectionGroup *getGroup(const std::string &name) const; + // Get a group by its index + CSheetSelectionGroup *getGroup(uint index); + const CSheetSelectionGroup *getGroup(uint index) const; + // Get the index of a group from its name, return -1 if not a group + sint getGroupIndex(const std::string &name) const; + // Deactivate all groups + void deactivateAll(); + // delete all groups + void deleteGroups(); + private: + // + typedef std::vector TGroupVect; + typedef std::map TGroupNameToIndex; + private: + TGroupVect _Groups; + TGroupNameToIndex _GroupNameToIndex; + }; + +} + +#endif diff --git a/code/nel/src/gui/ctrl_sheet_selection.cpp b/code/nel/src/gui/ctrl_sheet_selection.cpp new file mode 100644 index 000000000..ef63fc06a --- /dev/null +++ b/code/nel/src/gui/ctrl_sheet_selection.cpp @@ -0,0 +1,98 @@ +// Ryzom - MMORPG Framework +// 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 +#include +#include "nel/misc/types_nl.h" +#include "nel/misc/rgba.h" +#include "nel/gui/ctrl_sheet_selection.h" +#include "nel/gui/view_renderer.h" + +namespace NLGUI +{ + + //============================================================= + void CSheetSelectionGroup::setTexture(const std::string &texName) + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + _TextureIndex = rVR.getTextureIdFromName(texName); + rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight); + } + + //============================================================= + void CCtrlSheetSelection::deleteGroups() + { + _Groups.clear(); + _GroupNameToIndex.clear(); + } + + //============================================================= + sint CCtrlSheetSelection::addGroup(const std::string &name) + { + if (getGroupIndex(name) != -1) + { + nlwarning(" Group inserted twice : %s", name.c_str()); + return - 1; + } + _Groups.push_back(CSheetSelectionGroup(name)); + _GroupNameToIndex[name] = (uint)_Groups.size() - 1; + return (sint)_Groups.size() - 1; + } + + //============================================================= + sint CCtrlSheetSelection::getGroupIndex(const std::string &name) const + { + TGroupNameToIndex::const_iterator it = _GroupNameToIndex.find(name); + return it == _GroupNameToIndex.end() ? - 1 : (sint) it->second; + } + + //============================================================= + CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) + { + return getGroup(getGroupIndex(name)); + } + + //============================================================= + const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) const + { + return getGroup(getGroupIndex(name)); + } + + //============================================================= + CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) + { + if (index > _Groups.size()) + { + // nlwarning(" invalid group index"); + return NULL; + } + return &_Groups[index]; + } + + //============================================================= + const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const + { + if (index > _Groups.size()) + { + nlwarning(" invalid group index"); + return NULL; + } + return &_Groups[index]; + } + +} + + diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 4eb3a6cd7..6e6c3d2b8 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -35,7 +35,7 @@ #include "bot_chat_page_dynamic_mission.h" #include "bot_chat_page_ring_sessions.h" #include "dbctrl_sheet.h" -#include "ctrl_sheet_selection.h" +#include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/interface_expr.h" #include "nel/gui/group_menu.h" #include "nel/gui/group_container.h" diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp deleted file mode 100644 index f4c9b5f9f..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 "ctrl_sheet_selection.h" -#include "interface_manager.h" - -//============================================================= -void CSheetSelectionGroup::setTexture(const std::string &texName) -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - _TextureIndex = rVR.getTextureIdFromName(texName); - rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight); -} - -//============================================================= -void CCtrlSheetSelection::deleteGroups() -{ - _Groups.clear(); - _GroupNameToIndex.clear(); -} - -//============================================================= -sint CCtrlSheetSelection::addGroup(const std::string &name) -{ - if (getGroupIndex(name) != -1) - { - nlwarning(" Group inserted twice : %s", name.c_str()); - return - 1; - } - _Groups.push_back(CSheetSelectionGroup(name)); - _GroupNameToIndex[name] = (uint)_Groups.size() - 1; - return (sint)_Groups.size() - 1; -} - -//============================================================= -sint CCtrlSheetSelection::getGroupIndex(const std::string &name) const -{ - TGroupNameToIndex::const_iterator it = _GroupNameToIndex.find(name); - return it == _GroupNameToIndex.end() ? - 1 : (sint) it->second; -} - -//============================================================= -CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) -{ - return getGroup(getGroupIndex(name)); -} - -//============================================================= -const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) const -{ - return getGroup(getGroupIndex(name)); -} - -//============================================================= -CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) -{ - if (index > _Groups.size()) - { - // nlwarning(" invalid group index"); - return NULL; - } - return &_Groups[index]; -} - -//============================================================= -const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const -{ - if (index > _Groups.size()) - { - nlwarning(" invalid group index"); - return NULL; - } - return &_Groups[index]; -} - - - - diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h deleted file mode 100644 index febff220b..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h +++ /dev/null @@ -1,83 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 CL_SHEET_CTRL_SELECTION_H -#define CL_SHEET_CTRL_SELECTION_H - -namespace NLGUI -{ - class IActionHandler; -} - -/** Infos about a selection group - */ -class CSheetSelectionGroup -{ -public: - CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {} - void setTexture(const std::string &texName); - sint32 getTextureIndex() const { return _TextureIndex; } - sint32 getTextureWidth() const { return _TextureWidth; } - sint32 getTextureHeight() const { return _TextureHeight; } - void setColor(NLMISC::CRGBA color) { _Color = color; } - NLMISC::CRGBA getColor() const { return _Color; } - void setActive(bool active) { _Active = active; } - bool isActive() const { return _Active; } - const std::string &getName() const { return _Name; } - void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; } - bool isGlobalColorEnabled() const { return _GlobalColorEnabled; } -private: - std::string _Name; - bool _Active; - sint32 _TextureIndex; // index for the selection texture - sint32 _TextureWidth; - sint32 _TextureHeight; - NLMISC::CRGBA _Color; // color that modulate the texture of selection - bool _GlobalColorEnabled; -}; - -/** Class to manage selection of sheet. - * Sheet are managed by groups, identified by their ID. - */ -class CCtrlSheetSelection -{ -public: - // Add a group, and returns its index, or -1 if already created. - sint addGroup(const std::string &name); - // Get a group by its name (must exist) - CSheetSelectionGroup *getGroup(const std::string &name); - const CSheetSelectionGroup *getGroup(const std::string &name) const; - // Get a group by its index - CSheetSelectionGroup *getGroup(uint index); - const CSheetSelectionGroup *getGroup(uint index) const; - // Get the index of a group from its name, return -1 if not a group - sint getGroupIndex(const std::string &name) const; - // Deactivate all groups - void deactivateAll(); - // delete all groups - void deleteGroups(); -private: - // - typedef std::vector TGroupVect; - typedef std::map TGroupNameToIndex; -private: - TGroupVect _Groups; - TGroupNameToIndex _GroupNameToIndex; -}; - -#endif diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 23807a361..64c2b5648 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -22,7 +22,7 @@ #include "../sheet_manager.h" #include "nel/gui/interface_expr.h" #include "dbctrl_sheet.h" -#include "ctrl_sheet_selection.h" +#include "nel/gui/ctrl_sheet_selection.h" #include "dbgroup_list_sheet.h" #include "interface_manager.h" #include "sbrick_manager.h" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index a142f4d17..121504846 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -36,7 +36,7 @@ // InterfaceV3 #include "interface_parser.h" -#include "ctrl_sheet_selection.h" +#include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/interface_options.h" #include "interface_config.h" #include "interface_pointer.h" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 53798f910..7fb1bf405 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -642,13 +642,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) // todo hulud interface syntax error nlwarning ("could not parse sheet selection"); } - // Special Magic/Combat auto-generation - else if ( !strcmp((char*)root->name,"career_generator") ) - { - if (!parseCareerGenerator(root)) - // todo hulud interface syntax error - nlwarning ("could not parse 'career_generator'"); - } else if ( !strcmp((char*)root->name,"anim") ) { if (!parseAnim(root,rootGroup)) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 693b2e6da..e601b4058 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -21,7 +21,7 @@ #include "nel/misc/types_nl.h" #include "nel/3d/u_texture.h" -#include "ctrl_sheet_selection.h" +#include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/interface_link.h" #include "nel/misc/smart_ptr.h" #include "game_share/brick_types.h" From 5ffd1d3067b3f078557aa4877cfc76ddb54b68f3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 21:17:15 +0200 Subject: [PATCH 134/339] CHANGED: #1471 Some more cleanup in CInterfaceParser, removed some unused code, which also means less coupling and less refactoring to do :P --- .../src/interface_v3/interface_parser.cpp | 186 ------------------ .../src/interface_v3/interface_parser.h | 18 -- 2 files changed, 204 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 7fb1bf405..3f0ba583b 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -654,19 +654,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) // todo hulud interface syntax error nlwarning ("could not parse 'scene3d'"); } - // Special BrickViewer - else if ( !strcmp((char*)root->name,"brick_career_generator") ) - { - if (!parseBrickCareerGenerator(root)) - // todo hulud interface syntax error - nlwarning ("could not parse 'brick_career_generator'"); - } - else if ( !strcmp((char*)root->name,"brick_suffix_generator") ) - { - if (!parseBrickSuffixGenerator(root)) - // todo hulud interface syntax error - nlwarning ("could not parse 'brick_suffix_generator'"); - } else if ( !strcmp((char*)root->name,"ddx") ) { if (!parseDDX(root,rootGroup)) @@ -3198,179 +3185,6 @@ bool CInterfaceParser::getProcedureAction(const std::string &procName, uint acti return false; } - -// *************************************************************************** -bool CInterfaceParser::parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode) -{ - CXMLAutoPtr prop; - - // root_container - string rootContainer; - prop = xmlGetProp (cur, (xmlChar*)"root_container"); - if(prop) rootContainer= (const char*)prop; - else - { - // todo hulud interface syntax error - nlwarning("prop 'root_container' not found"); - return false; - } - - // search root container option - bool rootContainerSearch= false; - prop = xmlGetProp (cur, (xmlChar*)"root_container_search"); - if(prop) rootContainerSearch= CInterfaceElement::convertBool((const char*)prop); - - - // **** In all case, create or find the root_container - // if don't search but create the root container... - if(!rootContainerSearch) - { - rootTreeNode= xmlNewNode(cur->ns, (xmlChar*)"tree" ); - xmlSetProp(rootTreeNode, (xmlChar*)"node", (xmlChar*)rootContainer.c_str()); - // add it next to us now. - xmlAddNextSibling (cur, rootTreeNode); - } - else - { - rootTreeNode= NULL; - - // search from the cur place ALL the tree node that match rootContainer. - xmlNodePtr curSearch= cur; - curSearch= curSearch->next; - while(curSearch) - { - // if the node is a tree node. - if ( !strcmp((char*)curSearch->name,"tree") ) - { - // Test if him or one of his son match the name. - xmlNodePtr candidate= searchTreeNodeInHierarchy(curSearch, rootContainer.c_str()); - // found? stop! - if(candidate) - { - rootTreeNode= candidate; - break; - } - } - - curSearch= curSearch->next; - } - - // not found? abort - if(!rootTreeNode) - { - // todo hulud interface syntax error - nlwarning("career*_generator: thee root container '%s' was not found", rootContainer.c_str()); - return false; - } - } - - return true; -} - - -// *************************************************************************** -bool CInterfaceParser::parseCareerGeneratorParams(xmlNodePtr cur, - string &templateCareer, - string &templateJob, - string &careerWindow, - string &jobWindow, - xmlNodePtr &rootTreeNode, - bool &brickTypeFilter, - BRICK_TYPE::EBrickType &brickType - ) -{ - CXMLAutoPtr prop; - - // **** Parse the generator properties - // template_career - prop = xmlGetProp (cur, (xmlChar*)"template_career"); - if(prop) templateCareer= (const char*)prop; - else - { - // todo hulud interface syntax error - nlwarning("prop 'template_career' not found"); - return false; - } - - // template_job - prop = xmlGetProp (cur, (xmlChar*)"template_job"); - if(prop) templateJob= (const char*)prop; - else - { - // todo hulud interface syntax error - nlwarning("prop 'template_job' not found"); - return false; - } - - // career_window - prop = xmlGetProp (cur, (xmlChar*)"career_window"); - if(prop) careerWindow= (const char*)prop; - else - { - // todo hulud interface syntax error - nlwarning("prop 'career_window' not found"); - return false; - } - - // job_window - prop = xmlGetProp (cur, (xmlChar*)"job_window"); - if(prop) jobWindow= (const char*)prop; - else - { - // todo hulud interface syntax error - nlwarning("prop 'job_window' not found"); - return false; - } - - // get brick type - prop = xmlGetProp (cur, (xmlChar*)"brick_type"); - if(prop) - { - if( !strcmp(prop, "none") ) - { - brickTypeFilter= false; - } - else - { - brickTypeFilter= true; - brickType= BRICK_TYPE::toBrickType((const char*)prop); - if(brickType == BRICK_TYPE::UNKNOWN) - { - // todo hulud interface syntax error - nlwarning("'brick_type' UKNOWN"); - return false; - } - } - } - else - { - // todo hulud interface syntax error - nlwarning("prop 'brick_type' not found"); - return false; - } - - // create or search the root container. - if(!parseGeneratorRootContainer(cur, rootTreeNode)) - return false; - - return true; -} - - -// *************************************************************************** -bool CInterfaceParser::parseBrickCareerGenerator(xmlNodePtr /* cur */) -{ - return false; -} - - -// *************************************************************************** -bool CInterfaceParser::parseBrickSuffixGenerator(xmlNodePtr /* cur */) -{ - return false; -} - - // *************************************************************************** bool CInterfaceParser::parseStyle(xmlNodePtr cur) { diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index e601b4058..3b1bd4e4b 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -24,7 +24,6 @@ #include "nel/gui/ctrl_sheet_selection.h" #include "nel/gui/interface_link.h" #include "nel/misc/smart_ptr.h" -#include "game_share/brick_types.h" #include "nel/gui/lua_helper.h" #include "nel/gui/widget_manager.h" @@ -93,8 +92,6 @@ public: bool parseKey(xmlNodePtr cur); bool parseMacro(xmlNodePtr cur); bool parseCommand(xmlNodePtr cur); - bool parseBrickCareerGenerator(xmlNodePtr cur); - bool parseBrickSuffixGenerator(xmlNodePtr cur); bool parseStyle(xmlNodePtr cur); bool parseDDX (xmlNodePtr cur, CInterfaceGroup * parentGroup); bool parseLUAScript (xmlNodePtr cur); @@ -307,21 +304,6 @@ protected: typedef std::map TStyleMap; TStyleMap _StyleMap; -protected: - - bool parseCareerGeneratorParams(xmlNodePtr cur, - std::string &templateCareer, - std::string &templateJob, - std::string &careerWindow, - std::string &jobWindow, - xmlNodePtr &rootTreeNode, - bool &brickTypeFilter, - BRICK_TYPE::EBrickType &brickType - ); - - bool parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode); - - protected: // LUA // ---------------------------------------------------------------------------------- From 4ed62dc1c4e667ee3310bbe6ef57c12eb4b7c401 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 8 Jul 2012 01:56:49 +0200 Subject: [PATCH 135/339] CHANGED: #1471 Classes derived from CInterfaceOptions are now instantiated using a factory. --- code/nel/include/nel/gui/interface_options.h | 15 +++++++---- code/nel/src/gui/interface_options.cpp | 20 +++++++++++---- .../interface_v3/interface_options_ryzom.cpp | 5 +++- .../interface_v3/interface_options_ryzom.h | 4 ++- .../src/interface_v3/interface_parser.cpp | 25 ++++++------------- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/code/nel/include/nel/gui/interface_options.h b/code/nel/include/nel/gui/interface_options.h index 0ef9b0d6d..e46be901b 100644 --- a/code/nel/include/nel/gui/interface_options.h +++ b/code/nel/include/nel/gui/interface_options.h @@ -72,7 +72,12 @@ namespace NLGUI public: - CInterfaceOptions(); + // for factory construction + struct TCtorParam + { + }; + + CInterfaceOptions( const TCtorParam &/* param */ ); virtual ~CInterfaceOptions(); virtual bool parse (xmlNodePtr cur); @@ -103,7 +108,7 @@ namespace NLGUI { public: - COptionsLayer(); + COptionsLayer( const TCtorParam &/* param */ ); ~COptionsLayer(); virtual bool parse (xmlNodePtr cur); @@ -159,7 +164,7 @@ namespace NLGUI class COptionsContainerInsertion : public CInterfaceOptions { public: - COptionsContainerInsertion(); + COptionsContainerInsertion( const TCtorParam &/* param */ ); virtual bool parse (xmlNodePtr cur); sint32 TxId_R_Arrow; @@ -173,7 +178,7 @@ namespace NLGUI class COptionsContainerMove : public CInterfaceOptions { public: - COptionsContainerMove(); + COptionsContainerMove( const TCtorParam &/* param */ ); virtual bool parse (xmlNodePtr cur); sint32 TrackW; @@ -193,7 +198,7 @@ namespace NLGUI class COptionsList : public CInterfaceOptions { public: - COptionsList(); + COptionsList( const TCtorParam &/* param */ ); virtual bool parse (xmlNodePtr cur); uint getNumParams() const {return _NumParams;} diff --git a/code/nel/src/gui/interface_options.cpp b/code/nel/src/gui/interface_options.cpp index 28c1edafb..3423eb69b 100644 --- a/code/nel/src/gui/interface_options.cpp +++ b/code/nel/src/gui/interface_options.cpp @@ -19,6 +19,8 @@ #include "nel/gui/interface_element.h" #include "nel/gui/interface_options.h" #include "nel/gui/view_renderer.h" +#include "nel/misc/factory.h" +#include using namespace std; using namespace NLMISC; @@ -44,7 +46,7 @@ namespace NLGUI // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- - CInterfaceOptions::CInterfaceOptions() + CInterfaceOptions::CInterfaceOptions( const TCtorParam &/* param */ ) { } @@ -132,7 +134,9 @@ namespace NLGUI // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- - COptionsLayer::COptionsLayer() + NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsLayer, std::string, "layer"); + COptionsLayer::COptionsLayer( const TCtorParam ¶m ) : + CInterfaceOptions( param ) { TxId_TL = TxId_T = TxId_TR = TxId_L = TxId_R = TxId_Blank = TxId_BL = TxId_B = -2; TxId_BR = TxId_BL_Open = TxId_B_Open = TxId_BR_Open = TxId_EL_Open = TxId_EM_Open = TxId_ER_Open =-2; @@ -237,7 +241,9 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - COptionsContainerInsertion::COptionsContainerInsertion() + NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsContainerInsertion, std::string, "container_insertion_opt"); + COptionsContainerInsertion::COptionsContainerInsertion( const TCtorParam ¶m ) : + CInterfaceOptions( param ) { TxId_R_Arrow = -2; TxId_L_Arrow = -2; @@ -264,7 +270,9 @@ namespace NLGUI // *************************************************************************** - COptionsContainerMove::COptionsContainerMove() + NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsContainerMove, std::string, "container_move_opt"); + COptionsContainerMove::COptionsContainerMove( const TCtorParam ¶m ) : + CInterfaceOptions( param ) { TrackW = -8; TrackH = 22; @@ -289,7 +297,9 @@ namespace NLGUI } // *************************************************************************** - COptionsList::COptionsList() + NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsList, std::string, "list"); + COptionsList::COptionsList( const TCtorParam ¶m ) : + CInterfaceOptions( param ) { _NumParams= 0; } diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp index f4e0fe5cd..a2365fd1d 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.cpp @@ -38,6 +38,7 @@ using namespace NLMISC; extern CEntityAnimationManager *EAM; +NLMISC_REGISTER_OBJECT(CInterfaceOptions, CMissionIconList, std::string, "mission_icons"); // *************************************************************************** bool CMissionIconList::parse(xmlNodePtr cur) @@ -90,7 +91,9 @@ bool CMissionIconList::parse(xmlNodePtr cur) // *************************************************************************** -COptionsAnimationSet::COptionsAnimationSet() +NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsAnimationSet, std::string, "animation_set"); +COptionsAnimationSet::COptionsAnimationSet( const TCtorParam ¶m ) : +CInterfaceOptions( param ) { AnimationSet= NULL; } diff --git a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h index 24d3b7524..a8bbd2767 100644 --- a/code/ryzom/client/src/interface_v3/interface_options_ryzom.h +++ b/code/ryzom/client/src/interface_v3/interface_options_ryzom.h @@ -26,6 +26,8 @@ using namespace NLGUI; class CMissionIconList : public CInterfaceOptions { public: + CMissionIconList( const TCtorParam ¶m ) : CInterfaceOptions( param ){} + ~CMissionIconList(){} virtual bool parse (xmlNodePtr cur); sint32 getBackTexID(uint index) const { return index >= IconBackTexID.size() ? -1 : IconBackTexID[index]; } sint32 getTexID(uint index) const { return index >= IconTexID.size() ? -1 : IconTexID[index]; } @@ -40,7 +42,7 @@ private: class COptionsAnimationSet : public CInterfaceOptions { public: - COptionsAnimationSet(); + COptionsAnimationSet( const TCtorParam &/* param */ ); // see code for important release note virtual ~COptionsAnimationSet(); virtual bool parse (xmlNodePtr cur); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 3f0ba583b..195a70118 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -34,7 +34,6 @@ #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_manager.h" -#include "interface_options_ryzom.h" #include "interface_3d_scene.h" #include "lua_ihm_ryzom.h" #include "interface_ddx.h" @@ -1207,28 +1206,18 @@ bool CInterfaceParser::parseOptions (xmlNodePtr cur, CInterfaceGroup * /* parent H_AUTO(parseOptions ) // build the options from type - CInterfaceOptions *options; + CInterfaceOptions *options = NULL; CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" )); if (ptr) { - if (nlstricmp(ptr.getDatas(), "layer") == 0) - options = new COptionsLayer; - else if (nlstricmp(ptr.getDatas(), "container_insertion_opt") == 0) - options = new COptionsContainerInsertion; - else if (nlstricmp(ptr.getDatas(), "container_move_opt") == 0) - options = new COptionsContainerMove; - else if (nlstricmp(ptr.getDatas(), "list") == 0) - options = new COptionsList; - else if (nlstricmp(ptr.getDatas(), "mission_icons") == 0) - options = new CMissionIconList; - else if (nlstricmp(ptr.getDatas(), "animation_set") == 0) - options = new COptionsAnimationSet; - else - options = new CInterfaceOptions; + options = NLMISC_GET_FACTORY( CInterfaceOptions, std::string ).createObject( std::string( (const char*)ptr ), CInterfaceOptions::TCtorParam() ); + + if( options == NULL ) + options = new CInterfaceOptions( CInterfaceOptions::TCtorParam() ); } else { - options = new CInterfaceOptions; + options = new CInterfaceOptions( CInterfaceOptions::TCtorParam() ); } CWidgetManager *wm = CWidgetManager::getInstance(); @@ -1277,7 +1266,7 @@ bool CInterfaceParser::parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"type" )); if (ptr) { - group = dynamic_cast(NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam())); + group = dynamic_cast( NLMISC_GET_FACTORY(CViewBase, std::string).createObject(string((const char*)ptr), CViewBase::TCtorParam()) ); if (group == NULL) { group = dynamic_cast(NLMISC_GET_FACTORY(CViewBase, std::string).createObject("interface_group", CViewBase::TCtorParam())); From 7142b944497d6967e913ded3be37e6644de312b7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 9 Jul 2012 02:36:17 +0200 Subject: [PATCH 136/339] CHANGED: #1471 Modularized CInterfaceParser. It is now extendable with parser modules, so it can parse Ryzom game related stuff without the parser code having to be in the class itself. --- code/ryzom/client/src/actions.cpp | 13 +- .../src/interface_v3/interface_manager.cpp | 11 + .../src/interface_v3/interface_parser.cpp | 642 ++---------------- .../src/interface_v3/interface_parser.h | 48 +- .../src/interface_v3/parser_modules.cpp | 526 ++++++++++++++ .../client/src/interface_v3/parser_modules.h | 77 +++ 6 files changed, 734 insertions(+), 583 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/parser_modules.cpp create mode 100644 code/ryzom/client/src/interface_v3/parser_modules.h diff --git a/code/ryzom/client/src/actions.cpp b/code/ryzom/client/src/actions.cpp index 599f7a637..9052455d8 100644 --- a/code/ryzom/client/src/actions.cpp +++ b/code/ryzom/client/src/actions.cpp @@ -747,11 +747,20 @@ const CActionsManager::CCategoryLocator *CActionsManager::getActionLocator (cons while ((ite != _ActionCategory.end ()) && (ite->first == name.Name)) { // Ref on the base action - const CBaseAction &baseAction = _Categories[ite->second.CategoryId].BaseActions[ite->second.BaseActionId]; + const CCategory &cat = _Categories[ite->second.CategoryId]; + uint baseActionId = ite->second.BaseActionId; + uint baseActionSize = cat.BaseActions.size(); + + if( ite->second.BaseActionId >= cat.BaseActions.size() ) + return NULL; + + const CBaseAction &baseAction = cat.BaseActions[ite->second.BaseActionId]; // Check parameters uint i; - for (i=0; idriver = driver; this->textcontext = textcontext; diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 195a70118..76d378963 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -34,11 +34,8 @@ #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_manager.h" -#include "interface_3d_scene.h" #include "lua_ihm_ryzom.h" -#include "interface_ddx.h" -#include "macrocmd_manager.h" -#include "../commands.h" + #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -47,6 +44,7 @@ const uint32 UI_CACHE_SERIAL_CHECK = (uint32) 'IUG_'; using namespace NLMISC; using namespace NLGUI; +using namespace std; void saveXMLTree(COFile &f, xmlNodePtr node) { @@ -114,17 +112,6 @@ xmlNodePtr buildTree(CIFile &f) -// ---------------------------------------------------------------------------- - -extern CActionsManager Actions; // Actions Manager. -extern CActionsManager EditActions; // Actions Manager. -extern CActionsContext ActionsContext; // Actions context. - -// ---------------------------------------------------------------------------- - -using namespace NLMISC; -using namespace std; - // ---------------------------------------------------------------------------- // CRootGroup // ---------------------------------------------------------------------------- @@ -212,11 +199,13 @@ CInterfaceParser::CInterfaceParser() { // LUA _LuaState= NULL; + cacheUIParsing = false; } CInterfaceParser::~CInterfaceParser() { _LuaState = NULL; + removeAllModules(); } /** Convert a string into a memstream */ @@ -328,7 +317,7 @@ bool CInterfaceParser::parseInterface (const std::vector & strings, xmlNodePtr cur = NULL; bool saveParseResult = false; bool readFromUncompressedXML = true; - if( false /* isFilename && ClientCfg.CacheUIParsing */ ) + if( isFilename && cacheUIParsing ) { saveParseResult = true; std::string archive = CPath::lookup(nextFileName + "_compressed", false, false); @@ -457,11 +446,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) //parse templates xmlNodePtr curNode = root->children; - // Resize action category array - uint actionCategoryCount = CIXml::countChildren(curNode, "action_category"); - Actions.reserveCategories((uint)Actions.getCategories ().size()+actionCategoryCount); - EditActions.reserveCategories(1); - std::vector< CWidgetManager::SMasterGroup > &_MasterGroups = CWidgetManager::getInstance()->getAllMasterGroup(); while (curNode) @@ -515,30 +499,20 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) // todo hulud interface syntax error nlwarning ("could not parse define"); } - else if ( !strcmp((char*)curNode->name,"action_category") ) - { - if (!parseActionCategory(curNode)) - // todo hulud interface syntax error - nlwarning ("could not parse action_category"); - } - else if ( !strcmp((char*)curNode->name,"key") ) - { - parseKey(curNode); - } - else if ( !strcmp((char*)curNode->name,"macro") ) - { - parseMacro(curNode); - } - else if ( !strcmp((char*)curNode->name,"command") ) - { - parseCommand(curNode); - } else if ( !strcmp((char*)curNode->name,"style") ) { if (!parseStyle(curNode)) // todo hulud interface syntax error nlwarning ("could not parse 'style'"); } + else + { + IParserModule *module = getModuleFor( (char*)( curNode->name ) ); + if( module != NULL ){ + if( module->canParseInStage( IParserModule::Unresolved ) ) + module->parse( curNode, rootGroup ); + } + } curNode = curNode->next; } @@ -647,18 +621,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) // todo hulud interface syntax error nlwarning ("could not parse 'anim'"); } - else if ( !strcmp((char*)root->name,"scene3d") ) - { - if (!parseScene3D(root,rootGroup)) - // todo hulud interface syntax error - nlwarning ("could not parse 'scene3d'"); - } - else if ( !strcmp((char*)root->name,"ddx") ) - { - if (!parseDDX(root,rootGroup)) - // todo hulud interface syntax error - nlwarning ("could not parse 'ddx'"); - } else if ( !strcmp((char*)root->name,"lua") ) { if(!parseLUAScript(root)) @@ -667,6 +629,15 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload) exit( EXIT_FAILURE ); } } + else + { + IParserModule *module = getModuleFor( (char*)( root->name ) ); + if( module != NULL ) + { + if( module->canParseInStage( IParserModule::Resolved ) ) + module->parse( root, rootGroup ); + } + } root = root->next; } @@ -860,78 +831,6 @@ bool CInterfaceParser::parseInstance(xmlNodePtr cur) return true; } -// ---------------------------------------------------------------------------- -/*bool CInterfaceParser::parseDynamicList(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - CGroupListDynamic* li = new CGroupListDynamic; - if (!li->parse(cur,parentGroup)) - { - nlinfo("failed to parse a dynamic list"); - delete li; - return false; - } - - //copy the templates used by the instance of the list, otherwise it will be scratched after init - xmlNodePtr listChild = cur->children; - //listChild should exist here otherwise li->parse would have returned false - nlassert(listChild); - CXMLAutoPtr buf = (char*) xmlGetProp( listChild, (xmlChar*)"template" ); - if (!buf) - { - nlinfo(" dynamic list : the child instance has no template attribute"); - return false; - } - - for (vector::const_iterator it = _Templates.begin(); it != _Templates.end();it++) - { - CXMLAutoPtr ptr = (char*) xmlGetProp( *it, (xmlChar*)"name" ); - if (!ptr) - { - nlinfo("no name in a template node"); - return false; - } - if ( !strcmp(buf,ptr) ) - { - break; - } - } - xmlNodePtr node = xmlCopyNode(*it,1); - _KeptTemplates.push_back(node); - - CXMLAutoPtr dependencies = (char*) xmlGetProp( cur, (xmlChar*)"dependencies" ); - if (dependencies) - { - char *seekPtr = dependencies.getDatas(); - seekPtr = strtok(seekPtr," ,\t"); - while (seekPtr) - { - for (vector::const_iterator it = _Templates.begin(); it != _Templates.end();it++) - { - CXMLAutoPtr ptr = (char*) xmlGetProp( *it, (xmlChar*)"name" ); - if (!ptr) - { - nlinfo("no name in a template node"); - return false; - } - if ( !strcmp(seekPtr, ptr) ) - { - break; - } - } - xmlNodePtr node = xmlCopyNode(*it,1); - _KeptTemplates.push_back(node); - seekPtr = strtok(NULL," ,\t"); - } - } - - //add the list in the tree - if (parentGroup) - { - parentGroup->addGroup(li); - } - return true; -}*/ - // ---------------------------------------------------------------------------- bool CInterfaceParser::parseVector(xmlNodePtr cur) { @@ -1349,10 +1248,15 @@ bool CInterfaceParser::parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * pare ok = ok && parseVector(cur); else if ( !strcmp((char*)cur->name,"link") ) ok = ok && parseLink(cur,parentGroup); - else if ( !strcmp((char*)cur->name,"scene3d") ) - ok = ok && parseScene3D(cur,parentGroup); - else if ( !strcmp((char*)cur->name,"ddx") ) - ok = ok && parseDDX(cur,parentGroup); + else + { + IParserModule *module = getModuleFor( (char*)( cur->name ) ); + if( module != NULL ) + { + if( module->canParseInStage( IParserModule::GroupChildren ) ) + ok = ok && module->parse( cur, parentGroup ); + } + } cur = cur->next; @@ -1610,6 +1514,42 @@ bool CInterfaceParser::setupTreeNode (xmlNodePtr cur, CGroupContainer * /* paren return true; } +void CInterfaceParser::addModule( std::string name, IParserModule *module ) +{ + std::map< std::string, IParserModule* >::iterator itr = + moduleMap.find( name ); + + if( itr != moduleMap.end() ) + { + nlwarning( "Tried to add parser module %s, which already exists.",name.c_str() ); + delete module; + return; + } + + module->setParser( this ); + moduleMap[ name ] = module; +} + +CInterfaceParser::IParserModule* CInterfaceParser::getModuleFor( std::string name ) const +{ + std::map< std::string, IParserModule* >::const_iterator itr = + moduleMap.find( name ); + if( itr == moduleMap.end() ) + return NULL; + else + return itr->second; +} + +void CInterfaceParser::removeAllModules() +{ + std::map< std::string, IParserModule* >::iterator itr; + for( itr = moduleMap.begin(); itr != moduleMap.end(); ++itr ) + { + delete itr->second; + } + moduleMap.clear(); +} + // ---------------------------------------------------------------------------- bool CInterfaceParser::setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup * /* parentGroup */) { @@ -2471,435 +2411,6 @@ bool CInterfaceParser::parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup) return true; } -//================================================================== -bool CInterfaceParser::parseScene3D(xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - H_AUTO(parseScene3D) - - CInterface3DScene *pScene; - CXMLAutoPtr ptr; - - pScene = new CInterface3DScene(CViewBase::TCtorParam()); - - // parse the group attributes - if (!pScene->parse(cur,parentGroup)) - { - delete pScene; - // todo hulud interface syntax error - nlinfo ("cannot parse 3d scene attributes"); - return false; - } - - if (parentGroup) - { - CGroupList *pList = dynamic_cast(parentGroup); - if (pList != NULL) - pList->addChild (pScene); - else - parentGroup->addGroup (pScene); - } - else - { - string tmp = "no parent for "+pScene->getId(); - // todo hulud interface syntax error - nlinfo (tmp.c_str()); - delete pScene; - return false; - } - - return true; -} - -// ---------------------------------------------------------------------------- -bool CInterfaceParser::parseActionCategory(xmlNodePtr cur) -{ - H_AUTO(parseActionCategory) - - // The category - CCategory category; - - // Name - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"name" )); - if (ptr) - category.Name = (const char*)ptr; - - // Localized string - ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); - if (ptr) - category.LocalizedName = (const char*)ptr; - - // macroisable (per category) - ptr = (char*) xmlGetProp( cur, (xmlChar*)"macroisable" ); - if (ptr) - category.Macroisable= CInterfaceElement::convertBool(ptr); - - // Count number of action - category.BaseActions.resize (CIXml::countChildren(cur, "action")); - - - std::string actionCategoryContext = "game"; - - ptr = (char*) xmlGetProp( cur, (xmlChar*)"contexts" ); - if (ptr) - actionCategoryContext = (const char *) ptr; - - uint actionIndex = 0; - xmlNodePtr actionNode = CIXml::getFirstChildNode(cur, "action"); - if (actionNode) - { - do - { - // The action - CBaseAction &action = category.BaseActions[actionIndex]; - - // list of contexts in which this action is valid - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"contexts" ); - if (ptr) - action.Contexts = (const char *) ptr; - else - action.Contexts = actionCategoryContext; // inherit from action category - - // Repeat flag - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"repeat" ); - if (ptr) - fromString((const char*)ptr, action.Repeat); - - // KeyDown flag - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"keydown" ); - if (ptr) - fromString((const char*)ptr, action.KeyDown); - - // KeyUp flag - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"keyup" ); - if (ptr) - fromString((const char*)ptr, action.KeyUp); - - // WaitForServer flag (wait an answer from server before continuing) - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"waitforserver" ); - if (ptr) - fromString((const char*)ptr, action.WaitForServer); - - // Action name - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"name" ); - if (ptr) - action.Name = (const char*)ptr; - - - // Action localized name - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"hardtext" ); - if (ptr) - action.LocalizedName = (const char*)ptr; - - // macroisable (per action) - action.Macroisable= true; - ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"macroisable" ); - if (ptr) - action.Macroisable = CInterfaceElement::convertBool(ptr); - - - // Read the parameters - action.Parameters.resize (CIXml::countChildren(actionNode, "parameter")); - - uint parameterIndex = 0; - xmlNodePtr paramNode = CIXml::getFirstChildNode(actionNode, "parameter"); - if (paramNode) - { - do - { - // The parameter - CBaseAction::CParameter ¶meter = action.Parameters[parameterIndex]; - - // Parameter type - ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"type" ); - if (ptr) - { - sint32 tType; - fromString((const char*)ptr, tType); - parameter.Type = (CBaseAction::CParameter::TType)tType; - } - - // Parameter name - ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"name" ); - if (ptr) - parameter.Name = (const char*)ptr; - - // Parameter localized name - ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"hardtext" ); - if (ptr) - parameter.LocalizedName = (const char*)ptr; - - // Default value - ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"value" ); - if (ptr) - parameter.DefaultValue = (const char*)ptr; - - // Visible flag - //ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"visible" ); - //if (ptr) - // fromString((const char*)ptr, parameter.Visible); - - // Parse instance - xmlNodePtr instanceNode = CIXml::getFirstChildNode(paramNode, "instance"); - if (instanceNode) - { - do - { - if (!parseInstance(instanceNode)) - { - // todo hulud interface syntax error - nlwarning(" cannot create instance from template"); - } - } - while((instanceNode = CIXml::getNextChildNode(instanceNode, "instance"))); - } - - parameter.Values.resize (CIXml::countChildren(paramNode, "value")); - - uint valueIndex = 0; - xmlNodePtr valueNode = CIXml::getFirstChildNode(paramNode, "value"); - if (valueNode) - { - do - { - // The value - CBaseAction::CParameter::CValue &value = parameter.Values[valueIndex]; - - // Value - ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"value" ); - if (ptr) - value.Value = (const char*)ptr; - - // list of contexts in which this value is valid - ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"contexts" ); - if (ptr) value.Contexts = (const char*) ptr; - else value.Contexts = action.Contexts; // inherit context from action - - // Localized value - ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"hardtext" ); - if (ptr) - value.LocalizedValue = (const char*)ptr; - - valueIndex++; - } - while((valueNode = CIXml::getNextChildNode(valueNode, "value"))); - } - - parameterIndex++; - } - while((paramNode = CIXml::getNextChildNode(paramNode, "parameter"))); - } - - // Next action - actionIndex++; - } - while((actionNode = CIXml::getNextChildNode(actionNode, "action"))); - } - - // Add this category to the action manager - CActionsManager *actionManager = ActionsContext.getActionsManager (category.Name); - if (actionManager) - { -// They want to display debug shortcut in final version -#if FINAL_VERSION - if ((category.Name != "debug") || ClientCfg.AllowDebugCommands) -#else // FINAL_VERSION - if (1) -#endif // FINAL_VERSION - { - actionManager->removeCategory (category.Name); - actionManager->addCategory (category); - } - else - { - // Remove thoses actions from the manager - CAHManager *pAHFM = CAHManager::getInstance(); - uint i; - for (i=0; iFactoryMap.find (category.BaseActions[i].Name); - if (ite != pAHFM->FactoryMap.end()) - { - IActionHandler *ah = ite->second; - pAHFM->FactoryMap.erase (ite); - pAHFM->NameMap.erase (ah); - } - } - } - } - return true; -} - -//================================================================== -bool CInterfaceParser::parseKey(xmlNodePtr cur) -{ - H_AUTO(parseKey) - - // Parse the key - bool ret = false; - - // Localized string - TKey key; - CXMLAutoPtr ptrKey((const char*) xmlGetProp( cur, (xmlChar*)"name" )); - if (ptrKey) - { - bool isNA = string((const char*)ptrKey) == string("N/A"); - // Get the key from the string - key = CEventKey::getKeyFromString ((const char*)ptrKey); - if (key != KeyCount || isNA) - { - // Get the action - CXMLAutoPtr ptrAction((const char*) xmlGetProp( cur, (xmlChar*)"action" )); - if (ptrAction) - { - // Get the params - CXMLAutoPtr ptrParams((const char*) xmlGetProp( cur, (xmlChar*)"params" )); - - // Get the modifiers - bool shift=false; - bool ctrl=false; - bool menu=false; - CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"shift" )); - if (ptr) - fromString((const char*)ptr, shift); - ptr = (char*) xmlGetProp( cur, (xmlChar*)"ctrl" ); - if (ptr) - fromString((const char*)ptr, ctrl); - ptr = (char*) xmlGetProp( cur, (xmlChar*)"menu" ); - if (ptr) - fromString((const char*)ptr, menu); - - // Repeat flag - bool repeat=false; - ptr = (char*) xmlGetProp( cur, (xmlChar*)"repeat" ); - if (ptr) - fromString((const char*)ptr, repeat); - - // Get the context - CXMLAutoPtr ptrContext((const char*) xmlGetProp( cur, (xmlChar*)"context" )); - string context = (const char*)ptrContext?(const char*)ptrContext:""; - - // Add the action - CCombo combo; - combo.init(key, (TKeyButton)((shift?shiftKeyButton:noKeyButton)|(ctrl?ctrlKeyButton:noKeyButton)|(menu?altKeyButton:noKeyButton))); - ::CAction::CName actionName ((const char*)ptrAction, ptrParams?(const char*)ptrParams:""); - - // Get the actions context manager - CActionsManager *actionManager = ActionsContext.getActionsManager(context); - if (actionManager) - { - bool canAdd= true; - - // for keys.xml, don't replace already defined keys - if(getDefine("key_def_no_replace")=="1") - { - // if this combo key is already used for any action, - // or if this action is already bound to any key - if(isNA || actionManager->isComboAssociated(combo) || actionManager->isActionAssociated(actionName)) - // don't replace - canAdd= false; - } - - // add/replace the combo? - if(canAdd) - { - actionManager->addCombo(actionName, combo); - ::CAction *action = actionManager->getAction(actionName); - if (action && repeat) action->Repeat = true; - } - - // if the action is to be shown in the Key interface - if(getDefine("key_def_force_display")=="1") - actionManager->forceDisplayForAction(actionName, true); - } - - // Done - ret = true; - } - else - { - // todo hulud interface syntax error - nlwarning(" No action for key : %s", (const char*)ptrKey); - } - } - else - { - // todo hulud interface syntax error - nlwarning(" Unknown key : %s", (const char*)ptrKey); - } - } - else - { - // todo hulud interface syntax error - nlwarning(" No name for a key"); - } - - return ret; -} - -//================================================================== -bool CInterfaceParser::parseCommand(xmlNodePtr cur) -{ - H_AUTO(parseCommand) - - // Parse the key - bool ret = false; - - // Localized string - CXMLAutoPtr ptrName((const char*) xmlGetProp( cur, (xmlChar*)"name" )); - if (ptrName) - { - // Does the action exist ? - string name = ptrName; - if (!ICommand::exists (name) || (CUserCommand::CommandMap.find(name) != CUserCommand::CommandMap.end())) - { - // Get the action - CXMLAutoPtr ptrAction((const char*) xmlGetProp( cur, (xmlChar*)"action" )); - if (ptrAction) - { - // Get the params - CXMLAutoPtr ptrParams((const char*) xmlGetProp( cur, (xmlChar*)"params" )); - if (ptrParams) - { - CUserCommand::createCommand (ptrName, ptrAction, ptrParams); - - // if prop "ctrlchar" is declared with false, then disable ctrlchar for this command - CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"ctrlchar" )); - if( (const char*)prop && (CInterfaceElement::convertBool((const char*)prop)==false) ) - ICommand::enableControlCharForCommand(ptrName, false); - - // Done - ret = true; - } - } - else - { - // todo hulud interface syntax error - nlwarning(" No action for command : %s", (const char*)ptrName); - } - } - } - else - { - // todo hulud interface syntax error - nlwarning(" No name for a key"); - } - - return ret; -} - -//================================================================== -bool CInterfaceParser::parseMacro(xmlNodePtr cur) -{ - H_AUTO(parseMacro) - - CMacroCmd cmd; - if (cmd.readFrom(cur)) - CMacroCmdManager::getInstance()->addMacro(cmd); - else - return false; - return true; -} - //================================================================== void CInterfaceParser::freeXMLNodeAndSibblings(xmlNodePtr node) { @@ -3219,25 +2730,6 @@ bool CInterfaceParser::parseStyle(xmlNodePtr cur) return true; } -// *************************************************************************** -bool CInterfaceParser::parseDDX (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - H_AUTO(parseDDX ) - - CInterfaceDDX *pDDX = NULL; - pDDX = new CInterfaceDDX; - if (pDDX) - { - if (!pDDX->parse(cur,parentGroup)) - { - delete pDDX; - return false; - } - return true; - } - return false; -} - // *************************************************************************** bool CInterfaceParser::parseLUAScript (xmlNodePtr cur) { diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 3b1bd4e4b..c78d87577 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -55,6 +55,40 @@ class CInterfaceParser : public IParser { public: + + class IParserModule + { + public: + enum ParsingStage + { + None = 0, + Unresolved = 1, + Resolved = 2, + GroupChildren = 4 + }; + + IParserModule(){ + parser = NULL; + parsingStage = None; + } + virtual ~IParserModule(){} + + bool canParseInStage( ParsingStage stage ) + { + if( ( parsingStage & static_cast< uint >( stage ) ) != 0 ) + return true; + else + return false; + } + + virtual bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ) = 0; + void setParser( CInterfaceParser *p ){ parser = p; } + + protected: + CInterfaceParser *parser; + uint parsingStage; + }; + CInterfaceParser(); virtual ~CInterfaceParser(); @@ -87,16 +121,14 @@ public: bool parseProcedure(xmlNodePtr cur, bool reload); bool parseSheetSelection(xmlNodePtr cur); bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseScene3D (xmlNodePtr cur, CInterfaceGroup * parentGroup); - bool parseActionCategory (xmlNodePtr cur); - bool parseKey(xmlNodePtr cur); - bool parseMacro(xmlNodePtr cur); - bool parseCommand(xmlNodePtr cur); bool parseStyle(xmlNodePtr cur); - bool parseDDX (xmlNodePtr cur, CInterfaceGroup * parentGroup); bool parseLUAScript (xmlNodePtr cur); bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); + + void addModule( std::string name, IParserModule *module ); + IParserModule* getModuleFor( std::string name ) const; + void removeAllModules(); // Called by each parse in parseXMLDocument bool solveDefine(xmlNodePtr cur); @@ -197,6 +229,8 @@ public: // return false if procedure not found, or if bad action index. return false if has some param variable (@0...) bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const; + void setCacheUIParsing( bool b ){ cacheUIParsing = b; } + protected: /** @@ -305,6 +339,7 @@ protected: TStyleMap _StyleMap; protected: + std::map< std::string, IParserModule* > moduleMap; // LUA // ---------------------------------------------------------------------------------- // LUA Interface State. NB: The LUA environnement is not shared between Login/OutGame/InGame @@ -315,6 +350,7 @@ protected: std::set _LuaFileScripts; // Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed) bool loadLUA(const std::string &luaFile, std::string &error); + bool cacheUIParsing; }; #endif // RZ_INTERFACE_PARSER_H diff --git a/code/ryzom/client/src/interface_v3/parser_modules.cpp b/code/ryzom/client/src/interface_v3/parser_modules.cpp new file mode 100644 index 000000000..9d912bd77 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/parser_modules.cpp @@ -0,0 +1,526 @@ +// Ryzom - MMORPG Framework +// 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 "parser_modules.h" +#include "nel/gui/view_text.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_list.h" +#include "interface_ddx.h" +#include "macrocmd_manager.h" +#include "../commands.h" +#include "interface_3d_scene.h" +#include "nel/misc/i_xml.h" + +using namespace NLMISC; + +CIF3DSceneParser::CIF3DSceneParser() +{ + parsingStage |= ( Resolved | GroupChildren ); +} + +CIF3DSceneParser::~CIF3DSceneParser() +{ +} + +bool CIF3DSceneParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + CInterface3DScene *pScene; + CXMLAutoPtr ptr; + + pScene = new CInterface3DScene(CViewBase::TCtorParam()); + + // parse the group attributes + if (!pScene->parse(cur,parentGroup)) + { + delete pScene; + // todo hulud interface syntax error + nlinfo ("cannot parse 3d scene attributes"); + return false; + } + + if (parentGroup) + { + CGroupList *pList = dynamic_cast(parentGroup); + if (pList != NULL) + pList->addChild (pScene); + else + parentGroup->addGroup (pScene); + } + else + { + std::string tmp = "no parent for "+pScene->getId(); + // todo hulud interface syntax error + nlinfo (tmp.c_str()); + delete pScene; + return false; + } + + return true; +} + + + +CIFDDXParser::CIFDDXParser() +{ + parsingStage |= ( Resolved | GroupChildren ); +} + +CIFDDXParser::~CIFDDXParser() +{ +} + +bool CIFDDXParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + CInterfaceDDX *pDDX = NULL; + pDDX = new CInterfaceDDX; + if (pDDX) + { + if (!pDDX->parse(cur,parentGroup)) + { + delete pDDX; + return false; + } + return true; + } + return false; +} + + + + +CActionCategoryParser::CActionCategoryParser() +{ + parsingStage |= Unresolved; +} + +CActionCategoryParser::~CActionCategoryParser() +{ +} + +bool CActionCategoryParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + // The category + CCategory category; + + // Name + CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"name" )); + if (ptr) + category.Name = (const char*)ptr; + + // Localized string + ptr = (char*) xmlGetProp( cur, (xmlChar*)"hardtext" ); + if (ptr) + category.LocalizedName = (const char*)ptr; + + // macroisable (per category) + ptr = (char*) xmlGetProp( cur, (xmlChar*)"macroisable" ); + if (ptr) + category.Macroisable= CInterfaceElement::convertBool(ptr); + + // Count number of action + uint ns = CIXml::countChildren(cur, "action"); + category.BaseActions.resize( ns ); + + + std::string actionCategoryContext = "game"; + + ptr = (char*) xmlGetProp( cur, (xmlChar*)"contexts" ); + if (ptr) + actionCategoryContext = (const char *) ptr; + + uint actionIndex = 0; + xmlNodePtr actionNode = CIXml::getFirstChildNode(cur, "action"); + if (actionNode) + { + do + { + // The action + CBaseAction &action = category.BaseActions[actionIndex]; + + // list of contexts in which this action is valid + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"contexts" ); + if (ptr) + action.Contexts = (const char *) ptr; + else + action.Contexts = actionCategoryContext; // inherit from action category + + // Repeat flag + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"repeat" ); + if (ptr) + fromString((const char*)ptr, action.Repeat); + + // KeyDown flag + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"keydown" ); + if (ptr) + fromString((const char*)ptr, action.KeyDown); + + // KeyUp flag + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"keyup" ); + if (ptr) + fromString((const char*)ptr, action.KeyUp); + + // WaitForServer flag (wait an answer from server before continuing) + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"waitforserver" ); + if (ptr) + fromString((const char*)ptr, action.WaitForServer); + + // Action name + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"name" ); + if (ptr) + action.Name = (const char*)ptr; + + + // Action localized name + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"hardtext" ); + if (ptr) + action.LocalizedName = (const char*)ptr; + + // macroisable (per action) + action.Macroisable= true; + ptr = (char*) xmlGetProp( actionNode, (xmlChar*)"macroisable" ); + if (ptr) + action.Macroisable = CInterfaceElement::convertBool(ptr); + + + // Read the parameters + action.Parameters.resize (CIXml::countChildren(actionNode, "parameter")); + + uint parameterIndex = 0; + xmlNodePtr paramNode = CIXml::getFirstChildNode(actionNode, "parameter"); + if (paramNode) + { + do + { + // The parameter + CBaseAction::CParameter ¶meter = action.Parameters[parameterIndex]; + + // Parameter type + ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"type" ); + if (ptr) + { + sint32 tType; + fromString((const char*)ptr, tType); + parameter.Type = (CBaseAction::CParameter::TType)tType; + } + + // Parameter name + ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"name" ); + if (ptr) + parameter.Name = (const char*)ptr; + + // Parameter localized name + ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"hardtext" ); + if (ptr) + parameter.LocalizedName = (const char*)ptr; + + // Default value + ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"value" ); + if (ptr) + parameter.DefaultValue = (const char*)ptr; + + // Visible flag + //ptr = (char*) xmlGetProp( paramNode, (xmlChar*)"visible" ); + //if (ptr) + // fromString((const char*)ptr, parameter.Visible); + + // Parse instance + xmlNodePtr instanceNode = CIXml::getFirstChildNode(paramNode, "instance"); + if (instanceNode) + { + do + { + if (!parser->parseInstance(instanceNode)) + { + // todo hulud interface syntax error + nlwarning(" cannot create instance from template"); + } + } + while((instanceNode = CIXml::getNextChildNode(instanceNode, "instance"))); + } + + parameter.Values.resize (CIXml::countChildren(paramNode, "value")); + + uint valueIndex = 0; + xmlNodePtr valueNode = CIXml::getFirstChildNode(paramNode, "value"); + if (valueNode) + { + do + { + // The value + CBaseAction::CParameter::CValue &value = parameter.Values[valueIndex]; + + // Value + ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"value" ); + if (ptr) + value.Value = (const char*)ptr; + + // list of contexts in which this value is valid + ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"contexts" ); + if (ptr) value.Contexts = (const char*) ptr; + else value.Contexts = action.Contexts; // inherit context from action + + // Localized value + ptr = (char*) xmlGetProp( valueNode, (xmlChar*)"hardtext" ); + if (ptr) + value.LocalizedValue = (const char*)ptr; + + valueIndex++; + } + while((valueNode = CIXml::getNextChildNode(valueNode, "value"))); + } + + parameterIndex++; + } + while((paramNode = CIXml::getNextChildNode(paramNode, "parameter"))); + } + + // Next action + actionIndex++; + } + while((actionNode = CIXml::getNextChildNode(actionNode, "action"))); + } + + // Add this category to the action manager + CActionsManager *actionManager = ActionsContext.getActionsManager (category.Name); + if (actionManager) + { +// They want to display debug shortcut in final version +#if FINAL_VERSION + if ((category.Name != "debug") || ClientCfg.AllowDebugCommands) +#else // FINAL_VERSION + if (1) +#endif // FINAL_VERSION + { + actionManager->removeCategory (category.Name); + actionManager->addCategory (category); + } + else + { + // Remove thoses actions from the manager + CAHManager *pAHFM = CAHManager::getInstance(); + uint i; + for (i=0; iFactoryMap.find (category.BaseActions[i].Name); + if (ite != pAHFM->FactoryMap.end()) + { + IActionHandler *ah = ite->second; + pAHFM->FactoryMap.erase (ite); + pAHFM->NameMap.erase (ah); + } + } + } + } + return true; +} + + + +CCommandParser::CCommandParser() +{ + parsingStage |= Unresolved; +} + +CCommandParser::~CCommandParser() +{ +} + +bool CCommandParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + // Parse the key + bool ret = false; + + // Localized string + CXMLAutoPtr ptrName((const char*) xmlGetProp( cur, (xmlChar*)"name" )); + if (ptrName) + { + // Does the action exist ? + std::string name = ptrName; + if (!ICommand::exists (name) || (CUserCommand::CommandMap.find(name) != CUserCommand::CommandMap.end())) + { + // Get the action + CXMLAutoPtr ptrAction((const char*) xmlGetProp( cur, (xmlChar*)"action" )); + if (ptrAction) + { + // Get the params + CXMLAutoPtr ptrParams((const char*) xmlGetProp( cur, (xmlChar*)"params" )); + if (ptrParams) + { + CUserCommand::createCommand (ptrName, ptrAction, ptrParams); + + // if prop "ctrlchar" is declared with false, then disable ctrlchar for this command + CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"ctrlchar" )); + if( (const char*)prop && (CInterfaceElement::convertBool((const char*)prop)==false) ) + ICommand::enableControlCharForCommand(ptrName, false); + + // Done + ret = true; + } + } + else + { + // todo hulud interface syntax error + nlwarning(" No action for command : %s", (const char*)ptrName); + } + } + } + else + { + // todo hulud interface syntax error + nlwarning(" No name for a key"); + } + + return ret; +} + + + +CKeyParser::CKeyParser() +{ + parsingStage |= Unresolved; +} + +CKeyParser::~CKeyParser() +{ +} + +bool CKeyParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + // Parse the key + bool ret = false; + + // Localized string + TKey key; + CXMLAutoPtr ptrKey((const char*) xmlGetProp( cur, (xmlChar*)"name" )); + if (ptrKey) + { + bool isNA = std::string((const char*)ptrKey) == std::string("N/A"); + // Get the key from the string + key = CEventKey::getKeyFromString ((const char*)ptrKey); + if (key != KeyCount || isNA) + { + // Get the action + CXMLAutoPtr ptrAction((const char*) xmlGetProp( cur, (xmlChar*)"action" )); + if (ptrAction) + { + // Get the params + CXMLAutoPtr ptrParams((const char*) xmlGetProp( cur, (xmlChar*)"params" )); + + // Get the modifiers + bool shift=false; + bool ctrl=false; + bool menu=false; + CXMLAutoPtr ptr((const char*) xmlGetProp( cur, (xmlChar*)"shift" )); + if (ptr) + fromString((const char*)ptr, shift); + ptr = (char*) xmlGetProp( cur, (xmlChar*)"ctrl" ); + if (ptr) + fromString((const char*)ptr, ctrl); + ptr = (char*) xmlGetProp( cur, (xmlChar*)"menu" ); + if (ptr) + fromString((const char*)ptr, menu); + + // Repeat flag + bool repeat=false; + ptr = (char*) xmlGetProp( cur, (xmlChar*)"repeat" ); + if (ptr) + fromString((const char*)ptr, repeat); + + // Get the context + CXMLAutoPtr ptrContext((const char*) xmlGetProp( cur, (xmlChar*)"context" )); + std::string context = (const char*)ptrContext?(const char*)ptrContext:""; + + // Add the action + CCombo combo; + combo.init(key, (TKeyButton)((shift?shiftKeyButton:noKeyButton)|(ctrl?ctrlKeyButton:noKeyButton)|(menu?altKeyButton:noKeyButton))); + ::CAction::CName actionName ((const char*)ptrAction, ptrParams?(const char*)ptrParams:""); + + // Get the actions context manager + CActionsManager *actionManager = ActionsContext.getActionsManager(context); + if (actionManager) + { + bool canAdd= true; + + // for keys.xml, don't replace already defined keys + if( parser->getDefine("key_def_no_replace")=="1" ) + { + // if this combo key is already used for any action, + // or if this action is already bound to any key + if(isNA || actionManager->isComboAssociated(combo) || actionManager->isActionAssociated(actionName)) + // don't replace + canAdd= false; + } + + // add/replace the combo? + if(canAdd) + { + actionManager->addCombo(actionName, combo); + ::CAction *action = actionManager->getAction(actionName); + if (action && repeat) action->Repeat = true; + } + + // if the action is to be shown in the Key interface + if( parser->getDefine("key_def_force_display")=="1" ) + actionManager->forceDisplayForAction(actionName, true); + } + + // Done + ret = true; + } + else + { + // todo hulud interface syntax error + nlwarning(" No action for key : %s", (const char*)ptrKey); + } + } + else + { + // todo hulud interface syntax error + nlwarning(" Unknown key : %s", (const char*)ptrKey); + } + } + else + { + // todo hulud interface syntax error + nlwarning(" No name for a key"); + } + + return ret; +} + + + +CMacroParser::CMacroParser() +{ + parsingStage |= Unresolved; +} + +CMacroParser::~CMacroParser() +{ +} + +bool CMacroParser::parse( xmlNodePtr cur, NLGUI::CInterfaceGroup *parentGroup ) +{ + H_AUTO(parseMacro) + + CMacroCmd cmd; + if (cmd.readFrom(cur)) + CMacroCmdManager::getInstance()->addMacro(cmd); + else + return false; + return true; +} + diff --git a/code/ryzom/client/src/interface_v3/parser_modules.h b/code/ryzom/client/src/interface_v3/parser_modules.h new file mode 100644 index 000000000..375fccb9d --- /dev/null +++ b/code/ryzom/client/src/interface_v3/parser_modules.h @@ -0,0 +1,77 @@ +// Ryzom - MMORPG Framework +// 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 PARSER_MODULES_H +#define PARSER_MODULES_H + +#include "interface_parser.h" + +class CIF3DSceneParser : public CInterfaceParser::IParserModule +{ +public: + CIF3DSceneParser(); + ~CIF3DSceneParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +class CIFDDXParser : public CInterfaceParser::IParserModule +{ +public: + CIFDDXParser(); + ~CIFDDXParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +class CActionCategoryParser : public CInterfaceParser::IParserModule +{ +public: + CActionCategoryParser(); + ~CActionCategoryParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +class CCommandParser : public CInterfaceParser::IParserModule +{ +public: + CCommandParser(); + ~CCommandParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +class CKeyParser : public CInterfaceParser::IParserModule +{ +public: + CKeyParser(); + ~CKeyParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +class CMacroParser : public CInterfaceParser::IParserModule +{ +public: + CMacroParser(); + ~CMacroParser(); + + bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ); +}; + +#endif From e1bbfb74faa4acf1b044c7fcbffcacad7acb75b3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 9 Jul 2012 03:07:19 +0200 Subject: [PATCH 137/339] CHANGED: #1471 CInterfaceParser no longer depends on CLuaIHMRyzom. --- .../client/src/interface_v3/interface_manager.cpp | 13 +++++++++++++ .../client/src/interface_v3/interface_manager.h | 2 ++ .../client/src/interface_v3/interface_parser.cpp | 4 ---- .../client/src/interface_v3/interface_parser.h | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 39e942ede..87b1505dd 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -585,6 +585,19 @@ void CInterfaceManager::destroy () _Instance = NULL; } +void CInterfaceManager::initLUA() +{ + if( _LuaState != NULL ) + return; + + CInterfaceParser::initLUA(); + + if( _LuaState == NULL ) + return; + + CLuaIHMRyzom::RegisterRyzomFunctions( *_LuaState ); +} + // ------------------------------------------------------------------------------------------------ void CInterfaceManager::initLogin() { diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 121504846..55c8d3f4a 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -146,6 +146,8 @@ public: void setInGame( bool i ); bool isInGame() const { return _InGame; } + void initLUA(); + /// initialize the whole login interface void initLogin(); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 76d378963..8d66ae077 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -34,9 +34,6 @@ #include "nel/gui/lua_ihm.h" #include "nel/gui/lua_manager.h" -#include "lua_ihm_ryzom.h" - - #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger #endif @@ -2856,7 +2853,6 @@ void CInterfaceParser::initLUA() // register LUA methods CLuaIHM::registerAll(*_LuaState); - CLuaIHMRyzom::RegisterRyzomFunctions( *_LuaState ); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index c78d87577..b28a2ab9e 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -344,8 +344,8 @@ protected: // ---------------------------------------------------------------------------------- // LUA Interface State. NB: The LUA environnement is not shared between Login/OutGame/InGame NLMISC::CSmartPtr _LuaState; - void initLUA(); - void uninitLUA(); + virtual void initLUA(); + void uninitLUA(); // List of script loaded (for reloadLua command) std::set _LuaFileScripts; // Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed) From e97ec6788ec4354a168404e45f8850130118510b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 9 Jul 2012 03:45:00 +0200 Subject: [PATCH 138/339] CHANGED: #1471 CInterfaceParser is now part of the Nel GUI library and is under the NLGUI namespace. --- code/nel/include/nel/gui/interface_parser.h | 355 ++ code/nel/src/gui/interface_parser.cpp | 2885 ++++++++++++++++ code/ryzom/client/src/actions.h | 2 - .../src/interface_v3/interface_manager.h | 4 +- .../src/interface_v3/interface_parser.cpp | 2919 ----------------- .../src/interface_v3/interface_parser.h | 356 -- .../client/src/interface_v3/parser_modules.h | 4 +- 7 files changed, 3245 insertions(+), 3280 deletions(-) create mode 100644 code/nel/include/nel/gui/interface_parser.h create mode 100644 code/nel/src/gui/interface_parser.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_parser.cpp delete mode 100644 code/ryzom/client/src/interface_v3/interface_parser.h diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h new file mode 100644 index 000000000..2ddc359cd --- /dev/null +++ b/code/nel/include/nel/gui/interface_parser.h @@ -0,0 +1,355 @@ +// Ryzom - MMORPG Framework +// 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 RZ_INTERFACE_PARSER_H +#define RZ_INTERFACE_PARSER_H + +#include "nel/misc/types_nl.h" +#include "nel/3d/u_texture.h" +#include "nel/gui/ctrl_sheet_selection.h" +#include "nel/gui/interface_link.h" +#include "nel/misc/smart_ptr.h" +#include "nel/gui/lua_helper.h" +#include "nel/gui/widget_manager.h" + +namespace NLGUI +{ + class CInterfaceElement; + class CInterfaceGroup; + class CInterfaceOptions; + class CInterfaceLink; + class CCtrlBase; + class CGroupList; + class CGroupContainer; + class CInterfaceAnim; + class CViewPointer; + + // *************************************************************************** + /** + * class managing the interface parsing + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + + // this is the base class for CInterfaceManager + class CInterfaceParser : public IParser + { + + public: + + class IParserModule + { + public: + enum ParsingStage + { + None = 0, + Unresolved = 1, + Resolved = 2, + GroupChildren = 4 + }; + + IParserModule(){ + parser = NULL; + parsingStage = None; + } + virtual ~IParserModule(){} + + bool canParseInStage( ParsingStage stage ) + { + if( ( parsingStage & static_cast< uint >( stage ) ) != 0 ) + return true; + else + return false; + } + + virtual bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ) = 0; + void setParser( CInterfaceParser *p ){ parser = p; } + + protected: + CInterfaceParser *parser; + uint parsingStage; + }; + + CInterfaceParser(); + virtual ~CInterfaceParser(); + + public: + + /** + * Parsing methods + */ + + /** Load a set of xml files + * \param isFilename true if xmlFileNames array contains the names of the xml file, false, if each + * array is a script itself + */ + bool parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false); + + bool parseXMLDocument (xmlNodePtr root, bool reload); + bool parseTemplateNode (xmlNodePtr node,xmlNodePtr instance,xmlNodePtr templ); + bool parseInstance(xmlNodePtr cur); + bool parseVector (xmlNodePtr cur); + bool parseVariable (xmlNodePtr cur, CInterfaceGroup * parentGroup); + bool parseOptions (xmlNodePtr cur, CInterfaceGroup * parentGroup); + bool parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); + bool parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); + bool parseControl (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); + bool parseLink (xmlNodePtr cur, CInterfaceGroup * parentGroup); + bool parseView (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload); + bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); + bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); + bool parseDefine(xmlNodePtr cur); + bool parseProcedure(xmlNodePtr cur, bool reload); + bool parseSheetSelection(xmlNodePtr cur); + bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup); + bool parseStyle(xmlNodePtr cur); + bool parseLUAScript (xmlNodePtr cur); + bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); + bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); + + void addModule( std::string name, IParserModule *module ); + IParserModule* getModuleFor( std::string name ) const; + void removeAllModules(); + + // Called by each parse in parseXMLDocument + bool solveDefine(xmlNodePtr cur); + bool solveStyle(xmlNodePtr cur); + + // Solve All define in a string. return false if some define not founs (defError contains this define) + bool solveDefine(const std::string &propVal, std::string &newPropVal, std::string &defError); + + // Called after template & options parsing + virtual void setupOptions() { } + + /** + * Initializer + */ + + bool initCoordsAndLuaScript (); + + /// Association builders : associate an element of the interface with the string ID of + /// another element used as reference for position values + void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID); + void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID); + void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID); + + /// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed) + void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript); + + /** + * Accessors + */ + // access to control sheet selection + CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; } + + /// \name Parameter variable + // @{ + const std::string &getDefine(const std::string &id) const; + bool isDefineExist(const std::string &id) const; + void setDefine(const std::string &id, const std::string &value); + // @} + + /// \name Dynamic links mgt + // @{ + /** Associate the given dynamic link with an ID + * \return true if succesful + */ + bool addLink(CInterfaceLink *link, const std::string &id); + /** remove the given link from its ID + * \return true if succesful + */ + bool removeLink(const std::string &id); + // @} + + /** create a template from an instance consisting of a single group + * \param templateName name of the template in the xml + * \param templateParams array containing each template parameter and its name + * \param number of template parameters in the array + */ + CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks = true); + CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) + { + if (templateParams.size() > 0) + return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); + else + return createGroupInstance(templateName, parentID, NULL, 0, updateLinks); + } + + /** create a template from an instance consisting of a single control or group + * \param templateName name of the template in the xml + * \param templateParams array containing each template parameter and its name + * \param number of template parameters in the array + */ + CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks /* = true */); + CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true) + { + if (templateParams.size() > 0) + return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); + else + return createUIElement(templateName, parentID, NULL, 0, updateLinks); + } + + static void freeXMLNodeAndSibblings(xmlNodePtr node); + + // search a "tree" node in the hierarchy that match node. may return root! NULL if not found + static xmlNodePtr searchTreeNodeInHierarchy(xmlNodePtr root, const char *node); + + /// \name Clearing mgt + // @{ + void removeAllLinks(); + void removeAllProcedures(); + void removeAllDefines(); + void removeAllTemplates(); + void removeAllAnims(); + void removeAll(); + // @} + + // get info on procedure. return 0 if procedure not found + uint getProcedureNumActions( const std::string &procName ) const; + + // return false if procedure not found, or if bad action index. return false if has some param variable (@0...) + bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const; + + void setCacheUIParsing( bool b ){ cacheUIParsing = b; } + + protected: + + /** + * Temporary data for init + */ + + /// vector storing parsed templates during init. At the end of init, only used template are kept + std::vector _Templates; + + + // map linking an element to its parent position used during init only + std::map _ParentPositionsMap; + std::map _ParentSizesMap; + std::map _ParentSizesMaxMap; + + // map linking a group to its lua script. used during init only + std::map _LuaClassAssociation; + + /** + * Data of initialized interface + */ + + /// Define Variable list + typedef std::map TVarMap; + typedef TVarMap::iterator ItVarMap; + typedef TVarMap::const_iterator CstItVarMap; + TVarMap _DefineMap; + + bool validDefineChar(char c) const; + + /// Procedure def + class CParamBlock + { + public: + // -1 if not a param id, but a string + sint32 NumParam; + std::string String; + + CParamBlock() + { + NumParam= -1; + } + }; + class CAction + { + public: + // a condition to launch this action handler (is an expression) + std::vector CondBlocks; + + // the action handler (may be proc!!) + std::string Action; + // A list of string/or param number => to build the final params at execution + std::vector ParamBlocks; + + // build a paramBlock from a string + void buildParamBlock (const std::string ¶ms); + // from ParamBlock, and a paramList (skip the 0th), build params. + void buildParams (const std::vector ¶mList, std::string ¶ms) const; + + void buildCondBlock (const std::string ¶ms); + + void buildCond (const std::vector ¶mList, std::string &cond) const; + + static void buildBlocks (const std::string &in, std::vector &out); + static void eval (const std::vector &inArgs, const std::vector &inBlocks, std::string &out); + + }; + class CProcedure + { + public: + // List of the actions + std::vector Actions; + }; + class CStyleProperty + { + public: + std::string Name; + std::string Value; + }; + class CStyle + { + public: + std::vector Properties; + }; + + + /// Procedure list + typedef std::map TProcedureMap; + typedef TProcedureMap::iterator ItProcedureMap; + typedef TProcedureMap::const_iterator CstItProcedureMap; + TProcedureMap _ProcedureMap; + + // mgt of sheet selections (inventory, buy, sell..) + CCtrlSheetSelection _CtrlSheetSelection; + + // Map of dynamic links + typedef std::map > TLinkMap; + TLinkMap _LinkMap; + + // Map of anims + typedef std::map TAnimMap; + TAnimMap _AnimMap; + + // Map of styles. + typedef std::map TStyleMap; + TStyleMap _StyleMap; + + protected: + std::map< std::string, IParserModule* > moduleMap; + // LUA + // ---------------------------------------------------------------------------------- + // LUA Interface State. NB: The LUA environnement is not shared between Login/OutGame/InGame + NLMISC::CSmartPtr _LuaState; + virtual void initLUA(); + void uninitLUA(); + // List of script loaded (for reloadLua command) + std::set _LuaFileScripts; + // Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed) + bool loadLUA(const std::string &luaFile, std::string &error); + bool cacheUIParsing; + }; + +} + +#endif // RZ_INTERFACE_PARSER_H diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp new file mode 100644 index 000000000..22705fd64 --- /dev/null +++ b/code/nel/src/gui/interface_parser.cpp @@ -0,0 +1,2885 @@ +// Ryzom - MMORPG Framework +// 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 +#include "nel/misc/rgba.h" +#include "nel/gui/interface_parser.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/file.h" +#include "nel/misc/algo.h" +#include "nel/misc/mem_stream.h" +#include "nel/misc/factory.h" +#include "nel/misc/big_file.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/interface_options.h" +#include "nel/gui/interface_anim.h" +#include "nel/gui/interface_expr.h" +#include "nel/gui/view_pointer.h" +#include "nel/gui/group_modal.h" +#include "nel/gui/group_list.h" +#include "nel/gui/group_container.h" +#include "nel/gui/interface_link.h" +#include "nel/gui/lua_helper.h" +#include "nel/gui/lua_ihm.h" +#include "nel/gui/lua_manager.h" + +#ifdef LUA_NEVRAX_VERSION + #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger +#endif +const uint32 UI_CACHE_SERIAL_CHECK = (uint32) 'IUG_'; + +using namespace NLMISC; +using namespace std; + +namespace NLGUI +{ + + void saveXMLTree(COFile &f, xmlNodePtr node) + { + // save node name + std::string name = (const char *) node->name; + f.serial(name); + // save properties + uint32 numProp = 0; + xmlAttrPtr currProp = node->properties; + while (currProp) + { + ++ numProp; + currProp = currProp->next; + } + f.serial(numProp); + currProp = node->properties; + while (currProp) + { + std::string name = (const char *) currProp->name; + f.serial(name); + CXMLAutoPtr ptr(xmlGetProp(node, currProp->name)); + std::string value = (const char *) ptr; + f.serial(value); + currProp = currProp->next; + } + uint32 numChildren = 0; + xmlNodePtr currChild = node->children; + while (currChild) + { + ++ numChildren; + currChild = currChild->next; + } + f.serial(numChildren); + currChild = node->children; + while (currChild) + { + saveXMLTree(f, currChild); + currChild = currChild->next; + } + } + + xmlNodePtr buildTree(CIFile &f) + { + // load node name + std::string name; + f.serial(name); + xmlNodePtr node = xmlNewNode(NULL, (const xmlChar *) name.c_str()); + // slod properties + uint32 numProp; + f.serial(numProp); + for(uint k = 0; k < numProp; ++k) + { + std::string name, value; + f.serial(name, value); + xmlSetProp(node, (const xmlChar *) name.c_str(), (const xmlChar *) value.c_str()); + } + uint32 numChildren; + f.serial(numChildren); + for(uint k = 0; k < numChildren; ++k) + { + xmlAddChild(node, buildTree(f)); + } + return node; + } + + + + // ---------------------------------------------------------------------------- + // CRootGroup + // ---------------------------------------------------------------------------- + + class CRootGroup : public CInterfaceGroup + { + public: + CRootGroup(const TCtorParam ¶m) + : CInterfaceGroup(param) + { } + + /// Destructor + virtual ~CRootGroup() { } + + virtual CInterfaceElement* getElement (const std::string &id) + { + if (_Id == id) + return this; + + if (id.substr(0, _Id.size()) != _Id) + return NULL; + + vector::const_iterator itv; + for (itv = _Views.begin(); itv != _Views.end(); itv++) + { + CViewBase *pVB = *itv; + if (pVB->getId() == id) + return pVB; + } + + vector::const_iterator itc; + for (itc = _Controls.begin(); itc != _Controls.end(); itc++) + { + CCtrlBase* ctrl = *itc; + if (ctrl->getId() == id) + return ctrl; + } + + // Accelerate + string sTmp = id; + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + string::size_type pos = sTmp.find(':'); + if (pos != string::npos) + sTmp = sTmp.substr(0,pos); + + map::iterator it = _Accel.find(sTmp); + if (it != _Accel.end()) + { + CInterfaceGroup *pIG = it->second; + return pIG->getElement(id); + } + return NULL; + } + + virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1) + { + string sTmp = child->getId(); + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + _Accel.insert(pair(sTmp, child)); + CInterfaceGroup::addGroup(child,eltOrder); + } + + virtual bool delGroup (CInterfaceGroup *child, bool dontDelete = false) + { + string sTmp = child->getId(); + sTmp = sTmp.substr(_Id.size()+1,sTmp.size()); + map::iterator it = _Accel.find(sTmp); + if (it != _Accel.end()) + { + _Accel.erase(it); + } + return CInterfaceGroup::delGroup(child,dontDelete); + } + + private: + map _Accel; + }; + + // ---------------------------------------------------------------------------- + // CInterfaceParser + // ---------------------------------------------------------------------------- + + // ---------------------------------------------------------------------------- + CInterfaceParser::CInterfaceParser() + { + // LUA + _LuaState= NULL; + cacheUIParsing = false; + } + + CInterfaceParser::~CInterfaceParser() + { + _LuaState = NULL; + removeAllModules(); + } + /** Convert a string into a memstream + */ + static void interfaceScriptAsMemStream(const std::string &script, CMemStream &destStream) + { + NLMISC::contReset(destStream); + if (destStream.isReading()) // we must be sure that we are reading the stream + { + destStream.invert(); + } + destStream.seek(0, NLMISC::IStream::begin); + if (script.empty()) return; + destStream.serialBuffer(const_cast((const uint8 *) &script[0]), (uint)script.size()); + destStream.invert(); + destStream.seek(0, NLMISC::IStream::begin); + } + + // ---------------------------------------------------------------------------- + bool CInterfaceParser::parseInterface (const std::vector & strings, bool reload, bool isFilename, bool checkInData) + { + bool ok; + + bool needCheck = false; + + #if !FINAL_VERSION + needCheck = false; + #endif + + // TestYoyo. UnHide For Parsing Profile + /* + NLMISC::CHTimer::startBench(); + { + + H_AUTO(parseInterface); + */ + + //ignore the content of tags containing only white space + xmlKeepBlanksDefault(0); + //parse all interface files and build a single xml document + xmlNodePtr globalEnclosing; + nlassert (strings.size()); + CIXml read; + string nextFileName; + static const char *SCRIPT_AS_STRING = "